coupon-description.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view class="coupon-description" :class="'entry-' + entryType">
  3. <view class="title" v-text="description.title"></view>
  4. <view class="description">
  5. <view class="tip" v-text="description.tip"></view>
  6. <view class="content" v-text="content"></view>
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. import description from './config/description.js'
  12. import { fetchShareCouponList } from '@/services/api/coupon.js'
  13. export default {
  14. data() {
  15. return {
  16. entryType: 1,
  17. descriptionList: description,
  18. types: ['inviteCouponList', 'consumeCouponList', 'shareCouponList'],
  19. content: ''
  20. }
  21. },
  22. computed: {
  23. description() {
  24. return this.descriptionList[this.entryType - 1]
  25. }
  26. },
  27. onLoad(options) {
  28. this.entryType = options.entryType
  29. uni.setNavigationBarTitle({
  30. title: options.title
  31. })
  32. this.fetchShareCouponList()
  33. },
  34. methods: {
  35. async fetchShareCouponList() {
  36. try {
  37. const res = await fetchShareCouponList()
  38. const key = this.types[this.entryType - 1]
  39. const list = res.data[key]
  40. if (list && list.length <= 0) return
  41. const priceText = list.map(item => item + '元').join(',')
  42. this.content = this.description.content.replace('#price#', priceText)
  43. } catch (e) {
  44. //TODO handle the exception
  45. console.log(e)
  46. }
  47. }
  48. }
  49. }
  50. </script>
  51. <style lang="scss" scoped>
  52. $bg-coupon-desc-01: url('https://static.caimei365.com/app/mini-hehe/icon/bg-coupon-desc-01.png');
  53. $bg-coupon-desc-02: url('https://static.caimei365.com/app/mini-hehe/icon/bg-coupon-desc-02.png');
  54. $bg-coupon-desc-03: url('https://static.caimei365.com/app/mini-hehe/icon/bg-coupon-desc-03.png');
  55. .coupon-description {
  56. background-size: 750rpx 497rpx;
  57. .title {
  58. font-size: 60rpx;
  59. font-weight: bold;
  60. padding-top: 68rpx;
  61. text-align: center;
  62. @include ellipsis(1);
  63. }
  64. .description {
  65. @extend .cm-flex-center;
  66. flex-direction: column;
  67. justify-content: flex-start;
  68. width: 702rpx;
  69. margin: 0 24rpx;
  70. background-position: center;
  71. background-repeat: no-repeat;
  72. background-size: 702rpx 610rpx;
  73. .tip {
  74. width: 360rpx;
  75. height: 64rpx;
  76. font-size: 34rpx;
  77. font-weight: bold;
  78. line-height: 60rpx;
  79. text-align: center;
  80. @include ellipsis(1);
  81. }
  82. .content {
  83. width: 622rpx;
  84. margin-top: 48rpx;
  85. box-sizing: border-box;
  86. padding: 24rpx;
  87. background: #fef8f3;
  88. border-radius: 24rpx;
  89. font-size: 28rpx;
  90. font-weight: 400;
  91. line-height: 64rpx;
  92. text-align: justify;
  93. text-indent: 2em;
  94. }
  95. }
  96. &.entry-1 {
  97. background: linear-gradient(180deg, #f9ddc2 0%, rgba(255, 255, 255, 0) 100%) no-repeat;
  98. .title {
  99. color: #ee6531;
  100. }
  101. .description {
  102. background-image: $bg-coupon-desc-01;
  103. height: 610rpx;
  104. .tip {
  105. margin-top: 126rpx;
  106. color: #765334;
  107. }
  108. .content {
  109. height: 333rpx;
  110. color: #ee6531;
  111. }
  112. }
  113. }
  114. &.entry-2 {
  115. background: linear-gradient(180deg, #d9f2fd 0%, rgba(255, 255, 255, 0) 100%) no-repeat;
  116. .title {
  117. color: #4197ef;
  118. }
  119. .description {
  120. background-image: $bg-coupon-desc-02;
  121. height: 628rpx;
  122. .tip {
  123. margin-top: 114rpx;
  124. color: #fff;
  125. }
  126. .content {
  127. height: 376rpx;
  128. color: #4197ef;
  129. }
  130. }
  131. }
  132. &.entry-3 {
  133. background: linear-gradient(180deg, #ffd1d1 0%, rgba(255, 255, 255, 0) 100%) no-repeat;
  134. .title {
  135. color: #ff445e;
  136. }
  137. .description {
  138. height: 611rpx;
  139. background-image: $bg-coupon-desc-03;
  140. .tip {
  141. margin-top: 126rpx;
  142. color: #765334;
  143. }
  144. .content {
  145. height: 333rpx;
  146. color: #fd314d;
  147. }
  148. }
  149. }
  150. }
  151. </style>