Browse Source

1、优化第二十五期需求

shenjj 7 years ago
parent
commit
62775fd7a4
3 changed files with 26 additions and 14 deletions
  1. 16 13
      pages/mobile/center/vendor/attentionBus.vue
  2. 6 1
      store/product.js
  3. 4 0
      store/product/component.js

+ 16 - 13
pages/mobile/center/vendor/attentionBus.vue

@@ -46,7 +46,7 @@
       middleware: 'authenticated',
       middleware: 'authenticated',
       fetch({store}) {
       fetch({store}) {
         return Promise.all([
         return Promise.all([
-          store.dispatch('product/getUserCollectCode', {keyword: '', count: 10, page: 1, type: 'yes', enUU: store.state.option.user.data.enterprise.uu})
+          store.dispatch('product/getUserCollectCode', {keyword: '', count: 20, page: 1, type: 'yes', enUU: store.state.option.user.data.enterprise.uu})
         ])
         ])
       },
       },
       data() {
       data() {
@@ -109,30 +109,33 @@
             this.$http.post('/produce/kindConcern/modify', param).then(res => {
             this.$http.post('/produce/kindConcern/modify', param).then(res => {
               this.collectResult = '取消成功'
               this.collectResult = '取消成功'
               this.timeoutCount++
               this.timeoutCount++
-              this.attentionList.splice(index, 1)
-              if (this.attentionList.length <= 15 && this.page < this.allPage) {
-                this.page++
-                this.getAttentionListArray(this.page)
-              }
+              // kindConcern.status = 0
+              this.$store.dispatch('product/UpdateCollectCode', { key: index, status: 0 })
+              // this.attentionList.splice(index, 1)
+              // if (this.attentionList.length <= 15 && this.page < this.allPage) {
+              //   this.page++
+              //   this.getAttentionListArray(this.page)
+              // }
             })
             })
           } else {
           } else {
             this.$http.post('/produce/kindConcern/modify', param).then(res => {
             this.$http.post('/produce/kindConcern/modify', param).then(res => {
               this.collectResult = '关注成功'
               this.collectResult = '关注成功'
               this.timeoutCount++
               this.timeoutCount++
-              this.attentionList.splice(index, 1)
-              if (this.attentionList.length <= 15 && this.page < this.allPage) {
-                this.page++
-                this.getAttentionListArray(this.page)
-              }
+              this.$store.dispatch('product/UpdateCollectCode', {key: index, status: 1})
+              // this.attentionList.splice(index, 1)
+              // if (this.attentionList.length <= 15 && this.page < this.allPage) {
+              //   this.page++
+              //   this.getAttentionListArray(this.page)
+              // }
             })
             })
           }
           }
         },
         },
         getAttentionListArray(page) {
         getAttentionListArray(page) {
           this.isSearchSearchingMore = true
           this.isSearchSearchingMore = true
           if (this.activeType === 'attention') {
           if (this.activeType === 'attention') {
-            this.$store.dispatch('product/getUserCollectCode', {keyword: this.keyword, count: 20, page: page, type: 'yes', enUU: this.$store.state.option.user.data.enterprise.uu})
+            this.$store.dispatch('product/getUserCollectCode', {keyword: this.keyword, count: 20, page: page, enUU: this.$store.state.option.user.data.enterprise.uu})
           } else {
           } else {
-            this.$store.dispatch('product/getUserCollectCode', {keyword: this.keyword, count: 20, page: page, type: 'no', enUU: this.$store.state.option.user.data.enterprise.uu})
+            this.$store.dispatch('product/getUserCollectCode', {keyword: this.keyword, count: 20, page: page, enUU: this.$store.state.option.user.data.enterprise.uu})
           }
           }
         },
         },
         getMoreSearch() {
         getMoreSearch() {

+ 6 - 1
store/product.js

@@ -223,11 +223,16 @@ export const actions = {
   // 获取用户收藏类目数据
   // 获取用户收藏类目数据
   getUserCollectCode({ commit }, params = {}) {
   getUserCollectCode({ commit }, params = {}) {
     commit('component/REQUEST_COLLECTCODE')
     commit('component/REQUEST_COLLECTCODE')
-    return axios.get('/produce/kindConcern/list', { params: params })
+    return axios.get('/produce/kindConcern/kindList', { params: params })
       .then(response => {
       .then(response => {
         commit('component/REQUEST_COLLECTCODE_SUCCESS', response.data)
         commit('component/REQUEST_COLLECTCODE_SUCCESS', response.data)
       }, err => {
       }, err => {
         commit('component/REQUEST_COLLECTCODE_FAILURE', err)
         commit('component/REQUEST_COLLECTCODE_FAILURE', err)
       })
       })
+  },
+  // 修改当前选择的对象,是否已关注
+  UpdateCollectCode({commit}, params = {}) {
+    commit('component/UpdateOne_PRODUCTINFO', {key: params.key, status: params.status})
   }
   }
 }
 }
+

+ 4 - 0
store/product/component.js

@@ -60,5 +60,9 @@ export const mutations = {
   },
   },
   REQUEST_NOWPRODUCTINFO_FAILURE (state) {
   REQUEST_NOWPRODUCTINFO_FAILURE (state) {
     state.nowProductInfo = false
     state.nowProductInfo = false
+  },
+
+  UpdateOne_PRODUCTINFO(state, resulut) {
+    state.collectCode.data.content[resulut.key].status = resulut.status
   }
   }
 }
 }