displayCard.vue 8.1 KB

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