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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <view class="container" style="background-color:#E9EDF0;overflow: hidden;min-height: 100vh;">
  3. <view class="item" v-for="(item, index) in exchangeCodes" :key="index" @click.stop="click(item)">
  4. <view class="top">
  5. <view>
  6. <view style="display: flex;align-items: center;line-height: 58rpx;" v-if="item.vehiclePlate">
  7. <image class="car" :src="`${$imgUrl}equity-car.png`" mode=""></image>
  8. <text class="car-num">{{item.vehiclePlate}}</text>
  9. </view>
  10. <view class="youxiao">有效期:{{ item.periodOfValidity }}</view>
  11. </view>
  12. <view class="activate" :style="{'--bgimg':`url(${$imgUrl}equity-bg3.png)`}">{{item.getStatus}}</view>
  13. </view>
  14. <view v-for="(list, index) in item.equityInfoItems">
  15. <view class="go" v-if="list.equityType == 'COUPONS'">
  16. <view>
  17. <view class="title">权益名称:{{list.productName}}</view>
  18. <view class="title"><text style="color: #01243A;">卡卷状态:{{functBackName(list) == 'WAIT_ACTIVATED' ? '待激活' : functBackName(list) == 'WAIT_USE' ? '待领取' : functBackName(list) == 'USED' ? '已领取' : '已失效'}}</text></view>
  19. </view>
  20. <view class="btn" data-code="{{item}}"
  21. @click.stop="copyCode(list,functBackName(list),item)" v-if="functBackName(list) != 'EXPIRED' && list && list.equityType !='ZFB'">{{functBackName(list) == 'WAIT_ACTIVATED' ? '去激活' : functBackName(list) == 'WAIT_USE' ? '立即领取' :
  22. functBackName(list) == 'USED' ? '复制' : '已失效'}}</view>
  23. </view>
  24. <view class="go" v-if="list.equityType == 'ZFB'">
  25. <view>
  26. <view class="title">权益名称:{{list.productName}}</view>
  27. <view class="title">卡卷状态:正常</view>
  28. </view>
  29. <view class="btn" data-code="{{item}}" @click.stop="copyCode(list,'EXPIRED',null)">去使用</view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="item" v-for="(item, index) in alonePurchaseData" :key="index" @click.stop="click(item)">
  34. <view class="top">
  35. <view>
  36. <view style="display: flex;align-items: center;line-height: 58rpx;" v-if="item.vehiclePlate">
  37. <image class="car" :src="`${$imgUrl}equity-car.png`" mode=""></image>
  38. <text class="car-num">{{item.vehiclePlate}}</text>
  39. </view>
  40. <view class="youxiao">有效期:{{ item.periodOfValidity }}</view>
  41. </view>
  42. <view class="activate" :style="{'--bgimg':`url(${$imgUrl}equity-bg3.png)`}">{{item.getStatus}}</view>
  43. </view>
  44. <view class="go" v-if="item.equityType == 'COUPONS'">
  45. <view>
  46. <view class="title">权益名称:{{item.productName}}</view>
  47. <view class="title">卡券状态:<text style="color: #01243A;">{{functBackName(item) == 'WAIT_ACTIVATED' ? '待激活' : functBackName(item) == 'WAIT_USE' ? '待领取' : functBackName(item) == 'USED' ? '已领取' : '已失效'}}</text></view>
  48. </view>
  49. <view class="btn" data-code="{{item}}"
  50. @click.stop="copyCode(item,functBackName(item),item['couponInfoItem'])" v-if="functBackName(item) != 'EXPIRED' && item && item.equityType !='ZFB'">{{functBackName(item) == 'WAIT_ACTIVATED' ? '去激活' : functBackName(item) == 'WAIT_USE' ? '立即领取' :
  51. functBackName(item) == 'USED' ? '复制' : '已失效'}}</view>
  52. </view>
  53. <view class="go" v-if="item.equityType == 'ZFB'">
  54. <view>
  55. <view class="title">权益名称:{{item.productName}}</view>
  56. <view class="title">卡卷状态:正常</view>
  57. </view>
  58. <view class="btn" data-code="{{item}}" @click.stop="copyCode(item,'EXPIRED',item['couponInfoItem'])">去使用</view>
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. <script setup lang='ts'>
  64. import {
  65. ref
  66. } from 'vue';
  67. import {requestNew} from "@/utils/network/request.js";
  68. import {
  69. onLoad
  70. } from '@dcloudio/uni-app'
  71. import {
  72. getItem
  73. } from "@/utils/storage";
  74. let singleEquityId = ref('')
  75. let couponAgencyType = ref('')
  76. let purchasedEquityId = ref('')
  77. let couponId = ref('')
  78. let exchangeCodes: any = ref([])
  79. let alonePurchaseData: any = ref([])
  80. let page = ref('')
  81. import {couponActivate,couponQuery} from "@/utils/network/api.js";
  82. onLoad((options) => {
  83. couponId.value = options.couponId
  84. singleEquityId.value = options.singleEquityId
  85. couponAgencyType.value = options.couponAgencyType
  86. purchasedEquityId.value = options.purchasedEquityId
  87. loadExchangeCodes();
  88. })
  89. function loadExchangeCodes() {
  90. //卡券渠道类型获取单项权益列表
  91. requestNew(couponQuery, {
  92. type: 2,
  93. data: {
  94. mobile: getItem('mobile') + "",
  95. loginSource: getItem("loginSource"),
  96. singleEquityId: singleEquityId.value,
  97. equityId: singleEquityId.value,
  98. couponAgencyType: couponAgencyType.value,
  99. couponId: couponId.value,
  100. purchasedEquityId:purchasedEquityId.value
  101. },
  102. method: "POST",
  103. showLoading: true,
  104. }).then((item) => {
  105. let res = item
  106. console.log("res===", res)
  107. let newCodes = res.data.orderItems;
  108. let alonePurchase = res.data.alonePurchase;
  109. if (newCodes) {
  110. console.log(res, '111=========', newCodes);
  111. let newCodesNew = []
  112. newCodes.forEach(item => {
  113. //1 不能领取 0 可以领取 1(不能领取原因 notUseCase)
  114. // item.equityInfoItems[0].equityType
  115. // WAIT_GET
  116. item.status =
  117. item.equityInfoItems[0].isUse == '0' && item.equityInfoItems[0].couponStatus ==
  118. 'WAIT_GET' ? 'WAIT_USE' :
  119. item.equityInfoItems[0].isUse == '1' && item.equityInfoItems[0].couponStatus ==
  120. 'WAIT_GET' ? 'WAIT_ACTIVATED' : item.equityInfoItems[0].couponStatus == 'USED' ?
  121. 'USED' : '';
  122. //WAIT_ACTIVATED(待激活) WAIT_USE(待领取使用) USED(已使用) EXPIRED(已过期) OUINGSYNREE
  123. console.log(item.equityInfoItems[0].periodOfValidity,
  124. item.equityInfoItems[0].isUse, item.equityInfoItems[0].notUseCase,
  125. item.status, item.equityInfoItems[0].couponStatus, '=================',
  126. item.vehiclePlate);
  127. // functBackName(list) = item.equityInfoItems[0].couponStatus == 'WAIT_GET' ? 'WAIT_ACTIVATED' : item.equityInfoItems[0].couponStatus
  128. item.getStatus = getStatusValue(item.status)
  129. console.log("item.getStatus===",item.getStatus)
  130. item.redeemCodeStr = item.equityInfoItems[0].couponInfoItem && desensitize(item
  131. .equityInfoItems[0].couponInfoItem.redeemCode)
  132. item.periodOfValidity = item.equityInfoItems[0].periodOfValidity ? item
  133. .equityInfoItems[0].periodOfValidity.split('T')[0] : '激活领取后展示'
  134. item.redeemCode = item.equityInfoItems[0].couponInfoItem && item
  135. .equityInfoItems[0].couponInfoItem.redeemCode
  136. item.drawTime = item.equityInfoItems[0].drawTime && item.equityInfoItems[0]
  137. .drawTime.split('T')[0]
  138. console.log("item", item.equityInfoItems)
  139. // 不展示付宝数据
  140. for (var k = 0; k < item.equityInfoItems.length; k++) {
  141. if (item.equityInfoItems[k]['equityType'] != "ZFB") {
  142. console.log("alonePurchase1111", alonePurchase)
  143. newCodesNew.push(item)
  144. }
  145. }
  146. });
  147. exchangeCodes.value = newCodesNew
  148. // 购买的权益产品展示
  149. console.log("exchangeCodes.value", exchangeCodes.value);
  150. }
  151. let newAlonePurchase = []
  152. if (alonePurchase) {
  153. console.log("alonePurchase", alonePurchase)
  154. alonePurchase.forEach(item => {
  155. console.log("index", item.equityType == "ZFB")
  156. //1 不能领取 0 可以领取 1(不能领取原因 notUseCase)
  157. // item.equityInfoItems[0].equityType
  158. // WAIT_GET
  159. item.status =item.isUse == 0 && item.couponStatus ==
  160. 'WAIT_GET' ? 'WAIT_USE' :
  161. item.isUse == 1 && item.couponStatus ==
  162. 'WAIT_GET' ? 'WAIT_ACTIVATED' : item.couponStatus == 'USED' ?
  163. 'USED' : '';
  164. //WAIT_ACTIVATED(待激活) WAIT_USE(待领取使用) USED(已使用) EXPIRED(已过期) OUINGSYNREE
  165. console.log(item.periodOfValidity,
  166. item.isUse, item.notUseCase,
  167. item.status, item.couponStatus, '=================',
  168. item.vehiclePlate);
  169. item.getStatus = getStatusValue(item.status)
  170. item.redeemCodeStr = item.couponInfoItem && desensitize(item
  171. .couponInfoItem.redeemCode)
  172. item.periodOfValidity = item.periodOfValidity ? item
  173. .periodOfValidity.split('T')[0] : '激活领取后展示'
  174. item.redeemCode = item.couponInfoItem && item
  175. .couponInfoItem.redeemCode
  176. item.drawTime = item.drawTime && item
  177. .drawTime.split('T')[0]
  178. // 不展示付宝数据
  179. if (item.equityType != "ZFB") {
  180. console.log("alonePurchase1111", alonePurchase)
  181. newAlonePurchase.push(item)
  182. }
  183. });
  184. alonePurchaseData.value = newAlonePurchase
  185. }
  186. })
  187. }
  188. function click(item) {
  189. // console.log("item.equityInfoItems[0].equityType", item.equityInfoItems[0].equityType)
  190. // if (item.equityInfoItems[0].equityType == 'ZFB') {
  191. // console.log("1")
  192. // uni.navigateTo({
  193. // url: `/subpackage/service/zfbqy/zfbqy`
  194. // })
  195. // } else {
  196. // console.log("2")
  197. // uni.navigateTo({
  198. // url: '/subpackage/service/equityInfo/equityInfo?singleEquityId=' + singleEquityId.value +
  199. // "&couponAgencyType=" + couponAgencyType.value + "&couponId=" + couponId.value,
  200. // })
  201. // }
  202. console.log("item",item)
  203. uni.navigateTo({
  204. url: '/subpackage/service/equityInfo/equityInfo?singleEquityId=' + item.singleEquityId +
  205. "&couponAgencyType=" + couponAgencyType.value + "&couponId=" + item.couponId,
  206. })
  207. }
  208. function functBackName(item) {
  209. return item.isUse == '0' && item.couponStatus == 'WAIT_GET' ? 'WAIT_USE' :
  210. item.isUse == '1' && item.couponStatus == 'WAIT_GET' ? 'WAIT_ACTIVATED' : item.couponStatus == 'USED' ?
  211. 'USED' : '';
  212. }
  213. function copyCode(e, start, items) {
  214. console.log("e====",e,start,items)
  215. let item = e;
  216. // // 复制兑换码到剪贴板
  217. if (item.equityType == 'ZFB') {
  218. uni.navigateTo({
  219. url: `/subpackage/service/zfbqy/zfbqy`
  220. })
  221. return
  222. }else{
  223. let code = e.redeemCode ? e.redeemCode : items.redeemCode;
  224. console.log(item, "===e===", e.equityType, items, start);
  225. if (start == 'WAIT_ACTIVATED') { //待激活
  226. uni.showModal({
  227. title: '温馨提示',
  228. content: "激活后,可领取卡卷",
  229. confirmText: "去激活",
  230. success: function(res) {
  231. if (res.confirm) {
  232. uni.navigateTo({
  233. url: '/subpackage/personal-center/install-activation-order',
  234. })
  235. } else if (res.cancel) {
  236. console.log('用户点击取消');
  237. }
  238. }
  239. });
  240. } else if (start == 'WAIT_USE') { //待领取使用
  241. uni.showModal({
  242. title: '温馨提示',
  243. content: "请在领取后120天内使用,超期失效",
  244. success: function(res) {
  245. if (res.confirm) {
  246. requestNew(couponActivate, {
  247. type: 2,
  248. data: {
  249. mobile: getItem('mobile') + "",
  250. notificationType: 'USE',
  251. cardIds: [items.id],
  252. couponId: couponId.value,
  253. equityId: item.singleEquityId,
  254. orderId: items.orderId ? items.orderId : items.purchasedEquityId
  255. },
  256. method: "POST",
  257. showLoading: true,
  258. }).then((item) => {
  259. // uni.setClipboardData({
  260. // data: code,
  261. // success: function() {
  262. // uni.showToast({
  263. // title: '已复制兑换码',
  264. // icon: 'success',
  265. // });
  266. // },
  267. // });
  268. loadExchangeCodes();
  269. uni.showToast({
  270. title: '领取成功',
  271. icon: 'success',
  272. });
  273. // uni.navigateBack();
  274. })
  275. } else if (res.cancel) {
  276. console.log('用户点击取消');
  277. }
  278. }
  279. });
  280. // 已使用 USED
  281. // 已过期 EXPIRED
  282. } else if (start == 'USED') { //已使用
  283. console.log("已复制兑换码1111", code)
  284. uni.setClipboardData({
  285. data: code,
  286. success: function() {
  287. console.log("已复制兑换码")
  288. uni.showToast({
  289. title: '已复制兑换码',
  290. icon: 'success',
  291. });
  292. },
  293. });
  294. } else if (start == 'EXPIRED') { //已过期
  295. }
  296. }
  297. }
  298. function desensitize(str) {
  299. if (typeof str !== 'string') return str;
  300. if (str.length <= 6) return str;
  301. return '*'.repeat(str.length - 4) + str.slice(-4);
  302. }
  303. function getStatusValue(key) {
  304. const statusMap = {
  305. WAIT_GET: "待领取",
  306. WAIT_ACTIVATED: "待激活",
  307. WAIT_USE: "待使用",
  308. USED: "已使用",
  309. EXPIRED: "已过期"
  310. };
  311. // 定义状态对象
  312. return statusMap[key] || "状态未知";
  313. }
  314. </script>
  315. <style lang='scss' scoped>
  316. .item{
  317. width: 95%;
  318. background: #FFFFFF;
  319. border-radius: 32rpx;
  320. padding: 24rpx;
  321. font-size: 26rpx;
  322. box-sizing: border-box;
  323. margin: 20rpx auto;
  324. position: relative;
  325. }
  326. .btn{
  327. padding: 16rpx 24rpx;
  328. background-color:#01243A ;
  329. border-radius: 32rpx;
  330. color: white;
  331. }
  332. .activate{
  333. color: white;
  334. background-size: 100% 100%;
  335. background-repeat: no-repeat;
  336. width: 215rpx;
  337. height: 123rpx;
  338. text-align: center;
  339. display: flex;
  340. align-items: center;
  341. justify-content: center;
  342. background-image: var(--bgimg);
  343. position: absolute;
  344. right: -5px;
  345. top: -5px;
  346. }
  347. .car{
  348. width: 36rpx;
  349. height: 36rpx;
  350. }
  351. .top{
  352. border-bottom: 2rpx solid #E9EDF0;
  353. }
  354. .car-num{
  355. font-weight: 400;
  356. font-size: 30rpx;
  357. color: #111111;
  358. margin-left: 7rpx;
  359. }
  360. .youxiao{
  361. font-weight: 400;
  362. font-size: 26rpx;
  363. color: #999999;
  364. margin-left: 40rpx;
  365. line-height: 58rpx;
  366. }
  367. .go{
  368. display: flex;
  369. justify-content: space-between;
  370. align-items: center;
  371. }
  372. .go>view:first-child{
  373. width: 70%;
  374. margin-top: 10rpx;
  375. .title{
  376. margin-bottom: 10rpx;
  377. color: #545454;
  378. }
  379. }
  380. </style>