drawCard_box.vue 5.3 KB

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