Pārlūkot izejas kodu

手机端增加统计表

Administrator 7 gadi atpakaļ
vecāks
revīzija
ea97dcd027

+ 16 - 2
components/home/count/displayCard.vue

@@ -114,6 +114,20 @@
         }
         return num
       },
+      formatDouble (num) {
+        if (num.toString().indexOf('E') !== -1) {
+          let arr = num.toString().split('E')
+          num = arr[0] * Math.pow(10, arr[1])
+        }
+        if (num > 99999999) {
+          num = (num / 100000000).toFixed(2).slice(num.length - 1, 4) + '亿'
+        } else if (num > 9999) {
+          num = (num / 10000).toFixed(2).slice(num.length - 1, 4) + '万'
+        } else {
+            num += ''
+        }
+        return num
+      },
       goStoreApply: function () {
         if (this.user.logged) {
           if (this.enterprise && this.enterprise.isVendor === 313) {
@@ -138,11 +152,11 @@
       },
       inquirySheet () {
         let sheetNum = this.$store.state.count.inquirySheet.data.count
-        return this.formatNumber(sheetNum, 3)
+        return this.formatDouble(sheetNum)
       },
       inquirySheetLast () {
         let lastSheetNum = this.$store.state.count.inquirySheetLast.data.count
-        return this.formatNumber(lastSheetNum, 4)
+        return this.formatDouble(lastSheetNum)
       },
       all () {
         let count = this.$store.state.supplier.merchant.merchantAll.data

+ 8 - 2
components/mobile/Home.vue

@@ -48,6 +48,11 @@
           </nuxt-link>
         </li>
       </ul>
+
+      <div class="display_card">
+        <statistics-mobile/>
+      </div>
+
       <div class="seek-title">
         <img src="/images/mobile/@2x/applyPurchase/home/seek-title.png" alt="">
         <span>最新求购信息</span>
@@ -75,7 +80,7 @@
 <script>
   import SeekList from './applyPurchase/SeekList.vue'
   import MainSearch from '~/components/mobile/search/MainSearch.vue'
-  import { RemindBox, LoginBox, PullUp } from '~components/mobile/common'
+  import { RemindBox, LoginBox, PullUp, StatisticsMobile } from '~components/mobile/common'
   export default {
     data () {
       return {
@@ -113,7 +118,8 @@
       MainSearch,
       RemindBox,
       LoginBox,
-      PullUp
+      PullUp,
+      StatisticsMobile
     },
     watch: {
       '$store.state.applyPurchase.purchaseManList.purchaseHomeList.data': {

+ 153 - 0
components/mobile/common/StatisticsMobile.vue

@@ -0,0 +1,153 @@
+<template>
+  <div class="statistics">
+    <ul class="list-inline" :style="{top: widthTop + 'rem'}" :class="{no_tran: widthTop == 2.4}">
+      <li v-for="item in itemData">
+        <span v-text="item.id"></span>
+        <span v-text="formatNumber(item.count)"></span>
+      </li>
+    </ul>
+  </div>
+</template>
+<script>
+  export default {
+    name: 'StatisticsView',
+    data () {
+      return {
+        step: 1,
+        widthTop: 0,
+        timerIndex: 0,
+        timer: {} // 定时器实体
+      }
+    },
+    mounted () {
+      this.$nextTick(() => {
+        this.changeInterval()
+      })
+    },
+    methods: {
+      changeInterval () {
+        setInterval(() => {
+          this.widthTop += -0.6
+          if (this.widthTop < -2.4) {
+            this.widthTop = 0.6
+          }
+        }, 3000)
+      },
+      formatNumber (num, type) {
+        if (num.toString().indexOf('E') !== -1) {
+          let arr = num.toString().split('E')
+          num = arr[0] * Math.pow(10, arr[1])
+        }
+        if (num > 99999999) {
+          let str2 = num.toString()
+          num = Math.floor(num / 100000000)
+          if (parseInt(str2.charAt(str2.length - 8)) > 8) {
+            num = num + 1
+          }
+          num += '亿'
+        } else if (num > 9999) {
+          let str = num.toString()
+          num = Math.floor(num / 10000)
+          if (parseInt(str.charAt(str.length - 4)) > 4) {
+            num = num + 1
+          }
+          num += '万'
+        } else {
+          if (type === 1 || type === 2) {
+            num += '元'
+          } else {
+            num += ''
+          }
+        }
+        return num
+      },
+      formatDouble (num) {
+        if (num.toString().indexOf('E') !== -1) {
+          let arr = num.toString().split('E')
+          num = arr[0] * Math.pow(10, arr[1])
+        }
+        if (num > 99999999) {
+          num = (num / 100000000).toFixed(2).slice(num.length - 1, 4) + '亿'
+        } else if (num > 9999) {
+          num = (num / 10000).toFixed(2).slice(num.length - 1, 4) + '万'
+        } else {
+          num += ''
+        }
+        return num
+      }
+    },
+    computed: {
+      allCount () {
+        return this.$store.state.count.allCount.data
+      },
+      inquirySheet () {
+        let sheetNum = this.$store.state.count.inquirySheet.data.count
+        return this.formatDouble(sheetNum)
+      },
+      inquirySheetLast () {
+        let lastSheetNum = this.$store.state.count.inquirySheetLast.data.count
+        return this.formatDouble(lastSheetNum)
+      },
+      all () {
+        let count = this.$store.state.supplier.merchant.merchantAll.data
+        return count.content ? count.totalElements : '0'
+      },
+      counts () {
+        return this.$store.state.product.common.counts
+      },
+      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.allCount) {
+          this.allCount.forEach((value, key, $data) => {
+            str.push({id: $data[key].item, count: $data[key].count, type: 1})
+          })
+        }
+        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})
+        str.push({id: '供应商', count: this.all ? this.all : 0, type: 3})
+        console.log(str)
+        return str
+      }
+    }
+  }
+</script>
+<style lang="scss" scoped>
+  .statistics{
+    position:relative;
+    height: .6rem;
+    border-radius:.3rem;
+    background: #fff;
+    margin:0 .05rem .2rem;
+    overflow: hidden;
+    ul{
+      position:absolute;
+      transition: .5s all linear;
+      &:no_tran{
+        transition:none;
+      }
+      li{
+        width:50%;
+        height:.6rem;
+        line-height: .6rem;
+        padding: 0 .3rem;
+        text-align: center;
+        font-size: .28rem;
+        font-weight: bold;
+        white-space: nowrap;
+        overflow: hidden;
+        vertical-align:top;
+        span{
+          margin: 0 .1rem;
+          &:last-child{
+            color:red;
+          }
+        }
+      }
+    }
+  }
+</style>

+ 2 - 1
components/mobile/common/index.js

@@ -4,4 +4,5 @@ import LoginBox from './LoginBox.vue'
 import userHeader from './userHeader.vue'
 import PullUp from './PullUp.vue'
 import EmptyStatus from './EmptyStatus.vue'
-export { Loading, RemindBox, LoginBox, userHeader, PullUp, EmptyStatus }
+import StatisticsMobile from './StatisticsMobile.vue'
+export { Loading, RemindBox, LoginBox, userHeader, PullUp, EmptyStatus, StatisticsMobile }

+ 4 - 0
pages/index.vue

@@ -115,6 +115,10 @@
         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('supplier/loadVendorAll', {page: 1, size: 20}),
+        store.dispatch('loadAllCount', {_status: 'actived', usedFor: 'mall_home_banner'}),
+        store.dispatch('loadInquirySheet', {year: nowYear, month: nowMonth}),
+        store.dispatch('loadInquirySheetLast', {year: nowYear, month: LastMonth}),
         store.dispatch('applyPurchase/loadMobileHomeList', {pageNumber: 1, pageSize: 5, enUU: store.state.option.user.data.enterprise ? store.state.option.user.data.enterprise.uu : null})
       ])
     },