doubleElevenLottery.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <view>
  3. <u-modal title="恭喜" confirm-text="前往查看" cancel-color="#333333"
  4. :show-cancel-button="true"
  5. @confirm="modalConfirm"
  6. cancel-text="关闭"
  7. :title-style="{color: '#101010',fontSize:'48rpx'}"
  8. confirm-color="#00B962" v-model="show">
  9. <view class="slot-content">
  10. <p>恭喜您!获得本次抽奖的幸运大奖</p>
  11. <p>奖品:<span style="color:#F08736 ;font-weight: bold;">{{resultObj.name}}</span></p>
  12. <p></p>
  13. </view>
  14. </u-modal>
  15. <ujp-navbar title="双11活动中奖名单" :zIndex="999999"></ujp-navbar>
  16. <view class="top">
  17. <img class="cover" src="@/assets/img/topCover.png" alt="" />
  18. <img class="img1" src="@/assets/img/doubleEleven3x.png" alt="" />
  19. <img class="img2" src="@/assets/img/doubleElevenLogo.png" alt="" />
  20. </view>
  21. <view class="lotteryBox">
  22. <img class="cover2" src="@/assets/img/cover2.png" alt="" />
  23. <view class="chance">
  24. 您有 {{useNum}} 次抽奖机会
  25. </view>
  26. <Lottery class="lottery" :width="600" :height="600" :data="dataLottery" @end="showlottery=false"
  27. ref="refLottery" @clickBtn="clickBtn" @playRewardEnd="playRewardEnd" :setWinnerFn="getWinnerFn">
  28. </Lottery>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import * as API from '@/apis/temporary.js'
  34. import Lottery from '@/components/lottery/index11.vue'
  35. export default {
  36. components: {
  37. Lottery
  38. },
  39. data() {
  40. return {
  41. resultObj: {
  42. id: 2,
  43. name: '服务费免单卷',
  44. nameText: ['服务费免单卷'],
  45. url:"/pages/user/coupon/myCoupon",
  46. img: '1',
  47. color: "#f7e2c3",
  48. },
  49. show: false,
  50. useNum: 0,
  51. lotteryIndex: -1,
  52. dataLottery: [{
  53. id: 1,
  54. name: '充电免单卷(含电费)',
  55. nameText: ['充电免单卷', '(含电费)'],
  56. url:"/pages/user/coupon/myCoupon",
  57. img: '1',
  58. color: "#fbf0df"
  59. },
  60. {
  61. id: 2,
  62. name: '服务费免单卷',
  63. nameText: ['服务费免单卷'],
  64. url:"/pages/user/coupon/myCoupon",
  65. img: '1',
  66. color: "#f7e2c3",
  67. },
  68. {
  69. id: 3,
  70. name: '充电服务费6折月卡',
  71. nameText: ['充电服务费6折', '月卡'],
  72. url:"/pages/cardBag/cardBag",
  73. img: '1',
  74. color: "#fbf0df"
  75. },
  76. {
  77. id: 100,
  78. name: '谢谢参与',
  79. nameText: ['谢谢参与'],
  80. img: '2',
  81. color: "#f7e2c3",
  82. },
  83. ],
  84. }
  85. },
  86. onLoad() {
  87. this.getInfo()
  88. },
  89. methods: {
  90. modalConfirm(){
  91. uni.navigateTo({
  92. url:this.resultObj.url
  93. })
  94. },
  95. playRewardEnd() {
  96. if (this.resultObj.id != 100) {
  97. this.show = true;
  98. }
  99. },
  100. clickBtn() {
  101. uni.showLoading({
  102. title: "加载中",
  103. mask: true,
  104. })
  105. API.getActivityResults({
  106. }).then((res) => {
  107. uni.hideLoading();
  108. //this.useNum=res.data.useNum
  109. var lotteryIndex = this.dataLottery.findIndex(item => {
  110. item.weight = 0
  111. //console.log(res.data.serviceDiscountRatio,item.num,res.data.serviceDiscountRatio==item.num)
  112. return res.data == item.id
  113. })
  114. if (lotteryIndex != -1) {
  115. this.resultObj = this.dataLottery[lotteryIndex]
  116. this.dataLottery[lotteryIndex].weight = 100
  117. this.$refs.refLottery.playReward()
  118. }
  119. this.getInfo()
  120. }).catch(error => {
  121. //this.showNt = false;
  122. uni.showToast({
  123. title: error,
  124. icon: "none"
  125. })
  126. })
  127. },
  128. getInfo() {
  129. uni.showLoading({
  130. title: "加载中",
  131. mask: true,
  132. })
  133. API.activityDetails({
  134. }).then((res) => {
  135. uni.hideLoading();
  136. this.useNum = res.data.useNum
  137. }).catch(error => {
  138. //this.showNt = false;
  139. uni.showToast({
  140. title: error,
  141. icon: "none"
  142. })
  143. })
  144. },
  145. getWinnerFn() {
  146. // 自定义抽奖结果 ,返回值为 options 奖品列表下标,若返回 -1,则会进行随机抽奖
  147. return this.lotteryIndex
  148. },
  149. }
  150. }
  151. </script>
  152. <style lang="scss" scoped>
  153. page {
  154. background-color: #DD3032;
  155. padding-bottom: 44rpx;
  156. }
  157. .top {
  158. .cover {
  159. width: 100%;
  160. height: 100%;
  161. position: relative;
  162. }
  163. .img1 {
  164. width: 100%;
  165. height: 556rpx;
  166. position: absolute;
  167. top: 88rpx;
  168. left: 50%;
  169. transform: translateX(-50%);
  170. }
  171. .img2 {
  172. width: 594rpx;
  173. height: 268rpx;
  174. position: absolute;
  175. top: 168rpx;
  176. left: 50%;
  177. transform: translateX(-50%);
  178. }
  179. }
  180. .lotteryBox {
  181. margin-top: -248rpx;
  182. position: relative;
  183. background: linear-gradient(180deg, rgba(221, 48, 50, 0) 0%, rgba(221, 48, 50, 1) 76%);
  184. .chance {
  185. width: 402rpx;
  186. height: 72rpx;
  187. line-height: 72rpx;
  188. border-radius: 50px;
  189. background: linear-gradient(90deg, rgba(211, 51, 0, 1) 0%, rgba(255, 79, 63, 1) 53%, rgba(226, 19, 0, 1) 100%);
  190. text-align: center;
  191. margin: 0 auto;
  192. color: rgba(255, 255, 215, 1);
  193. font-size: 18px;
  194. position: absolute;
  195. top: 0;
  196. left: 50%;
  197. transform: translateX(-50%);
  198. }
  199. .cover2 {
  200. width: 100%;
  201. height: 100%;
  202. }
  203. .lottery {
  204. margin-top: -400rpx;
  205. }
  206. }
  207. .slot-content {
  208. font-size: 36rpx;
  209. padding: 30rpx;
  210. margin-top: 40rpx;
  211. p{
  212. margin-bottom: 16rpx;
  213. line-height: 40rpx;
  214. text{
  215. color: #00B962;
  216. }
  217. }
  218. }
  219. </style>