drawCard_box.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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">规则</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. methods: {
  49. init() {
  50. // 获取抽盒机详情
  51. this.getDetail()
  52. //获取盒子列表
  53. this.getBoxs()
  54. },
  55. getDetail() {
  56. let params = {
  57. raffleId: this.raffleId,
  58. }
  59. raffleDetailApi(params).then(res => {
  60. console.log(res, '详情')
  61. this.detail = res.data
  62. })
  63. },
  64. boxChange(value) {
  65. let num = this.num + value
  66. console.log(num, 'num')
  67. if (num > 0 && num <= this.detail.roundNum) {
  68. this.num = num
  69. this.getBoxs()
  70. } else {
  71. wx.showToast({
  72. title: '没有更多',
  73. icon: 'none',
  74. })
  75. }
  76. },
  77. getBoxs() {
  78. let params = {
  79. raffleId: this.raffleId,
  80. roundId: this.num,
  81. }
  82. getBoxList(params).then(res => {
  83. console.log(res, 'res盒子数量')
  84. this.bosList = res.data
  85. })
  86. },
  87. toKnapsack() {
  88. // 跳转背包界面
  89. wx.navigateTo({
  90. url: '/pages/knapsack/knapsack',
  91. })
  92. },
  93. toWinningRecord() {
  94. let params = {
  95. raffleId: this.raffleId,
  96. }
  97. this.$navigateTo('/pages/winningRecord/winningRecord', params)
  98. },
  99. toDrawCard_boxDetail(item) {
  100. let params = {
  101. raffleId: this.raffleId, //抽盒机id
  102. roundId: this.num, //箱id
  103. boxId: item.boxId, //盒id
  104. }
  105. this.$navigateTo('/pages/drawCard_box/drawCard_boxDetail', params)
  106. },
  107. },
  108. }
  109. </script>
  110. <style scoped lang="scss">
  111. .container {
  112. background: #9ec8f9;
  113. overflow: inherit;
  114. .title {
  115. padding: 20px 0;
  116. text-align: center;
  117. font-weight: 600;
  118. }
  119. .boxsBr {
  120. margin: 20vw auto 0 auto;
  121. width: 70vw;
  122. height: 70vw;
  123. background: linear-gradient(180deg, #f29b9b 0%, #e5bfb9 100%);
  124. border-radius: 8px 8px 8px 8px;
  125. padding: 4px;
  126. .boxs {
  127. width: 100%;
  128. height: 100%;
  129. background: linear-gradient(180deg, #829bfb 0%, #9cdbfc 100%);
  130. border-radius: 6px;
  131. display: grid;
  132. grid-template-columns: 1fr 1fr 1fr;
  133. grid-template-rows: 1fr 1fr 1fr;
  134. grid-gap: 2px;
  135. .box {
  136. background: linear-gradient(139deg, #a292e9 0%, #a0dfff 100%);
  137. border-radius: 4px 4px 4px 4px;
  138. opacity: 1;
  139. border: 1px solid #ffffff;
  140. display: inline-flex;
  141. justify-content: center;
  142. align-items: center;
  143. color: #ffffff;
  144. text-shadow: 2px 2px 2px #829bfb;
  145. font-weight: 600;
  146. position: relative;
  147. .boxImg {
  148. width: 80%;
  149. height: 80%;
  150. }
  151. .tip {
  152. position: absolute;
  153. background: rgba(0, 0, 0, 0.45);
  154. height: 100%;
  155. width: 100%;
  156. display: flex;
  157. justify-content: center;
  158. align-items: center;
  159. }
  160. }
  161. }
  162. }
  163. .text {
  164. margin-top: 4vw;
  165. color: #000;
  166. width: 100%;
  167. font-size: 14px;
  168. text-align: center;
  169. }
  170. .number {
  171. margin-top: 4vw;
  172. text-align: center;
  173. color: #ffffff;
  174. text-shadow: 2px 2px 2px #829bfb;
  175. font-weight: 600;
  176. }
  177. .buttons {
  178. margin-top: 10px;
  179. display: flex;
  180. justify-content: space-around;
  181. .button {
  182. color: #fff;
  183. font-weight: 600;
  184. background: linear-gradient(180deg, #89a9fa 0%, #716ff5 100%);
  185. height: 40px;
  186. border-radius: 20px;
  187. padding: 0 30px;
  188. line-height: 40px;
  189. width: 20vw;
  190. text-align: center;
  191. }
  192. .button1 {
  193. width: 25vw;
  194. }
  195. .button2 {
  196. width: 35vw;
  197. margin-bottom: 5px;
  198. }
  199. }
  200. .rightButtons {
  201. position: fixed;
  202. right: 0;
  203. width: 50px;
  204. height: 70vh;
  205. top: 50%;
  206. transform: translateY(-50%);
  207. .button {
  208. position: absolute;
  209. right: 0;
  210. background: rgba(255, 255, 255, 0.7);
  211. font-size: 10px;
  212. text-align: center;
  213. height: 24px;
  214. line-height: 24px;
  215. border-radius: 12px 0 0 12px;
  216. width: 46px;
  217. }
  218. }
  219. }
  220. </style>