displayCard.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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. goStoreApply: function () {
  163. if (this.user.logged) {
  164. if (this.enterprise && this.enterprise.isVendor === 313) {
  165. window.location.href = '/vendor#/index'
  166. } else {
  167. this.$router.push('/register-saler')
  168. }
  169. } else {
  170. this.$router.push('/auth/login')
  171. }
  172. }
  173. },
  174. computed: {
  175. allCount () {
  176. return this.$store.state.count.allCount.data
  177. },
  178. payMoneyLast () {
  179. return this.allCount[0] ? this.formatNumber(this.allCount[0].count, 1) : 0
  180. },
  181. payMoney () {
  182. return this.allCount[1] ? this.formatNumber(this.allCount[1].count, 1) : 0
  183. },
  184. inquirySheet () {
  185. let sheetNum = this.$store.state.count.inquirySheet.data
  186. return sheetNum ? this.formatDouble(sheetNum.count) : 0
  187. },
  188. inquirySheetLast () {
  189. let lastSheetNum = this.$store.state.count.inquirySheetLast.data
  190. return lastSheetNum ? this.formatDouble(lastSheetNum.count) : 0
  191. },
  192. all () {
  193. let count = this.$store.state.supplier.merchant.merchantAll.data
  194. let supplierCount = count.content ? count.totalElements + '' : 0
  195. return this.formatNumber(supplierCount, 0)
  196. },
  197. itemCounts () {
  198. let arr = []
  199. 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})
  200. return arr
  201. },
  202. list () {
  203. let list = JSON.parse(JSON.stringify(this.$store.state.provider.stores.storeList.data))
  204. return list
  205. },
  206. counts () {
  207. let arr = []
  208. let countM = this.$store.state.product.common.counts.data
  209. if (countM) {
  210. countM.forEach((value, key, $data) => {
  211. arr.push({count: value.count, logo: 1})
  212. })
  213. }
  214. arr.push({count: this.list.totalElements, logo: 0})
  215. return arr
  216. },
  217. enterprise () {
  218. return this.user.data.enterprise
  219. }
  220. }
  221. }
  222. </script>
  223. <style lang="scss" scoped>
  224. .display-card{
  225. position: fixed;
  226. right: 100px;
  227. top: 100px;
  228. width: 180px;
  229. height: 540px;
  230. z-index: 100;
  231. .cardClose{
  232. position: absolute;
  233. right: 3px;
  234. top: 1px;
  235. opacity: 0.8;
  236. &:hover{
  237. cursor: pointer;
  238. }
  239. }
  240. .content{
  241. margin-top: 10px;
  242. width: 178px;
  243. height: 536px;
  244. background: url('/images/all/countBackground2.png') no-repeat;
  245. div{
  246. height: 72px;
  247. width: 158px;
  248. padding-top: 30px;
  249. margin-left: 6px;
  250. &:first-child{
  251. height: 109px;
  252. padding-top: 1px;
  253. ul{
  254. &:first-child{
  255. max-height: 30px;
  256. width: 100%;
  257. text-align: center;
  258. overflow: hidden;
  259. position: relative;
  260. top: 16px;
  261. li{
  262. height: 30px;
  263. line-height: 30px;
  264. font-weight: bold;
  265. font-size: 21px;
  266. letter-spacing: 0px;
  267. color: #fff000;
  268. position: relative;
  269. top: 0;
  270. transition: top 1s;
  271. -moz-transition: top 1s; /* Firefox 4 */
  272. -webkit-transition: top 1s; /* Safari and Chrome */
  273. -o-transition: top 1s; /* Opera */
  274. &.top {
  275. transition: top 0s;
  276. -moz-transition: top 0s; /* Firefox 4 */
  277. -webkit-transition: top 0s; /* Safari and Chrome */
  278. -o-transition: top 0s; /* Opera */
  279. }
  280. }
  281. }
  282. &:last-child{
  283. max-height: 30px;
  284. width: 100%;
  285. overflow: hidden;
  286. position: relative;
  287. top: 21px;
  288. text-align: right;
  289. li{
  290. height: 30px;
  291. line-height: 30px;
  292. font-weight: bold;
  293. font-size: 21px;
  294. color: #fff;
  295. position: relative;
  296. top: 0;
  297. left: -28px;
  298. transition: top 1s;
  299. -moz-transition: top 1s; /* Firefox 4 */
  300. -webkit-transition: top 1s; /* Safari and Chrome */
  301. -o-transition: top 1s; /* Opera */
  302. &.top {
  303. transition: top 0s;
  304. -moz-transition: top 0s; /* Firefox 4 */
  305. -webkit-transition: top 0s; /* Safari and Chrome */
  306. -o-transition: top 0s; /* Opera */
  307. }
  308. }
  309. }
  310. }
  311. }
  312. p{
  313. width: 100%;
  314. text-align: center;
  315. font-size: 20px;
  316. color: #f14e4e;
  317. }
  318. }
  319. .enter{
  320. width: 100%;
  321. display: inline-block;
  322. position: absolute;
  323. bottom: 35px;
  324. left: -5px;
  325. text-align: center;
  326. }
  327. }
  328. }
  329. </style>