drawCard_box.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <view class="container">
  3. <PageTitle color="#000" :title="detail.name || ''" />
  4. <view class="boxsBr">
  5. <view class="boxs">
  6. <view class="box" v-for="(item, index) in bosList" @click="toDrawCard_boxDetail(item)">
  7. <image
  8. class="boxImg"
  9. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/drawCard_box/boxImg.png'"
  10. mode="widthFix"
  11. ></image>
  12. <view class="tip" v-if="item.boxLeft == 0">已抽完</view>
  13. <view class="tip" v-if="item.boxLeft != 0 && item.boxStatus == 1">已爆头</view>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="text">官方正品,非质量问题不支持退换</view>
  18. <view class="number">{{ num }} / {{ detail.roundNum || 0 }} 箱</view>
  19. <view class="buttons">
  20. <view class="button" @click="boxChange(-1)">上一箱</view>
  21. <view class="button" @click="boxChange(1)">下一箱</view>
  22. </view>
  23. <view class="rightButtons">
  24. <view class="button" @click="$navigateTo('/pages/rule/rule', { type: 4 })">规则</view>
  25. <view class="button" style="top: 88rpx" @click="toKnapsack">背包</view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import { raffleDetailApi, getBoxList } from '@/api/drawCard.js'
  31. import PageTitle from '@/component/pageTitle.vue'
  32. export default {
  33. components: {
  34. PageTitle,
  35. },
  36. data() {
  37. return {
  38. raffleId: null,
  39. detail: {},
  40. num: 1,
  41. bosList: [],
  42. }
  43. },
  44. onLoad(query) {
  45. if (query.id) {
  46. this.raffleId = query.id
  47. this.init()
  48. }
  49. },
  50. onShow() {
  51. this.init()
  52. },
  53. methods: {
  54. init() {
  55. // 获取抽盒机详情
  56. this.getDetail()
  57. //获取盒子列表
  58. this.getBoxs()
  59. },
  60. getDetail() {
  61. let params = {
  62. raffleId: this.raffleId,
  63. }
  64. raffleDetailApi(params).then(res => {
  65. console.log(res, '详情')
  66. this.detail = res.data
  67. })
  68. },
  69. boxChange(value) {
  70. let num = this.num + value
  71. console.log(num, 'num')
  72. if (num > 0 && num <= this.detail.roundNum) {
  73. this.num = num
  74. this.getBoxs()
  75. } else {
  76. wx.showToast({
  77. title: '没有更多',
  78. icon: 'none',
  79. })
  80. }
  81. },
  82. getBoxs() {
  83. let params = {
  84. raffleId: this.raffleId,
  85. roundId: this.num,
  86. }
  87. getBoxList(params).then(res => {
  88. console.log(res, 'res盒子数量')
  89. this.bosList = res.data
  90. })
  91. },
  92. toKnapsack() {
  93. // 跳转背包界面
  94. wx.navigateTo({
  95. url: '/pages/knapsack/knapsack',
  96. })
  97. },
  98. toWinningRecord() {
  99. let params = {
  100. raffleId: this.raffleId,
  101. }
  102. this.$navigateTo('/pages/winningRecord/winningRecord', params)
  103. },
  104. toDrawCard_boxDetail(item) {
  105. let params = {
  106. raffleId: this.raffleId, //抽盒机id
  107. roundId: this.num, //箱id
  108. boxId: item.boxId, //盒id
  109. }
  110. this.$navigateTo('/pages/drawCard_box/drawCard_boxDetail', params)
  111. },
  112. },
  113. }
  114. </script>
  115. <style scoped lang="scss">
  116. .container {
  117. background-image: url(https://file.rongcyl.cn/festatic/bkm/imgv2/drawCard_box/bk.png);
  118. background-repeat: no-repeat;
  119. background-size: 100% 100%;
  120. background-color: #9ec8f9;
  121. overflow: inherit;
  122. padding-bottom: 20vw;
  123. .title {
  124. padding: 40rpx 0;
  125. text-align: center;
  126. font-weight: 600;
  127. }
  128. .boxsBr {
  129. margin: 20vw auto 0 auto;
  130. width: 70vw;
  131. // height: 70vw;
  132. background: linear-gradient(180deg, #f29b9b 0%, #e5bfb9 100%);
  133. border-radius: 16rpx 16rpx 16rpx 16rpx;
  134. padding: 8rpx;
  135. .boxs {
  136. width: 100%;
  137. height: 100%;
  138. background: linear-gradient(180deg, #829bfb 0%, #9cdbfc 100%);
  139. border-radius: 12rpx;
  140. display: grid;
  141. grid-template-columns: 1fr 1fr 1fr;
  142. grid-template-rows: 1fr 1fr 1fr;
  143. grid-gap: 4rpx;
  144. .box {
  145. background: linear-gradient(139deg, #a292e9 0%, #a0dfff 100%);
  146. border-radius: 8rpx 8rpx 8rpx 8rpx;
  147. opacity: 1;
  148. border: 2rpx solid #ffffff;
  149. display: inline-flex;
  150. justify-content: center;
  151. align-items: center;
  152. color: #ffffff;
  153. text-shadow: 4rpx 4rpx 4rpx #829bfb;
  154. font-weight: 600;
  155. position: relative;
  156. .boxImg {
  157. width: 80%;
  158. height: 80%;
  159. }
  160. .tip {
  161. position: absolute;
  162. background: rgba(0, 0, 0, 0.45);
  163. height: 100%;
  164. width: 100%;
  165. display: flex;
  166. justify-content: center;
  167. align-items: center;
  168. }
  169. }
  170. }
  171. }
  172. .text {
  173. margin-top: 4vw;
  174. color: #000;
  175. width: 100%;
  176. font-size: 28rpx;
  177. text-align: center;
  178. }
  179. .number {
  180. margin-top: 4vw;
  181. text-align: center;
  182. color: #ffffff;
  183. text-shadow: 4rpx 4rpx 4rpx #829bfb;
  184. font-weight: 600;
  185. }
  186. .buttons {
  187. margin-top: 20rpx;
  188. display: flex;
  189. justify-content: space-around;
  190. .button {
  191. color: #fff;
  192. font-weight: 600;
  193. background: linear-gradient(180deg, #89a9fa 0%, #716ff5 100%);
  194. height: 80rpx;
  195. border-radius: 40rpx;
  196. padding: 0 60rpx;
  197. line-height: 80rpx;
  198. width: 20vw;
  199. text-align: center;
  200. }
  201. .button1 {
  202. width: 25vw;
  203. }
  204. .button2 {
  205. width: 35vw;
  206. margin-bottom: 10rpx;
  207. }
  208. }
  209. .rightButtons {
  210. position: fixed;
  211. right: 0;
  212. width: 100rpx;
  213. height: 70vh;
  214. top: 50%;
  215. transform: translateY(-50%);
  216. .button {
  217. position: absolute;
  218. right: 0;
  219. background: rgba(255, 255, 255, 0.7);
  220. font-size: 20rpx;
  221. text-align: center;
  222. height: 48rpx;
  223. line-height: 48rpx;
  224. border-radius: 24rpx 0 0 24rpx;
  225. width: 92rpx;
  226. }
  227. }
  228. }
  229. </style>