displayCard.vue 11 KB

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