detail.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view>
  3. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="优惠券详情"></u-navbar>
  4. <view class="detail">
  5. <view class="flex detail-item">
  6. <image src="../../static/icon/coupon.png" mode=""></image>
  7. <view class="flex info">
  8. <view class="flex desc">
  9. <view class="title">{{ info.title }}</view>
  10. <view class="txt">使用期限:{{ $parseTime(info.validStart, '{y}.{m}.{d}') }}-{{ $parseTime(info.validEnd, '{y}.{m}.{d}') }}</view>
  11. <view class="txt">使用范围:{{ info.useAreaDesc || '-' }}</view>
  12. </view>
  13. <view class="flex btn">
  14. <view class="amt"><text>¥</text>{{ info.discount / 100 }}</view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="flex detail-code" v-if = "info && info.useArea && JSON.parse(info.useArea).value != 4">
  19. <canvas style="width: 220px;height: 220px;" canvas-id="couponQrcode"></canvas>
  20. </view>
  21. <view class="detail-explain">
  22. <view class="txt">使用说明:</view>
  23. <view class="txt">{{ info.description }}</view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import $http from '@/utils/request.js'
  30. const qrCode = require('@/common/weapp-qrcode.js')
  31. export default {
  32. data() {
  33. return {
  34. info: {},
  35. id: null,
  36. };
  37. },
  38. onLoad(options) {
  39. this.id = options.id
  40. this.getDetail()
  41. },
  42. methods: {
  43. getDetail() {
  44. uni.showLoading({
  45. title: '加载中'
  46. });
  47. $http.post('/api/v1/mp/user/mine/coupon/detail', {
  48. id: this.id
  49. }).then(res => {
  50. uni.hideLoading();
  51. if (res.code == 0) {
  52. this.info = res.data
  53. setTimeout(() => {
  54. uni.hideLoading();
  55. this.couponQrCode()
  56. }, 50)
  57. }
  58. }).catch(() => {
  59. uni.hideLoading();
  60. })
  61. },
  62. // 二维码生成工具
  63. couponQrCode() {
  64. new qrCode('couponQrcode', {
  65. text: this.info.verifyCode,
  66. width: 213,
  67. height: 213,
  68. colorDark: "#333333",
  69. colorLight: "#FFFFFF",
  70. correctLevel: qrCode.CorrectLevel.H
  71. })
  72. },
  73. }
  74. }
  75. </script>
  76. <style lang="scss" scoped>
  77. .detail {
  78. margin: 20rpx;
  79. padding: 26rpx 24rpx;
  80. background-color: #FFFFFF;
  81. border-radius: 10rpx;
  82. &-item {
  83. justify-content: space-between;
  84. padding-bottom: 26rpx;
  85. border-bottom: 1px dashed rgba(236, 236, 236, 100);
  86. image {
  87. width: 120rpx;
  88. height: 106rpx;
  89. }
  90. .info {
  91. position: relative;
  92. justify-content: space-between;
  93. flex: 1;
  94. }
  95. .desc {
  96. height: 106rpx;
  97. flex-direction: column;
  98. justify-content: space-between;
  99. align-items: flex-start;
  100. padding-left: 20rpx;
  101. }
  102. .title{
  103. font-weight: bold;
  104. }
  105. .txt {
  106. font-size: 24rpx;
  107. }
  108. .btn {
  109. flex-direction: column;
  110. }
  111. .amt {
  112. font-size: 48rpx;
  113. font-weight: bold;
  114. line-height: 72rpx;
  115. }
  116. text {
  117. font-size: 24rpx;
  118. }
  119. }
  120. &-code {
  121. width: 100%;
  122. height: 550rpx;
  123. }
  124. &-explain {
  125. font-size: 24rpx;
  126. .txt {
  127. line-height: 50rpx;
  128. }
  129. }
  130. }
  131. </style>