drawCard_box.vue 4.6 KB

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