details.vue 3.7 KB

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