BrandCouponList.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <view class="brand-coupon-container">
  3. <scroll-view
  4. refresher-enabled refresher-background="#3f3d3d" scroll-y style="height: 100%;"
  5. scroll-with-animation
  6. >
  7. <view class="main">
  8. <view v-if="couponList && couponList.length">
  9. <view v-for="item in couponList" :key="item.id" class="item">
  10. <view class="left" :style="{ background: '#FFA74D' }">
  11. <view class="money">¥<text>{{ item.discount }}</text></view>
  12. <view class="full">满{{ item.min }}可用</view>
  13. </view>
  14. <view class="right">
  15. <view class="type" :style="{ background: '#FFA74D' }">{{ item.name }}</view>
  16. <view class="rule">{{ item.desc }}</view>
  17. <view v-if="item.days" class="rule">有效天数:{{ item.days }}</view>
  18. <view class="list">
  19. <view class="time" style="flex: 1;width: 0;">
  20. <view v-if="item.startTime && item.endTime">
  21. <view style="width: fit-content;">可使用时间范围:</view>
  22. <view style="display: flex;flex-wrap: wrap;">
  23. <view>{{ new Date(item.startTime).toLocaleString() || '--' }}至</view>
  24. <view>{{ new Date(item.endTime).toLocaleString() || '--' }}</view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="order" @click="$emit('click-btn', item)">{{ btnText }}</view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <view v-else>
  34. <tui-no-data>暂无优惠券</tui-no-data>
  35. </view>
  36. </view>
  37. <LoadMore v-show="couponList.length" :status="status"></LoadMore>
  38. </scroll-view>
  39. </view>
  40. </template>
  41. <script>
  42. import { getBrandCouponListApi } from '../../api/user'
  43. export default {
  44. name: 'BrandCouponList',
  45. components: {},
  46. props: {
  47. brandId: {
  48. type: [String, Number],
  49. default: ''
  50. },
  51. btnText: {
  52. type: String,
  53. default: '选择'
  54. }
  55. // couponList: {
  56. // type: Array,
  57. // default() {
  58. // return []
  59. // }
  60. // }
  61. },
  62. data() {
  63. return {
  64. couponList: [],
  65. status: 'none'
  66. }
  67. },
  68. watch: {
  69. brandId: {
  70. handler(newVal) {
  71. if (newVal) {
  72. this.getBrandCouponList()
  73. }
  74. },
  75. immediate: true,
  76. deep: true
  77. }
  78. },
  79. methods: {
  80. getBrandCouponList() {
  81. if (!this.brandId) return
  82. uni.showLoading({
  83. title: '加载中'
  84. })
  85. this.status = 'loading'
  86. getBrandCouponListApi({ brandId: this.brandId })
  87. .then(({ data }) => {
  88. this.couponList = data
  89. uni.hideLoading()
  90. this.status = 'none'
  91. })
  92. .catch(() => {
  93. uni.hideLoading()
  94. this.status = 'none'
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="less" scoped>
  101. .brand-coupon-container {
  102. height: 100%;
  103. padding: 32upx 10upx;
  104. box-sizing: border-box;
  105. .main {
  106. padding: 0upx 4upx 40upx 4upx;
  107. .item {
  108. margin-bottom: 22upx;
  109. box-sizing: border-box;
  110. width: 100%;
  111. // height: 226upx;
  112. border-radius: 10upx;
  113. box-shadow: 0upx 4upx 10upx 0upx rgba(0, 0, 0, 0.1);
  114. background: #FFFFFF;
  115. display: flex;
  116. .left {
  117. width: 29%;
  118. // padding: 28upx 18upx;
  119. display: flex;
  120. flex-direction: column;
  121. justify-content: center;
  122. align-items: center;
  123. border-radius: 10upx 0upx 0upx 10upx;
  124. color: #FFFFFF;
  125. .money {
  126. font-size: 36upx;
  127. font-weight: 500;
  128. text {
  129. font-size: 56upx;
  130. font-weight: 500;
  131. }
  132. }
  133. .full {
  134. font-size: 28upx;
  135. }
  136. }
  137. .right {
  138. width: 71%;
  139. padding: 24upx 20upx 26upx 18upx;
  140. box-sizing: border-box;
  141. .type {
  142. // width: 110upx;
  143. width: fit-content;
  144. height: 40upx;
  145. padding: 0 20upx;
  146. border-radius: 100upx;
  147. background: #89AEFC;
  148. color: #FFFFFF;
  149. font-size: 24upx;
  150. font-weight: 500;
  151. display: flex;
  152. justify-content: center;
  153. align-items: center;
  154. }
  155. .rule {
  156. padding-top: 4upx;
  157. padding-bottom: 2upx;
  158. font-size: 28upx;
  159. color: #3D3D3D;
  160. }
  161. .list {
  162. padding-top: 20upx;
  163. display: flex;
  164. justify-content: space-between;
  165. align-items: center;
  166. .time {
  167. font-size: 20upx;
  168. color: #777777;
  169. }
  170. .order {
  171. width: 148upx;
  172. height: 40upx;
  173. border-radius: 100upx;
  174. background: #FF4654;
  175. font-size: 24upx;
  176. font-weight: 500;
  177. color: #FFFFFF;
  178. display: flex;
  179. justify-content: center;
  180. align-items: center;
  181. }
  182. }
  183. }
  184. }
  185. }
  186. }
  187. </style>