drawCard_boxDetail.vue 6.2 KB

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