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 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  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"
  7. style="display: flex;flex-direction: column; justify-content: center;padding: 20px 40px;background-color: rgb(246, 246, 250);">
  8. <view style="margin-bottom: 20px;font-size: 38rpx; text-align: center;font-family: Microsoft Yahei;">
  9. 我的权益</view>
  10. <!-- <view v-if="exchangeCodes.length > 0" style="text-align: center;">暂无权益内容</view> @scrolltolower="loadMore" -->
  11. <scroll-view scroll-y="true">
  12. <view v-for="(item, index) in exchangeCodes" :key="index" class="item" @click.stop="click(item)">
  13. <view style="display: flex;flex-direction: column;flex: 1;margin: 10px;">
  14. <view style="display: flex;flex-direction: column;">
  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 v-for="(list, index) in item.equityInfoItems">
  25. <view v-if="list.equityType == 'COUPONS'">
  26. <div class="horizontal-line"></div>
  27. <view style="display: flex;flex-direction: column;">
  28. <text style="width: 100%;">权益名称:{{list.productName}}</text>
  29. <view
  30. style="display: flex;flex-direction: row;min-height: 60rpx;justify-content: space-between;text-align: baseline;">
  31. <text class="text-w" style="flex: 1;margin-top: 5rpx;"
  32. :style="functBackName(list) == 'WAIT_ACTIVATED' ? 'color: #023F8F;' : functBackName(list) == 'WAIT_USE' ? 'color: orange;' : functBackName(list) == 'USED' ? 'color: green;' : 'color: gray;'">卡卷状态:{{functBackName(list) == 'WAIT_ACTIVATED' ? '待激活' : functBackName(list) == 'WAIT_USE' ? '待领取' : functBackName(list) == 'USED' ? '已领取' : '已失效'}}</text>
  33. <button
  34. v-if="functBackName(list) != 'EXPIRED' && list && list.equityType !='ZFB'"
  35. :style="functBackName(list) == 'WAIT_ACTIVATED' ? 'background-color: #023F8F;' : functBackName(list) == 'WAIT_USE' ? 'background-color: orange;' : functBackName(list) == 'USED' ? 'background-color: green;' : 'background-color: gray;'"
  36. class="copy-btn" data-code="{{item}}"
  37. @click.stop="copyCode(list,functBackName(list),item)">
  38. {{functBackName(list) == 'WAIT_ACTIVATED' ? '去激活' : functBackName(list) == 'WAIT_USE' ? '立即领取' :
  39. functBackName(list) == 'USED' ? '复制' : '已失效'}}</button>
  40. </view>
  41. </view>
  42. </view>
  43. <view v-if="list.equityType == 'ZFB'">
  44. <div class="horizontal-line"></div>
  45. <view style="display: flex;flex-direction: column;">
  46. <text style="width: 100%;">权益名称:{{list.productName}}</text>
  47. <view
  48. style="display: flex;flex-direction: row;min-height: 60rpx;justify-content: space-between;text-align: baseline;">
  49. <text class="text-w" style="flex: 1;margin-top: 5rpx;color: #4caf50;">
  50. 卡卷状态:正常
  51. </text>
  52. <button style="background-color: #4caf50;" class="copy-btn"
  53. data-code="{{item}}" @click.stop="copyCode(list,'EXPIRED',null)">
  54. 去使用
  55. </button>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <view v-for="(item, index) in alonePurchaseData" :key="index" class="item"
  63. @click.stop="click(item)">
  64. <view style="display: flex;flex-direction: column;flex: 1;margin: 10px;">
  65. <view style="display: flex;flex-direction: column;">
  66. <!-- <text style="margin-top: 10rpx;">车牌号:{{item.vehiclePlate}}</text> -->
  67. <text v-if="item.drawTime" style="margin-top: 10rpx;">领取时间:{{item.drawTime}}</text>
  68. <text style="margin-top: 10rpx;">领取时间:{{item.getStatus}}</text>
  69. <text style="margin-top: 10rpx;">有效期:{{ item.periodOfValidity }}</text>
  70. <view
  71. style="display: flex;justify-content: flex-start;flex-direction: row;width: 100%;margin-top: 10rpx;">
  72. <text v-if="item.redeemCodeStr" class="code">券码:{{ item.redeemCodeStr}}</text>
  73. </view>
  74. </view>
  75. <view>
  76. <view v-if="item.equityType == 'COUPONS'">
  77. <div class="horizontal-line"></div>
  78. <view style="display: flex;flex-direction: column;">
  79. <text style="width: 100%;">权益名称:{{item.productName}}</text>
  80. <view
  81. style="display: flex;flex-direction: row;min-height: 60rpx;justify-content: space-between;text-align: baseline;">
  82. <text class="text-w" style="flex: 1;margin-top: 5rpx;"
  83. :style="functBackName(item) == 'WAIT_ACTIVATED' ? 'color: #023F8F;' : functBackName(item) == 'WAIT_USE' ? 'color: orange;' : functBackName(item) == 'USED' ? 'color: green;' : 'color: gray;'">卡卷状态:{{functBackName(item) == 'WAIT_ACTIVATED' ? '待激活' : functBackName(item) == 'WAIT_USE' ? '待领取' : functBackName(item) == 'USED' ? '已领取' : '已失效'}}</text>
  84. <button
  85. v-if="functBackName(item) != 'EXPIRED' && item && item.equityType !='ZFB'"
  86. :style="functBackName(item) == 'WAIT_ACTIVATED' ? 'background-color: #023F8F;' : functBackName(item) == 'WAIT_USE' ? 'background-color: orange;' : functBackName(item) == 'USED' ? 'background-color: green;' : 'background-color: gray;'"
  87. class="copy-btn" data-code="{{item}}"
  88. @click.stop="copyCode(item,functBackName(item),item['couponInfoItem'])">
  89. {{functBackName(item) == 'WAIT_ACTIVATED' ? '去激活' : functBackName(item) == 'WAIT_USE' ? '立即领取' :
  90. functBackName(item) == 'USED' ? '复制' : '已失效'}}</button>
  91. </view>
  92. </view>
  93. </view>
  94. <view v-if="item.equityType == 'ZFB'">
  95. <div class="horizontal-line"></div>
  96. <view style="display: flex;flex-direction: column;">
  97. <text style="width: 100%;">权益名称:{{item.productName}}</text>
  98. <view
  99. style="display: flex;flex-direction: row;min-height: 60rpx;justify-content: space-between;text-align: baseline;">
  100. <text class="text-w" style="flex: 1;margin-top: 5rpx;color: #4caf50;">
  101. 卡卷状态:正常
  102. </text>
  103. <button style="background-color: #4caf50;" class="copy-btn"
  104. data-code="{{item}}" @click.stop="copyCode(item,'EXPIRED',null)">
  105. 去使用
  106. </button>
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. </view>
  113. </scroll-view>
  114. </view>
  115. </view>
  116. <!-- <view style="width: 100%; text-align: center;margin-top: 20rpx; ">暂无更多数据内容!</view> -->
  117. </view>
  118. </template>
  119. <script setup lang='ts'>
  120. import {
  121. ref
  122. } from 'vue';
  123. import {
  124. request
  125. } from "@/utils/network/request.js";
  126. import {
  127. onLoad
  128. } from '@dcloudio/uni-app'
  129. import {
  130. getItem
  131. } from "@/utils/storage";
  132. let singleEquityId = ref('')
  133. let couponAgencyType = ref('')
  134. let couponId = ref('')
  135. let exchangeCodes: any = ref([])
  136. let alonePurchaseData: any = ref([])
  137. let page = ref('')
  138. onLoad((options) => {
  139. couponId.value = options.couponId
  140. singleEquityId.value = options.singleEquityId
  141. couponAgencyType.value = options.couponAgencyType
  142. loadExchangeCodes();
  143. })
  144. function loadExchangeCodes() {
  145. //卡券渠道类型获取单项权益列表
  146. request("bbce0fdfba9b41dabfcb2f19f9a35c97", {
  147. type: 2,
  148. data: {
  149. mobile: getItem('mobile') + "",
  150. loginSource: getItem("loginSource"),
  151. singleEquityId: singleEquityId.value,
  152. equityId: singleEquityId.value,
  153. couponAgencyType: couponAgencyType.value,
  154. couponId: couponId.value
  155. },
  156. method: "POST",
  157. showLoading: true,
  158. }).then((item) => {
  159. let res = JSON.parse(item.bizContent)
  160. console.log("res===", res)
  161. let newCodes = res.data.orderItems;
  162. let alonePurchase = res.data.alonePurchase;
  163. if (newCodes) {
  164. console.log(res, '111=========', newCodes);
  165. newCodes.forEach(item => {
  166. //1 不能领取 0 可以领取 1(不能领取原因 notUseCase)
  167. // item.equityInfoItems[0].equityType
  168. // WAIT_GET
  169. item.status =
  170. item.equityInfoItems[0].isUse == '0' && item.equityInfoItems[0].couponStatus ==
  171. 'WAIT_GET' ? 'WAIT_USE' :
  172. item.equityInfoItems[0].isUse == '1' && item.equityInfoItems[0].couponStatus ==
  173. 'WAIT_GET' ? 'WAIT_ACTIVATED' : item.equityInfoItems[0].couponStatus == 'USED' ?
  174. 'USED' : '';
  175. //WAIT_ACTIVATED(待激活) WAIT_USE(待领取使用) USED(已使用) EXPIRED(已过期) OUINGSYNREE
  176. console.log(item.equityInfoItems[0].periodOfValidity,
  177. item.equityInfoItems[0].isUse, item.equityInfoItems[0].notUseCase,
  178. item.status, item.equityInfoItems[0].couponStatus, '=================',
  179. item.vehiclePlate);
  180. // functBackName(list) = item.equityInfoItems[0].couponStatus == 'WAIT_GET' ? 'WAIT_ACTIVATED' : item.equityInfoItems[0].couponStatus
  181. item.getStatus = getStatusValue(item.status)
  182. item.redeemCodeStr = item.equityInfoItems[0].couponInfoItem && desensitize(item
  183. .equityInfoItems[0].couponInfoItem.redeemCode)
  184. item.periodOfValidity = item.equityInfoItems[0].periodOfValidity ? item
  185. .equityInfoItems[0].periodOfValidity.split('T')[0] : '激活领取后展示'
  186. item.redeemCode = item.equityInfoItems[0].couponInfoItem && item
  187. .equityInfoItems[0].couponInfoItem.redeemCode
  188. item.drawTime = item.equityInfoItems[0].drawTime && item.equityInfoItems[0]
  189. .drawTime.split('T')[0]
  190. // item.periodOfValidity = item.equityInfoItems[0].periodOfValidity.replace(/T/g, " ");
  191. // item.periodOfValidity = item.equityInfoItems[0].periodOfValidity.split('T')[0]
  192. });
  193. exchangeCodes.value = newCodes
  194. // 购买的权益产品展示
  195. console.log("exchangeCodes.value", exchangeCodes.value);
  196. }
  197. if (alonePurchase) {
  198. console.log("alonePurchase", alonePurchase)
  199. alonePurchase.forEach(item => {
  200. //1 不能领取 0 可以领取 1(不能领取原因 notUseCase)
  201. // item.equityInfoItems[0].equityType
  202. // WAIT_GET
  203. item.status =
  204. item.isUse == '0' && item.couponStatus ==
  205. 'WAIT_GET' ? 'WAIT_USE' :
  206. item.isUse == '1' && item.couponStatus ==
  207. 'WAIT_GET' ? 'WAIT_ACTIVATED' : item.couponStatus == 'USED' ?
  208. 'USED' : '';
  209. //WAIT_ACTIVATED(待激活) WAIT_USE(待领取使用) USED(已使用) EXPIRED(已过期) OUINGSYNREE
  210. console.log(item.periodOfValidity,
  211. item.isUse, item.notUseCase,
  212. item.status, item.couponStatus, '=================',
  213. item.vehiclePlate);
  214. item.getStatus = getStatusValue(item.status)
  215. item.redeemCodeStr = item.couponInfoItem && desensitize(item
  216. .couponInfoItem.redeemCode)
  217. item.periodOfValidity = item.periodOfValidity ? item
  218. .periodOfValidity.split('T')[0] : '激活领取后展示'
  219. item.redeemCode = item.couponInfoItem && item
  220. .couponInfoItem.redeemCode
  221. item.drawTime = item.drawTime && item
  222. .drawTime.split('T')[0]
  223. });
  224. alonePurchaseData.value = alonePurchase
  225. }
  226. })
  227. }
  228. function click(item) {
  229. // console.log("item.equityInfoItems[0].equityType", item.equityInfoItems[0].equityType)
  230. // if (item.equityInfoItems[0].equityType == 'ZFB') {
  231. // console.log("1")
  232. // uni.navigateTo({
  233. // url: `/subpackage/service/zfbqy/zfbqy`
  234. // })
  235. // } else {
  236. // console.log("2")
  237. // uni.navigateTo({
  238. // url: '/subpackage/service/equityInfo/equityInfo?singleEquityId=' + singleEquityId.value +
  239. // "&couponAgencyType=" + couponAgencyType.value + "&couponId=" + couponId.value,
  240. // })
  241. // }
  242. uni.navigateTo({
  243. url: '/subpackage/service/equityInfo/equityInfo?singleEquityId=' + singleEquityId.value +
  244. "&couponAgencyType=" + couponAgencyType.value + "&couponId=" + couponId.value,
  245. })
  246. }
  247. function functBackName(item) {
  248. return item.isUse == '0' && item.couponStatus == 'WAIT_GET' ? 'WAIT_USE' :
  249. item.isUse == '1' && item.couponStatus == 'WAIT_GET' ? 'WAIT_ACTIVATED' : item.couponStatus == 'USED' ?
  250. 'USED' : '';
  251. }
  252. function copyCode(e, start, items) {
  253. let item = e;
  254. // // 复制兑换码到剪贴板
  255. let code = e.redeemCode ? e.redeemCode : items.redeemCode;
  256. if (item.equityType == 'ZFB') {
  257. uni.navigateTo({
  258. url: `/subpackage/service/zfbqy/zfbqy`
  259. })
  260. return
  261. }
  262. console.log(item, "===e===", e.equityType, items, start);
  263. if (start == 'WAIT_ACTIVATED') { //待激活
  264. uni.showModal({
  265. title: '温馨提示',
  266. content: "激活后,可领取卡卷",
  267. confirmText: "去激活",
  268. success: function(res) {
  269. if (res.confirm) {
  270. uni.navigateTo({
  271. url: '/subpackage/personal-center/install-activation-order',
  272. })
  273. } else if (res.cancel) {
  274. console.log('用户点击取消');
  275. }
  276. }
  277. });
  278. } else if (start == 'WAIT_USE') { //待领取使用
  279. uni.showModal({
  280. title: '温馨提示',
  281. content: "请在领取后120天内使用,超期失效",
  282. success: function(res) {
  283. if (res.confirm) {
  284. request("a6bd3d8c855548eb8015655ea8d9287b", {
  285. type: 2,
  286. data: {
  287. mobile: getItem('mobile') + "",
  288. notificationType: 'USE',
  289. cardIds: [items.id],
  290. couponId: couponId.value,
  291. equityId: item.singleEquityId,
  292. orderId: items.orderId ? items.orderId : items.purchasedEquityId
  293. },
  294. method: "POST",
  295. showLoading: true,
  296. }).then((item) => {
  297. // uni.setClipboardData({
  298. // data: code,
  299. // success: function() {
  300. // uni.showToast({
  301. // title: '已复制兑换码',
  302. // icon: 'success',
  303. // });
  304. // },
  305. // });
  306. loadExchangeCodes();
  307. uni.showToast({
  308. title: '领取成功,卷码以复制到剪贴板。请前往途虎APP中使用',
  309. icon: 'success',
  310. });
  311. uni.navigateBack();
  312. })
  313. } else if (res.cancel) {
  314. console.log('用户点击取消');
  315. }
  316. }
  317. });
  318. // 已使用 USED
  319. // 已过期 EXPIRED
  320. } else if (start == 'USED') { //已使用
  321. console.log("已复制兑换码1111", code)
  322. uni.setClipboardData({
  323. data: code,
  324. success: function() {
  325. console.log("已复制兑换码")
  326. uni.showToast({
  327. title: '已复制兑换码',
  328. icon: 'success',
  329. });
  330. },
  331. });
  332. } else if (start == 'EXPIRED') { //已过期
  333. }
  334. }
  335. function desensitize(str) {
  336. if (typeof str !== 'string') return str;
  337. if (str.length <= 6) return str;
  338. return '*'.repeat(str.length - 4) + str.slice(-4);
  339. }
  340. function getStatusValue(key) {
  341. const statusMap = {
  342. WAIT_GET: "待领取",
  343. WAIT_ACTIVATED: "待激活",
  344. WAIT_USE: "待使用",
  345. USED: "已使用",
  346. EXPIRED: "已过期"
  347. };
  348. // 定义状态对象
  349. return statusMap[key] || "状态未知";
  350. }
  351. </script>
  352. <style lang='scss' scoped>
  353. .container {
  354. width: 100%;
  355. height: 96vh;
  356. }
  357. .item {
  358. display: flex;
  359. margin-top: 10px;
  360. width: 100%;
  361. align-items: center;
  362. justify-content: space-around;
  363. background-color: white;
  364. /* 淡灰色,透明度为 50% */
  365. border-bottom: 1rpx solid #e0e0e0;
  366. border-radius: 8px;
  367. font-size: 14px;
  368. }
  369. .code {
  370. flex: 1;
  371. height: 100%;
  372. color: #333;
  373. }
  374. .copy-btn {
  375. background-color: #4caf50;
  376. color: #fff;
  377. border: none;
  378. min-width: 120rpx;
  379. border-radius: 10rpx;
  380. font-size: 24rpx;
  381. height: 60rpx;
  382. box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.2);
  383. text-align: center;
  384. display: inline-block;
  385. line-height: 60rpx;
  386. }
  387. .copy-btn:hover {
  388. background-color: #388e3c;
  389. }
  390. .text-w {
  391. font-weight: bold;
  392. }
  393. .horizontal-line {
  394. width: 100%;
  395. /* 设置横线的宽度 */
  396. height: 1px;
  397. /* 设置横线的高度 */
  398. background-color: #9ACDFA;
  399. /* 设置横线的颜色 */
  400. margin: 10px 0;
  401. /* 可以根据需要调整横线与周围内容的间距 */
  402. }
  403. </style>