displayCard.vue 7.7 KB

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