coupon-center.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <style-dialog
  3. v-if="visible"
  4. @close="handleClose"
  5. title="">
  6. <view class="page pt-20 pr-40 pl-40">
  7. <view class="tab-list flex-align-end">
  8. <view class="fs-28 color-666 mt-20 w50" :class="mode===0?'active':''" @click="changeTab(0)">权益卡</view>
  9. <view class="fs-28 color-666 mt-20 w50" :class="mode===1?'active':''" @click="changeTab(1)">优惠券</view>
  10. </view>
  11. <view>
  12. <view
  13. class="item mt-20 "
  14. v-for="(item, index) in list"
  15. :class="item.status==0?'inactive':''"
  16. :key="index"
  17. >
  18. <image class="full-percent" src="/pages-charge/static/discount-bg.png"></image>
  19. <view class="absolute-full flex pt-8 pb-8">
  20. <view class="left flex-justify-center pl-48">
  21. <view class="item-content_left">
  22. <view class="flex-align-end">
  23. <view class="item-header__left">
  24. <image class="width-84" src="/pages-charge/static/discount-rights-card.png" mode="widthFix"></image>
  25. <view class="fs-48 lh-58 color-000 fw-500 ml-16">{{ item.discountAmount }}折
  26. </view>
  27. <view class="fs-26 color-999 ml-16" v-if="mode === 0"
  28. >用于充电服务费抵扣
  29. </view>
  30. </view>
  31. <!-- <view class="item-header__right flex-grow">
  32. <view class="item-status ml-10">{{ item.status == 0 ? '已失效' : '生效中' }}</view>
  33. </view>-->
  34. </view>
  35. <block>
  36. <view class="fs-26 color-999 mt-8"
  37. >
  38. <view class="fs-26 color-999 mt-24">到期时间:{{ item.endTime }}</view>
  39. <!-- <view class="flex-align-center" v-if="mode === 0">
  40. <view class="fs-26 color-999 mt-24">权益余额:{{ ((item.rightsBalance || 0) / 100).toFixed(2) }}元
  41. <text class="color-primary">详细规则</text>
  42. <text class="fs-24 ml-4 color-primary">>></text>
  43. </view>
  44. </view>-->
  45. </view>
  46. </block>
  47. </view>
  48. <view class="item-content_right">
  49. <view class="item-status ml-10" @click.stop="handleCollectCoupon(item)">领券</view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. >
  57. </style-dialog>
  58. </template>
  59. <script setup lang="ts">
  60. import {onPullDownRefresh} from "@dcloudio/uni-app";
  61. import {ref} from "vue";
  62. import {collectCoupon, listAvailableCoupons} from "@/api/user";
  63. const mode = ref(0);
  64. const list = ref<any[]>([]);
  65. const couponList = ref<any[]>([]);
  66. const stationId = ref(-1);
  67. const visible = ref(false);
  68. const handleClose = () => {
  69. }
  70. onPullDownRefresh(() => {
  71. loadData();
  72. });
  73. const changeTab = (tab: number) => {
  74. mode.value = tab;
  75. }
  76. const handleCollectCoupon = (coupon: any) => {
  77. collectCoupon(coupon.id).then((res) => {
  78. console.log(res)
  79. uni.showToast({
  80. title: "领券成功",
  81. icon: "success"
  82. });
  83. });
  84. }
  85. const loadData = () => {
  86. uni.showLoading({
  87. title: "加载中",
  88. });
  89. listAvailableCoupons(stationId.value).then((res) => {
  90. console.log(res)
  91. uni.hideLoading();
  92. couponList.value = res.list;
  93. });
  94. }
  95. const open = (stationId: any) => {
  96. visible.value = true;
  97. stationId.value = stationId;
  98. loadData()
  99. }
  100. defineExpose({
  101. open
  102. })
  103. </script>
  104. <style lang="scss" scoped>
  105. .page {
  106. min-height: 100vh;
  107. width: 100%;
  108. background-color: #f6f7fa;
  109. .item {
  110. position: relative;
  111. min-height: 220rpx;
  112. border-radius: 20rpx;
  113. overflow: hidden;
  114. background: #fff;
  115. .left {
  116. flex-grow: 1;
  117. }
  118. .right {
  119. flex-shrink: 0;
  120. .btn {
  121. border-radius: 8rpx;
  122. border: 1px solid var(--color-primary);
  123. color: var(--color-primary);
  124. width: 144rpx;
  125. height: 56rpx;
  126. }
  127. }
  128. }
  129. .tab-list {
  130. width: 100%;
  131. .w50 {
  132. width: 50%;
  133. text-align: center;
  134. }
  135. .active {
  136. color: var(--color-primary);
  137. }
  138. }
  139. }
  140. .item-status {
  141. font-size: 24rpx;
  142. padding: 0rpx 2rpx;
  143. color: var(--color-primary);
  144. border: 2rpx solid var(--color-primary);
  145. border-radius: 6rpx;
  146. }
  147. .item-header__left {
  148. display: inline-flex;
  149. align-items: flex-end;
  150. }
  151. .item-header__right {
  152. padding: 5rpx;
  153. display: flex;
  154. //justify-content: flex-end;
  155. }
  156. .inactive {
  157. cursor: not-allowed;
  158. pointer-events: none;
  159. .item-status {
  160. font-size: 24rpx;
  161. padding: 0rpx 2rpx;
  162. color: #ccc !important;
  163. border: 2rpx solid #ccc;
  164. border-radius: 6rpx;
  165. }
  166. .color-primary {
  167. color: #ccc !important;
  168. }
  169. }
  170. .item-content_left {
  171. flex-grow: 1;
  172. display: flex;
  173. flex-direction: column;
  174. justify-content: space-around;
  175. }
  176. .item-content_right {
  177. width: 120rpx;
  178. display: flex;
  179. align-items: center;
  180. align-content: center;
  181. }
  182. </style>