index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <view :style="colorStyle">
  3. <tui-drawer :mode="mode" :visible="visible" @close="closeDrawer">
  4. <view class="acea-row row-column container">
  5. <!-- #ifdef MP -->
  6. <view :style="{height: getHeight.barTop+'px'}"></view>
  7. <view :style="{height: getHeight.barHeight+'px'}" class="head-box acea-row row-center-wrapper">筛选</view>
  8. <!-- #endif -->
  9. <!-- #ifndef MP -->
  10. <view class="head-box acea-row row-center-wrapper">筛选</view>
  11. <!-- #endif -->
  12. <scroll-view scroll-y="true" class="scroll-view">
  13. <view class="d-container">
  14. <!-- 品牌 -->
  15. <view class="box brand-box">
  16. <tui-collapse :index="brandIndex" :current="brandCurrent" @click="brandCollapse">
  17. <template v-slot:title>
  18. <tui-list-cell>品牌</tui-list-cell>
  19. </template>
  20. <template v-slot:content>
  21. <view class="box-list acea-row">
  22. <view class="box-list acea-row">
  23. <view class="list acea-row row-center-wrapper line1" :class="{'bgcolor':spanIndex.indexOf(index)>-1}" v-for="(item,index) in list" :key="index"
  24. @click="changeSpan(index,item)">
  25. {{item.brand_name}}
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. </tui-collapse>
  31. </view>
  32. <!-- 分类 -->
  33. <view class="box">
  34. <view class="font">分类</view>
  35. <scroll-view scroll-x="true" class="scroll-x-view" v-if="level == 3">
  36. <view class="item" :class="{ on: navOneActive == index }" v-for="(item,index) in categoryList" :key="item.id" @click="tapNavOne(item,index)">
  37. <view class="img-box">
  38. <image :src="item.pic" class="img"></image>
  39. </view>
  40. <view class="title">{{item.cate_name}}</view>
  41. </view>
  42. </scroll-view>
  43. <template v-for="(item,index) in categoryErList">
  44. <tui-collapse :key="item.id" :index="index" :current="item.current" :disabled="item.disabled" @click="change">
  45. <template v-slot:title>
  46. <tui-list-cell>{{item.cate_name}}</tui-list-cell>
  47. </template>
  48. <template v-slot:content>
  49. <view class="box-list acea-row">
  50. <view class="list acea-row row-center-wrapper" v-for="(data,indexn) in item.children" :key="indexn" @click="categoryFn(data,item)">
  51. <view class="acea-row row-center-wrapper" :class="{bgcolor:sortIndex===data.id}">
  52. {{data.cate_name}}
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. </tui-collapse>
  58. </template>
  59. </view>
  60. </view>
  61. </scroll-view>
  62. <!-- 底部按钮 -->
  63. <view class="btn-box acea-row">
  64. <view class="btn" @click="submit(2)">
  65. 重置
  66. </view>
  67. <view class="btn btnColor" @click="submit(1)">
  68. 确认
  69. </view>
  70. </view>
  71. <view class="safe-area-inset-bottom"></view>
  72. </view>
  73. </tui-drawer>
  74. <!-- 确认 -->
  75. </view>
  76. </template>
  77. <script>
  78. import colors from "@/mixins/color";
  79. import tuiDrawer from "@/components/thorui/tui-drawer"
  80. import tuiCollapse from "@/components/thorui/tui-collapse"
  81. import tuiListCell from "@/components/thorui/tui-list-cell"
  82. let statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
  83. export default {
  84. components: {
  85. tuiDrawer,
  86. tuiCollapse,
  87. tuiListCell
  88. },
  89. props: {
  90. storeCategory: {
  91. type: Array, // 分类数据
  92. default: []
  93. },
  94. storeBrand: {
  95. type: Array, //品牌数据
  96. },
  97. level: {
  98. type: Number,
  99. default: 2
  100. }
  101. },
  102. mixins: [colors],
  103. data() {
  104. return {
  105. getHeight: this.$util.getWXStatusHeight(),
  106. statusBarHeight: statusBarHeight,
  107. visible: false,
  108. mode: "right",
  109. sortIndex: 0,
  110. spanIndex: [],
  111. newList: [],
  112. open: 1,
  113. forArr: [],
  114. serchData: {
  115. sort: '', //new 最新, sales价值
  116. sort_type: '', // DESC 倒序 ASC 正序
  117. send: '',
  118. cate_id: [],
  119. },
  120. brandIndex: 0,
  121. brandCurrent: 0,
  122. navOneActive: 0,
  123. categoryList: [],
  124. categoryErList: [],
  125. }
  126. },
  127. computed: {
  128. storeArr() {
  129. return this.storeCategory
  130. },
  131. list() {
  132. if (this.open === 1) {
  133. return this.storeBrand.slice(0, 10)
  134. } else if (this.open === 2) {
  135. return this.storeBrand
  136. }
  137. },
  138. },
  139. watch: {
  140. storeCategory(val) {
  141. this.categoryList = val;
  142. if (this.level == 2) {
  143. this.categoryErList = this.categoryList;
  144. } else {
  145. this.categoryErList = this.categoryList[0].children;
  146. }
  147. this.sortIndex = this.categoryErList[0].children[0].id;
  148. console.log(this.sortIndex)
  149. },
  150. },
  151. mounted() {
  152. console.log(2, '父组件传过来的值')
  153. // this.newListArr()
  154. // this.openFn()
  155. },
  156. methods: {
  157. // newListArr() {
  158. // // this.forArr = this.list
  159. // if (this.open == 1) {
  160. // console.log('进入')
  161. // this.$set(this.forArr,this.forArr.length,...this.list.slice(0, 10))
  162. // console.log(this.forArr)
  163. // } else {
  164. // console.log('全部')
  165. // this.forArr = this.list
  166. // }
  167. // },
  168. closeDrawer() {
  169. this.visible = false
  170. },
  171. // 点击展开
  172. openFn(num) {
  173. switch (num) {
  174. case 1:
  175. this.open = 2
  176. break;
  177. case 2:
  178. this.open = 1
  179. break;
  180. }
  181. // this.newListArr()
  182. },
  183. // 单选
  184. categoryFn(row, item) {
  185. console.log(row, item)
  186. this.sortIndex = row.id
  187. let cid = this.categoryList[this.navOneActive].id;
  188. let sid = row.pid;
  189. let tid = row.id;
  190. if (this.level == 2) {
  191. cid = row.pid;
  192. sid = row.id;
  193. tid = 0;
  194. }
  195. let data = {
  196. cid: cid,
  197. sid: sid,
  198. tid: tid,
  199. }
  200. console.log(data)
  201. this.$emit('categoryChange', data)
  202. },
  203. change(e) {
  204. let index = e.index;
  205. let item = this.categoryErList[index];
  206. item.current = item.current == index ? -1 : index
  207. },
  208. // 多选
  209. changeSpan(index, row) {
  210. let arrIndex = this.spanIndex.indexOf(index);
  211. if (arrIndex > -1) {
  212. this.spanIndex.splice(arrIndex, 1);
  213. this.newList.splice(arrIndex, 1);
  214. } else {
  215. this.spanIndex.push(index);
  216. this.newList.push(row.id);
  217. }
  218. let result = this.newList.join(",")
  219. this.$emit('brandChange', result)
  220. },
  221. // 确认提交
  222. submit(val) {
  223. if (val == 2) {
  224. this.sortIndex = 0
  225. this.spanIndex = []
  226. }
  227. this.$emit('submitFn', val)
  228. },
  229. brandCollapse(e) {
  230. this.brandCurrent = this.brandCurrent == e.index ? -1 : e.index;
  231. },
  232. tapNavOne(item, index) {
  233. this.navOneActive = index;
  234. this.categoryErList = this.categoryList[this.navOneActive].children;
  235. }
  236. }
  237. }
  238. </script>
  239. <style lang="scss" scoped>
  240. .safe-area-inset-bottom {
  241. height: 0;
  242. height: constant(safe-area-inset-bottom);
  243. height: env(safe-area-inset-bottom);
  244. }
  245. .container {
  246. flex-wrap: nowrap;
  247. height: 100%;
  248. .head-box {
  249. height: 80rpx;
  250. font-weight: 500;
  251. font-size: 34rpx;
  252. color: #333333;
  253. }
  254. .scroll-view {
  255. flex: 1;
  256. min-height: 0;
  257. }
  258. .btn-box {
  259. padding: 20rpx 32rpx;
  260. .btn {
  261. flex: 1;
  262. height: 72rpx;
  263. border: 1rpx solid var(--view-theme);
  264. border-radius: 36rpx;
  265. margin-left: 14rpx;
  266. text-align: center;
  267. font-weight: 500;
  268. font-size: 26rpx;
  269. line-height: 72rpx;
  270. color: var(--view-theme);
  271. transform: rotateZ(360deg);
  272. &:first-child {
  273. margin-left: 0;
  274. }
  275. }
  276. .btnColor {
  277. background: var(--view-theme);
  278. color: #FFFFFF;
  279. }
  280. }
  281. }
  282. .bgcolor {
  283. background: var(--view-minorColorT) !important;
  284. border: 1px solid var(--view-theme);
  285. border-radius: 34rpx;
  286. color: var(--view-theme) !important;
  287. height: 100%;
  288. width: 100%;
  289. }
  290. .font {
  291. margin-top: 24rpx;
  292. font-size: 28rpx;
  293. font-weight: 500;
  294. color: #333333;
  295. }
  296. .font-live {
  297. font-size: 28rpx;
  298. font-weight: 500;
  299. color: #333333;
  300. }
  301. .font-right {
  302. margin-top: 30rpx;
  303. font-size: 20rpx;
  304. font-weight: 400;
  305. color: #666666;
  306. }
  307. .icon-xialazhankai {
  308. font-size: 20rpx;
  309. color: #666666;
  310. margin-left: 6rpx;
  311. }
  312. .icon-xiangshang {
  313. font-size: 20rpx;
  314. color: #666666;
  315. margin-left: 6rpx;
  316. }
  317. .d-container {
  318. padding: 0 32rpx;
  319. .box {
  320. .title {
  321. /* #ifndef MP */
  322. // margin-top: 30rpx;
  323. /* #endif */
  324. // display: flex;
  325. // justify-content: space-between;
  326. // padding: 24rpx 0;
  327. }
  328. .box-list {
  329. margin: 0 -26rpx 0 0;
  330. .list {
  331. width: 184rpx;
  332. height: 56rpx;
  333. border-radius: 28rpx;
  334. margin: 0 26rpx 24rpx 0;
  335. background: #F5F5F5;
  336. font-size: 24rpx;
  337. color: #333333;
  338. }
  339. }
  340. }
  341. }
  342. .scroll-x-view {
  343. white-space: nowrap;
  344. .item {
  345. display: inline-block;
  346. padding: 24rpx 0;
  347. margin-right: 8rpx;
  348. vertical-align: middle;
  349. &.on {
  350. .img-box {
  351. border-color: var(--view-theme);
  352. }
  353. .title {
  354. background: linear-gradient(90deg, var(--view-gradient) 0%, var(--view-theme) 100%);
  355. color: #FFFFFF;
  356. }
  357. }
  358. }
  359. .img-box {
  360. width: 104rpx;
  361. height: 104rpx;
  362. padding: 6rpx;
  363. border: 3rpx solid transparent;
  364. border-radius: 50%;
  365. margin: 0 auto;
  366. }
  367. .img {
  368. width: 92rpx;
  369. height: 92rpx;
  370. border-radius: 50%;
  371. }
  372. .title {
  373. width: 120rpx;
  374. height: 40rpx;
  375. border-radius: 20rpx;
  376. margin-top: 8rpx;
  377. text-align: center;
  378. font-size: 24rpx;
  379. line-height: 40rpx;
  380. color: #333333;
  381. }
  382. }
  383. </style>