index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <base-drawer mode="bottom" :visible="visible" background-color="transparent" mask maskClosable @close="closeDrawer">
  3. <view class="classify rd-t-40rpx">
  4. <view class="title">修改分类
  5. <view class="close acea-row row-center-wrapper" @tap="closeDrawer">
  6. <text class="iconfont icon-ic_close"></text>
  7. </view>
  8. </view>
  9. <checkbox-group @change="checkboxChange($event)" v-if="categoryList.length">
  10. <view class="list acea-row">
  11. <view class="item">
  12. <view class="tips">一级分类</view>
  13. <scroll-view scroll-y="true" class="scroll-Y">
  14. <view class="itemn line1" :class="{checked: index == currentOne,on:checkedIds.includes(item.id+'')}" v-for="(item,index) in categoryList" :key="index" @click="categoryTap(index)">
  15. <!-- #ifndef MP -->
  16. <checkbox :value="(item.id).toString()" :checked='checkedIds.includes(item.id+"")' style="transform:scale(0.9)" />
  17. <!-- #endif -->
  18. <!-- #ifdef MP -->
  19. <checkbox :value="item.id" :checked='checkedIds.includes(item.id+"")' style="transform:scale(0.9)" />
  20. <!-- #endif -->
  21. {{item.cate_name}}
  22. </view>
  23. </scroll-view>
  24. </view>
  25. <view class="item on" :class="!categoryList[currentOne].children.length?'on3':''" v-if="categoryList[currentOne]">
  26. <view class="tips">二级分类</view>
  27. <scroll-view scroll-y="true" class="scroll-Y">
  28. <view class="itemn line1" :class="{checked: jIndex == currentTwo,on:checkedIds.includes(j.id+'')}" v-for="(j,jIndex) in categoryList[currentOne].children" :key="jIndex" @click="categoryTwoTap(jIndex)">
  29. <!-- #ifndef MP -->
  30. <checkbox :value="(j.id).toString()" :checked='checkedIds.includes(j.id+"")' style="transform:scale(0.9)" />
  31. <!-- #endif -->
  32. <!-- #ifdef MP -->
  33. <checkbox :value="j.id" :checked='checkedIds.includes(j.id+"")' style="transform:scale(0.9)" />
  34. <!-- #endif -->
  35. {{j.cate_name}}
  36. </view>
  37. </scroll-view>
  38. </view>
  39. <view class="item on2" v-if="categoryList[currentOne] && categoryList[currentOne].children.length">
  40. <view class="tips">三级分类</view>
  41. <scroll-view scroll-y="true" class="scroll-Y">
  42. <view class="itemn line1" :class="{on:checkedIds.includes(x.id+'')}" v-for="(x,xIndex) in categoryList[currentOne].children[currentTwo].children" :key="xIndex">
  43. <!-- #ifndef MP -->
  44. <checkbox :value="(x.id).toString()" :checked='checkedIds.includes(x.id+"")' style="transform:scale(0.9)" />
  45. <!-- #endif -->
  46. <!-- #ifdef MP -->
  47. <checkbox :value="x.id" :checked='checkedIds.includes(x.id+"")' style="transform:scale(0.9)" />
  48. <!-- #endif -->
  49. {{x.cate_name}}{{x.id}}
  50. </view>
  51. </scroll-view>
  52. </view>
  53. </view>
  54. </checkbox-group>
  55. <view class="empty-box" v-else>
  56. <emptyPage title="暂无分类~" src="/statics/images/empty-box.png"></emptyPage>
  57. </view>
  58. <view class="footer acea-row row-between-wrapper">
  59. <view class="bnt acea-row row-center-wrapper" @tap="reset">重置</view>
  60. <view class="bnt on acea-row row-center-wrapper" @tap="define">确定</view>
  61. </view>
  62. </view>
  63. </base-drawer>
  64. </template>
  65. <script>
  66. import emptyPage from '@/components/emptyPage.vue';
  67. import {
  68. getStoreCategory,
  69. getCategory,
  70. storeBatchProcess,
  71. postBatchProcess
  72. } from "@/api/admin";
  73. export default {
  74. components: {
  75. emptyPage
  76. },
  77. props:{
  78. visible: {
  79. type: Boolean,
  80. default: false,
  81. },
  82. storeNum: {
  83. type: Number,
  84. default: 0
  85. }
  86. },
  87. data: function() {
  88. return {
  89. categoryList:[],
  90. currentOne:0,
  91. currentTwo:0,
  92. checkedIds:[],
  93. ids:null //父级商品id
  94. };
  95. },
  96. mounted() {},
  97. methods:{
  98. checkboxChange(e, index, item){
  99. this.checkedIds = e.detail.value;
  100. },
  101. categoryTwoTap(index){
  102. this.currentTwo = index
  103. },
  104. categoryTap(index){
  105. this.currentOne = index
  106. this.currentTwo = 0
  107. },
  108. category(id,cateId){
  109. this.ids = id;
  110. if(cateId){
  111. this.checkedIds = cateId.split(',')
  112. }else{
  113. this.checkedIds = []
  114. }
  115. let funApi = '';
  116. if(this.storeNum){
  117. funApi = getCategory;
  118. }else{
  119. funApi = getStoreCategory;
  120. }
  121. funApi().then(res=>{
  122. this.categoryList = res.data;
  123. }).catch(err=>{
  124. this.$util.Tips({
  125. title: err
  126. });
  127. })
  128. },
  129. reset(){
  130. this.checkedIds = [];
  131. },
  132. define(){
  133. if(!this.checkedIds.length){
  134. this.$util.Tips({
  135. title: '请选择分类'
  136. });
  137. return
  138. }
  139. let data = {
  140. type:1,
  141. data:{
  142. cate_id:this.checkedIds
  143. },
  144. ids:this.ids
  145. }
  146. let funApi = '';
  147. if(this.storeNum){
  148. funApi = postBatchProcess;
  149. }else{
  150. funApi = storeBatchProcess;
  151. }
  152. funApi(data).then(res=>{
  153. this.$util.Tips({
  154. title: res.msg
  155. });
  156. this.$emit('successChange');
  157. }).catch(err=>{
  158. this.$util.Tips({
  159. title: err
  160. });
  161. })
  162. },
  163. closeDrawer() {
  164. this.$emit('closeDrawer');
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. /deep/checkbox{
  171. margin-right: 13rpx;
  172. }
  173. /deep/uni-checkbox .uni-checkbox-input{
  174. border-radius: 4rpx;
  175. width: 28rpx;
  176. height: 28rpx;
  177. }
  178. .classify{
  179. background-color: #fff;
  180. padding-bottom: 60rpx;
  181. .title{
  182. text-align: center;
  183. height: 108rpx;
  184. line-height: 108rpx;
  185. font-size: 32rpx;
  186. font-family: PingFang SC, PingFang SC;
  187. font-weight: 600;
  188. color: #333333;
  189. position: relative;
  190. padding: 0 30rpx;
  191. .close{
  192. width: 36rpx;
  193. height: 36rpx;
  194. line-height: 36rpx;
  195. background: #EEEEEE;
  196. border-radius: 50%;
  197. position: absolute;
  198. right: 30rpx;
  199. top:38rpx;
  200. .iconfont {
  201. font-weight: 300;
  202. font-size: 20rpx;
  203. }
  204. }
  205. }
  206. .list{
  207. height: 770rpx;
  208. .scroll-Y{
  209. height: 684rpx;
  210. }
  211. .item{
  212. width: 33.33%;
  213. padding-left: 32rpx;
  214. font-size: 26rpx;
  215. font-family: PingFang SC, PingFang SC;
  216. font-weight: 400;
  217. color: #666666;
  218. padding-top: 30rpx;
  219. .tips{
  220. color: #999;
  221. font-size: 24rpx;
  222. margin-bottom: 30rpx;
  223. }
  224. .itemn{
  225. margin-bottom: 58rpx;
  226. &.checked{
  227. color: #000;
  228. }
  229. &.on{
  230. color: #2A7EFB;
  231. }
  232. }
  233. &.on{
  234. background-color: #FAFAFA;
  235. }
  236. &.on2{
  237. background-color: #F5F5F5;
  238. }
  239. &.on3{
  240. width: 66.66%;
  241. }
  242. }
  243. }
  244. .footer {
  245. box-sizing: border-box;
  246. padding: 0 20rpx;
  247. width: 100%;
  248. height: 112rpx;
  249. background-color: #fff;
  250. position: fixed;
  251. bottom: 0;
  252. z-index: 30;
  253. height: calc(112rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  254. height: calc(112rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  255. padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
  256. padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
  257. left: 0;
  258. .bnt {
  259. width: 347rpx;
  260. height: 72rpx;
  261. border-radius: 50rpx;
  262. border: 1px solid #2A7EFB;
  263. color: #2A7EFB;
  264. font-size: 26rpx;
  265. font-family: PingFang SC, PingFang SC;
  266. font-weight: 500;
  267. &.on{
  268. background-color: #2A7EFB;
  269. color: #fff;
  270. }
  271. }
  272. }
  273. }
  274. </style>