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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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 wx: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: '69af303ba2eb4608a099163f0d2a5dbd',
  74. singleEquityId:singleEquityId.value,
  75. couponAgencyType: couponAgencyType.value,
  76. couponId: couponId.value
  77. },
  78. method: "POST",
  79. showLoading: true,
  80. }).then((item) => {
  81. let res = JSON.parse(item.bizContent)
  82. console.log(res, '=========');
  83. let newCodes = res.data;
  84. if (newCodes) {
  85. newCodes.forEach(item => {
  86. //1 不能领取 0 可以领取 1(不能领取原因 notUseCase)
  87. // WAIT_GET
  88. item.status = item.equityInfoItems[0].isUse == '0' && item.equityInfoItems[0]
  89. .couponStatus == 'WAIT_GET' ? 'WAIT_USE' :
  90. item.equityInfoItems[0].isUse == '1' && item.equityInfoItems[0]
  91. .couponStatus == 'WAIT_GET' ? 'WAIT_ACTIVATED' : item.equityInfoItems[0]
  92. .couponStatus == 'USED' ? 'USED' : '';
  93. //WAIT_ACTIVATED(待激活) WAIT_USE(待领取使用) USED(已使用) EXPIRED(已过期) OUINGSYNREE
  94. console.log(item.equityInfoItems[0].periodOfValidity,
  95. item.equityInfoItems[0].isUse, item.equityInfoItems[0].notUseCase,
  96. item.status, item.equityInfoItems[0].couponStatus, '=================',
  97. item.vehiclePlate);
  98. // item.status = item.equityInfoItems[0].couponStatus == 'WAIT_GET' ? 'WAIT_ACTIVATED' : item.equityInfoItems[0].couponStatus
  99. item.getStatus = that.getStatusValue(item.status)
  100. item.redeemCodeStr = item.equityInfoItems[0].couponInfoItem && that
  101. .desensitize(item.equityInfoItems[0].couponInfoItem.redeemCode)
  102. item.periodOfValidity = item.equityInfoItems[0].periodOfValidity ? item
  103. .equityInfoItems[0].periodOfValidity.split('T')[0] : '激活领取后展示'
  104. item.redeemCode = item.equityInfoItems[0].couponInfoItem && item
  105. .equityInfoItems[0].couponInfoItem.redeemCode
  106. item.drawTime = item.equityInfoItems[0].drawTime && item.equityInfoItems[0]
  107. .drawTime.split('T')[0]
  108. // item.periodOfValidity = item.equityInfoItems[0].periodOfValidity.replace(/T/g, " ");
  109. // item.periodOfValidity = item.equityInfoItems[0].periodOfValidity.split('T')[0]
  110. });
  111. exchangeCodes.value = newCodes
  112. }
  113. })
  114. }
  115. function click() {
  116. let that = this
  117. wx.navigateTo({
  118. url: '/subpackage/service/equityInfo/equityInfo?singleEquityId=' + that.data.singleEquityId +
  119. "&couponAgencyType=" + that.data.couponAgencyType + "&couponId=" + that.data.couponId,
  120. })
  121. }
  122. function copyCode(e) {
  123. console.log(e.currentTarget);
  124. let item = e.currentTarget.dataset.code;
  125. // 复制兑换码到剪贴板
  126. let code = e.currentTarget.dataset.code.redeemCode;
  127. if (item.status == 'WAIT_ACTIVATED') { //待激活
  128. wx.showModal({
  129. title: '温馨提示',
  130. content: "激活后,可领取卡卷",
  131. confirmText: "去激活",
  132. success: function(res) {
  133. if (res.confirm) {
  134. wx.navigateTo({
  135. url: '/pages/etc/explain/index',
  136. })
  137. } else if (res.cancel) {
  138. console.log('用户点击取消');
  139. }
  140. }
  141. });
  142. } else if (item.status == 'WAIT_USE') { //待领取使用
  143. wx.showModal({
  144. title: '温馨提示',
  145. content: "请在领取后120天内使用,超期失效",
  146. success: function(res) {
  147. if (res.confirm) {
  148. request("a6bd3d8c855548eb8015655ea8d9287b", {
  149. type: 2,
  150. data: {
  151. mobile: getItem('mobile') + "",
  152. notificationType: 'USE',
  153. cardIds: [item.id],
  154. couponId: couponId.value,
  155. equityId: item.equityId,
  156. orderId: item.orderId
  157. },
  158. method: "POST",
  159. showLoading: true,
  160. }).then((item) => {
  161. // uni.setClipboardData({
  162. // data: code,
  163. // success: function() {
  164. // uni.showToast({
  165. // title: '已复制兑换码',
  166. // icon: 'success',
  167. // });
  168. // },
  169. // });
  170. loadExchangeCodes();
  171. uni.showToast({
  172. title: '领取成功',
  173. icon: 'success',
  174. });
  175. })
  176. } else if (res.cancel) {
  177. console.log('用户点击取消');
  178. }
  179. }
  180. });
  181. // 已使用 USED
  182. // 已过期 EXPIRED
  183. } else if (item.status == 'USED') { //已使用
  184. uni.setClipboardData({
  185. data: code,
  186. success: function() {
  187. uni.showToast({
  188. title: '已复制兑换码',
  189. icon: 'success',
  190. });
  191. },
  192. });
  193. } else if (item.status == 'EXPIRED') { //已过期
  194. }
  195. }
  196. function desensitize(str) {
  197. if (typeof str !== 'string') return str;
  198. if (str.length <= 6) return str;
  199. return '*'.repeat(str.length - 4) + str.slice(-4);
  200. }
  201. function getStatusValue(key) {
  202. const statusMap = {
  203. WAIT_GET: "待领取",
  204. WAIT_ACTIVATED: "待激活",
  205. WAIT_USE: "待使用",
  206. USED: "已使用",
  207. EXPIRED: "已过期"
  208. };
  209. // 定义状态对象
  210. return statusMap[key] || "状态未知";
  211. }
  212. </script>
  213. <style lang='scss' scoped>
  214. /* index.wxss */
  215. .container {
  216. width: 100%;
  217. height: 96vh;
  218. }
  219. .item {
  220. display: flex;
  221. margin-top: 10px;
  222. width: 100%;
  223. align-items: center;
  224. justify-content: space-around;
  225. /* background-color: rgba(204, 204, 204, 0.2); 淡灰色,透明度为 50% */
  226. background-color: white;
  227. /* 淡灰色,透明度为 50% */
  228. border-bottom: 1rpx solid #e0e0e0;
  229. border-radius: 8px;
  230. font-size: 14px;
  231. }
  232. .code {
  233. flex: 1;
  234. height: 100%;
  235. color: #333;
  236. }
  237. .copy-btn {
  238. background-color: #4caf50;
  239. color: #fff;
  240. border: none;
  241. min-width: 120rpx;
  242. margin-top: 20px;
  243. border-radius: 10rpx;
  244. font-size: 24rpx;
  245. /* 调整字体大小 */
  246. box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.2);
  247. }
  248. .copy-btn:hover {
  249. background-color: #388e3c;
  250. }
  251. .text-w {
  252. font-weight: bold;
  253. }
  254. </style>