index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <base-drawer mode="right" :visible="visible" background-color="transparent" mask maskClosable @close="closeDrawer">
  3. <view class="edit-lable">
  4. <!-- #ifdef MP -->
  5. <view class="accountTitle">
  6. <view :style="{height:getHeight.barTop+'px'}"></view>
  7. <view class="sysTitle acea-row row-center-wrapper" :style="{height:getHeight.barHeight+'px'}">
  8. <view>筛选</view>
  9. </view>
  10. </view>
  11. <view :style="{height:(getHeight.barTop+getHeight.barHeight)+'px'}"></view>
  12. <view class="list" v-if="isStore"
  13. :style="'height: calc(100% - '+(getHeight.barTop+getHeight.barHeight*2+150)+'rpx - constant(safe-area-inset-bottom));height: calc(100% - '+(getHeight.barTop+getHeight.barHeight*2+150)+'rpx - env(safe-area-inset-bottom))'">
  14. <!-- #endif -->
  15. <!-- #ifndef MP -->
  16. <view class="header">筛选</view>
  17. <view class="list" v-if="isStore">
  18. <!-- #endif -->
  19. <scroll-view scroll-y="true" style="height: 100%">
  20. <view class="goods_type">
  21. 商品类型
  22. </view>
  23. <view class="goods_type_box">
  24. <view class="goods_type_item" v-for="(item,index) in goodsType" :key="item.id"
  25. @click="selectProduct(item.id)" :class="{selectActive:item.id===selectId.productType}">
  26. {{item.text}}
  27. </view>
  28. </view>
  29. <view class="merchants_type">
  30. 商家分类
  31. </view>
  32. <view class="merchants_type_box">
  33. <view class="merchants_type_item" v-for="(item,index) in productType" :key="item.id">
  34. <view class="type_item_operate">
  35. <text :class="{oneSelectActive:item.id==selectId.cateId}" @click="selectMerchant(item.id)">{{item.name}}</text>
  36. <text v-if="item.childList.length>3" @click="changeHide(item)">{{item.hide?'展开':'收起'}}<text class="iconfont"
  37. :class="item.hide?'icon-xiangxia':'icon-xiangshang'"></text></text>
  38. </view>
  39. <view class="main_box">
  40. <template v-for="(citem,cindex) in item.childList">
  41. <view class="main_item" :key="citem.id" v-if="!(cindex>2&&item.hide)"
  42. @click="selectMerchant(citem.id)"
  43. :class="{selectActive:citem.id==selectId.cateId}">
  44. {{citem.name}}
  45. </view>
  46. </template>
  47. </view>
  48. </view>
  49. </view>
  50. </scroll-view>
  51. </view>
  52. <view class="empty-box" v-else>
  53. <emptyPage title="暂无分类~" :imgSrc="urlDomain+'crmebimage/presets/noSearch.png'"></emptyPage>
  54. </view>
  55. <view class="footer acea-row row-between-wrapper">
  56. <view class="bnt acea-row row-center-wrapper" @tap="reset">重置</view>
  57. <view class="bnt on acea-row row-center-wrapper" @tap="define">确定</view>
  58. </view>
  59. </view>
  60. </view>
  61. </base-drawer>
  62. </template>
  63. <script>
  64. import {
  65. mapGetters
  66. } from "vuex";
  67. import emptyPage from '@/components/emptyPage.vue';
  68. import baseDrawer from '@/components/tui-drawer/tui-drawer.vue';
  69. import {productCategroyGetTree} from '@/api/work.js'
  70. export default {
  71. computed:{
  72. ...mapGetters(['selectMerId']),
  73. },
  74. components: {
  75. emptyPage,
  76. baseDrawer
  77. },
  78. props: {
  79. visible: {
  80. type: Boolean,
  81. default: false,
  82. },
  83. },
  84. data: function() {
  85. return {
  86. urlDomain: this.$Cache.get("imgHost"),
  87. // #ifdef MP
  88. getHeight: this.$util.getWXStatusHeight(),
  89. // #endif
  90. selectId: {
  91. cateId: '',
  92. productType: '',
  93. },
  94. labelList: [],
  95. goodsInfo: {}, //列表中已存在id(固定不变)
  96. dataLabel: [], //已存在选中id(随着选中可以变化)
  97. isStore: true, //判断是否存在标签
  98. num: 0, // 判断是否为批量
  99. ids: [], //批量时的id集合
  100. goodsType: [
  101. {
  102. id: 0,
  103. text: '普通商品'
  104. },
  105. {
  106. id: 2,
  107. text: '虚拟商品'
  108. },
  109. {
  110. id: 5,
  111. text: '云盘商品'
  112. },
  113. {
  114. id: 6,
  115. text: '卡密商品'
  116. }
  117. ],
  118. productType: [],
  119. };
  120. },
  121. mounted() {},
  122. created() {
  123. this.getTree()
  124. },
  125. methods: {
  126. // 确认
  127. define(){
  128. this.$emit('successChange',this.selectId)
  129. },
  130. getTree(){
  131. productCategroyGetTree(this.selectMerId).then(res=>{
  132. this.productType=res.data
  133. this.productType.forEach(item=>{
  134. item.hide=true
  135. })
  136. })
  137. },
  138. changeHide(item){
  139. item.hide=!item.hide
  140. this.productType=[...this.productType]
  141. },
  142. //重置
  143. reset() {
  144. this.selectId = {
  145. cateId: '',
  146. productType: '',
  147. }
  148. },
  149. //选择商品分类
  150. selectProduct(id) {
  151. this.selectId.productType = id
  152. },
  153. //选择商户分类
  154. selectMerchant(id) {
  155. this.selectId.cateId = id
  156. },
  157. closeDrawer() {
  158. this.$emit('closeDrawer');
  159. }
  160. }
  161. }
  162. </script>
  163. <style lang="scss" scoped>
  164. .accountTitle {
  165. position: fixed;
  166. left: 0;
  167. top: 0;
  168. width: 100%;
  169. z-index: 99;
  170. padding-bottom: 6rpx;
  171. .sysTitle {
  172. width: 100%;
  173. position: relative;
  174. font-weight: 600;
  175. color: #333333;
  176. font-size: 34rpx;
  177. font-family: PingFang SC, PingFang SC;
  178. }
  179. }
  180. .edit-lable {
  181. background-color: #fff;
  182. width: 670rpx;
  183. // border-radius: 40rpx 0 0 40rpx;
  184. height: 100%;
  185. padding: 20rpx 34rpx 0 32rpx;
  186. .header {
  187. text-align: center;
  188. height: 96rpx;
  189. line-height: 96rpx;
  190. font-size: 34rpx;
  191. font-family: PingFang SC, PingFang SC;
  192. font-weight: 600;
  193. color: #333333;
  194. position: relative;
  195. }
  196. .list {
  197. overflow: auto;
  198. height: calc(100% - 208rpx);
  199. height: calc(100% - (208rpx + constant(safe-area-inset-bottom)));
  200. height: calc(100% - (208rpx + env(safe-area-inset-bottom)));
  201. .item {
  202. margin-top: 48rpx;
  203. .title {
  204. font-size: 28rpx;
  205. font-family: PingFang SC, PingFang SC;
  206. font-weight: 600;
  207. color: #333333;
  208. }
  209. .listn {
  210. .name {
  211. width: 184rpx;
  212. height: 56rpx;
  213. background-color: #F5F5F5;
  214. border-radius: 50rpx;
  215. border: 1rpx solid #F5F5F5;
  216. font-size: 24rpx;
  217. font-family: PingFang SC, PingFang SC;
  218. font-weight: 400;
  219. color: #333333;
  220. margin-right: 26rpx;
  221. margin-top: 24rpx;
  222. padding: 0 8rpx;
  223. &.on {
  224. background-color: #E9F2FE;
  225. border-color: #2A7EFB;
  226. color: #2A7EFB;
  227. }
  228. &:nth-of-type(3n) {
  229. margin-right: 0;
  230. }
  231. }
  232. }
  233. }
  234. }
  235. .footer {
  236. width: 100%;
  237. height: 112rpx;
  238. position: fixed;
  239. bottom: 0;
  240. left: 0;
  241. padding: 0 32rpx;
  242. background-color: #fff;
  243. border-radius: 0 0 0 40rpx;
  244. height: calc(112rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  245. height: calc(112rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  246. padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
  247. padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
  248. .bnt {
  249. width: 296rpx;
  250. height: 72rpx;
  251. border: 1px solid #2A7EFB;
  252. border-radius: 200rpx;
  253. font-size: 26rpx;
  254. font-family: PingFang SC, PingFang SC;
  255. font-weight: 400;
  256. color: #2A7EFB;
  257. &.on {
  258. background: #2A7EFB;
  259. border-color: #2A7EFB;
  260. color: #fff;
  261. }
  262. }
  263. }
  264. .goods_type {
  265. font-weight: 600;
  266. font-size: 14px;
  267. color: #333333;
  268. }
  269. .goods_type_box {
  270. display: flex;
  271. flex-wrap: wrap;
  272. padding: 0 10rpx;
  273. justify-content: space-between;
  274. margin-top: 14rpx;
  275. .goods_type_item {
  276. background: #F5F5F5;
  277. border-radius: 200rpx;
  278. width: 184rpx;
  279. height: 56rpx;
  280. text-align: center;
  281. line-height: 56rpx;
  282. margin-top: 20rpx;
  283. }
  284. }
  285. .merchants_type {
  286. font-weight: 600;
  287. font-size: 14px;
  288. color: #333333;
  289. margin-top: 24rpx;
  290. }
  291. .merchants_type_box {
  292. .merchants_type_item {
  293. .type_item_operate {
  294. display: flex;
  295. justify-content: space-between;
  296. font-weight: 400;
  297. font-size: 24rpx;
  298. color: #666666;
  299. padding: 20rpx 0;
  300. .icon-xiangshang,
  301. .icon-xiangxia {
  302. font-weight: 400;
  303. font-size: 24rpx;
  304. color: #666666;
  305. }
  306. }
  307. }
  308. .main_box {
  309. margin-bottom: 30rpx;
  310. .main_item {
  311. display: inline-block;
  312. background: #F5F5F5;
  313. border-radius: 100px 100px 100px 100px;
  314. width: 184rpx;
  315. height: 56rpx;
  316. text-align: center;
  317. line-height: 56rpx;
  318. margin-right: 26rpx;
  319. margin-top: 20rpx;
  320. white-space: nowrap;
  321. overflow: hidden;
  322. text-overflow: ellipsis;
  323. &:nth-of-type(3n) {
  324. margin-right: 0rpx !important;
  325. }
  326. }
  327. }
  328. }
  329. }
  330. .selectActive {
  331. background: #E9F2FE !important;
  332. border-radius: 200rpx;
  333. border: 1px solid #2A7EFB;
  334. color: #2A7EFB;
  335. }
  336. .oneSelectActive{
  337. color: #2A7EFB;
  338. }
  339. </style>