payLottery.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <view class="lottery_container">
  3. <view class="grid_wrap">
  4. <view class="lottery_wrap">
  5. <ul class="lottery_grid">
  6. <li v-for="(item, index) in prizeData" :class="{ active: current_index == index && index != 8 }"
  7. :key="index" @click="luck_draw" :data-index="index">
  8. <view :class="{in_line:index != 8 }" class="lottery-msg">
  9. <image v-if="index != 8" class="grid_img" mode='aspectFit' :src="item.image" alt="" />
  10. <text v-if="index !=8" class="name">
  11. {{ index == 8 ? '抽奖' : item.name }}
  12. </text>
  13. <view v-else class="flex-col flex-center lottery-click">
  14. <image src="../../static/lottery_text.png" class="w-140 h-32 block"></image>
  15. <text class="fs-20 lh-28rpx pt-6">剩余 {{lotteryNum}} 次机会</text>
  16. </view>
  17. </view>
  18. </li>
  19. </ul>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import LotteryDraw from './js/grids_lottery.js';
  26. export default {
  27. data() {
  28. return {
  29. current_index: -1,
  30. lotteryBtn: true
  31. };
  32. },
  33. props: {
  34. prizeData: {
  35. type: Array,
  36. default: function() {
  37. return []
  38. }
  39. },
  40. lotteryType: {
  41. type: Number,
  42. default: 0
  43. },
  44. datatime: {
  45. type: Number,
  46. default: 0
  47. },
  48. lotteryNum:{
  49. type: Number,
  50. default: 0
  51. }
  52. },
  53. onLoad() {
  54. },
  55. methods: {
  56. luck_draw(event) {
  57. console.log(123456);
  58. let timestamp = Date.parse(new Date())/1000;
  59. if(this.lotteryType == 1 && parseInt(timestamp)>parseInt(this.datatime)){
  60. return this.$util.Tips({
  61. title: '您抽奖的有效时间已到期'
  62. },function(){
  63. uni.switchTab({
  64. url: '/pages/index/index'
  65. })
  66. });
  67. }
  68. let index = event.currentTarget.dataset.index;
  69. if (this.lotteryBtn && index == 8) {
  70. this.lotteryBtn = false
  71. } else {
  72. return
  73. }
  74. let that = this;
  75. if (index == 8) {
  76. // 点击抽奖之后知道获奖位置,修改父组件中lottery_draw_param的值
  77. this.$emit('get_winingIndex', function(res) {
  78. let lottery_draw_param = res;
  79. let win = new LotteryDraw({
  80. domData: that.prizeData,
  81. ...lottery_draw_param
  82. },
  83. function(index, count) {
  84. that.current_index = index;
  85. if (lottery_draw_param.winingIndex == index && lottery_draw_param.totalCount ==
  86. count) {
  87. that.lotteryBtn = true
  88. that.$emit('luck_draw_finish', that.prizeData[index])
  89. }
  90. }
  91. );
  92. });
  93. }
  94. }
  95. }
  96. };
  97. </script>
  98. <style scoped lang="scss">
  99. @import './css/pay_lottery.css';
  100. .lottery-msg {
  101. width: 100%;
  102. height: 100%;
  103. padding: 0 4rpx;
  104. .name {}
  105. }
  106. .lottery-click {
  107. width: 100%;
  108. height: 100%;
  109. }
  110. .lottery_wrap{
  111. height: 424rpx !important;
  112. }
  113. </style>