index.vue 4.7 KB

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