index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <view :style="colorStyle">
  3. <tui-drawer :mode="mode" :visible="visible" @close="closeDrawer">
  4. <!-- #ifdef MP -->
  5. <view :style="'height:'+(statusBarHeight+43)+'px'"></view>
  6. <scroll-view scroll-y="true" class="scroll-Y" :style="'height: calc(100vh - '+(statusBarHeight+214)+'rpx)'">
  7. <!-- #endif -->
  8. <!-- #ifndef MP -->
  9. <scroll-view scroll-y="true" class="scroll-Y" :style="'height: calc(100vh - 128rpx)'">
  10. <!-- #endif -->
  11. <view class="d-container">
  12. <!-- 品牌 -->
  13. <view class="box">
  14. <view class="title">
  15. <view class="font">品牌</view>
  16. <view class="font-right" @click="openFn(1)" v-if="open==1">展开 <text
  17. class="iconfont icon-xialazhankai"></text>
  18. </view>
  19. <view class="font-right" v-if="open==2" @click="openFn(2)">收起 <text class="iconfont icon-xiangshang"></text>
  20. </view>
  21. </view>
  22. <!-- 品牌显示十个 -->
  23. <view class="box-list">
  24. <view class="list acea-row row-center-wrapper" :class="{'bgcolor':spanIndex.indexOf(index)>-1}" v-for="(item,index) in list"
  25. :key="index" @click="changeSpan(index,item)">
  26. {{item.brand_name}}
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 分类 -->
  31. <view class="box">
  32. <view class="font">分类</view>
  33. <template v-for="(item,indexw) in storeArr">
  34. <tui-collapse :index="indexw" :current="item.current" :disabled="item.disabled" @click="change">
  35. <template v-slot:title>
  36. <view class="title" :key="item.id">
  37. <view class="font-live">
  38. <tui-list-cell :hover="!item.disabled">{{item.cate_name}}</tui-list-cell>
  39. </view>
  40. </view>
  41. </template>
  42. <template v-slot:content>
  43. <view class="box-list">
  44. <view class="list acea-row row-center-wrapper" v-for="(data,indexn) in item.children" :key="indexn"
  45. @click="categoryFn(data,item)">
  46. <view class="acea-row row-center-wrapper" :class="{bgcolor:sortIndex===data.id}">
  47. {{data.cate_name}}
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. </tui-collapse>
  53. </template>
  54. </view>
  55. </view>
  56. </scroll-view>
  57. <!-- 底部按钮 -->
  58. <view class="footer">
  59. <view class="btn" @click="submit(2)">
  60. 重置
  61. </view>
  62. <view class="btn btnColor" @click="submit(1)">
  63. 确认
  64. </view>
  65. </view>
  66. </tui-drawer>
  67. <!-- 确认 -->
  68. </view>
  69. </template>
  70. <script>
  71. import colors from "@/mixins/color";
  72. import tuiDrawer from "@/components/thorui/tui-drawer"
  73. import tuiCollapse from "@/components/thorui/tui-collapse"
  74. import tuiListCell from "@/components/thorui/tui-list-cell"
  75. let statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
  76. export default {
  77. components: {
  78. tuiDrawer,
  79. tuiCollapse,
  80. tuiListCell
  81. },
  82. props: {
  83. storeCategory: {
  84. type: Array, // 分类数据
  85. default: []
  86. },
  87. storeBrand: {
  88. type: Array, //品牌数据
  89. }
  90. },
  91. mixins: [colors],
  92. data() {
  93. return {
  94. statusBarHeight:statusBarHeight,
  95. visible: false,
  96. mode: "right",
  97. sortIndex: 0,
  98. spanIndex: [],
  99. newList: [],
  100. open: 1,
  101. forArr: [],
  102. serchData: {
  103. sort: '', //new 最新, sales价值
  104. sort_type: '', // DESC 倒序 ASC 正序
  105. send: '',
  106. cate_id: [],
  107. }
  108. }
  109. },
  110. computed: {
  111. storeArr() {
  112. return this.storeCategory
  113. },
  114. list() {
  115. if(this.open===1) {
  116. return this.storeBrand.slice(0, 10)
  117. } else if( this.open===2) {
  118. return this.storeBrand
  119. }
  120. }
  121. },
  122. onLoad() {
  123. },
  124. mounted() {
  125. console.log(2,'父组件传过来的值')
  126. // this.newListArr()
  127. // this.openFn()
  128. },
  129. methods: {
  130. // newListArr() {
  131. // // this.forArr = this.list
  132. // if (this.open == 1) {
  133. // console.log('进入')
  134. // this.$set(this.forArr,this.forArr.length,...this.list.slice(0, 10))
  135. // console.log(this.forArr)
  136. // } else {
  137. // console.log('全部')
  138. // this.forArr = this.list
  139. // }
  140. // },
  141. closeDrawer() {
  142. this.visible = false
  143. },
  144. // 点击展开
  145. openFn(num) {
  146. switch (num) {
  147. case 1:
  148. this.open = 2
  149. break;
  150. case 2:
  151. this.open = 1
  152. break;
  153. }
  154. // this.newListArr()
  155. },
  156. // 单选
  157. categoryFn(row,item) {
  158. console.log(row,item)
  159. this.sortIndex = row.id
  160. let data ={
  161. cid:item.id,
  162. sid:row.id
  163. }
  164. console.log(data)
  165. this.$emit('categoryChange',data)
  166. },
  167. change(e) {
  168. let index = e.index;
  169. let item = this.storeArr[index];
  170. item.current = item.current == index ? -1 : index
  171. },
  172. // 多选
  173. changeSpan(index, row) {
  174. let arrIndex = this.spanIndex.indexOf(index);
  175. if (arrIndex > -1) {
  176. this.spanIndex.splice(arrIndex, 1);
  177. this.newList.splice(arrIndex, 1);
  178. } else {
  179. this.spanIndex.push(index);
  180. this.newList.push(row.id);
  181. }
  182. let result = this.newList.join(",")
  183. this.$emit('brandChange', result)
  184. },
  185. // 确认提交
  186. submit(val) {
  187. if(val==2) {
  188. this.sortIndex =0
  189. this.spanIndex=[]
  190. }
  191. this.$emit('submitFn',val)
  192. }
  193. }
  194. }
  195. </script>
  196. <style lang="scss">
  197. .bgcolor {
  198. background: var(--view-minorColorT) !important;
  199. border: 1px solid var(--view-theme);
  200. border-radius: 34rpx;
  201. color: var(--view-theme) !important;
  202. height: 100%;
  203. width: 100%;
  204. }
  205. .font {
  206. margin-top: 30rpx;
  207. font-size: 28rpx;
  208. font-weight: 500;
  209. color: #333333;
  210. }
  211. .font-live {
  212. font-size: 24rpx;
  213. font-weight: 400;
  214. color: #666666;
  215. }
  216. .font-right {
  217. margin-top: 30rpx;
  218. font-size: 20rpx;
  219. font-weight: 400;
  220. color: #666666;
  221. }
  222. .icon-xialazhankai {
  223. font-size: 20rpx;
  224. color: #666666;
  225. margin-left: 6rpx;
  226. }
  227. .icon-xiangshang {
  228. font-size: 20rpx;
  229. color: #666666;
  230. margin-left: 6rpx;
  231. }
  232. .d-container {
  233. width:600rpx;
  234. padding: 0 34rpx 20rpx 34rpx;
  235. .box {
  236. .title {
  237. /* #ifndef MP */
  238. margin-top: 30rpx;
  239. /* #endif */
  240. display: flex;
  241. justify-content: space-between;
  242. }
  243. .box-list {
  244. display: flex;
  245. flex-wrap: wrap;
  246. justify-content: space-between;
  247. margin-bottom: 20rpx;
  248. .list {
  249. width: 240rpx;
  250. height: 68rpx;
  251. background: #F5F5F5;
  252. border-radius: 34rpx;
  253. font-size: 24rpx;
  254. font-weight: 400;
  255. color: #666666;
  256. margin-top: 30rpx;
  257. }
  258. }
  259. }
  260. }
  261. .footer {
  262. // position: fixed;
  263. // bottom: 10rpx;
  264. margin: 20rpx 30rpx 38rpx 30rpx;
  265. display: flex;
  266. justify-content: space-between;
  267. .btn {
  268. width: 240rpx;
  269. height: 68rpx;
  270. background: #F5F5F5;
  271. border-radius: 34rpx;
  272. font-size: 24rpx;
  273. font-weight: 400;
  274. text-align: center;
  275. line-height: 68rpx;
  276. }
  277. .btnColor {
  278. background: var(--view-theme);
  279. color: #fff;
  280. }
  281. }
  282. </style>