index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <view class="container">
  3. <view class="storeClassContent">
  4. <view class="storeClassContent_item" v-for="(item, index) in storeClassList" :key="index">
  5. <view class="storeClassContent_item_father" @click.stop="selectStoreClass(item)" @longtap.stop="deleteItem(item,index)">
  6. <view class="storeClassContent_item_father_label">
  7. <button class="iconfont" :class="selectStoreClassId == item.store_category_id ? 'icon-jian' : 'icon-tianjia1'"></button>
  8. <span>{{ item.cate_name }}</span>
  9. </view>
  10. <view class="storeClassContent_item_father_right">
  11. <span class="iconfont icon-bianji" @click.stop="edit(item)"></span>
  12. </view>
  13. </view>
  14. <view class="storeClassContent_item_child" v-if="selectStoreClassId == item.store_category_id">
  15. <view class="storeClassContent_item_child_item" v-for="(val, i) in item.children" :key="i" @longtap="deleteItem(val,i)">
  16. <span>{{ val.cate_name }}</span>
  17. <span class="iconfont icon-bianji" @click.stop="edit(val)"></span>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="storeClassContent_tip">
  22. <text class="iconfont icon-duoshanghupc-shuomingdanchuang"></text>
  23. <span>长按分类标题可删除</span>
  24. </view>
  25. </view>
  26. <view class="handle_bottom"><navigator :url="`/pages/product/storeClassification/addStoreClass?mer_id=${mer_id}`" class="handle_bottom_button">添加分类</navigator></view>
  27. </view>
  28. </template>
  29. <script>
  30. // +----------------------------------------------------------------------
  31. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  32. // +----------------------------------------------------------------------
  33. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  34. // +----------------------------------------------------------------------
  35. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  36. // +----------------------------------------------------------------------
  37. // | Author: CRMEB Team <admin@crmeb.com>
  38. // +----------------------------------------------------------------------
  39. import { Modal, Toast } from '../../../libs/uniApi.js';
  40. import { storeClassifyLst, storeClassifyDel } from "@/api/product";
  41. export default {
  42. data() {
  43. return {
  44. selectStoreClassId: 1,
  45. mer_id: '',
  46. storeClassList: []
  47. };
  48. },
  49. onLoad(options) {
  50. this.mer_id = options.mer_id
  51. this.getStoreClassification()
  52. },
  53. onShow: function() {
  54. },
  55. methods: {
  56. deleteItem(item,index) {
  57. let that = this
  58. Modal('温馨提示', `"${item.cate_name}"将被删除,请问是否继续`).then(() => {
  59. storeClassifyDel(that.mer_id, item.store_category_id).then(res => {
  60. that.$util.Tips({
  61. title: res.message,
  62. icon: 'success'
  63. });
  64. that.getStoreClassification()
  65. }).catch(res => {
  66. return that.$util.Tips({
  67. title: res
  68. });
  69. });
  70. // Toast('删除成功');
  71. })
  72. },
  73. selectStoreClass(item) {
  74. if (item.store_category_id == this.selectStoreClassId) {
  75. this.selectStoreClassId = '';
  76. return;
  77. }
  78. this.selectStoreClassId = item.store_category_id;
  79. },
  80. /*获取店铺分类*/
  81. getStoreClassification(){
  82. var that = this;
  83. uni.showLoading({
  84. title: '加载中',
  85. mask: true
  86. });
  87. storeClassifyLst(this.mer_id).then(
  88. res => {
  89. uni.hideLoading();
  90. that.storeClassList = res.data;
  91. },
  92. error => {
  93. that.$util.Tips({
  94. title: error.msg
  95. })
  96. }
  97. );
  98. },
  99. /*编辑*/
  100. edit(item){
  101. uni.navigateTo({
  102. url: `/pages/product/storeClassification/addStoreClass?mer_id=${this.mer_id}&pid=${item.store_category_id}`
  103. })
  104. }
  105. }
  106. };
  107. </script>
  108. <style lang="scss" scoped>
  109. @import './scss/index.scss';
  110. </style>