展品维保小程序前端代码接口
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.

214 lines
4.9 KiB

2 weeks ago
  1. <template>
  2. <view class="goods-detail">
  3. <!-- 轮播图 -->
  4. <view class="banner-container">
  5. <uv-swiper
  6. indicator
  7. indicatorMode="dot"
  8. indicatorActiveColor="blue"
  9. height="700rpx"
  10. :list="goodsData.image ? goodsData.image.split(',') : []"></uv-swiper>
  11. </view>
  12. <!-- 商品信息 -->
  13. <view class="goods-info">
  14. <!-- 积分信息 -->
  15. <view class="points-section">
  16. <image src="/static/积分图标.png" class="points-icon" mode="aspectFit"></image>
  17. <text class="points-text">{{ goodsData.price }}积分</text>
  18. </view>
  19. <!-- 商品标题 -->
  20. <view class="title-section">
  21. <text class="goods-title">{{ goodsData.title }}</text>
  22. </view>
  23. </view>
  24. <!-- 商品详情独立容器 -->
  25. <view class="detail-container">
  26. <!-- 商品详情标题 -->
  27. <view class="detail-title-section">
  28. <rich-text :nodes="goodsData.details"></rich-text>
  29. </view>
  30. </view>
  31. <!-- 底部操作栏 - 只在待领取状态显示 -->
  32. <view v-if="status === 'pending'" class="bottom-bar">
  33. <view class="exchange-btn" @click="confirmReceive">
  34. <text class="exchange-text">确认取货</text>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. name: 'ExchangeDetail',
  42. data() {
  43. return {
  44. goodsId: '',
  45. status: 'pending', // pending: 待领取, received: 已领取, cancelled: 系统取消
  46. goodsData: {
  47. // id: 1,
  48. // title: '哪吒之魔童闹海新款首套装哪吒校内艺术手办树脂摆件学生小礼品',
  49. // price: 100,
  50. // category: '积分兑换',
  51. // exchangeCount: 120,
  52. // sales: 0,
  53. // inventory: 50,
  54. // details: '这是一款美味的薄脆小饼干,口感酥脆,营养丰富。采用优质原料制作,无添加剂,适合全家人享用。每一口都能感受到浓郁的香味和酥脆的口感,是您休闲时光的最佳选择。',
  55. // image: '/static/商城_商品1.png,/static/商城_商品2.png,/static/bannerImage.png'
  56. }
  57. }
  58. },
  59. onLoad(options) {
  60. if (options.id) {
  61. this.goodsId = options.id;
  62. }
  63. if (options.status) {
  64. this.status = options.status;
  65. }
  66. this.getGoodsDetail(this.goodsId);
  67. },
  68. methods: {
  69. async getGoodsDetail(id) {
  70. const res = await this.$api.user.queryOrderById({ orderId: id })
  71. this.goodsData = res.result
  72. },
  73. previewImage(current, urls) {
  74. uni.previewImage({
  75. current: current,
  76. urls: urls
  77. });
  78. },
  79. confirmReceive() {
  80. uni.showModal({
  81. title: '确认取货',
  82. content: `确定已取货${this.goodsData.title}吗?`,
  83. success: async (res) => {
  84. if (res.confirm) {
  85. const res2 = await this.$api.user.finishOrder({ orderId: this.goodsId })
  86. if (res2.code === 200) {
  87. uni.showToast({
  88. title: `已成功取货${this.goodsData.title}`,
  89. icon: 'success'
  90. });
  91. // 延迟返回上一页
  92. setTimeout(() => {
  93. uni.navigateBack();
  94. }, 1500);
  95. }else {
  96. uni.showToast({
  97. title: res2.msg,
  98. icon: 'error'
  99. });
  100. }
  101. }
  102. }
  103. });
  104. }
  105. }
  106. }
  107. </script>
  108. <style lang="scss" scoped>
  109. .goods-detail {
  110. background: #f8f8f8;
  111. min-height: 100vh;
  112. padding-bottom: 120rpx; // 为底部固定栏留出空间
  113. }
  114. .banner-container {
  115. height: 700rpx;
  116. .banner-swiper {
  117. width: 100%;
  118. .banner-image {
  119. width: 100%;
  120. height: 100%;
  121. }
  122. }
  123. }
  124. .goods-info {
  125. background: #ffffff;
  126. margin-top: 20rpx;
  127. padding: 30rpx;
  128. }
  129. .points-section {
  130. display: flex;
  131. align-items: center;
  132. margin-bottom: 20rpx;
  133. .points-icon {
  134. width: 32rpx;
  135. height: 32rpx;
  136. margin-right: 8rpx;
  137. }
  138. .points-text {
  139. font-size: 32rpx;
  140. font-weight: bold;
  141. color: #1488DB;
  142. }
  143. }
  144. .title-section {
  145. margin-bottom: 40rpx;
  146. .goods-title {
  147. font-size: 28rpx;
  148. color: #333333;
  149. line-height: 1.5;
  150. display: block;
  151. }
  152. }
  153. .detail-container {
  154. background: #ffffff;
  155. margin-top: 20rpx;
  156. padding: 30rpx;
  157. margin-bottom: 120rpx;
  158. }
  159. .detail-title-section {
  160. display: flex;
  161. align-items: center;
  162. justify-content: center;
  163. margin-bottom: 30rpx;
  164. }
  165. .bottom-bar {
  166. position: fixed;
  167. bottom: 0;
  168. left: 0;
  169. right: 0;
  170. background: #ffffff;
  171. padding: 20rpx 30rpx;
  172. border-top: 1rpx solid #f0f0f0;
  173. z-index: 999;
  174. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);
  175. display: flex;
  176. align-items: center;
  177. justify-content: center;
  178. .exchange-btn {
  179. width: 100%;
  180. height: 80rpx;
  181. border-radius: 40rpx;
  182. background-color: #218cdd;
  183. display: flex;
  184. align-items: center;
  185. justify-content: center;
  186. .exchange-text {
  187. color: #ffffff;
  188. font-size: 28rpx;
  189. }
  190. }
  191. }
  192. </style>