center.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <view class="page-wrap">
  3. <view class="coupon-panel">
  4. <view class="item" v-for="(item, index) in couponList" :key="index">
  5. <view class="name">
  6. <view class="price">{{ item.showMoney }}</view>
  7. <view class="text">{{ item.name }}</view>
  8. </view>
  9. <view class="desc time">有效日期:{{ item.endTime ? '至 ' + item.endTime : '无限制' }}</view>
  10. <view class="desc">{{ item.productIds || item.categoryIds ? '指定产品品类可用' : '所有产品品类可用' }}</view>
  11. <view class="desc">{{ item.line ? `满${item.line}元可用` : '无限制' }}</view>
  12. <view class="side" v-if="item.leftNumber">
  13. <text class="number">仅剩\n{{ item.leftNumber }}张</text>
  14. <button class="btn" @click="handleClaim(item.couponId)">可领{{ item.everyoneMax }}张</button>
  15. </view>
  16. <view class="side" v-else>
  17. <view class="over">已领完</view>
  18. <text>持续发放中\n下次再领</text>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import couponService from '@/api/coupon.js';
  26. export default {
  27. data() {
  28. return {
  29. couponList: []
  30. };
  31. },
  32. onLoad() {
  33. this.getCouponList();
  34. },
  35. onPullDownRefresh() {
  36. this.getCouponList();
  37. },
  38. methods: {
  39. // 获取优惠券列表
  40. async getCouponList() {
  41. const { tabActive } = this;
  42. const { rows } = await couponService.getCouponList();
  43. this.couponList = rows;
  44. uni.pageScrollTo({ scrollTop: 0 });
  45. uni.stopPullDownRefresh();
  46. },
  47. // 领取优惠券
  48. async handleClaim(id) {
  49. try {
  50. await couponService.claimCoupon(id);
  51. setTimeout(() => {
  52. uni.showToast({
  53. title: '领取成功',
  54. icon: 'none'
  55. });
  56. }, 100);
  57. this.getCouponList();
  58. } catch {
  59. this.getCouponList();
  60. }
  61. }
  62. }
  63. };
  64. </script>
  65. <style lang="scss" scoped>
  66. .coupon-panel {
  67. padding: 13.74rpx 0;
  68. .item {
  69. width: 708.79rpx;
  70. height: 192.31rpx;
  71. border-radius: 8.24rpx;
  72. position: relative;
  73. overflow: hidden;
  74. padding: 27.47rpx 233.52rpx 27.47rpx 41.21rpx;
  75. box-sizing: border-box;
  76. margin: 13.74rpx auto;
  77. &:before {
  78. content: '';
  79. position: absolute;
  80. left: 0;
  81. top: 0;
  82. width: 100%;
  83. height: 100%;
  84. background: #fff;
  85. -webkit-mask-image: radial-gradient(circle at 13.74rpx 50%, transparent 13.74rpx, red 13.74rpx);
  86. -webkit-mask-position: -13.74rpx;
  87. z-index: -1;
  88. }
  89. &::after {
  90. content: '';
  91. position: absolute;
  92. right: -27.47rpx;
  93. top: 0;
  94. height: 100%;
  95. width: 239.01rpx;
  96. background: #00bdef;
  97. -webkit-mask-image: radial-gradient(circle at 5rpx, transparent 6rpx, red 6rpx);
  98. -webkit-mask-position: -6rpx;
  99. -webkit-mask-size: 100% 19rpx;
  100. z-index: -1;
  101. }
  102. &.disabled::after {
  103. background: #ccc;
  104. }
  105. }
  106. .name {
  107. font-size: 30.22rpx;
  108. height: 68.68rpx;
  109. display: flex;
  110. align-items: center;
  111. margin-top: -14rpx;
  112. .text {
  113. flex: 1;
  114. width: 0;
  115. white-space: nowrap;
  116. overflow: hidden;
  117. text-overflow: ellipsis;
  118. }
  119. .price {
  120. line-height: 1;
  121. margin: -14rpx 10rpx 0 0;
  122. }
  123. }
  124. .desc {
  125. font-size: 24.73rpx;
  126. color: #999;
  127. white-space: nowrap;
  128. overflow: hidden;
  129. text-overflow: ellipsis;
  130. line-height: 1.3;
  131. }
  132. .side {
  133. position: absolute;
  134. right: 0;
  135. top: 0;
  136. height: 100%;
  137. width: 211.54rpx;
  138. display: flex;
  139. flex-direction: column;
  140. align-items: center;
  141. font-size: 21.98rpx;
  142. color: #fff;
  143. padding-top: 27.47rpx;
  144. text-align: center;
  145. }
  146. .price {
  147. font-size: 68.68rpx;
  148. &:before {
  149. content: '¥';
  150. font-size: 38.46rpx;
  151. }
  152. }
  153. .number {
  154. font-size: 27.47rpx;
  155. line-height: 38.46rpx;
  156. }
  157. .over {
  158. font-size: 30.22rpx;
  159. margin: 13.74rpx 0 20.6rpx;
  160. }
  161. .time {
  162. color: #000;
  163. }
  164. .btn {
  165. width: 164.84rpx;
  166. height: 49.45rpx;
  167. background: #fff;
  168. border-radius: 8.24rpx;
  169. color: #00bdef;
  170. font-size: 24.73rpx;
  171. line-height: 49.45rpx;
  172. padding: 0;
  173. margin-top: 13.74rpx;
  174. }
  175. }
  176. .foot-btn {
  177. position: fixed;
  178. left: 0;
  179. bottom: 0;
  180. width: 100%;
  181. height: 96.15rpx;
  182. background: #fff;
  183. font-size: 30.22rpx;
  184. color: #00bcd2;
  185. line-height: 96.15rpx;
  186. border: none;
  187. border-radius: 0;
  188. &:before {
  189. content: '';
  190. position: absolute;
  191. top: 0;
  192. left: 0;
  193. right: 0;
  194. height: 1rpx;
  195. background: #e0e0e0;
  196. }
  197. &::after {
  198. display: none;
  199. }
  200. }
  201. </style>