details.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view class="voucher-coupon-detail">
  3. <image class="voucher-coupon-detail-header-img" mode="aspectFit" v-if="coupon.photo" :src="fileUrl + coupon.photo"></image>
  4. <view class="voucher-coupon-detail-header">
  5. <view class="voucher-coupon-detail-header-info">
  6. <view class="voucher-coupon-detail-header-info-title">{{coupon.name}}</view>
  7. <view class="voucher-coupon-detail-header-info-time">代金券面额:¥{{coupon.money}}</view>
  8. <view class="voucher-coupon-detail-header-info-desc">剩余数量:{{coupon.remainCount || 0}}</view>
  9. <view class="voucher-coupon-detail-header-info-time">需要积分:{{coupon.integral}}</view>
  10. <view class="voucher-coupon-detail-header-info-time">开始领取:{{coupon.startTime}}</view>
  11. <view class="voucher-coupon-detail-header-info-time">结束领取:{{coupon.endTime}}</view>
  12. <view class="voucher-coupon-detail-header-info-time">领取地点:{{coupon.location}}</view>
  13. </view>
  14. </view>
  15. <view class="voucher-coupon-detail-content">
  16. <view class="voucher-coupon-detail-content-title">说明</view>
  17. <view class="voucher-coupon-detail-content-desc" v-html="coupon.details"></view>
  18. </view>
  19. <view class="voucher-coupon-detail-footer-btn" :class="{ remainCount: coupon.remainCount == 0 }" @click="receive">立即领取</view>
  20. <popup ref="popup" :popupInfo="popupInfo" @confirm="popupBtnClick" @close="popupBtnClick"></popup>
  21. </view>
  22. </template>
  23. <script>
  24. import { BASE_URL } from '../../env.js';
  25. import voucher from '../../api/voucher.js';
  26. import popup from '../../components/popup.vue'
  27. export default {
  28. components: {
  29. popup
  30. },
  31. data() {
  32. return {
  33. fileUrl: BASE_URL.fileUrl,
  34. coupon: {
  35. photo: '',
  36. title: '',
  37. remain_count: '',
  38. describe: ``,
  39. money: '',
  40. integral:'',
  41. location:'',
  42. startTime:'',
  43. endTime:''
  44. },
  45. popupInfo: {
  46. msgType: 'success',
  47. cancelText: '关闭',
  48. confirmText: '确认',
  49. title: '通知',
  50. content: '默认消息'
  51. },
  52. };
  53. },
  54. onLoad: async function(option) {
  55. if(option.id) this.id = option.id;
  56. this.query();
  57. },
  58. methods: {
  59. async query() {
  60. const res = await voucher.getInfo(this.id);
  61. this.coupon = res.data;
  62. },
  63. popupBtnClick() {
  64. this.query();
  65. },
  66. async receive() {
  67. if (this.coupon.remainCount == 0) return;
  68. // 领取流程
  69. const res = await voucher.receivevoucher(this.coupon.discountId);
  70. if (res.code == 200) {
  71. this.popupInfo.content = '领取成功'
  72. this.$refs.popup.open();
  73. this.query();
  74. }
  75. }
  76. }
  77. };
  78. </script>
  79. <style>
  80. .voucher-coupon-detail {
  81. padding: 20rpx;
  82. width: 90%;
  83. margin: 0 auto;
  84. }
  85. .voucher-coupon-detail-header {
  86. display: flex;
  87. align-items: center;
  88. margin-bottom: 20rpx;
  89. }
  90. .voucher-coupon-detail-header-img {
  91. width: 100%;
  92. /* height: 120rpx; */
  93. /* margin-right: 20rpx; */
  94. }
  95. .voucher-coupon-detail-header-info {
  96. flex: 1;
  97. }
  98. .voucher-coupon-detail-header-info-title {
  99. font-size: 32rpx;
  100. font-weight: bold;
  101. margin-bottom: 10rpx;
  102. margin-top: 30rpx;
  103. }
  104. .voucher-coupon-detail-header-info-desc {
  105. font-size: 28rpx;
  106. color: #999;
  107. margin-bottom: 10rpx;
  108. }
  109. .voucher-coupon-detail-header-info-time {
  110. font-size: 28rpx;
  111. color: #999;
  112. }
  113. .voucher-coupon-detail-content {
  114. margin-top: 30rpx;
  115. }
  116. .voucher-coupon-detail-content-title {
  117. font-size: 32rpx;
  118. font-weight: bold;
  119. margin-bottom: 20rpx;
  120. }
  121. .voucher-coupon-detail-content-desc {
  122. font-size: 28rpx;
  123. color: #999;
  124. line-height: 1.5;
  125. margin-bottom: 20rpx;
  126. }
  127. .voucher-coupon-detail-footer {
  128. display: flex;
  129. justify-content: space-between;
  130. align-items: center;
  131. background-color: #f5f5f5;
  132. padding: 20rpx;
  133. border-radius: 10rpx;
  134. }
  135. .voucher-coupon-detail-footer-price {
  136. font-size: 36rpx;
  137. font-weight: bold;
  138. }
  139. .voucher-coupon-detail-footer-btn {
  140. display: flex;
  141. justify-content: center;
  142. align-items: center;
  143. height: 80rpx;
  144. background-color: #f60;
  145. color: #FFFFFF;
  146. font-size: 32rpx;
  147. font-weight: bold;
  148. border-radius: 10rpx;
  149. margin-top: 50rpx;
  150. }
  151. .remainCount {
  152. background-color: #999;
  153. }
  154. </style>