drawCard_boxDetail.vue 6.7 KB

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