displayCard.vue 10 KB

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