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

278 lines
5.9 KiB

  1. <template>
  2. <!-- 礼物购买页面 -->
  3. <view class="gift-purchase-page">
  4. <!-- 顶部导航栏 -->
  5. <navbar title="礼物购买" leftClick @leftClick="$utils.navigateBack" />
  6. <!-- 礼物购买卡片 -->
  7. <view class="card gift-card">
  8. <view class="card-title">礼物购买</view>
  9. <view class="form-row">
  10. <view class="form-label">礼物名称</view>
  11. <view class="form-value">{{ giftName }}</view>
  12. </view>
  13. <view class="divider"></view>
  14. <view class="form-row">
  15. <view class="form-label required"><text class="star">*</text> 购买数量</view>
  16. <input class="form-input" placeholder="请输入数量" v-model="buyCount" type="number" :placeholder-style="'color:#bbb;'" :style="buyCount ? 'color:#222;' : ''" />
  17. </view>
  18. <view class="divider"></view>
  19. <view class="form-row">
  20. <view class="form-label">支付方式</view>
  21. </view>
  22. <view class="form-row">
  23. <view class="balance">账户余额<text class="bean">{{ balance }} 豆豆</text></view>
  24. </view>
  25. </view>
  26. <!-- 订单信息卡片 -->
  27. <view class="card order-card">
  28. <view class="order-title">订单信息</view>
  29. <view class="row">
  30. <view class="order-content">内容</view>
  31. </view>
  32. <view class="row total-row">
  33. <view class="order-total-label">合计</view>
  34. <view class="order-total"><text class="order-total-highlight">{{ totalPrice.toFixed(2) }}</text> </view>
  35. </view>
  36. <view class="order-divider"></view>
  37. </view>
  38. <!-- 提示信息 -->
  39. <view class="tip-text">
  40. 请仔细核查并确认相关信息因用户个人疏忽导致的充值错误需由用户自行承担一旦完成充值概不退换
  41. </view>
  42. <!-- 底部购买按钮 -->
  43. <view class="footer-bar">
  44. <button class="buy-btn" @click="handleBuy">购买</button>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. export default {
  50. data() {
  51. return {
  52. giftName: '小星星',
  53. price: 0.1, // 单价
  54. buyCount: '',
  55. balance: 0, // 账户余额
  56. }
  57. },
  58. computed: {
  59. totalPrice() {
  60. const count = parseInt(this.buyCount, 10)
  61. return isNaN(count) ? 0 : count * this.price
  62. }
  63. },
  64. onLoad(query) {
  65. // 支持通过路由参数动态显示礼物信息
  66. if (query.name) this.giftName = decodeURIComponent(query.name)
  67. if (query.price) this.price = Number(query.price)
  68. if (query.count) this.buyCount = query.count
  69. },
  70. methods: {
  71. handleBuy() {
  72. if (!this.buyCount || parseInt(this.buyCount, 10) <= 0) {
  73. uni.showToast({ title: '请输入购买数量', icon: 'none' })
  74. return
  75. }
  76. // 这里可添加余额校验和购买逻辑
  77. uni.showToast({ title: `成功购买${this.buyCount}${this.giftName}`, icon: 'success' })
  78. }
  79. }
  80. }
  81. </script>
  82. <style scoped lang="scss">
  83. .gift-purchase-page {
  84. min-height: 100vh;
  85. background: #f8f8f8;
  86. padding-bottom: 120rpx;
  87. }
  88. .card {
  89. background: #fff;
  90. border-radius: 18rpx;
  91. margin: 24rpx 16rpx 0 16rpx;
  92. padding: 24rpx 24rpx 10rpx 24rpx;
  93. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.03);
  94. }
  95. .card-title {
  96. font-size: 24rpx;
  97. font-weight: bold;
  98. color: #222;
  99. margin-bottom: 18rpx;
  100. }
  101. .row {
  102. display: flex;
  103. align-items: center;
  104. margin-bottom: 16rpx;
  105. }
  106. .label {
  107. color: #888;
  108. font-size: 26rpx;
  109. width: 160rpx;
  110. }
  111. .label.required {
  112. color: #222;
  113. font-weight: 500;
  114. }
  115. .value {
  116. color: #222;
  117. font-size: 26rpx;
  118. }
  119. .input {
  120. flex: 1;
  121. border: none;
  122. border-bottom: 1rpx solid #eee;
  123. font-size: 26rpx;
  124. padding: 8rpx 0;
  125. background: transparent;
  126. outline: none;
  127. }
  128. .order-card {
  129. border-radius: 20px;
  130. box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  131. padding: 24px 20px 16px 20px;
  132. margin: 16px;
  133. position: relative;
  134. }
  135. .order-title {
  136. font-size: 18px;
  137. font-weight: bold;
  138. color: #222;
  139. margin-bottom: 12px;
  140. }
  141. .order-content {
  142. color: #bbb;
  143. font-size: 15px;
  144. margin-bottom: 8px;
  145. }
  146. .row.total-row {
  147. display: flex;
  148. align-items: center;
  149. margin-bottom: 0;
  150. }
  151. .order-total-label {
  152. color: #222;
  153. font-size: 18px;
  154. font-weight: 500;
  155. }
  156. .order-total {
  157. color: #222;
  158. font-size: 18px;
  159. font-weight: 500;
  160. margin-left: 8px;
  161. }
  162. .order-total-highlight {
  163. color: #ff7e00;
  164. font-size: 18px;
  165. font-weight: bold;
  166. margin: 0 2px;
  167. }
  168. .order-divider {
  169. width: 100%;
  170. height: 1px;
  171. background: #f2f2f2;
  172. margin-top: 16px;
  173. }
  174. .tip-text {
  175. color: #bbb;
  176. font-size: 22rpx;
  177. margin: 32rpx 32rpx 0 32rpx;
  178. line-height: 1.6;
  179. }
  180. .footer-bar {
  181. position: fixed;
  182. left: 0;
  183. right: 0;
  184. bottom: 90rpx;
  185. background: #fff;
  186. padding: 24rpx 32rpx 32rpx 32rpx;
  187. box-shadow: 0 -2rpx 10rpx rgba(0,0,0,0.05);
  188. z-index: 10;
  189. }
  190. .buy-btn {
  191. width: 100%;
  192. background: #223a7a;
  193. color: #fff;
  194. font-size: 32rpx;
  195. border-radius: 32rpx;
  196. height: 88rpx;
  197. line-height: 88rpx;
  198. border: none;
  199. font-weight: 500;
  200. }
  201. .card.gift-card {
  202. border-radius: 20px;
  203. box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  204. padding: 24px 20px 16px 20px;
  205. margin: 16px;
  206. position: relative;
  207. }
  208. .card-title {
  209. font-size: 18px;
  210. font-weight: bold;
  211. color: #222;
  212. margin-bottom: 12px;
  213. }
  214. .form-row {
  215. display: flex;
  216. flex-direction: column;
  217. align-items: flex-start;
  218. min-height: 36px;
  219. padding: 0;
  220. margin-top: 5rpx;
  221. }
  222. .form-label {
  223. color: #888;
  224. font-size: 14px;
  225. margin-bottom: 9px;
  226. font-weight: 400;
  227. margin-top: 5px;
  228. }
  229. .form-label.required {
  230. color: #222;
  231. font-weight: 500;
  232. display: flex;
  233. align-items: center;
  234. }
  235. .star {
  236. color: #e94f7a;
  237. margin-right: 2px;
  238. font-size: 16px;
  239. }
  240. .form-value {
  241. color: #0e0e0e;
  242. font-size: 14px;
  243. font-weight: 600;
  244. margin-bottom: 2px;
  245. }
  246. .form-input {
  247. flex: 1;
  248. border: none;
  249. background: transparent;
  250. font-size: 14px;
  251. outline: none;
  252. padding: 0;
  253. color: #222;
  254. }
  255. .divider {
  256. height: 1px;
  257. background: #f2f2f2;
  258. margin: 0 0 0 0;
  259. border: none;
  260. }
  261. .balance {
  262. color: #0e0e0e;
  263. font-size: 14px;
  264. margin: 0 0 8px 0;
  265. }
  266. .bean {
  267. color: #222;
  268. font-weight: 600;
  269. }
  270. </style>