drawCard_boxDetail.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <view class="container">
  3. <view class="product">
  4. <uni-swiper-dot class="uni-swiper-dot-box" :info="info" :current="current" :mode="mode" field="content">
  5. <swiper class="swiper-box" @change="swiperChange" :current="swiperDotIndex">
  6. <swiper-item v-for="(item, index) in boxDetail.boxLeft">
  7. <image class="swiperItem" :src="detail.prizeIcon" mode="aspectFit" />
  8. </swiper-item>
  9. </swiper>
  10. </uni-swiper-dot>
  11. </view>
  12. <view class="number">{{ num }} / {{ boxDetail.boxLeft }} 包</view>
  13. <view class="tipText">官方正品,非质量问题不支持退换</view>
  14. <view class="prizes">
  15. <view class="prizesLine">
  16. <view class="prize" v-for="(item, index) in prizeList" @click="showImg(item)">
  17. <image class="prizeImg" :src="item.icon" mode="aspectFit"></image>
  18. <view class="info">
  19. <view class="name">
  20. {{ item.name }}
  21. </view>
  22. <view class="price">¥{{ detail.price }}</view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="buttons">
  28. <view class="button button1" @click="currentChange">换一包</view>
  29. <view class="button button2" @click="buy" style="color: #6a3d11">就买它</view>
  30. </view>
  31. <view class="rightButtons">
  32. <view class="button">规则</view>
  33. <view class="button" @click="toKnapsack" style="top: 44px">背包</view>
  34. <view class="button" @click="toWinningRecord" style="bottom: 0">中奖记录</view>
  35. </view>
  36. <paymentPopup ref="paymentPopup" @callBack="paymentSuccess" />
  37. <imgPopup ref="imgPopup" />
  38. </view>
  39. </template>
  40. <script>
  41. import paymentPopup from '@/component/paymentPopup.vue'
  42. import imgPopup from '@/component/imgPopup.vue'
  43. import { raffleDetailApi, getRoundPrizes, getBoxDetail } from '@/api/drawCard.js'
  44. export default {
  45. components: {
  46. paymentPopup,
  47. imgPopup,
  48. },
  49. data() {
  50. return {
  51. query: null,
  52. detail: null,
  53. boxDetail: null,
  54. current: 0,
  55. mode: 'dot',
  56. swiperDotIndex: 0,
  57. num: 1,
  58. prizeList: [],
  59. }
  60. },
  61. onLoad(query) {
  62. console.log(query, 'query')
  63. this.query = query
  64. if (query.raffleId) {
  65. this.init()
  66. }
  67. },
  68. methods: {
  69. init() {
  70. this.getBoxDetail()
  71. this.getDetail()
  72. this.getCard()
  73. },
  74. showImg(value) {
  75. this.$refs.imgPopup.show(value)
  76. },
  77. aniRun() {
  78. // 同时右平移到 100px,旋转 360 读
  79. this.$refs.ani.step({
  80. translateX: '100px',
  81. rotate: '360',
  82. })
  83. // 上面的动画执行完成后,等待200毫秒平移到 0px,旋转到 0 读
  84. this.$refs.ani.step(
  85. {
  86. translateX: '0px',
  87. rotate: '0',
  88. },
  89. {
  90. timingFunction: 'ease-in',
  91. duration: 200,
  92. },
  93. )
  94. // 开始执行动画
  95. this.$refs.ani.run(() => {
  96. this.aniRun()
  97. })
  98. },
  99. // 购买
  100. buy() {
  101. this.$refs.paymentPopup.show(this.query, 1, this.detail)
  102. },
  103. // 支付成功后回调
  104. paymentSuccess() {
  105. this.init()
  106. },
  107. getDetail() {
  108. let params = {
  109. raffleId: this.query.raffleId,
  110. }
  111. raffleDetailApi(params).then(res => {
  112. console.log(res, '详情')
  113. this.detail = res.data
  114. })
  115. },
  116. getBoxDetail() {
  117. getBoxDetail(this.query).then(res => {
  118. console.log(res, 'res')
  119. this.boxDetail = res.data
  120. })
  121. },
  122. getCard() {
  123. let params = {
  124. raffleId: this.query.raffleId,
  125. roundId: this.query.roundId,
  126. }
  127. getRoundPrizes(params).then(res => {
  128. console.log(res, '抽盒机奖品预览')
  129. this.prizeList = res.data
  130. })
  131. },
  132. swiperChange(value) {
  133. console.log(value)
  134. this.num = value.detail.current + 1
  135. },
  136. currentChange() {
  137. if (this.swiperDotIndex < this.boxDetail.boxLeft - 1) {
  138. this.swiperDotIndex += 1
  139. } else {
  140. this.swiperDotIndex = 0
  141. }
  142. },
  143. toKnapsack() {
  144. // 跳转背包界面
  145. wx.navigateTo({
  146. url: '/pages/knapsack/knapsack',
  147. })
  148. },
  149. toWinningRecord() {
  150. this.$navigateTo('/pages/winningRecord/winningRecord', this.query)
  151. },
  152. },
  153. }
  154. </script>
  155. <style scoped lang="scss">
  156. .container {
  157. background: #9ec8f9;
  158. overflow: inherit;
  159. .product {
  160. display: flex;
  161. justify-content: center;
  162. margin: 20vw auto 0 auto;
  163. // background: #fff;
  164. .uni-swiper-dot-box {
  165. display: inline-block;
  166. width: 60vw;
  167. height: 60vw;
  168. .swiper-box {
  169. width: 60vw;
  170. height: 60vw;
  171. }
  172. .swiperItem {
  173. width: 60vw;
  174. height: 60vw;
  175. }
  176. }
  177. }
  178. .number {
  179. margin-top: 5vw;
  180. text-align: center;
  181. color: #ffffff;
  182. text-shadow: 2px 2px 2px #829bfb;
  183. font-weight: 600;
  184. }
  185. .tipText {
  186. text-align: center;
  187. margin-top: 3vw;
  188. font-size: 13px;
  189. font-weight: 600;
  190. }
  191. .prizes {
  192. margin-top: 15vw;
  193. overflow: auto;
  194. padding: 0 20px;
  195. .prizesLine {
  196. position: relative;
  197. white-space: nowrap;
  198. }
  199. .prize {
  200. display: inline-block;
  201. margin-right: 10px;
  202. background: linear-gradient(180deg, #faf1a7 0%, #ffe456 100%);
  203. border-radius: 5px;
  204. overflow: hidden;
  205. .prizeImg {
  206. width: 20vw;
  207. height: 20vw;
  208. }
  209. .info {
  210. background: #fff;
  211. text-align: center;
  212. .name {
  213. font-size: 12px;
  214. }
  215. .price {
  216. color: #ff2c43;
  217. font-size: 12px;
  218. font-weight: 600;
  219. }
  220. }
  221. }
  222. }
  223. .buttons {
  224. margin-top: 5vw;
  225. display: flex;
  226. justify-content: space-around;
  227. .button {
  228. width: 35vw;
  229. height: 40px;
  230. padding: 0 20px;
  231. border-radius: 20px;
  232. line-height: 40px;
  233. color: #fff;
  234. font-weight: 600;
  235. font-size: 18px;
  236. text-align: center;
  237. }
  238. .button1 {
  239. background: linear-gradient(180deg, #89a9fa 0%, #716ff5 100%);
  240. }
  241. .button2 {
  242. background: linear-gradient(180deg, #fae5af 0%, #f3ba8e 100%);
  243. }
  244. }
  245. .rightButtons {
  246. position: fixed;
  247. right: 0;
  248. width: 50px;
  249. height: 70vh;
  250. top: 50%;
  251. transform: translateY(-50%);
  252. .button {
  253. position: absolute;
  254. right: 0;
  255. background: rgba(255, 255, 255, 0.7);
  256. font-size: 10px;
  257. text-align: center;
  258. height: 24px;
  259. line-height: 24px;
  260. border-radius: 12px 0 0 12px;
  261. width: 46px;
  262. }
  263. }
  264. }
  265. </style>