displayCard.vue 9.3 KB

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