Browse Source

首页悬浮

gaoxm 7 years ago
parent
commit
558c898d85
5 changed files with 48 additions and 59 deletions
  1. 32 17
      components/home/displayCard.vue
  2. 0 1
      components/main/count/Item.vue
  3. 1 3
      pages/index.vue
  4. 8 22
      store/count.js
  5. 7 16
      store/index.js

+ 32 - 17
components/home/displayCard.vue

@@ -6,13 +6,16 @@
          <count-box></count-box>
        </div>
        <div>
-         <p><span v-text="all"></span></p>
+         <p v-if="allCount[1].count"><span v-text="allCount[1].count"></span></p>
+         <p v-else><span>0</span></p>
        </div>
        <div>
-         <p><span v-text="payMoney"></span></p>
+         <p v-if="payMoney"><span>${{payMoney}}</span><span v-if="isShow">亿</span><span v-if="isMore">万</span></p>
+         <p v-else><span>0</span></p>
        </div>
        <div>
-         <p><span v-text="inquirySheet"></span></p>
+         <p v-if="allCount[3].count"><span v-text="allCount[3].count"></span></p>
+         <p v-else><span>0</span></p>
        </div>
        <a class="enter" @click="onRegisterClick"><img src="/images/all/enter.png"></a>
      </div>
@@ -24,7 +27,9 @@
     name: 'display-card',
     data () {
       return {
-        cardShow: true
+        cardShow: true,
+        isShow: false,
+        isMore: false
       }
     },
     components: {
@@ -34,6 +39,25 @@
       cardClose () {
         this.cardShow = false
       },
+      formatNumber (num) {
+        if (num > 99999999) {
+          this.isShow = true
+          let str2 = num.toString()
+          num = Math.floor(num / 100000000)
+          if (parseInt(str2.charAt(str2.length - 8)) > 8) {
+            num = num + 1
+          }
+        }
+        if (num > 9999 && num < 99999999) {
+          this.isMore = true
+          let str = num.toString()
+          num = Math.floor(num / 10000)
+          if (parseInt(str.charAt(str.length - 4)) > 4) {
+            num = num + 1
+          }
+        }
+        return num
+      },
       onRegisterClick () {
         this.$http.get('/register/page').then(response => {
           if (response.data) {
@@ -43,20 +67,11 @@
       }
     },
     computed: {
-      payMoney () {
-        let count = this.$store.state.count.payMoney.data
-        let supplierCount = count.content ? count.totalElements + '' : '0'
-        return supplierCount
+      allCount () {
+        return this.$store.state.count.allCount.data
       },
-      inquirySheet () {
-        let count = this.$store.state.count.inquirySheet.data
-        let supplierCount = count.content ? count.totalElements + '' : '0'
-        return supplierCount
-      },
-      all () {
-        let count = this.$store.state.supplier.merchant.merchantAll.data
-        let supplierCount = count.content ? count.totalElements + '' : '0'
-        return supplierCount
+      payMoney () {
+        return this.formatNumber(this.allCount[2].count)
       }
     }
   }

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

@@ -30,7 +30,6 @@
     methods: {
       formatNumber (num) {
 //        let re = /(\d+)(\d{3})/
-        console.log(1111111)
         if (num > 99999999) {
           this.isShow = true
           let str2 = num.toString()

+ 1 - 3
pages/index.vue

@@ -78,9 +78,7 @@
         store.dispatch('loadBanners', {type: 'home'}),
         store.dispatch('loadProductKinds', { id: 0 }),
         store.dispatch('loadNewsSnapshot', { page: 1, pageSize: 10 }),
-        store.dispatch('supplier/loadVendorAll', {page: 1, size: 20}),
-        store.dispatch('loadPayMoney', {page: 1, size: 20}),
-        store.dispatch('loadInquirySheet', {page: 1, size: 20}),
+        store.dispatch('loadAllCount', {_status: 'actived', usedFor: 'mall_home_banner'}),
         store.dispatch('loadBatchCommodities', {batchCodeList: store.state.option.url === 'http://www.usoftmall.com' ? [
           'BT2018013000000043',
           'BT2018013000000026',

+ 8 - 22
store/count.js

@@ -1,33 +1,19 @@
 export const state = () => ({
-  payMoney: {
-    fetching: false,
-    data: []
-  },
-  inquirySheet: {
+  allCount: {
     fetching: false,
     data: []
   }
 })
 
 export const mutations = {
-  REQUEST_PAYMONEY (state) {
-    state.payMoney.fetching = true
-  },
-  GET_PAYMONEY_FAILURE (state) {
-    state.payMoney.fetching = false
-  },
-  GET_PAYMONEY_SUCCESS (state, result) {
-    state.payMoney.fetching = false
-    state.payMoney.data = result
-  },
-  REQUEST_INQUIRYSHEET (state) {
-    state.inquirySheet.fetching = true
+  REQUEST_ALLCOUNT (state) {
+    state.allCount.fetching = true
   },
-  GET_INQUIRYSHEET_FAILURE (state) {
-    state.inquirySheet.fetching = false
+  GET_ALLCOUNT_FAILURE (state) {
+    state.allCount.fetching = false
   },
-  GET_INQUIRYSHEET_SUCCESS (state, result) {
-    state.inquirySheet.fetching = false
-    state.inquirySheet.data = result
+  GET_ALLCOUNT_SUCCESS (state, result) {
+    state.allCount.fetching = false
+    state.allCount.data = result
   }
 }

+ 7 - 16
store/index.js

@@ -437,24 +437,15 @@ export const actions = {
         commit('option/REQUEST_STORE_STATUS_FAILURE', err)
       })
   },
-  // 获取首页展示交易金额数
-  loadPayMoney ({commit}, params) {
-    commit('count/REQUEST_PAYMONEY')
-    return axios.get('/vendor/introduction/vendor/list', {params})
+  // 获取首页悬浮交易金额、供应商、询价单计数器
+  loadAllCount ({commit}, params) {
+    commit('count/REQUEST_ALLCOUNT')
+    return axios.get('/api/product/commoncount', {params})
       .then(res => {
-        commit('count/GET_PAYMONEY_SUCCESS', res.data)
+        console.log(res.data)
+        commit('count/GET_ALLCOUNT_SUCCESS', res.data)
       }, (err) => {
-        commit('count/GET_PAYMONEY_FAILURE', err)
-      })
-  },
- // 获取首页展示询价单数
-  loadInquirySheet ({commit}, params) {
-    commit('count/REQUEST_INQUIRYSHEET')
-    return axios.get('/vendor/introduction/vendor/list', {params})
-      .then(res => {
-        commit('count/GET_INQUIRYSHEET_SUCCESS', res.data)
-      }, (err) => {
-        commit('count/GET_INQUIRYSHEET_FAILURE', err)
+        commit('count/GET_ALLCOUNT_FAILURE', err)
       })
   }
 }