Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

equity.vue 17KB

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