小说小程序前端代码仓库(小程序)
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.

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