index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. import { Modal, Toast } from '../../../libs/uniApi.js';
  31. import { storeClassifyLst, storeClassifyDel } from "@/api/product";
  32. export default {
  33. data() {
  34. return {
  35. selectStoreClassId: 1,
  36. mer_id: '',
  37. storeClassList: []
  38. };
  39. },
  40. onLoad(options) {
  41. this.mer_id = options.mer_id
  42. this.getStoreClassification()
  43. },
  44. onShow: function() {
  45. },
  46. methods: {
  47. deleteItem(item,index) {
  48. let that = this
  49. Modal('温馨提示', `"${item.cate_name}"将被删除,请问是否继续`).then(() => {
  50. storeClassifyDel(that.mer_id, item.store_category_id).then(res => {
  51. that.$util.Tips({
  52. title: res.message,
  53. icon: 'success'
  54. });
  55. that.getStoreClassification()
  56. }).catch(res => {
  57. return that.$util.Tips({
  58. title: res
  59. });
  60. });
  61. // Toast('删除成功');
  62. })
  63. },
  64. selectStoreClass(item) {
  65. if (item.store_category_id == this.selectStoreClassId) {
  66. this.selectStoreClassId = '';
  67. return;
  68. }
  69. this.selectStoreClassId = item.store_category_id;
  70. },
  71. /*获取店铺分类*/
  72. getStoreClassification(){
  73. var that = this;
  74. uni.showLoading({
  75. title: '加载中',
  76. mask: true
  77. });
  78. storeClassifyLst(this.mer_id).then(
  79. res => {
  80. uni.hideLoading();
  81. that.storeClassList = res.data;
  82. },
  83. error => {
  84. that.$util.Tips({
  85. title: error.msg
  86. })
  87. }
  88. );
  89. },
  90. /*编辑*/
  91. edit(item){
  92. uni.navigateTo({
  93. url: `/pages/product/storeClassification/addStoreClass?mer_id=${this.mer_id}&pid=${item.store_category_id}`
  94. })
  95. }
  96. }
  97. };
  98. </script>
  99. <style lang="scss" scoped>
  100. @import './scss/index.scss';
  101. </style>