index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <mobile-frame :frameStyle="frameStyle" @toPath="toPath">
  3. <view class="main">
  4. <view class="one">
  5. <input type="text" placeholder="搜索商品" @tap="toCommon('pagesHome/market/search')" placeholder-class="placss">
  6. </view>
  7. <view class="two">
  8. <view class="two_1">
  9. <scroll-view scroll-y="true" class="scroll-view">
  10. <view class="list-scroll-view">
  11. <view class="list" :class="[active==index?'listActive':'']" v-for="(item,index) in typeList" :key="index" @tap="toChange(index,item)">
  12. <text>{{item.label}}</text>
  13. </view>
  14. </view>
  15. </scroll-view>
  16. </view>
  17. <view class="two_2">
  18. <scroll-view scroll-y="true" class="scroll-view">
  19. <view class="list-scroll-view">
  20. <view class="list" v-for="(item,index) in list" :key="index" @tap="toCommon('pagesHome/market/search')">
  21. <view class="title">
  22. {{item.label}}
  23. </view>
  24. <view class="market">
  25. <view class="marketList" v-for="(tag,indexs) in item.children" :key="indexs">
  26. <image class="image" :src="tag.file&&tag.file.length>0?tag.file[0].url:''" mode=""></image>
  27. <view class="name">
  28. {{tag.label}}
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </scroll-view>
  35. </view>
  36. </view>
  37. </view>
  38. </mobile-frame>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. frameStyle: {
  45. useBar: true
  46. },
  47. active: '0',
  48. typeList: [],
  49. list: []
  50. };
  51. },
  52. onShow: function() {
  53. const that = this;
  54. that.searchOther();
  55. },
  56. methods: {
  57. async searchOther() {
  58. const that = this;
  59. let res;
  60. res = await that.$api(`/goodsTags`, 'GET', {
  61. status: '0'
  62. })
  63. if (res.errcode == '0') {
  64. that.$set(that, `typeList`, res.data);
  65. if (res.total > 0) that.searchRight(res.data[0]);
  66. }
  67. },
  68. toChange(index, e) {
  69. const that = this;
  70. that.$set(that, `active`, index);
  71. that.searchRight(e);
  72. },
  73. // 查询左侧信息
  74. async searchRight(e) {
  75. const that = this;
  76. let info = {};
  77. if (e.id) info.pid = e.id;
  78. const res = await that.$api(`/goodsTags/tree`, 'GET', {
  79. ...info
  80. })
  81. if (res.errcode == '0' && res.data.length > 0) {
  82. that.$set(that, `list`, res.data[0].children)
  83. }
  84. },
  85. // 公共跳转
  86. toCommon(e) {
  87. uni.navigateTo({
  88. url: `/${e}`
  89. })
  90. },
  91. // 菜单跳转
  92. toPath(e) {
  93. if (e && e.route && e.type == '0') {
  94. uni.redirectTo({
  95. url: `/${e.route}`
  96. })
  97. } else {
  98. uni.navigateTo({
  99. url: `/${e.route}`
  100. })
  101. }
  102. }
  103. }
  104. }
  105. </script>
  106. <style lang="scss">
  107. .main {
  108. display: flex;
  109. flex-direction: column;
  110. width: 100vw;
  111. height: 91vh;
  112. .one {
  113. padding: 2vw;
  114. border: 1px solid var(--f1Color);
  115. input {
  116. background-color: var(--fFB1Color);
  117. border-radius: 30px;
  118. padding: 2vw;
  119. color: var(--fffColor);
  120. font-size: var(--font15Size);
  121. }
  122. .placss {
  123. color: var(--fffColor);
  124. }
  125. }
  126. .two {
  127. height: 83vh;
  128. display: flex;
  129. flex-direction: row;
  130. .two_1 {
  131. position: relative;
  132. width: 25vw;
  133. background-color: #fafafa;
  134. display: flex;
  135. flex-direction: column;
  136. .list {
  137. text-align: center;
  138. padding: 2.5vw 0;
  139. border-bottom: 1px solid var(--f1Color);
  140. text {
  141. font-size: var(--font14Size);
  142. }
  143. }
  144. .listActive {
  145. background-color: var(--fffColor);
  146. }
  147. }
  148. .two_2 {
  149. padding: 2vw;
  150. flex-grow: 1;
  151. position: relative;
  152. display: flex;
  153. flex-direction: column;
  154. .list {
  155. margin: 0 0 2vw 0;
  156. padding: 2vw;
  157. .title {
  158. font-size: var(--font16Size);
  159. margin: 0 0 2vw 0;
  160. }
  161. .market {
  162. display: flex;
  163. flex-direction: row;
  164. flex-wrap: wrap;
  165. .marketList {
  166. text-align: center;
  167. margin: 0 2vw 2vw 0;
  168. width: 22vw;
  169. .image {
  170. width: 100%;
  171. height: 15vw;
  172. }
  173. .name {
  174. font-size: var(--font14Size);
  175. }
  176. }
  177. .marketList:nth-child(3n) {
  178. margin: 0 0 2vw 0;
  179. }
  180. }
  181. }
  182. }
  183. }
  184. }
  185. .scroll-view {
  186. position: absolute;
  187. top: 0;
  188. left: 0;
  189. right: 0;
  190. bottom: 0;
  191. .list-scroll-view {
  192. display: flex;
  193. flex-direction: column;
  194. }
  195. }
  196. </style>