Browse Source

1.计数器算法优化。
2.处理产品详情页,修改店铺类型后刷新页面店铺信息不变的bug。

yangc 8 years ago
parent
commit
381bf7bec5
3 changed files with 18 additions and 2 deletions
  1. 1 1
      components/main/count/Item.vue
  2. 1 1
      pages/store/_uuid/_batchCode.vue
  3. 16 0
      store/shop.js

+ 1 - 1
components/main/count/Item.vue

@@ -19,7 +19,7 @@
     methods: {
       formatNumber (num) {
         let re = /(\d+)(\d{3})/
-        num = (Array(10 - String(num).length).join(0) + num)
+        num = (Array(Math.max(0, 10 - String(num).length)).join(0) + num)
         while (re.test(num)) {
           num = num.replace(re, '$1,$2')
         }

+ 1 - 1
pages/store/_uuid/_batchCode.vue

@@ -11,7 +11,7 @@ export default {
   layout: 'shop',
   fetch ({ store, route }) {
     return Promise.all([
-      store.dispatch('shop/findStoreInfoFromUuid', route.params),
+//      store.dispatch('shop/findStoreInfoFromUuid', route.params),
       store.dispatch('shop/findCommodityOnBatchInfo', route.params)
     ])
   },

+ 16 - 0
store/shop.js

@@ -10,6 +10,19 @@ function StoreFocusList ({ commit }, params = {}) {
       commit('storeInfo/GET_FOCUSLIST_FAILURE', err)
     })
 }
+// 根据UUID获取某店铺信息
+function findStoreInfoFromUuid ({ commit }, params = {}) {
+  commit('storeInfo/REQUEST_STORE_INFO')
+  return axios.get('/api/store-service/stores', { params })
+    .then(response => {
+      commit('storeInfo/GET_STORE_INFO_SUCCESS', response.data)
+      return Promise.all([
+        StoreFocusList({ commit }, {id: response.data.id})
+      ])
+    }, err => {
+      commit('storeInfo/GET_STORE_INFO_FAILURE', err)
+    })
+}
 
 export const actions = {
   // 根据UUID获取某店铺信息
@@ -35,6 +48,9 @@ export const actions = {
         return axios.get(`/api/commodity/component/${commodity.uuid}`)
           .then(response => {
             commit('storeInfo/GET_COMPONENT_SUCCESS', response.data)
+            return Promise.all([
+              findStoreInfoFromUuid({ commit }, {uuid: commodity.storeid})
+            ])
           }, err => {
             commit('storeInfo/GET_COMPONENT_FAILURE', err)
           })