displayCard.vue 8.7 KB

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