ソースを参照

fix[litemall-vue]: 收藏功能修复

Junling Bu 6 年 前
コミット
fc3886fff4

+ 11 - 6
litemall-vue/src/views/items/detail/index.vue

@@ -148,12 +148,17 @@ computed: {
     },
     addCollect() {
       collectAddOrDelete({valueId: this.itemId, type: 0}).then(res => {
-        let type = res.data.data.type;
-        this.goods.userHasCollect = type === 'add' ? 1 : 0;
-        this.$toast({
-          message: type === 'add' ? '添加成功' : '取消成功',
-          duration: 1500
-        });
+        if(this.goods.userHasCollect === 1){
+          this.goods.userHasCollect = 0
+        }
+        else{
+          this.goods.userHasCollect = 1
+          this.$toast({
+            message: '收藏成功',
+            duration: 1500
+        });          
+        }
+
       });
     },
     getProductId(s1, s2) {

+ 4 - 2
litemall-vue/src/views/user/module-collect/index.vue

@@ -60,8 +60,10 @@ export default {
   methods: {
     init() {
       collectList({type:0, page:this.page, limit:this.limit}).then(res => {
-        const { collectList, page } = res.data.data;
-        this.items.push(...collectList);
+        this.page = res.data.data.page;
+        this.limit = res.data.data.limit;
+        this.total = res.data.data.total;
+        this.items.push(...res.data.data.list);
       });
     },
     cancelCollect(event, i, item) {