displayCard.vue 8.3 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.data" :style="'top: -' + 30 * timerIndex + 'px'" :class="{'top': isTop}">
  13. <count-item :value ="c.count"></count-item>
  14. </li>
  15. </ul>
  16. </div>
  17. <div>
  18. <p><span v-html="all"></span><span style="color: #333">家</span>
  19. </p>
  20. </div>
  21. <div>
  22. <p v-if="payMoney">
  23. <span v-html="payMoney"></span>
  24. </p>
  25. <p v-else><span>0元</span></p>
  26. </div>
  27. <div>
  28. <p v-if="payMoneyLast">
  29. <span v-html="payMoneyLast"></span>
  30. </p>
  31. <p v-else><span>0元</span></p>
  32. </div>
  33. <div>
  34. <p v-if="inquirySheet">
  35. <span v-html="inquirySheet"></span><span style="color: #333">条</span>
  36. </p>
  37. <p v-else><span>0条</span></p>
  38. </div>
  39. <div>
  40. <p v-if="inquirySheetLast">
  41. <span v-html="inquirySheetLast"></span><span style="color: #333">条</span>
  42. </p>
  43. <p v-else><span>0条</span></p>
  44. </div>
  45. <a class="enter" @click="goStoreApply()">
  46. <img src="/images/all/enter2.png">
  47. </a>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import CountItem from './countItem.vue'
  53. export default {
  54. name: 'display-card',
  55. data () {
  56. return {
  57. cardShow: true,
  58. timerIndex: 0,
  59. isTop: false, // 判断是否滚动至顶,
  60. timer: {}, // 定时器实体
  61. title: [ '品牌', '现货', '规格书' ]
  62. }
  63. },
  64. components: {
  65. CountItem
  66. },
  67. mounted () {
  68. this.$nextTick(() => {
  69. this.changeInterval(true)
  70. })
  71. },
  72. methods: {
  73. changeInterval: function (flag) {
  74. if (flag) {
  75. this.timer = setInterval(() => {
  76. this.timerIndex ++
  77. this.isTop = (this.timerIndex % 3 === 0)
  78. if (this.isTop) {
  79. this.timerIndex = 0
  80. }
  81. }, 3000)
  82. } else {
  83. clearInterval(this.timer)
  84. }
  85. },
  86. cardClose () {
  87. this.cardShow = false
  88. },
  89. formatNumber (num, type) {
  90. if (num) {
  91. if (num.toString().indexOf('E') !== -1) {
  92. let arr = num.toString().split('E')
  93. num = arr[0] * Math.pow(10, arr[1])
  94. }
  95. if (num > 99999999) {
  96. let str2 = num.toString()
  97. num = Math.floor(num / 100000000)
  98. if (parseInt(str2.charAt(str2.length - 8)) > 8) {
  99. num = num + 1
  100. }
  101. num += '<span style="color: #333">亿</span>'
  102. } else if (num > 9999) {
  103. let str = num.toString()
  104. num = Math.floor(num / 10000)
  105. if (parseInt(str.charAt(str.length - 4)) > 4) {
  106. num = num + 1
  107. }
  108. num += '<span style="color: #333">万</span>'
  109. } else {
  110. if (type === 1 || type === 2) {
  111. num += '<span style="color: #333">元</span>'
  112. } else {
  113. num += ''
  114. }
  115. }
  116. }
  117. return num
  118. },
  119. formatDouble (num) {
  120. if (num) {
  121. if (num.toString().indexOf('E') !== -1) {
  122. let arr = num.toString().split('E')
  123. num = arr[0] * Math.pow(10, arr[1])
  124. }
  125. if (num > 99999999) {
  126. num = (num / 100000000).toFixed(2).slice(num.length - 1, 4) + '亿'
  127. } else if (num > 9999) {
  128. num = (num / 10000).toFixed(2).slice(num.length - 1, 4) + '万'
  129. } else {
  130. num += ''
  131. }
  132. }
  133. return num
  134. },
  135. goStoreApply: function () {
  136. if (this.user.logged) {
  137. if (this.enterprise && this.enterprise.isVendor === 313) {
  138. window.location.href = '/vendor#/index'
  139. } else {
  140. this.$router.push('/register-saler')
  141. }
  142. } else {
  143. this.$router.push('/auth/login')
  144. }
  145. }
  146. },
  147. computed: {
  148. allCount () {
  149. return this.$store.state.count.allCount.data
  150. },
  151. payMoneyLast () {
  152. return this.allCount[0] ? this.formatNumber(this.allCount[0].count, 2) : 0
  153. },
  154. payMoney () {
  155. return this.allCount[1] ? this.formatNumber(this.allCount[1].count, 1) : 0
  156. },
  157. inquirySheet () {
  158. let sheetNum = this.$store.state.count.inquirySheet.data.count
  159. return this.formatDouble(sheetNum)
  160. },
  161. inquirySheetLast () {
  162. let lastSheetNum = this.$store.state.count.inquirySheetLast.data.count
  163. return this.formatDouble(lastSheetNum)
  164. },
  165. all () {
  166. let count = this.$store.state.supplier.merchant.merchantAll.data
  167. let supplierCount = count.content ? count.totalElements + '' : '0'
  168. return this.formatNumber(supplierCount, 0)
  169. },
  170. counts () {
  171. return this.$store.state.product.common.counts
  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: 135px;
  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>