小说小程序前端代码仓库(小程序)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

253 lines
4.9 KiB

  1. <template>
  2. <!-- 礼物盒页面 -->
  3. <view class="giftbox-container">
  4. <navbar title="礼物盒" leftClick @leftClick="$utils.navigateBack" />
  5. <!-- 礼物列表 -->
  6. <view class="gift-list">
  7. <!-- <view v-for="(gift, idx) in gifts" :key="gift.id"
  8. :class="['gift-item', { selected: idx === selectedIndex }]" @click="selectGift(idx)">
  9. <view class="gift-img">
  10. <text class="gift-emoji">{{ gift.emoji }}</text>
  11. </view>
  12. <view class="gift-name">{{ gift.name }}</view>
  13. <view class="gift-info">
  14. <text class="gift-count">x{{ gift.count }}</text>
  15. <text class="gift-bean">{{ gift.price }}豆豆</text>
  16. </view>
  17. </view> -->
  18. <view v-for="(gift, idx) in list" :key="gift.id"
  19. :class="['gift-item', { selected: idx === selectedIndex }]" @click="selectGift(idx)">
  20. <view class="gift-img">
  21. <text class="gift-emoji">{{ gift.emoji }}</text>
  22. </view>
  23. <view class="gift-name">{{ gift.name }}</view>
  24. <view class="gift-info">
  25. <text class="gift-count">x{{ gift.count }}</text>
  26. <text class="gift-bean">{{ gift.price }}豆豆</text>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 底部操作栏 -->
  31. <view class="giftbox-bottom">
  32. <view class="giftbox-left">剩余{{ gifts[selectedIndex].count }} </view>
  33. <view class="giftbox-buy">
  34. <button class="buy-btn" @click="buyGift">购买</button>
  35. <uv-number-box v-model="buyCount" :min="1" :max="gifts[selectedIndex].count" />
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import mixinsList from '@/mixins/list.js'
  42. export default {
  43. mixins: [mixinsList],
  44. components: {
  45. },
  46. data() {
  47. return {
  48. mixinsListApi : 'getInteractionGiftList',
  49. gifts: [{
  50. id: 1,
  51. name: '小星星',
  52. emoji: '🌟',
  53. count: 6,
  54. price: 1
  55. },
  56. {
  57. id: 2,
  58. name: '爱你哟',
  59. emoji: '🧡',
  60. count: 5,
  61. price: 1
  62. },
  63. {
  64. id: 3,
  65. name: '加油鸭',
  66. emoji: '🦆',
  67. count: 5,
  68. price: 1
  69. },
  70. {
  71. id: 4,
  72. name: '蓝色烟花',
  73. emoji: '🎆',
  74. count: 5,
  75. price: 1
  76. },
  77. {
  78. id: 5,
  79. name: '沙滩椅',
  80. emoji: '🏖️',
  81. count: 5,
  82. price: 1
  83. },
  84. {
  85. id: 6,
  86. name: '菠萝',
  87. emoji: '🍍',
  88. count: 5,
  89. price: 1
  90. },
  91. {
  92. id: 7,
  93. name: '咖啡',
  94. emoji: '☕',
  95. count: 5,
  96. price: 1
  97. },
  98. {
  99. id: 8,
  100. name: '早餐',
  101. emoji: '🥐',
  102. count: 5,
  103. price: 1
  104. },
  105. {
  106. id: 9,
  107. name: '花花',
  108. emoji: '🌷',
  109. count: 5,
  110. price: 1
  111. },
  112. {
  113. id: 10,
  114. name: '玫瑰',
  115. emoji: '🌹',
  116. count: 5,
  117. price: 1
  118. },
  119. {
  120. id: 11,
  121. name: '玫瑰花',
  122. emoji: '🥀',
  123. count: 5,
  124. price: 1
  125. },
  126. {
  127. id: 12,
  128. name: '跑车',
  129. emoji: '🏎️',
  130. count: 5,
  131. price: 1
  132. },
  133. ],
  134. selectedIndex: 0,
  135. buyCount: 1,
  136. }
  137. },
  138. methods: {
  139. selectGift(idx) {
  140. this.selectedIndex = idx
  141. this.buyCount = 1
  142. },
  143. buyGift() {
  144. // 跳转到礼物购买页面,并传递选中礼物信息
  145. const gift = this.gifts[this.selectedIndex]
  146. uni.navigateTo({
  147. url: `/pages_order/novel/Giftpurchases?name=${encodeURIComponent(gift.name)}&price=${gift.price}&count=${this.buyCount}`
  148. })
  149. },
  150. },
  151. }
  152. </script>
  153. <style scoped lang="scss">
  154. .giftbox-container {
  155. min-height: 100vh;
  156. background: #f8f8f8;
  157. padding-bottom: 120rpx;
  158. }
  159. .gift-list {
  160. display: flex;
  161. flex-wrap: wrap;
  162. gap: 24rpx;
  163. padding: 32rpx 16rpx 0 16rpx;
  164. }
  165. .gift-item {
  166. width: 30%;
  167. background: #fff;
  168. border-radius: 18rpx;
  169. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03);
  170. margin-bottom: 24rpx;
  171. display: flex;
  172. flex-direction: column;
  173. align-items: center;
  174. padding: 24rpx 0 16rpx 0;
  175. border: 2rpx solid transparent;
  176. transition: border 0.2s;
  177. }
  178. .gift-item.selected {
  179. border: 2rpx solid #223a7a;
  180. box-shadow: 0 4rpx 16rpx 0 rgba(34, 58, 122, 0.08);
  181. }
  182. .gift-img {
  183. width: 80rpx;
  184. height: 80rpx;
  185. display: flex;
  186. align-items: center;
  187. justify-content: center;
  188. margin-bottom: 8rpx;
  189. }
  190. .gift-emoji {
  191. font-size: 56rpx;
  192. }
  193. .gift-name {
  194. font-size: 28rpx;
  195. color: #222;
  196. margin-bottom: 4rpx;
  197. }
  198. .gift-info {
  199. display: flex;
  200. align-items: center;
  201. gap: 8rpx;
  202. font-size: 22rpx;
  203. color: #888;
  204. }
  205. .giftbox-bottom {
  206. position: fixed;
  207. left: 0;
  208. right: 0;
  209. bottom: 90rpx;
  210. background: #fff;
  211. display: flex;
  212. align-items: center;
  213. justify-content: space-between;
  214. height: 100rpx;
  215. padding: 0 32rpx;
  216. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  217. z-index: 10;
  218. }
  219. .giftbox-left {
  220. font-size: 28rpx;
  221. color: #666;
  222. }
  223. .giftbox-buy {
  224. display: flex;
  225. align-items: center;
  226. gap: 18rpx;
  227. }
  228. .buy-btn {
  229. background: #223a7a;
  230. color: #fff;
  231. font-size: 28rpx;
  232. border-radius: 32rpx;
  233. padding: 0 36rpx;
  234. height: 68rpx;
  235. line-height: 68rpx;
  236. border: none;
  237. }
  238. </style>