displayCard.vue 11 KB

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