displayCard.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <div class="display-card" v-if="cardShow">
  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 ref="pingdanListWrapper" 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 ref="pingdanListWrapper" v-for="(c, index) in counts" :style="'top: -' + 30 * timerIndex + 'px'" :class="{'top': isTop}">
  13. <span v-html="formatScrollNumber(c.count, c.logo)"></span>
  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 {whichTransitionEvent} from '~utils/baseUtils.js'
  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. mounted () {
  43. this.$nextTick(() => {
  44. this.changeInterval(true)
  45. })
  46. },
  47. methods: {
  48. changeInterval: function (flag) {
  49. if (flag) {
  50. this.timer = setInterval(() => {
  51. this.isTop = false
  52. let isChange = true
  53. this.timerIndex++
  54. if (this.$refs.pingdanListWrapper[0]) {
  55. let _transitionEvent = whichTransitionEvent()
  56. _transitionEvent && this.$refs.pingdanListWrapper[0].addEventListener(
  57. _transitionEvent, () => {
  58. if (isChange) {
  59. let title = this.title.shift()
  60. let count = this.counts.shift()
  61. this.title.push(title)
  62. this.counts.push(count)
  63. this.timerIndex = 0
  64. isChange = false
  65. this.isTop = true
  66. }
  67. })
  68. }
  69. }, 3000)
  70. } else {
  71. clearInterval(this.timer)
  72. }
  73. },
  74. cardClose () {
  75. this.cardShow = false
  76. },
  77. formatScrollNumber (num, logo) {
  78. // let re = /(\d+)(\d{3})/
  79. if (num > 99999999) {
  80. let str2 = num.toString()
  81. num = Math.floor(num / 100000000)
  82. if (parseInt(str2.charAt(str2.length - 8)) > 8) {
  83. num = num + 1
  84. }
  85. let length = String(num).length
  86. this.len = length > 3 ? length + 1 : length
  87. num = (Array(7 - length).join(0) + num)
  88. num += '&nbsp;<span style="color: #376ef3;font-size: 16px;position:relative;top: -3px;">亿</span>'
  89. } else if (num > 9999) {
  90. let str = num.toString()
  91. num = Math.floor(num / 10000)
  92. if (parseInt(str.charAt(str.length - 4)) > 4) {
  93. num = num + 1
  94. }
  95. let length = String(num).length
  96. this.len = length > 3 ? length + 1 : length
  97. num = (Array(7 - length).join(0) + num)
  98. num += '&nbsp;<span style="color: #376ef3;font-size: 16px;position:relative;top: -3px;">万</span>'
  99. } else {
  100. let length = String(num).length
  101. this.len = length > 3 ? length + 1 : length
  102. num = (Array(7 - length).join(0) + num)
  103. if (logo === 0) {
  104. num += '&nbsp;<span style="color: #376ef3;font-size: 16px;position:relative;top: -3px;">家</span>'
  105. } else {
  106. num += '&nbsp;<span style="color: #376ef3;font-size: 16px;position:relative;top: -3px;">个</span>'
  107. }
  108. }
  109. // while (re.test(num)) {
  110. // num = num.replace(re, '$1,$2')
  111. // }
  112. // num = num.split('')
  113. // console.log(num)
  114. return num
  115. },
  116. formatNumber (num, type) {
  117. if (num) {
  118. if (num.toString().indexOf('E') !== -1) {
  119. let arr = num.toString().split('E')
  120. num = arr[0] * Math.pow(10, arr[1])
  121. }
  122. if (num > 99999999) {
  123. let str2 = num.toString()
  124. num = Math.floor(num / 100000000)
  125. if (parseInt(str2.charAt(str2.length - 8)) > 8) {
  126. num = num + 1
  127. }
  128. num += '<span style="color: #333">亿</span>'
  129. } else if (num > 9999) {
  130. let str = num.toString()
  131. num = Math.floor(num / 10000)
  132. if (parseInt(str.charAt(str.length - 4)) > 4) {
  133. num = num + 1
  134. }
  135. num += '<span style="color: #333">万</span>'
  136. } else {
  137. if (type === 1) {
  138. num += '<span style="color: #333">元</span>'
  139. } else {
  140. num += ''
  141. }
  142. }
  143. }
  144. return num
  145. },
  146. formatDouble (num) {
  147. if (num) {
  148. if (num.toString().indexOf('E') !== -1) {
  149. let arr = num.toString().split('E')
  150. num = arr[0] * Math.pow(10, arr[1])
  151. }
  152. if (num > 99999999) {
  153. num = (num / 100000000).toFixed(2).slice(num.length - 1, 4) + '<span style="color: #333">亿</span>'
  154. } else if (num > 9999) {
  155. num = (num / 10000).toFixed(2).slice(num.length - 1, 4) + '<span style="color: #333">万</span>'
  156. } else {
  157. num += ''
  158. }
  159. }
  160. return num
  161. }
  162. },
  163. computed: {
  164. allCount () {
  165. return this.$store.state.count.allCount.data
  166. },
  167. payMoneyLast () {
  168. return this.allCount[0] ? this.formatNumber(this.allCount[0].count, 1) : 0
  169. },
  170. payMoney () {
  171. return this.allCount[1] ? this.formatNumber(this.allCount[1].count, 1) : 0
  172. },
  173. inquirySheet () {
  174. let sheetNum = this.$store.state.count.inquirySheet.data
  175. return sheetNum ? this.formatDouble(sheetNum.count) : 0
  176. },
  177. inquirySheetLast () {
  178. let lastSheetNum = this.$store.state.count.inquirySheetLast.data
  179. return lastSheetNum ? this.formatDouble(lastSheetNum.count) : 0
  180. },
  181. all () {
  182. let count = this.$store.state.supplier.merchant.merchantAll.data
  183. let supplierCount = count.content ? count.totalElements + '' : 0
  184. return this.formatNumber(supplierCount, 0)
  185. },
  186. itemCounts () {
  187. let arr = []
  188. 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})
  189. return arr
  190. },
  191. list () {
  192. let list = JSON.parse(JSON.stringify(this.$store.state.provider.stores.storeList.data))
  193. return list
  194. },
  195. counts () {
  196. let arr = []
  197. let countM = this.$store.state.product.common.counts.data
  198. if (countM) {
  199. countM.forEach((value, key, $data) => {
  200. arr.push({count: value.count, logo: 1})
  201. })
  202. }
  203. arr.push({count: this.list.totalElements, logo: 0})
  204. return arr
  205. },
  206. enterprise () {
  207. return this.user.data.enterprise
  208. }
  209. }
  210. }
  211. </script>
  212. <style lang="scss" scoped>
  213. .display-card{
  214. position: fixed;
  215. right: 100px;
  216. top: 100px;
  217. width: 180px;
  218. height: 540px;
  219. z-index: 100;
  220. .cardClose{
  221. position: absolute;
  222. right: 3px;
  223. top: 1px;
  224. opacity: 0.8;
  225. &:hover{
  226. cursor: pointer;
  227. }
  228. }
  229. .content{
  230. margin-top: 10px;
  231. width: 178px;
  232. height: 536px;
  233. background: url('/images/all/countBackground2.png') no-repeat;
  234. div{
  235. height: 72px;
  236. width: 158px;
  237. padding-top: 30px;
  238. margin-left: 6px;
  239. &:first-child{
  240. height: 109px;
  241. padding-top: 1px;
  242. ul{
  243. &:first-child{
  244. max-height: 30px;
  245. width: 100%;
  246. text-align: center;
  247. overflow: hidden;
  248. position: relative;
  249. top: 16px;
  250. li{
  251. height: 30px;
  252. line-height: 30px;
  253. font-weight: bold;
  254. font-size: 21px;
  255. letter-spacing: 0px;
  256. color: #fff000;
  257. position: relative;
  258. top: 0;
  259. transition: top 1s;
  260. -moz-transition: top 1s; /* Firefox 4 */
  261. -webkit-transition: top 1s; /* Safari and Chrome */
  262. -o-transition: top 1s; /* Opera */
  263. &.top {
  264. transition: top 0s;
  265. -moz-transition: top 0s; /* Firefox 4 */
  266. -webkit-transition: top 0s; /* Safari and Chrome */
  267. -o-transition: top 0s; /* Opera */
  268. }
  269. }
  270. }
  271. &:last-child{
  272. max-height: 30px;
  273. width: 100%;
  274. overflow: hidden;
  275. position: relative;
  276. top: 21px;
  277. text-align: right;
  278. li{
  279. height: 30px;
  280. line-height: 30px;
  281. font-weight: bold;
  282. font-size: 21px;
  283. color: #fff;
  284. position: relative;
  285. top: 0;
  286. left: -28px;
  287. transition: top 1s;
  288. -moz-transition: top 1s; /* Firefox 4 */
  289. -webkit-transition: top 1s; /* Safari and Chrome */
  290. -o-transition: top 1s; /* Opera */
  291. &.top {
  292. transition: top 0s;
  293. -moz-transition: top 0s; /* Firefox 4 */
  294. -webkit-transition: top 0s; /* Safari and Chrome */
  295. -o-transition: top 0s; /* Opera */
  296. }
  297. }
  298. }
  299. }
  300. }
  301. p{
  302. width: 100%;
  303. text-align: center;
  304. font-size: 20px;
  305. color: #f14e4e;
  306. }
  307. }
  308. .enter{
  309. width: 100%;
  310. display: inline-block;
  311. position: absolute;
  312. bottom: 35px;
  313. left: -5px;
  314. text-align: center;
  315. }
  316. }
  317. }
  318. </style>