You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

equity.vue 9.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <view class="container" style="background-color:#F4F6FA;">
  3. <image style="width: 100%;" mode="widthFix"
  4. src="https://qtzl.etcjz.cn/default-bucket/20240322/7380a0422a1e49fdb2fefc9d_beijing.png"></image>
  5. <view style="position: absolute;width: 100%;top: 30%;">
  6. <view class="top" style="display: flex;flex-direction: column; justify-content: center;padding: 20px 40px;">
  7. <view style="margin-bottom: 20px;font-size: 38rpx; text-align: center;font-family: Microsoft Yahei;">
  8. 我的权益</view>
  9. <!-- <view v-if="exchangeCodes.length > 0" style="text-align: center;">暂无权益内容</view> @scrolltolower="loadMore" -->
  10. <scroll-view scroll-y="true">
  11. <view v-for="(item, index) in exchangeCodes" :key="index" class="item" @click="click">
  12. <view style="display: flex;flex-direction: row;flex: 1;">
  13. <view style="display: flex;flex-direction: column;margin: 10px;">
  14. <text>权益名称:{{item.equityInfoItems[0].productName}}</text>
  15. <text style="margin-top: 10rpx;">车牌号:{{item.vehiclePlate}}</text>
  16. <text v-if="item.drawTime" style="margin-top: 10rpx;">领取时间:{{item.drawTime}}</text>
  17. <text style="margin-top: 10rpx;">领取时间:{{item.getStatus}}</text>
  18. <text style="margin-top: 10rpx;">有效期:{{ item.periodOfValidity }}</text>
  19. <view
  20. style="display: flex;justify-content: flex-start;flex-direction: row;width: 100%;margin-top: 10rpx;">
  21. <text v-if="item.redeemCodeStr" class="code">券码:{{ item.redeemCodeStr}}</text>
  22. </view>
  23. </view>
  24. <view
  25. style="margin: 10px;border-radius: 0 8px 8px 0 ;justify-content: center;text-align: center; display: flex;flex-direction: column;background: white;flex: 1;">
  26. <text class="text-w"
  27. :style="item.status == 'WAIT_ACTIVATED' ? 'color: #023F8F;' : item.status == 'WAIT_USE' ? 'color: orange;' : item.status == 'USED' ? 'color: green;' : 'color: gray;'">{{item.status == 'WAIT_ACTIVATED' ? '待激活' : item.status == 'WAIT_USE' ? '待领取' :
  28. item.status == 'USED' ? '已领取' : '已失效'}}</text>
  29. <button v-if="item.status != 'EXPIRED'"
  30. :style="item.status == 'WAIT_ACTIVATED' ? 'background-color: #023F8F;' : item.status == 'WAIT_USE' ? 'background-color: orange;' : item.status == 'USED' ? 'background-color: green;' : 'background-color: gray;'"
  31. class="copy-btn" data-code="{{item}}" @click="copyCode">
  32. {{item.status == 'WAIT_ACTIVATED' ? '去激活' : item.status == 'WAIT_USE' ? '立即领取' :
  33. item.status == 'USED' ? '复制' : ''}}</button>
  34. </view>
  35. </view>
  36. </view>
  37. </scroll-view>
  38. </view>
  39. </view>
  40. <!-- <view style="width: 100%; text-align: center;margin-top: 20rpx; ">暂无更多数据内容!</view> -->
  41. </view>
  42. </template>
  43. <script setup lang='ts'>
  44. import {
  45. ref
  46. } from 'vue';
  47. import {
  48. request
  49. } from "@/utils/network/request.js";
  50. import {
  51. onLoad
  52. } from '@dcloudio/uni-app'
  53. import {
  54. getItem
  55. } from "@/utils/storage";
  56. let singleEquityId = ref('')
  57. let couponAgencyType = ref('')
  58. let couponId = ref('')
  59. let exchangeCodes: any = ref([])
  60. let page = ref('')
  61. onLoad((options) => {
  62. couponId.value = options.couponId
  63. singleEquityId.value = options.singleEquityId
  64. couponAgencyType.value = options.couponAgencyType
  65. loadExchangeCodes();
  66. })
  67. function loadExchangeCodes() {
  68. //卡券渠道类型获取单项权益列表
  69. request("bbce0fdfba9b41dabfcb2f19f9a35c97", {
  70. type: 2,
  71. data: {
  72. mobile: getItem('mobile') + "",
  73. loginSource: getItem("loginSource"),
  74. singleEquityId: singleEquityId.value,
  75. equityId: singleEquityId.value,
  76. couponAgencyType: couponAgencyType.value,
  77. couponId: couponId.value
  78. },
  79. method: "POST",
  80. showLoading: true,
  81. }).then((item) => {
  82. let res = JSON.parse(item.bizContent)
  83. let newCodes = res.data.orderItems;
  84. console.log(res, '=========', newCodes);
  85. if (newCodes) {
  86. newCodes.forEach(item => {
  87. //1 不能领取 0 可以领取 1(不能领取原因 notUseCase)
  88. // WAIT_GET
  89. item.status =
  90. item.equityInfoItems[0].isUse == '0' && item.equityInfoItems[0].couponStatus ==
  91. 'WAIT_GET' ? 'WAIT_USE' :
  92. item.equityInfoItems[0].isUse == '1' && item.equityInfoItems[0].couponStatus ==
  93. 'WAIT_GET' ? 'WAIT_ACTIVATED' :
  94. item.equityInfoItems[0].couponStatus == 'USED' ? 'USED' : '';
  95. //WAIT_ACTIVATED(待激活) WAIT_USE(待领取使用) USED(已使用) EXPIRED(已过期) OUINGSYNREE
  96. console.log(item.equityInfoItems[0].periodOfValidity,
  97. item.equityInfoItems[0].isUse, item.equityInfoItems[0].notUseCase,
  98. item.status, item.equityInfoItems[0].couponStatus, '=================',
  99. item.vehiclePlate);
  100. // item.status = item.equityInfoItems[0].couponStatus == 'WAIT_GET' ? 'WAIT_ACTIVATED' : item.equityInfoItems[0].couponStatus
  101. item.getStatus = getStatusValue(item.status)
  102. item.redeemCodeStr = item.equityInfoItems[0].couponInfoItem && desensitize(item
  103. .equityInfoItems[0].couponInfoItem.redeemCode)
  104. item.periodOfValidity = item.equityInfoItems[0].periodOfValidity ? item
  105. .equityInfoItems[0].periodOfValidity.split('T')[0] : '激活领取后展示'
  106. item.redeemCode = item.equityInfoItems[0].couponInfoItem && item
  107. .equityInfoItems[0].couponInfoItem.redeemCode
  108. item.drawTime = item.equityInfoItems[0].drawTime && item.equityInfoItems[0]
  109. .drawTime.split('T')[0]
  110. // item.periodOfValidity = item.equityInfoItems[0].periodOfValidity.replace(/T/g, " ");
  111. // item.periodOfValidity = item.equityInfoItems[0].periodOfValidity.split('T')[0]
  112. });
  113. exchangeCodes.value = newCodes
  114. console.log("exchangeCodes.value", exchangeCodes.value);
  115. }
  116. })
  117. }
  118. function click() {
  119. uni.navigateTo({
  120. url: '/subpackage/service/equityInfo/equityInfo?singleEquityId=' + singleEquityId.value +
  121. "&couponAgencyType=" + couponAgencyType.value + "&couponId=" + couponId.value,
  122. })
  123. }
  124. function copyCode(e) {
  125. console.log(e.currentTarget);
  126. let item = e.currentTarget.dataset.code;
  127. // 复制兑换码到剪贴板
  128. let code = e.currentTarget.dataset.code.redeemCode;
  129. if (item.status == 'WAIT_ACTIVATED') { //待激活
  130. uni.showModal({
  131. title: '温馨提示',
  132. content: "激活后,可领取卡卷",
  133. confirmText: "去激活",
  134. success: function(res) {
  135. if (res.confirm) {
  136. uni.navigateTo({
  137. url: '/pages/etc/explain/index',
  138. })
  139. } else if (res.cancel) {
  140. console.log('用户点击取消');
  141. }
  142. }
  143. });
  144. } else if (item.status == 'WAIT_USE') { //待领取使用
  145. uni.showModal({
  146. title: '温馨提示',
  147. content: "请在领取后120天内使用,超期失效",
  148. success: function(res) {
  149. if (res.confirm) {
  150. request("a6bd3d8c855548eb8015655ea8d9287b", {
  151. type: 2,
  152. data: {
  153. mobile: getItem('mobile') + "",
  154. notificationType: 'USE',
  155. cardIds: [item.id],
  156. couponId: couponId.value,
  157. equityId: item.equityId,
  158. orderId: item.orderId
  159. },
  160. method: "POST",
  161. showLoading: true,
  162. }).then((item) => {
  163. // uni.setClipboardData({
  164. // data: code,
  165. // success: function() {
  166. // uni.showToast({
  167. // title: '已复制兑换码',
  168. // icon: 'success',
  169. // });
  170. // },
  171. // });
  172. loadExchangeCodes();
  173. uni.showToast({
  174. title: '领取成功',
  175. icon: 'success',
  176. });
  177. })
  178. } else if (res.cancel) {
  179. console.log('用户点击取消');
  180. }
  181. }
  182. });
  183. // 已使用 USED
  184. // 已过期 EXPIRED
  185. } else if (item.status == 'USED') { //已使用
  186. uni.setClipboardData({
  187. data: code,
  188. success: function() {
  189. uni.showToast({
  190. title: '已复制兑换码',
  191. icon: 'success',
  192. });
  193. },
  194. });
  195. } else if (item.status == 'EXPIRED') { //已过期
  196. }
  197. }
  198. function desensitize(str) {
  199. if (typeof str !== 'string') return str;
  200. if (str.length <= 6) return str;
  201. return '*'.repeat(str.length - 4) + str.slice(-4);
  202. }
  203. function getStatusValue(key) {
  204. const statusMap = {
  205. WAIT_GET: "待领取",
  206. WAIT_ACTIVATED: "待激活",
  207. WAIT_USE: "待使用",
  208. USED: "已使用",
  209. EXPIRED: "已过期"
  210. };
  211. // 定义状态对象
  212. return statusMap[key] || "状态未知";
  213. }
  214. </script>
  215. <style lang='scss' scoped>
  216. /* index.wxss */
  217. .container {
  218. width: 100%;
  219. height: 96vh;
  220. }
  221. .item {
  222. display: flex;
  223. margin-top: 10px;
  224. width: 100%;
  225. align-items: center;
  226. justify-content: space-around;
  227. /* background-color: rgba(204, 204, 204, 0.2); 淡灰色,透明度为 50% */
  228. background-color: white;
  229. /* 淡灰色,透明度为 50% */
  230. border-bottom: 1rpx solid #e0e0e0;
  231. border-radius: 8px;
  232. font-size: 14px;
  233. }
  234. .code {
  235. flex: 1;
  236. height: 100%;
  237. color: #333;
  238. }
  239. .copy-btn {
  240. background-color: #4caf50;
  241. color: #fff;
  242. border: none;
  243. min-width: 120rpx;
  244. margin-top: 20px;
  245. border-radius: 10rpx;
  246. font-size: 24rpx;
  247. /* 调整字体大小 */
  248. box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.2);
  249. }
  250. .copy-btn:hover {
  251. background-color: #388e3c;
  252. }
  253. .text-w {
  254. font-weight: bold;
  255. }
  256. </style>