card.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <view class="page pt-20 pr-40 pl-40">
  3. <view class="tab-list flex-align-end">
  4. <view class="fs-28 color-666 mt-20 w50" :class="mode===0?'active':''" @click="changeTab(0)">权益卡</view>
  5. <view class="fs-28 color-666 mt-20 w50" :class="mode===1?'active':''" @click="changeTab(1)">优惠券</view>
  6. </view>
  7. <view v-if="mode===0">
  8. <view
  9. class="item mt-20 "
  10. v-for="(item, index) in list"
  11. :class="item.status==0?'inactive':''"
  12. :key="index"
  13. >
  14. <image class="full-percent" src="/pages-charge/static/discount-bg.png"></image>
  15. <view class="absolute-full flex pt-8 pb-8">
  16. <view class="left flex-justify-center pl-48">
  17. <view class="item-content_left">
  18. <view class="flex-align-end">
  19. <view class="item-header__left">
  20. <image class="width-84" src="/pages-charge/static/discount-rights-card.png" mode="widthFix"></image>
  21. <view class="fs-48 lh-58 color-000 fw-500 ml-16">
  22. {{ (item.discount / 10).toFixed(1) }}折
  23. </view>
  24. <view class="fs-26 color-999 ml-16" v-if="mode === 0"
  25. >抵扣充电服务费
  26. </view>
  27. </view>
  28. <!-- <view class="item-header__right flex-grow">
  29. <view class="item-status ml-10">{{ item.status == 0 ? '已失效' : '生效中' }}</view>
  30. </view>-->
  31. </view>
  32. <block>
  33. <view class="fs-26 color-999 mt-8"
  34. @click.stop="to(`/pages-common/activity/activity?id=${item.activityId}`)">
  35. <view class="fs-26 color-999">到期时间:{{ item.endTime }}</view>
  36. <view class="flex-align-center" v-if="mode === 0">
  37. <view class="fs-26 color-999">权益余额:{{ ((item.rightsBalance || 0) / 100).toFixed(2) }}元
  38. <text class="color-primary">详细规则</text>
  39. <text class="fs-24 ml-4 color-primary">>></text>
  40. </view>
  41. </view>
  42. </view>
  43. </block>
  44. </view>
  45. <view class="item-content_right">
  46. <view class="item-status ml-10">{{ item.status == 0 ? '已失效' : '生效中' }}</view>
  47. </view>
  48. </view>
  49. <!-- <view v-if="mode === 0" class="right width-80 flex-center">
  50. <style-checkbox
  51. :size="48"
  52. :checked="checkIndex === index"
  53. :iconsize="17"
  54. ></style-checkbox>
  55. </view>-->
  56. <!-- <view
  57. v-if="mode === 1"
  58. class="right flex-center"
  59. :style="{
  60. width: '210rpx',
  61. borderLeft: '1px dashed rgba(0, 0, 0, 0.10)',
  62. }"
  63. >
  64. <view class="btn flex-center fs-28" @click.stop="toCharge(index)"
  65. >前往充值</view
  66. >
  67. </view>-->
  68. </view>
  69. </view>
  70. <view style="width: 100%;text-align: center;">
  71. <image v-if="!list||list.length==0" style="width: 240rpx;" mode="widthFix" src="/static/images/search-empty.png"></image>
  72. </view>
  73. </view>
  74. <view v-else-if="mode===1">
  75. <view
  76. class="item mt-20"
  77. :class="item.usageStatus==1||item.status==0?'inactive':''"
  78. v-for="(item, index) in couponList"
  79. :key="index"
  80. >
  81. <!-- <image
  82. class="full-percent"
  83. src="/pages-charge/static/discount-bg.png"
  84. ></image>-->
  85. <view class="absolute-full flex pt-8 pb-8">
  86. <view class="left flex-justify-center pl-48">
  87. <view class="item-content_left">
  88. <view class="flex-align-end">
  89. <view class="item-header__left">
  90. <image
  91. class="width-84"
  92. src="/pages-charge/static/discount-coupon.png"
  93. mode="widthFix"
  94. ></image>
  95. <view></view>
  96. <view class="fs-48 lh-58 color-000 fw-500 ml-16" v-if="item.couponType=='FullDiscount'">
  97. {{ ((item.discount || 0) / 100).toFixed(2) }}元
  98. </view>
  99. <view class="fs-48 lh-58 color-000 fw-500 ml-16" v-else>
  100. {{ (item.discount / 10).toFixed(1) }}折
  101. </view>
  102. <view class="fs-26 color-999 ml-16">
  103. 充电服务费:{{ item.couponType == 'FullDiscount' ? '满减券' : '折扣券' }}
  104. </view>
  105. </view>
  106. <!--
  107. <view class="item-header__right flex-grow">
  108. <view class="item-status ml-10" v-if="item.status==0">已失效</view>
  109. <view class="item-status ml-10" v-else>{{ item.usageStatus == 0 ? '未使用' : '已使用' }}</view>
  110. </view>
  111. -->
  112. </view>
  113. <block v-if="mode === 1">
  114. <view class="fs-26 color-999 mt-8"
  115. @click.stop="to(`/pages-common/activity/activity?id=${item.activityId}`)">
  116. <view class="fs-26 color-999">到期时间:{{ item.endTime }}</view>
  117. <view class="flex-align-center">
  118. <view class="fs-26 color-999">服务费门槛:{{ ((item.minServiceMoney || 0) / 100).toFixed(2) }}元
  119. <text class="color-primary">详细规则</text>
  120. <text class="fs-24 ml-4 color-primary">>></text>
  121. </view>
  122. </view>
  123. </view>
  124. </block>
  125. </view>
  126. <view class="item-content_right">
  127. <view class="item-status ml-10" v-if="item.status==0">已失效</view>
  128. <view class="item-status ml-10" v-else>{{ item.usageStatus == 0 ? '未使用' : '已使用' }}</view>
  129. </view>
  130. </view>
  131. </view>
  132. </view>
  133. <view style="width: 100%;text-align: center;">
  134. <image v-if="!couponList||couponList.length==0" style="width: 240rpx;" mode="widthFix" src="/static/images/search-empty.png"></image>
  135. </view>
  136. </view>
  137. </view>
  138. </template>
  139. <script setup lang="ts">
  140. import {onPullDownRefresh, onShow} from "@dcloudio/uni-app";
  141. import {ref} from "vue";
  142. import {to} from "../../utils/navigate";
  143. import {fetchRightsAndCoupons} from "@/api/user";
  144. const mode = ref(0);
  145. const list = ref<any[]>([]);
  146. const couponList = ref<any[]>([]);
  147. const activity = ref();
  148. const checkIndex = ref(-1);
  149. const needRefresh = ref(false);
  150. onPullDownRefresh(() => {
  151. loadData();
  152. });
  153. const changeTab = (tab: number) => {
  154. mode.value = tab;
  155. }
  156. const loadData = () => {
  157. uni.showLoading({
  158. title: "加载中",
  159. });
  160. fetchRightsAndCoupons().then((res) => {
  161. uni.stopPullDownRefresh();
  162. console.log(res)
  163. uni.hideLoading();
  164. let {userCouponList, userRechargeRightsList} = res;
  165. list.value = userRechargeRightsList;
  166. couponList.value = userCouponList;
  167. });
  168. }
  169. onShow(() => {
  170. loadData();
  171. });
  172. </script>
  173. <style lang="scss" scoped>
  174. .page {
  175. min-height: 100vh;
  176. width: 100%;
  177. background-color: #f6f7fa;
  178. .item {
  179. position: relative;
  180. min-height: 220rpx;
  181. border-radius: 20rpx;
  182. overflow: hidden;
  183. background: #fff;
  184. .left {
  185. flex-grow: 1;
  186. }
  187. .right {
  188. flex-shrink: 0;
  189. .btn {
  190. border-radius: 8rpx;
  191. border: 1px solid var(--color-primary);
  192. color: var(--color-primary);
  193. width: 144rpx;
  194. height: 56rpx;
  195. }
  196. }
  197. }
  198. .tab-list {
  199. width: 100%;
  200. .w50 {
  201. width: 50%;
  202. text-align: center;
  203. }
  204. .active {
  205. color: var(--color-primary);
  206. }
  207. }
  208. }
  209. .item-status {
  210. font-size: 24rpx;
  211. padding: 0rpx 2rpx;
  212. color: var(--color-primary);
  213. border: 2rpx solid var(--color-primary);
  214. border-radius: 6rpx;
  215. }
  216. .item-header__left {
  217. display: inline-flex;
  218. align-items: flex-end;
  219. }
  220. .item-header__right {
  221. padding: 5rpx;
  222. display: flex;
  223. //justify-content: flex-end;
  224. }
  225. .inactive {
  226. cursor: not-allowed;
  227. pointer-events: none;
  228. .item-status {
  229. font-size: 24rpx;
  230. padding: 0rpx 2rpx;
  231. color: #ccc !important;
  232. border: 2rpx solid #ccc;
  233. border-radius: 6rpx;
  234. }
  235. .color-primary {
  236. color: #ccc !important;
  237. }
  238. }
  239. .item-content_left {
  240. flex-grow: 1;
  241. display: flex;
  242. flex-direction: column;
  243. justify-content: space-around;
  244. }
  245. .item-content_right {
  246. width: 120rpx;
  247. display: flex;
  248. align-items: center;
  249. align-content: center;
  250. }
  251. </style>