card.vue 9.0 KB

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