yangc 7 years ago
parent
commit
764952dcef
1 changed files with 32 additions and 13 deletions
  1. 32 13
      pages/mobile/center/user/collect/component/_key.vue

+ 32 - 13
pages/mobile/center/user/collect/component/_key.vue

@@ -49,11 +49,6 @@
   export default {
     middleware: 'authenticated',
     layout: 'mobileNoHeader',
-    fetch ({ store, route }) {
-      return Promise.all([
-        store.dispatch('searchData/searchForListInMobile', { page: 1, count: 10, type: 'component', keyword: route.params.key })
-      ])
-    },
     data () {
       return {
         keyword: '',
@@ -92,6 +87,12 @@
         immediate: true
       }
     },
+    fetch ({ store, params }) {
+      console.log(111)
+      return Promise.all([
+        store.dispatch('searchData/searchForListInMobile', { page: 1, count: 10, type: 'component', keyword: params.key })
+      ])
+    },
     computed: {
       compCollectList () {
         return this.$store.state.searchData.searchList.lists
@@ -169,15 +170,33 @@
       },
       cancelFocus: function (item, event) {
         event.stopPropagation()
-        if (!item.isFocus) {
-          this.$store.dispatch('product/saveEntity', {cmpuuid: item.cmpUuId, kind: 2})
-          this.collectResult = '收藏成功'
-          this.timeoutCount++
+        if (item.standard === 1) {
+          if (!item.isFocus) {
+            this.$http.post('/trade/collection/save', {cmpuuid: item.cmpUuId, kind: 2})
+              .then(res => {
+                if (res.data.code === 1) {
+                  this.onRemind('收藏成功')
+                } else {
+                  this.onRemind(res.data.data || '收藏失败')
+                }
+              }, err => {
+                this.onRemind(err.response.data || '收藏失败')
+                console.log(err)
+              })
+          } else {
+            this.$http.post('/trade/collection/delete', [item.focusId]).then(response => {
+              if (response.data === 'success') {
+                this.onRemind('取消收藏成功')
+              } else {
+                this.onRemind('取消收藏失败')
+              }
+            }, err => {
+              console.log(err)
+              this.onRemind(err.response.data || '取消收藏失败')
+            })
+          }
         } else {
-          this.$http.post('/trade/collection/delete/cmpId', [item.focusId]).then(response => {
-            this.collectResult = '取消成功'
-            this.timeoutCount++
-          })
+          this.onRemind('非标物料暂不可收藏')
         }
       },
       reloadList: function () {