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

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