Browse Source

器件详情页收藏

yangc 7 years ago
parent
commit
ff363c247a
1 changed files with 14 additions and 3 deletions
  1. 14 3
      components/mobile/brand/ComponentDetail.vue

+ 14 - 3
components/mobile/brand/ComponentDetail.vue

@@ -306,9 +306,20 @@
       collectComponent: function () {
         if (this.user.logged) {
           if (!this.isCollect) {
-            this.$store.dispatch('product/saveEntity', {componentid: this.component.id, kind: 2})
-            this.collectResult = '收藏成功'
-            this.timeoutCount++
+            this.$http.post('/trade/collection/save', {componentid: this.component.id, kind: 2})
+              .then(res => {
+                if (res.data.code === 1) {
+                  this.collectResult = '收藏成功'
+                  this.$store.dispatch('product/saveStores')
+                } else {
+                  this.collectResult = res.data.data || '收藏失败'
+                }
+                this.timeoutCount++
+              }, err => {
+                this.collectResult = err.response.data || '收藏失败'
+                this.timeoutCount++
+                console.log(err)
+              })
           } else {
             this.$http.post('/trade/collection/delete/cmpId', [this.component.id]).then(response => {
               this.collectResult = '取消成功'