paopao-countdown.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <!-- 倒计时和排名统计 -->
  3. <view class="djs-pm" v-show="isClose==false">
  4. <view class="djs flex">
  5. <view class="djs-tit">
  6. 有奖竞猜即将开始
  7. </view>
  8. <view class="djs-time ">
  9. <view class="djs-time1" :class="{'xxx':isActive}">
  10. {{countdown_time}}
  11. </view>
  12. <!-- v-if="second>3||second==0" -->
  13. <!-- <view class="djs-time1 xxx" v-else>
  14. lalalalal
  15. </view> -->
  16. </view>
  17. </view>
  18. <view class="pm flex">
  19. <view class="pm-ear ear-left"></view>
  20. <view class="pm-ear ear-right"></view>
  21. <view class="pm-tit">
  22. 近100期冠军数据统计
  23. </view>
  24. <view class="pm-list flex">
  25. <view class="pm-item" v-for="(pmItem, pmIndex) in list" :key="pmIndex">
  26. <view class="item-logo flex">
  27. <image :src="`../../static/img/ganme01/xdw0${pmIndex+1}.png`" mode="widthFix"></image>
  28. </view>
  29. <view class="item-num flex">
  30. <image src="../../../static/img/ganme01/win.png" mode="widthFix"></image>
  31. <text>
  32. {{pmItem.winNum}}
  33. </text>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. name: "paopao-countdown",
  43. props: {
  44. // 小动物列表
  45. list: {
  46. type: Array,
  47. default: []
  48. },
  49. // 是否倒计时已经结束
  50. isClose: {
  51. type: Boolean,
  52. default: false
  53. },
  54. // 倒计时结束时间
  55. downTime: {
  56. type: Number,
  57. default: '10086',
  58. },
  59. },
  60. data() {
  61. return {
  62. isActive: false, //倒计时动画
  63. countdown_time: '00:00',
  64. };
  65. },
  66. watch: {
  67. downTime(newValue, oldValue) {
  68. this.isActive = false;
  69. this.counTime();
  70. }
  71. },
  72. methods: {
  73. counTime() {
  74. //获取当前时间
  75. let data = new Date()
  76. let newTime = data.getTime()
  77. //获取结束时间
  78. // let end = this.downTime
  79. let end = this.downTime
  80. //时间差
  81. let leftTime = end - newTime
  82. if (leftTime <= 0) {
  83. return
  84. }
  85. //定义保存倒计时时间
  86. let m, s;
  87. if (leftTime >= 0) {
  88. // 分钟
  89. m = Math.floor(leftTime / 1000 / 60 % 60)
  90. // 秒数
  91. s = Math.floor(leftTime / 1000 % 60)
  92. // 当前秒数
  93. this.second = s
  94. this.la = m + s
  95. //倒计时赋值view
  96. this.countdown_time = `${m}:${s}`
  97. let timers = setTimeout(this.counTime, 1000)
  98. // 获取当前剩余时间
  99. const timeOut = Math.floor( leftTime/1000);
  100. if ( timeOut<= 3) {
  101. this.isActive = true;
  102. if(timeOut==0){
  103. setTimeout(() => {
  104. this.$emit('timeOut',true)
  105. }, 1000);
  106. }
  107. return this.countdown_time = `${s}`
  108. let timers = setTimeout(this.counTime, 1000)
  109. }
  110. //显示动态时间效果
  111. if (s < 10) {
  112. return this.countdown_time = `${m}:0${s}`
  113. let timers = setTimeout(this.counTime, 1000)
  114. }
  115. if (m < 10) {
  116. return this.countdown_time = `0${m}:${s}`
  117. let timers = setTimeout(this.counTime, 1000)
  118. }
  119. }
  120. }
  121. }
  122. }
  123. </script>
  124. <style lang="scss">
  125. .djs-pm {
  126. pointer-events: none;
  127. position: fixed;
  128. z-index: 99999;
  129. top: 0;
  130. bottom: 0;
  131. left: 0;
  132. right: 0;
  133. padding-top: 300rpx;
  134. .djs {
  135. width: 297rpx;
  136. padding: 20rpx;
  137. background: #FFFCFF;
  138. border-radius: 30rpx;
  139. flex-direction: column;
  140. justify-content: center;
  141. margin: auto;
  142. .djs-tit {
  143. font-size: 19rpx;
  144. font-weight: bold;
  145. color: #FF2553;
  146. padding-bottom: 10rpx;
  147. padding-top: 0;
  148. }
  149. .djs-time {
  150. width: 257rpx;
  151. line-height: 78rpx;
  152. background: #F0486B;
  153. border-radius: 20rpx;
  154. font-size: 58rpx;
  155. font-weight: 400;
  156. color: #FFFFFF;
  157. text-align: center;
  158. }
  159. .djs-time1 {}
  160. .xxx {
  161. position: relative;
  162. animation: mymove 1.2s;
  163. animation-iteration-count: infinite;
  164. /* Safari and Chrome */
  165. -webkit-animation: mymove 1s;
  166. -webkit-animation-iteration-count: infinite;
  167. }
  168. @keyframes mymove {
  169. from {
  170. font-size: 77rpx;
  171. }
  172. to {
  173. font-size: 0rpx;
  174. }
  175. }
  176. @-webkit-keyframes mymove
  177. /* Safari and Chrome */
  178. {
  179. from {
  180. font-size: 58rpx;
  181. }
  182. to {
  183. font-size: 0rpx;
  184. }
  185. }
  186. // .xxx:hover {
  187. // font-size: 30rpx;
  188. // -webkit-transform: rotate(180deg);
  189. // /* Chrome, Safari, Opera */
  190. // transform: rotate(180deg);
  191. // }
  192. }
  193. .pm {
  194. margin: 0 auto;
  195. width: 601rpx;
  196. height: 285rpx;
  197. background: linear-gradient(0deg, #FFD5DE, #FFFFFF);
  198. box-shadow: 0px 12rpx 15rpx 3rpx rgba(240, 72, 107, 0.29);
  199. border-radius: 20rpx;
  200. margin-top: 18rpx;
  201. position: relative;
  202. padding-top: 29rpx;
  203. flex-direction: column;
  204. justify-content: space-between;
  205. .pm-ear {
  206. width: 18rpx;
  207. height: 18rpx;
  208. background: #FFFCFF;
  209. border-radius: 8rpx 8rpx 0px 0px;
  210. position: absolute;
  211. top: -18rpx;
  212. }
  213. .ear-left {
  214. left: 232rpx;
  215. }
  216. .ear-right {
  217. right: 232rpx;
  218. }
  219. .pm-tit {
  220. flex-grow: 0;
  221. min-width: 300rpx;
  222. padding: 0 37rpx;
  223. line-height: 42rpx;
  224. background: #FFB310;
  225. box-shadow: 0px 7rpx 16rpx 0px rgba(255, 179, 16, 0.35);
  226. border-radius: 21rpx;
  227. font-size: 23rpx;
  228. font-weight: bold;
  229. color: #FFFFFF;
  230. margin: auto;
  231. }
  232. .pm-list {
  233. padding: 22rpx 17rpx 50rpx;
  234. width: 100%;
  235. .pm-item {
  236. width: 85rpx;
  237. .item-logo {
  238. width: 85rpx;
  239. height: 85rpx;
  240. background: #FFC1CE;
  241. border-radius: 50%;
  242. justify-content: center;
  243. image {
  244. width: 70rpx;
  245. }
  246. }
  247. .item-num {
  248. text-align: center;
  249. font-size: 23rpx;
  250. font-weight: bold;
  251. color: #7B3C0E;
  252. padding-top: 7rpx;
  253. justify-content: center;
  254. image {
  255. margin-right: 4rpx;
  256. width: 20rpx;
  257. height: 24rpx;
  258. }
  259. }
  260. }
  261. }
  262. }
  263. }
  264. </style>