chou.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <view class="wap">
  3. <view class="base-pst djs-wrap flex">
  4. <uni-countdown color="#000000" background-color="#fff" splitor-color="#FFFFFF" :show-day="false" :day="0"
  5. :hour="seckillObj.stopTimeH" :minute="seckillObj.stopTimeM" :second="seckillObj.stopTimeS"
  6. @timeup="goStop"></uni-countdown>
  7. </view>
  8. <image src="../../static/img/goto.png" mode="" class="base-pst goto" @click="golock"></image>
  9. <view class="base-pst content-wrap">
  10. <view class="tit">
  11. 只要完成视频任务,即可参与抽奖
  12. </view>
  13. <view class="jl-list flex" v-for="item in puser.draw">
  14. <view class="jl-tit">
  15. {{item.awards}}:{{item.name}}
  16. </view>
  17. <view class="jl-mun">
  18. {{item.num}} 份
  19. </view>
  20. </view>
  21. <image src="../../static/img/zjmd.png" mode="" class="zjmd"></image>
  22. <scroll-view scroll-y="true" class="jl-end">
  23. <view class="end-list flex" v-for="(item,index) in endList">
  24. <view class="">
  25. {{showTime(item.add_time)}}
  26. </view>
  27. <view class="">
  28. {{showPhone(item.phone) }}
  29. </view>
  30. <view class="">
  31. {{showTit(item.draw_id)}}
  32. </view>
  33. </view>
  34. </scroll-view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import {
  40. passUser,lotteryLst
  41. } from '@/api/zero.js'
  42. import uniCountdown from '@/components/uni-countdown/uni-countdown.vue';
  43. export default {
  44. components: {
  45. uniCountdown
  46. },
  47. data() {
  48. return {
  49. seckillObj: {
  50. stopTime: 0, //结束时间
  51. stop: false, //是否结束
  52. stopTimeH: 0, //小时
  53. stopTimeM: 0, //分钟
  54. stopTimeS: 5 //秒钟
  55. },
  56. puser: {},
  57. endList: []
  58. }
  59. },
  60. onLoad() {
  61. },
  62. onShow() {
  63. this.passUser()
  64. this.lotteryLst()
  65. },
  66. onReachBottom() {
  67. },
  68. onReady() {
  69. },
  70. methods: {
  71. showPhone(phone) {
  72. const phoneNumber = phone + ''; // 手机号
  73. const hiddenNumber = phoneNumber.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
  74. return hiddenNumber
  75. },
  76. showTime(time) {
  77. const timestamp = time*1000; // 时间戳
  78. const date = new Date(timestamp); // 创建 Date 对象
  79. const year = date.getFullYear(); // 获取年份
  80. const month = date.getMonth() + 1; // 获取月份(注意月份是从 0 开始计数的,所以要加 1)
  81. const day = date.getDate(); // 获取日期
  82. const hours = date.getHours(); // 获取小时
  83. const minutes = date.getMinutes(); // 获取分钟
  84. const seconds = date.getSeconds(); // 获取秒钟
  85. // const formattedTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  86. return `${month}-${day} ${hours}:${minutes}:${seconds}`
  87. // console.log(formattedTime);
  88. },
  89. passUser() {
  90. passUser().then(res => {
  91. // console.log(res)
  92. let data = res.data
  93. this.puser = res.data
  94. this.getStep(data.service_time,data.lottery)
  95. })
  96. },
  97. lotteryLst() {
  98. lotteryLst().then(res => {
  99. this.endList = res.data.list
  100. })
  101. },
  102. showTit(id) {
  103. let qdata = this.puser.draw.find(item => item.id == id)
  104. return qdata.name
  105. },
  106. goStop() {
  107. // console.log('is_end')
  108. this.lotteryLst()
  109. },
  110. golock() {
  111. uni.navigateTo({
  112. url: '/pages/zero/ren'
  113. })
  114. },
  115. getStep(timestamp1, timestamp2) {
  116. //timestamp1 服务器时间
  117. //timestamp2 开奖时间
  118. const diff = (timestamp2 - timestamp1)*1000; // 计算时间戳差值(毫秒)
  119. if (diff < 0) {
  120. this.seckillObj = {
  121. stopTime: 0, //结束时间
  122. stop: true, //是否结束
  123. stopTimeH: 0, //小时
  124. stopTimeM: 0, //分钟
  125. stopTimeS: 0 //秒钟
  126. }
  127. this.lotteryLst()
  128. }else {
  129. this.seckillObj = {
  130. stopTime: timestamp2, //结束时间
  131. stop: false, //是否结束
  132. stopTimeH: Math.floor(diff / (1000 * 60 * 60)), //小时
  133. stopTimeM: Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60)), //分钟
  134. stopTimeS: Math.floor((diff % (1000 * 60)) / 1000) //秒钟
  135. }
  136. }
  137. }
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. .base-pst {
  143. position: absolute;
  144. left: 0;
  145. right: 0;
  146. margin: auto;
  147. }
  148. .wap {
  149. width: 100%;
  150. height: 1800rpx;
  151. background-image: url('../../static/img/choubg.png');
  152. background-size: 100% 100%;
  153. .djs-wrap {
  154. width: 698rpx;
  155. height: 247rpx;
  156. top: 323rpx;
  157. background-image: url('../../static/img/djs-wap-bg.png');
  158. background-size: 100% 100%;
  159. justify-content: center;
  160. padding-top: 80rpx;
  161. }
  162. .goto {
  163. width: 354rpx;
  164. height: 104rpx;
  165. top: 600rpx;
  166. }
  167. .content-wrap {
  168. // background-color: red;
  169. color: #C90605;
  170. height: 960rpx;
  171. top: 750rpx;
  172. width: 630rpx;
  173. text-align: center;
  174. font-size: 30rpx;
  175. .tit {
  176. padding-top: 50rpx;
  177. padding-bottom: 20rpx;
  178. }
  179. .jl-list {
  180. background-image: url('../../static/img/jllist.png');
  181. background-size: 100% 100%;
  182. width: 444rpx;
  183. height: 69rpx;
  184. margin: 20rpx auto;
  185. .jl-tit {
  186. font-weight: 500;
  187. font-size: 32rpx;
  188. color: #A10920;
  189. padding-left: 30rpx;
  190. }
  191. .jl-mun {
  192. text-align: center;
  193. width: 100rpx;
  194. font-weight: 800;
  195. font-size: 26rpx;
  196. color: #FFF2D6;
  197. }
  198. }
  199. .zjmd {
  200. width: 414rpx;
  201. height: 73rpx;
  202. margin: 30rpx auto;
  203. }
  204. }
  205. }
  206. .jl-end {
  207. height: 300rpx;
  208. }
  209. .end-list {
  210. padding: 0 30rpx;
  211. }
  212. </style>