drawCard_boxDetail.vue 7.1 KB

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