detail.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <view>
  3. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="优惠券详情"></u-navbar>
  4. <view class="detail">
  5. <!-- 优惠券信息 -->
  6. <view class="flex detail-item">
  7. <!-- <image src="../../static/icon/coupon.png" mode=""></image>
  8. <view class="flex info">
  9. <view class="flex desc">
  10. <view class="title">{{ info.title }}</view>
  11. <view class="txt">使用期限:{{ $parseTime(info.validStart, '{y}.{m}.{d}') }}-{{ $parseTime(info.validEnd, '{y}.{m}.{d}') }}</view>
  12. <view class="txt">使用范围:{{ info.useAreaDesc || '-' }}</view>
  13. </view>
  14. <view class="flex btn">
  15. <view class="amt"><text>¥</text>{{ info.discount / 100 }}</view>
  16. </view>
  17. </view> -->
  18. <view class="content flex">
  19. <view class="content-left flex">
  20. <image src="../static/prize_coupon.png" mode=""></image>
  21. <view class="price flex">
  22. <text>{{ info.discount / 100 }}</text>
  23. <text>元</text>
  24. </view>
  25. </view>
  26. <view class="content-right flex">
  27. <view class="title ells-one">{{ info.title }}</view>
  28. <view class="desc">适用范围:{{ info.useAreaDesc || '-' }}</view>
  29. <view class="desc">使用期限:{{ $parseTime(info.validStart, '{y}.{m}.{d}') }} ~ {{ $parseTime(info.validEnd, '{y}.{m}.{d}') }}</view>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 间隔 -->
  34. <view class="detail-interval flex">
  35. <view class="detail-interval__left"></view>
  36. <view class="detail-interval__line"></view>
  37. <view class="detail-interval__right"></view>
  38. </view>
  39. <!-- 二维码 -->
  40. <view class="flex detail-code" v-if = "info && info.useArea && JSON.parse(info.useArea).value != 4">
  41. <canvas style="width: 220px;height: 220px;" canvas-id="couponQrcode"></canvas>
  42. </view>
  43. <!-- 说明 -->
  44. <view class="detail-explain">
  45. <view class="txt">使用说明:</view>
  46. <view class="txt">{{ info.description }}</view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import $http from '@/utils/request.js'
  53. const qrCode = require('@/common/weapp-qrcode.js')
  54. export default {
  55. data() {
  56. return {
  57. info: {},
  58. id: null,
  59. };
  60. },
  61. onLoad(options) {
  62. this.id = options.id
  63. this.getDetail()
  64. },
  65. methods: {
  66. getDetail() {
  67. uni.showLoading({
  68. title: '加载中'
  69. });
  70. $http.post('/api/v1/mp/user/mine/coupon/detail', {
  71. id: this.id
  72. }).then(res => {
  73. uni.hideLoading();
  74. if (res.code == 0) {
  75. this.info = res.data
  76. setTimeout(() => {
  77. uni.hideLoading();
  78. this.couponQrCode()
  79. }, 50)
  80. }
  81. }).catch(() => {
  82. uni.hideLoading();
  83. })
  84. },
  85. // 二维码生成工具
  86. couponQrCode() {
  87. new qrCode('couponQrcode', {
  88. text: this.info.verifyCode,
  89. width: 213,
  90. height: 213,
  91. colorDark: "#333333",
  92. colorLight: "#FFFFFF",
  93. correctLevel: qrCode.CorrectLevel.H
  94. })
  95. },
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .detail {
  101. margin: 20rpx;
  102. background-color: #FFFFFF;
  103. border-radius: 10rpx;
  104. overflow: hidden;
  105. // 优惠券信息
  106. &-item {
  107. padding: 30rpx 0 30rpx;
  108. background-color: #fff;
  109. .content {
  110. width: 100%;
  111. height: 184rpx;
  112. justify-content: flex-start;
  113. &-left {
  114. width: 210rpx;
  115. height: 100%;
  116. margin-right: 20rpx;
  117. image {
  118. width: 100%;
  119. height: 100%;
  120. }
  121. .price {
  122. position: absolute;
  123. color: #fff;
  124. text:first-child {
  125. font-size: 70rpx;
  126. padding-right: 20rpx;
  127. }
  128. text:last-child {
  129. font-size: 40rpx;
  130. }
  131. }
  132. }
  133. &-right {
  134. flex: 1;
  135. align-items: flex-start;
  136. flex-direction: column;
  137. justify-content: space-between;
  138. height: 100%;
  139. padding: 24rpx 0;
  140. .title {
  141. font-size: 32rpx;
  142. line-height: 32rpx;
  143. height: 32rpx;
  144. overflow: hidden;
  145. font-weight: bold;
  146. }
  147. .desc {
  148. font-size: 24rpx;
  149. line-height: 24rpx;
  150. color: #999999;
  151. }
  152. }
  153. }
  154. }
  155. // 间隔
  156. &-interval {
  157. position: relative;
  158. width: 100%;
  159. height: 30rpx;
  160. margin-bottom: 10rpx;
  161. &__left {
  162. position: absolute;
  163. left: -15rpx;
  164. width: 30rpx;
  165. height: 30rpx;
  166. background: #F9F7F5;
  167. border-radius: 50%;
  168. }
  169. &__line {
  170. height: 1px;
  171. background-color: #F9F7F5;
  172. width: 90%;
  173. }
  174. &__right {
  175. position: absolute;
  176. right: -15rpx;
  177. width: 30rpx;
  178. height: 30rpx;
  179. background: #F9F7F5;
  180. border-radius: 50%;
  181. }
  182. }
  183. // 二维码
  184. &-code {
  185. width: 100%;
  186. height: 460rpx;
  187. margin-bottom: 20rpx;
  188. }
  189. // 说明
  190. &-explain {
  191. font-size: 26rpx;
  192. padding: 0 34rpx 34rpx;
  193. .txt {
  194. line-height: 40rpx;
  195. }
  196. }
  197. }
  198. </style>