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

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