index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <!--
  2. * @Author: wangjiacheng
  3. * @Date: 2021-10-14 11:57:19
  4. * @LastEditors: wjc
  5. * @LastEditTime: 2024-05-31 14:11:52
  6. * @Description:
  7. -->
  8. <template>
  9. <div class="total-sum">
  10. <canvas id="canvas" :style="{ visibility: showFire ? 'visible' : 'hidden' }"></canvas>
  11. <div class="content">
  12. <div class="title">
  13. 线上缴费累计金额
  14. </div>
  15. <div :class="{ sum: true, 'sum-billion': isBillion }">
  16. <digit-roll
  17. v-model="moneny"
  18. :duration="1000"
  19. :delay="0"
  20. >
  21. </digit-roll>
  22. </div>
  23. </div>
  24. <div class="footer">
  25. <img :src="wcLogoUrl" class="footer-logo" style="height: 64px" />
  26. <el-divider direction="vertical"></el-divider>
  27. <img :src="huiguanjiaLogoUrl" class="footer-logo" @click="playFire" />
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. import dayjs from 'dayjs'
  33. import isSameOrAfter from 'dayjs/plugin/isSameOrAfter'
  34. // import { totalSum } from '@/api'
  35. import mixin from './mixin.js'
  36. import wcLogo from '@/assets/images/wc2.png'
  37. import huiguanjiaLogo from '@/assets/images/huiguanjia.png'
  38. import digitRoll from '@/components/digit-roll'
  39. dayjs.extend(isSameOrAfter)
  40. export default {
  41. name: 'TotalSum',
  42. mixins: [mixin],
  43. components: {
  44. digitRoll
  45. },
  46. data () {
  47. return {
  48. targetMoney: 5e8,
  49. moneny: 499571013.49,
  50. timer: null,
  51. showFire: false,
  52. isBillion: false,
  53. targetDate: '2024-05-31 17:10:00'
  54. }
  55. },
  56. computed: {
  57. wcLogoUrl () {
  58. return wcLogo
  59. },
  60. huiguanjiaLogoUrl () {
  61. return huiguanjiaLogo
  62. }
  63. },
  64. watch: {
  65. moneny (nVal) {
  66. if (nVal >= this.targetMoney && !this.showFire) {
  67. setTimeout(() => {
  68. this.showFire = true
  69. }, 500)
  70. }
  71. if (nVal >= this.targetMoney && !this.showFire) {
  72. setTimeout(() => {
  73. this.isBillion = true
  74. }, 500)
  75. }
  76. }
  77. },
  78. methods: {
  79. playFire () {
  80. setTimeout(() => {
  81. this.showFire = !this.showFire
  82. this.isBillion = !this.isBillion
  83. }, 500)
  84. },
  85. getTotalSum () {
  86. this.timer = setInterval(() => {
  87. const date = dayjs()
  88. const add = Math.floor(Math.random() * 2000)
  89. this.moneny = this.moneny + add
  90. if (date.isSameOrAfter(dayjs(this.targetDate)) && this.moneny <= this.targetMoney) {
  91. this.moneny = this.targetMoney + add
  92. }
  93. }, 10000)
  94. }
  95. },
  96. created () {
  97. // totalSum.getTotalSum().then(res => {
  98. // if (res && res.data) {
  99. // const data = Number(res.data.data)
  100. // this.moneny = data
  101. // }
  102. // })
  103. this.getTotalSum()
  104. },
  105. mounted () {
  106. this.fireworkss()
  107. },
  108. beforeDestroy () {
  109. clearInterval(this.timer)
  110. }
  111. }
  112. </script>
  113. <style lang="scss">
  114. @import './fr.scss';
  115. @font-face {
  116. font-family: AIdrich-Regular;
  117. src: url('../../assets/css/Aldrich-Regular.ttf');
  118. }
  119. #canvas {
  120. top: 105px;
  121. position: relative;
  122. z-index: 100;
  123. background: transparent;
  124. }
  125. .total-sum {
  126. position: relative;
  127. text-align: center;
  128. height: 100%;
  129. background: url('../../assets/images/total-sum-bg.png');
  130. background-repeat: no-repeat;
  131. background-size: cover;
  132. .content {
  133. position: absolute;
  134. z-index: 1001;
  135. left: 0;
  136. top: 0;
  137. right: 0;
  138. bottom: 100px;
  139. margin: auto;
  140. display: flex;
  141. flex-direction: column;
  142. justify-content: center;
  143. height: calc(100% - 258px);
  144. }
  145. .title {
  146. font-size: 58px;
  147. color: rgb(255, 210, 132);
  148. margin-bottom: 80px;
  149. font-family: 'Source Han Sans CN';
  150. }
  151. .sum {
  152. z-index: 1001;
  153. font-size: 11.25em;
  154. font-family: 'AIdrich-Regular';
  155. -webkit-box-reflect: below -30px linear-gradient(transparent,rgba(255, 255, 255, 0.4));
  156. span {
  157. background: linear-gradient(180deg, #e1bc7e 10%, #8a5510 70%);
  158. background-clip: text;
  159. -webkit-background-clip: text;
  160. color: transparent;
  161. }
  162. }
  163. .footer {
  164. z-index: 101;
  165. position: fixed;
  166. bottom: 0;
  167. width: 100%;
  168. display: flex;
  169. justify-content: center;
  170. align-items: center;
  171. background: #bb9148;
  172. height: 98px;
  173. .el-divider {
  174. margin: 0 16px;
  175. height: 2em;
  176. }
  177. .footer-logo {
  178. height: 56px;
  179. cursor: pointer;
  180. }
  181. }
  182. .sum-billion {
  183. animation: billion 4s;
  184. }
  185. @keyframes billion {
  186. 0% {
  187. transform: scale(1);
  188. }
  189. 30% {
  190. transform: scale(1.23);
  191. }
  192. 60% {
  193. transform: scale(1.23);
  194. }
  195. 90% {
  196. transform: scale(1);
  197. }
  198. }
  199. }
  200. </style>