details.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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" v-if="type !== 'my'" >剩余数量:{{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" v-if="type !== 'my'" :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. type: ''
  53. };
  54. },
  55. onLoad: async function(option) {
  56. if(option.id) this.id = option.id;
  57. if (option.type) this.type = option.type;
  58. this.query();
  59. },
  60. methods: {
  61. async query() {
  62. const res = await voucher.getInfo(this.id);
  63. this.coupon = res.data;
  64. },
  65. popupBtnClick() {
  66. this.query();
  67. },
  68. async receive() {
  69. if (this.coupon.remainCount == 0) return;
  70. // 领取流程
  71. const res = await voucher.receivevoucher(this.coupon.discountId);
  72. if (res.code == 200) {
  73. this.popupInfo.content = '领取成功'
  74. this.$refs.popup.open();
  75. this.query();
  76. }
  77. }
  78. }
  79. };
  80. </script>
  81. <style>
  82. .voucher-coupon-detail {
  83. padding: 20rpx;
  84. width: 90%;
  85. margin: 0 auto;
  86. }
  87. .voucher-coupon-detail-header {
  88. display: flex;
  89. align-items: center;
  90. margin-bottom: 20rpx;
  91. }
  92. .voucher-coupon-detail-header-img {
  93. width: 100%;
  94. /* height: 120rpx; */
  95. /* margin-right: 20rpx; */
  96. }
  97. .voucher-coupon-detail-header-info {
  98. flex: 1;
  99. }
  100. .voucher-coupon-detail-header-info-title {
  101. font-size: 32rpx;
  102. font-weight: bold;
  103. margin-bottom: 10rpx;
  104. margin-top: 30rpx;
  105. }
  106. .voucher-coupon-detail-header-info-desc {
  107. font-size: 28rpx;
  108. color: #999;
  109. margin-bottom: 10rpx;
  110. }
  111. .voucher-coupon-detail-header-info-time {
  112. font-size: 28rpx;
  113. color: #999;
  114. }
  115. .voucher-coupon-detail-content {
  116. margin-top: 30rpx;
  117. }
  118. .voucher-coupon-detail-content-title {
  119. font-size: 32rpx;
  120. font-weight: bold;
  121. margin-bottom: 20rpx;
  122. }
  123. .voucher-coupon-detail-content-desc {
  124. font-size: 28rpx;
  125. color: #999;
  126. line-height: 1.5;
  127. margin-bottom: 20rpx;
  128. }
  129. .voucher-coupon-detail-footer {
  130. display: flex;
  131. justify-content: space-between;
  132. align-items: center;
  133. background-color: #f5f5f5;
  134. padding: 20rpx;
  135. border-radius: 10rpx;
  136. }
  137. .voucher-coupon-detail-footer-price {
  138. font-size: 36rpx;
  139. font-weight: bold;
  140. }
  141. .voucher-coupon-detail-footer-btn {
  142. display: flex;
  143. justify-content: center;
  144. align-items: center;
  145. height: 80rpx;
  146. background-color: #f60;
  147. color: #FFFFFF;
  148. font-size: 32rpx;
  149. font-weight: bold;
  150. border-radius: 10rpx;
  151. margin-top: 50rpx;
  152. }
  153. .remainCount {
  154. background-color: #999;
  155. }
  156. </style>