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.4KB

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