wangcz 7 жил өмнө
parent
commit
d75dd57fe9

+ 27 - 42
components/home/displayCard.vue

@@ -4,18 +4,19 @@
      <div class="content" v-if="cardShow">
        <div>
          <ul class="list-unstyled">
-           <li ref="pingdanListWrapper" v-for="(item, index) in title"  :style="'top: -' + 30 * timerIndex + 'px'" :class="{'top': isTop}">
-             <span>{{item}}</span>
+           <li ref="pingdanListWrapper" v-for="item in counts"  :style="'top: -' + 30 * timerIndex + 'px'" :class="{'top': isTop}">
+             <span>{{item.item}}</span>
            </li>
          </ul>
          <ul class="list-unstyled">
-           <li ref="pingdanListWrapper" v-for="(c, index) in counts"  :style="'top: -' + 30 * timerIndex + 'px'" :class="{'top': isTop}">
+           <li ref="pingdanListWrapper" v-for="c in counts"  :style="'top: -' + 30 * timerIndex + 'px'" :class="{'top': isTop}">
              <span v-for="(item, index) in formatScrollNumber(c.count, c.logo)" class="count-distance" :class="'count' + index">{{item}}</span>
            </li>
          </ul>
        </div>
        <div v-for="item in itemCounts">
-         <p><span v-html="item.count"></span>
+         <p>
+           <span v-html="item.count"></span>
            <span style="color: #333" v-if="item.type === 3">家</span>
            <span style="color: #333" v-if="item.type === 2">条</span>
          </p>
@@ -31,8 +32,7 @@
         cardShow: true,
         timerIndex: 0,
         isTop: false, // 判断是否滚动至顶,
-        timer: {}, // 定时器实体
-        title: [ '品牌', '现货', '规格书', '店铺' ]
+        timer: {} // 定时器实体
       }
     },
     mounted () {
@@ -52,9 +52,7 @@
               _transitionEvent && this.$refs.pingdanListWrapper[0].addEventListener(
                 _transitionEvent, () => {
                   if (isChange) {
-                    let title = this.title.shift()
                     let count = this.counts.shift()
-                    this.title.push(title)
                     this.counts.push(count)
                     this.timerIndex = 0
                     isChange = false
@@ -71,7 +69,6 @@
         this.cardShow = false
       },
       formatScrollNumber (num, logo) {
-//        let re = /(\d+)(\d{3})/
         if (num) {
           if (num > 99999999) {
             let str2 = num.toString()
@@ -104,11 +101,6 @@
             }
           }
         }
-//        while (re.test(num)) {
-//          num = num.replace(re, '$1,$2')
-//        }
-//        num = num.split('')
-//        console.log(num)
         let _arr = []
         for (let i = 0; i < num.length; i++) {
           _arr.push(num[i])
@@ -163,14 +155,8 @@
       },
     },
     computed: {
-      allCount () {
-        return this.$store.state.count.allCount.data
-      },
-      payMoneyLast () {
-        return this.allCount[0] ? this.formatNumber(this.allCount[0].count, 1) : 0
-      },
-      payMoney () {
-        return this.allCount[1] ? this.formatNumber(this.allCount[1].count, 1) : 0
+      counter () {
+        return this.$store.state.option.counter.data
       },
       inquirySheet () {
         let sheetNum = this.$store.state.count.inquirySheet.data
@@ -180,33 +166,32 @@
         let lastSheetNum = this.$store.state.count.inquirySheetLast.data
         return lastSheetNum ? this.formatDouble(lastSheetNum.count) : 0
       },
-      all () {
-        let count = this.$store.state.supplier.merchant.merchantAll.data
-        let supplierCount = count.content ? count.totalElements + '' : 0
-        return this.formatNumber(supplierCount, 0)
-      },
       itemCounts () {
         let arr = []
-        arr.push({count: this.all ? this.all : 0, type: 3}, {count: this.payMoney ? this.payMoney : 0, type: 1}, {count: this.payMoneyLast ? this.payMoneyLast : 0, type: 1}, {count: this.inquirySheet ? this.inquirySheet : 0, type: 2}, {count: this.inquirySheetLast ? this.inquirySheetLast : 0, type: 2})
+        let count = this.baseUtils.deepCopy(this.counter)
+        count.forEach((value) => {
+          if (value.usedFor === 'mall_home_banner') {
+            value.type = value.detno === 2 ? 3: 1
+            value.count = this.formatNumber(value.count)
+            arr.push(value)
+          }
+        })
+        arr = arr.sort((a,b) => {return a.detno - b.detno})
+        arr.push({count: this.inquirySheet ? this.inquirySheet : 0, type: 2},
+          {count: this.inquirySheetLast ? this.inquirySheetLast : 0, type: 2})
         return arr
       },
-      list () {
-        let list = JSON.parse(JSON.stringify(this.$store.state.provider.stores.storeList.data))
-        return list
-      },
       counts () {
         let arr = []
-        let countM = this.$store.state.product.common.counts.data
-        if (countM) {
-          countM.forEach((value, key, $data) => {
-            arr.push({count: value.count, logo: 1})
-          })
-        }
-        arr.push({count: this.list.totalElements, logo: 0})
+        let count = this.baseUtils.deepCopy(this.counter)
+        count.forEach((value) => {
+          if (value.usedFor === 'b2c_index') {
+            value.logo = value.detno === 4 ? 0: 1
+            arr.push(value)
+          }
+        })
+        arr = arr.sort((a,b) => {return a.detno - b.detno})
         return arr
-      },
-      enterprise () {
-        return this.user.data.enterprise
       }
     }
   }

+ 12 - 25
components/mobile/common/StatisticsMobile.vue

@@ -156,8 +156,8 @@
       }
     },
     computed: {
-      allCount () {
-        return this.$store.state.count.allCount.data
+      counter () {
+        return this.$store.state.option.counter.data
       },
       inquirySheet () {
         let sheetNum = this.$store.state.count.inquirySheet.data
@@ -167,35 +167,22 @@
         let lastSheetNum = this.$store.state.count.inquirySheetLast.data
         return lastSheetNum ? this.formatDouble(lastSheetNum.count) : 0
       },
-      all () {
-        let count = this.$store.state.supplier.merchant.merchantAll.data
-        return count.content ? count.totalElements : '0'
-      },
-      counts () {
-        return this.$store.state.product.common.counts
-      },
-      list () {
-        let list = JSON.parse(JSON.stringify(this.$store.state.provider.stores.storeList.data))
-        // console.log(list)
-        return list.totalElements
-      },
       itemData () {
         let str = []
-        if (this.counts.data) {
-          this.counts.data.forEach((value, key, $data) => {
-            str.push({id: $data[key].item, count: $data[key].count, type: 1})
+        if (this.counter) {
+          this.counter.forEach((value, key, $data) => {
+            if($data[key].item === '店铺' || $data[key].item ==='供应商') {
+              str.push({id: $data[key].item, count: $data[key].count, type: 3})
+            } else if($data[key].item === '本年交易金额' || $data[key].item ==='上年交易金额') {
+              str.push({id: $data[key].item, count: $data[key].count, type: 4})
+            } else {
+              str.push({id: $data[key].item, count: $data[key].count, type: 1})
+            }
           })
         }
-        str.push({id: '供应商', count: this.all ? this.all : 0, type: 3})
         str.push({id: '本月询价单', count: this.$store.state.count.inquirySheet.data ? this.$store.state.count.inquirySheet.data.count : 0, type: 2})
         str.push({id: '上月询价单', count: this.$store.state.count.inquirySheetLast.data ? this.$store.state.count.inquirySheetLast.data.count : 0, type: 2})
-        if (this.allCount) {
-          this.allCount.forEach((value, key, $data) => {
-            str.push({id: $data[key].item, count: $data[key].count, type: 4})
-          })
-        }
-        str.push({id: '店铺', count: this.list ? this.list : 0, type: 3})
-        str = [str[1], str[0], str[2], str[3], str[8], str[5], str[4], str[6], str[7]]
+        str = [str[1], str[0], str[2], str[4], str[3], str[8], str[7], str[5], str[6]]
         return str
       },
       itemLeft () {

+ 2 - 10
pages/index.vue

@@ -52,25 +52,17 @@
 //      let nowMonth = today.getMonth() + 1
 //      let LastMonth = today.getMonth()
       return !store.state.option.isMobile ? Promise.all([
+        store.dispatch('loadCounterData'),
         store.dispatch('loadNewFloors', {type: 'home_floor_f1,home_floor_f2,home_floor_f3,home_floor_f4,home_floor_f5,home_expand_f1,home_expand_f2'}),
         store.dispatch('loadBanners', {type: 'home_banner_carousel'}),
         store.dispatch('loadProductKinds', { id: 0 }),
         store.dispatch('loadNewsSnapshot', { page: 1, pageSize: 10 }),
-        store.dispatch('supplier/loadVendorAll', {page: 1, size: 20}),
-        store.dispatch('loadAllCount', {_status: 'actived', usedFor: 'mall_home_banner'}),
         store.dispatch('loadInquirySheet'),
-        store.dispatch('loadProductCounts', { _status: 'actived' }),
-//        store.dispatch('loadInquirySheetLast', {year: nowYear, month: LastMonth}),
-        store.dispatch('provider/findSimilarStoreList', {page: 1, count: 10, type: 'ORIGINAL_FACTORY-DISTRIBUTION-AGENCY-CONSIGNMENT', keyword: ''}),
         store.dispatch('applyPurchase/loadPurchaseManList', {pageNumber: 1, pageSize: 50, enUU: store.state.option.user.data.enterprise ? store.state.option.user.data.enterprise.uu : null}),
         store.dispatch('loadStoreStatus', { op: 'check' })
       ]) : Promise.all([
-        store.dispatch('loadProductCounts', { _status: 'actived' }),
-        store.dispatch('supplier/loadVendorAll', {page: 1, size: 20}),
-        store.dispatch('loadAllCount', {_status: 'actived', usedFor: 'mall_home_banner'}),
+        store.dispatch('loadCounterData'),
         store.dispatch('loadInquirySheet'),
-//        store.dispatch('loadInquirySheetLast', {year: nowYear, month: LastMonth}),
-        store.dispatch('provider/findSimilarStoreList', {page: 1, count: 10, type: 'ORIGINAL_FACTORY-DISTRIBUTION-AGENCY-CONSIGNMENT', keyword: ''}),
         store.dispatch('applyPurchase/loadMobileHomeList', {pageNumber: 1, pageSize: 5, enUU: store.state.option.user.data.enterprise ? store.state.option.user.data.enterprise.uu : null})
       ])
     },

+ 10 - 0
store/index.js

@@ -98,6 +98,16 @@ export const actions = {
         commit('option/REQUEST_LOGOUT_SUCCESS', response.data)
       })
   },
+  // 获取商城统计数据
+  loadCounterData ({commit}) {
+    commit('option/REQUEST_COUNTER')
+    return axios.get('/api/product/commoncount')
+      .then(res => {
+        commit('option/REQUEST_COUNTER_SUCCESS', res.data)
+      }, err => {
+        commit('option/REQUEST_COUNTER_FAILURE')
+      })
+  },
   // 获取楼层配置
   loadFloors({ commit }) {
     commit('floor/REQUEST_LIST')

+ 16 - 0
store/option.js

@@ -18,6 +18,11 @@ export const state = () => ({
     fetching: false,
     data: {}
   },
+  //计数器统计数据
+  counter: {
+    fetching: false,
+    data: {}
+  },
   // 系统设置
   globalOptions: {
     fetching: false,
@@ -71,6 +76,17 @@ export const mutations = {
     state.user.fetching = false
     state.user.data = {}
   },
+  REQUEST_COUNTER (state) {
+    state.counter.fetching = true
+  },
+  REQUEST_COUNTER_SUCCESS (state, result) {
+    state.counter.fetching = false
+    state.counter.data = result || {}
+  },
+  REQUEST_COUNTER_FAILURE (state) {
+    state.counter.fetching = false
+    state.counter.data = {}
+  },
   REQUEST_ADMIN_INFO (state) {
     state.infoWithAdmin.fetching = true
   },