displayCard.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <div class="display-card">
  3. <span @click="cardClose" v-if="cardShow" class="cardClose"><img src="/images/all/close.png"></span>
  4. <div class="content" v-if="cardShow">
  5. <div>
  6. <ul class="list-unstyled">
  7. <li v-for="(item, index) in title" :style="'top: -' + 30 * timerIndex + 'px'" :class="{'top': isTop}">
  8. <span>{{item}}</span>
  9. </li>
  10. </ul>
  11. <ul class="list-unstyled">
  12. <li v-for="(c, index) in counts" :style="'top: -' + 30 * timerIndex + 'px'" :class="{'top': isTop}">
  13. <count-item :value ="c" :index ="index"></count-item>
  14. </li>
  15. </ul>
  16. </div>
  17. <div v-for="item in itemCounts">
  18. <p><span v-html="item.count"></span>
  19. <span style="color: #333" v-if="item.type === 3">家</span>
  20. <span style="color: #333" v-if="item.type === 2">条</span>
  21. </p>
  22. </div>
  23. <a class="enter" @click="goStoreApply()">
  24. <img src="/images/all/enter2.png">
  25. </a>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import CountItem from './countItem.vue'
  31. export default {
  32. name: 'display-card',
  33. data () {
  34. return {
  35. cardShow: true,
  36. timerIndex: 0,
  37. isTop: false, // 判断是否滚动至顶,
  38. timer: {}, // 定时器实体
  39. title: [ '品牌', '现货', '规格书', '店铺' ]
  40. }
  41. },
  42. components: {
  43. CountItem
  44. },
  45. mounted () {
  46. this.$nextTick(() => {
  47. this.changeInterval(true)
  48. })
  49. },
  50. methods: {
  51. changeInterval: function (flag) {
  52. if (flag) {
  53. this.timer = setInterval(() => {
  54. this.timerIndex ++
  55. this.isTop = (this.timerIndex % 4 === 0)
  56. if (this.isTop) {
  57. this.timerIndex = 0
  58. }
  59. }, 3000)
  60. } else {
  61. clearInterval(this.timer)
  62. }
  63. },
  64. cardClose () {
  65. this.cardShow = false
  66. },
  67. formatNumber (num, type) {
  68. if (num) {
  69. if (num.toString().indexOf('E') !== -1) {
  70. let arr = num.toString().split('E')
  71. num = arr[0] * Math.pow(10, arr[1])
  72. }
  73. if (num > 99999999) {
  74. let str2 = num.toString()
  75. num = Math.floor(num / 100000000)
  76. if (parseInt(str2.charAt(str2.length - 8)) > 8) {
  77. num = num + 1
  78. }
  79. num += '<span style="color: #333">亿</span>'
  80. } else if (num > 9999) {
  81. let str = num.toString()
  82. num = Math.floor(num / 10000)
  83. if (parseInt(str.charAt(str.length - 4)) > 4) {
  84. num = num + 1
  85. }
  86. num += '<span style="color: #333">万</span>'
  87. } else {
  88. if (type === 1) {
  89. num += '<span style="color: #333">元</span>'
  90. } else {
  91. num += ''
  92. }
  93. }
  94. }
  95. return num
  96. },
  97. formatDouble (num) {
  98. if (num) {
  99. if (num.toString().indexOf('E') !== -1) {
  100. let arr = num.toString().split('E')
  101. num = arr[0] * Math.pow(10, arr[1])
  102. }
  103. if (num > 99999999) {
  104. num = (num / 100000000).toFixed(2).slice(num.length - 1, 4) + '<span style="color: #333">亿</span>'
  105. } else if (num > 9999) {
  106. num = (num / 10000).toFixed(2).slice(num.length - 1, 4) + '<span style="color: #333">万</span>'
  107. } else {
  108. num += ''
  109. }
  110. }
  111. return num
  112. },
  113. goStoreApply: function () {
  114. if (this.user.logged) {
  115. if (this.enterprise && this.enterprise.isVendor === 313) {
  116. window.location.href = '/vendor#/index'
  117. } else {
  118. this.$router.push('/register-saler')
  119. }
  120. } else {
  121. this.$router.push('/auth/login')
  122. }
  123. }
  124. },
  125. computed: {
  126. allCount () {
  127. return this.$store.state.count.allCount.data
  128. },
  129. payMoneyLast () {
  130. return this.allCount[0] ? this.formatNumber(this.allCount[0].count, 1) : 0
  131. },
  132. payMoney () {
  133. return this.allCount[1] ? this.formatNumber(this.allCount[1].count, 1) : 0
  134. },
  135. inquirySheet () {
  136. let sheetNum = this.$store.state.count.inquirySheet.data
  137. return sheetNum ? this.formatDouble(sheetNum.count) : 0
  138. },
  139. inquirySheetLast () {
  140. let lastSheetNum = this.$store.state.count.inquirySheetLast.data
  141. return lastSheetNum ? this.formatDouble(lastSheetNum.count) : 0
  142. },
  143. all () {
  144. let count = this.$store.state.supplier.merchant.merchantAll.data
  145. let supplierCount = count.content ? count.totalElements + '' : 0
  146. return this.formatNumber(supplierCount, 0)
  147. },
  148. itemCounts () {
  149. let arr = []
  150. 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})
  151. return arr
  152. },
  153. list () {
  154. let list = JSON.parse(JSON.stringify(this.$store.state.provider.stores.storeList.data))
  155. return list
  156. },
  157. counts () {
  158. let arr = []
  159. let countM = this.$store.state.product.common.counts.data
  160. if (countM) {
  161. countM.forEach((value, key, $data) => {
  162. arr.push(value.count)
  163. })
  164. }
  165. arr.push(this.list.totalElements)
  166. return arr
  167. },
  168. enterprise () {
  169. return this.user.data.enterprise
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="scss" scoped>
  175. .display-card{
  176. position: fixed;
  177. right: 100px;
  178. top: 100px;
  179. width: 180px;
  180. height: 540px;
  181. z-index: 100;
  182. .cardClose{
  183. position: absolute;
  184. right: 3px;
  185. top: 1px;
  186. opacity: 0.8;
  187. &:hover{
  188. cursor: pointer;
  189. }
  190. }
  191. .content{
  192. margin-top: 10px;
  193. width: 178px;
  194. height: 536px;
  195. background: url('/images/all/countBackground2.png') no-repeat;
  196. div{
  197. height: 72px;
  198. width: 158px;
  199. padding-top: 30px;
  200. margin-left: 6px;
  201. &:first-child{
  202. height: 109px;
  203. padding-top: 1px;
  204. ul{
  205. &:first-child{
  206. max-height: 30px;
  207. width: 100%;
  208. text-align: center;
  209. overflow: hidden;
  210. position: relative;
  211. top: 16px;
  212. li{
  213. height: 30px;
  214. line-height: 30px;
  215. font-weight: bold;
  216. font-size: 21px;
  217. letter-spacing: 0px;
  218. color: #fff000;
  219. position: relative;
  220. top: 0;
  221. transition: top 1s;
  222. -moz-transition: top 1s; /* Firefox 4 */
  223. -webkit-transition: top 1s; /* Safari and Chrome */
  224. -o-transition: top 1s; /* Opera */
  225. /* &.top {
  226. transition: top 0s;
  227. -moz-transition: top 0s; !* Firefox 4 *!
  228. -webkit-transition: top 0s; !* Safari and Chrome *!
  229. -o-transition: top 0s; !* Opera *!
  230. }*/
  231. }
  232. }
  233. &:last-child{
  234. max-height: 30px;
  235. width: 100%;
  236. overflow: hidden;
  237. position: relative;
  238. top: 21px;
  239. text-align: right;
  240. li{
  241. height: 30px;
  242. line-height: 30px;
  243. font-weight: bold;
  244. font-size: 21px;
  245. color: #fff;
  246. position: relative;
  247. top: 0;
  248. transition: top 1s;
  249. -moz-transition: top 1s; /* Firefox 4 */
  250. -webkit-transition: top 1s; /* Safari and Chrome */
  251. -o-transition: top 1s; /* Opera */
  252. /*&.top {
  253. transition: top 0s;
  254. -moz-transition: top 0s; !* Firefox 4 *!
  255. -webkit-transition: top 0s; !* Safari and Chrome *!
  256. -o-transition: top 0s; !* Opera *!
  257. }*/
  258. }
  259. }
  260. }
  261. }
  262. p{
  263. width: 100%;
  264. text-align: center;
  265. font-size: 20px;
  266. color: #f14e4e;
  267. }
  268. }
  269. .enter{
  270. width: 100%;
  271. display: inline-block;
  272. position: absolute;
  273. bottom: 35px;
  274. left: -5px;
  275. text-align: center;
  276. }
  277. }
  278. }
  279. </style>