prize.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <view class="content">
  3. <view class="bg">
  4. <image src="../../static/user/prizebg.png" mode="widthFix"></image>
  5. </view>
  6. <view class="title">
  7. <image src="../../static/user/prizetitle.png" mode=""></image>
  8. </view>
  9. <view class="zp" v-if="show == 0">
  10. <pt-lottery ref="pt-lottery" lotteryBg="../../static/user/prizezhuan.png"
  11. lotteryBtn="../../static/user/prizebtn.png" :times="3" :prizeList="prizeList" @start="start"
  12. @end="end"></pt-lottery>
  13. </view>
  14. <view class="btn" @click="navTo('/pages/sign/info')">
  15. 抽奖记录
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import {
  21. getgacha,
  22. gacha
  23. } from '@/api/sign.js'
  24. import ptLottery from '@/components/pt-lottery/pt-lottery.vue'
  25. export default {
  26. comments: {
  27. ptLottery
  28. },
  29. data() {
  30. return {
  31. prizeList: [],
  32. show: 1,
  33. zj: ''
  34. };
  35. },
  36. onLoad() {},
  37. onShow() {
  38. this.loadData();
  39. },
  40. onReachBottom() {},
  41. onReady() {},
  42. methods: {
  43. start() {
  44. const obj = this;
  45. gacha().then(e => {
  46. console.log(e);
  47. for (let i = 0; i < obj.prizeList.length; i++) {
  48. if (e.data.gacha_res.award == obj.prizeList[i].value) {
  49. obj.$refs['pt-lottery'].init(i + '')
  50. this.zj = obj.prizeList[i]
  51. break;
  52. }
  53. }
  54. })
  55. },
  56. end() {
  57. this.$api.msg('恭喜抽中' + this.zj.prizeName)
  58. },
  59. navTo(url) {
  60. uni.navigateTo({
  61. url
  62. })
  63. },
  64. loadData() {
  65. const obj = this
  66. getgacha().then(({
  67. data
  68. }) => {
  69. data.award.forEach(e => {
  70. console.log(e);
  71. let ar = {
  72. prizeName: '',
  73. value: ''
  74. }
  75. if (e.award_type == 1) {
  76. ar.prizeName = e.award + '积分';
  77. ar.value = e.award
  78. } else {
  79. ar.prizeName = e.award
  80. ar.value = e.award
  81. }
  82. obj.prizeList.push(ar)
  83. })
  84. obj.show = 0
  85. })
  86. }
  87. }
  88. };
  89. </script>
  90. <style lang="scss">
  91. page,
  92. .content {
  93. min-height: 100%;
  94. height: auto;
  95. background: #fd8c54;
  96. }
  97. .bg {
  98. position: absolute;
  99. top: 0;
  100. left: 0;
  101. right: 0;
  102. width: 750rpx;
  103. image {
  104. width: 100%;
  105. height: 100%;
  106. }
  107. }
  108. .title {
  109. margin: 0 auto;
  110. width: 630rpx;
  111. height: 210rpx;
  112. padding-top: 50rpx;
  113. image {
  114. width: 100%;
  115. height: 100%;
  116. }
  117. }
  118. .zp {
  119. margin: 100rpx auto 0;
  120. width: 750rpx;
  121. height: 750rpx;
  122. }
  123. .btn {
  124. position: relative;
  125. z-index: 2;
  126. margin: 50rpx auto 0;
  127. width: 476rpx;
  128. height: 83rpx;
  129. background: #FF5421;
  130. border-radius: 42rpx;
  131. display: flex;
  132. justify-content: center;
  133. align-items: center;
  134. font-size: 28rpx;
  135. font-family: Source Han Sans SC;
  136. font-weight: 400;
  137. color: #FFFFFF;
  138. }
  139. </style>