選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

equity.vue 17KB

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