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

equity.vue 13KB

1年前
7ヶ月前
7ヶ月前
1年前
7ヶ月前
7ヶ月前
1年前
7ヶ月前
1年前
7ヶ月前
7ヶ月前
7ヶ月前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
7ヶ月前
1年前
7ヶ月前
1年前
1年前
1年前
1年前
7ヶ月前
7ヶ月前
1年前
11ヶ月前
11ヶ月前
11ヶ月前
7ヶ月前
11ヶ月前
11ヶ月前
11ヶ月前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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="item.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. item.redeemCodeStr = item.equityInfoItems[0].couponInfoItem && desensitize(item
  130. .equityInfoItems[0].couponInfoItem.redeemCode)
  131. item.periodOfValidity = item.equityInfoItems[0].periodOfValidity ? item
  132. .equityInfoItems[0].periodOfValidity.split('T')[0] : '激活领取后展示'
  133. item.redeemCode = item.equityInfoItems[0].couponInfoItem && item
  134. .equityInfoItems[0].couponInfoItem.redeemCode
  135. item.drawTime = item.equityInfoItems[0].drawTime && item.equityInfoItems[0]
  136. .drawTime.split('T')[0]
  137. console.log("item", item.equityInfoItems)
  138. // 不展示付宝数据
  139. for (var k = 0; k < item.equityInfoItems.length; k++) {
  140. if (item.equityInfoItems[k]['equityType'] != "ZFB") {
  141. console.log("alonePurchase1111", alonePurchase)
  142. newCodesNew.push(item)
  143. }
  144. }
  145. });
  146. exchangeCodes.value = newCodesNew
  147. // 购买的权益产品展示
  148. console.log("exchangeCodes.value", exchangeCodes.value);
  149. }
  150. let newAlonePurchase = []
  151. if (alonePurchase) {
  152. console.log("alonePurchase", alonePurchase)
  153. alonePurchase.forEach(item => {
  154. console.log("index", item.equityType == "ZFB")
  155. //1 不能领取 0 可以领取 1(不能领取原因 notUseCase)
  156. // item.equityInfoItems[0].equityType
  157. // WAIT_GET
  158. item.status =item.isUse == 0 && item.couponStatus ==
  159. 'WAIT_GET' ? 'WAIT_USE' :
  160. item.isUse == 1 && item.couponStatus ==
  161. 'WAIT_GET' ? 'WAIT_ACTIVATED' : item.couponStatus == 'USED' ?
  162. 'USED' : '';
  163. //WAIT_ACTIVATED(待激活) WAIT_USE(待领取使用) USED(已使用) EXPIRED(已过期) OUINGSYNREE
  164. console.log(item.periodOfValidity,
  165. item.isUse, item.notUseCase,
  166. item.status, item.couponStatus, '=================',
  167. item.vehiclePlate);
  168. item.getStatus = getStatusValue(item.status)
  169. item.redeemCodeStr = item.couponInfoItem && desensitize(item
  170. .couponInfoItem.redeemCode)
  171. item.periodOfValidity = item.periodOfValidity ? item
  172. .periodOfValidity.split('T')[0] : '激活领取后展示'
  173. item.redeemCode = item.couponInfoItem && item
  174. .couponInfoItem.redeemCode
  175. item.drawTime = item.drawTime && item
  176. .drawTime.split('T')[0]
  177. // 不展示付宝数据
  178. if (item.equityType != "ZFB") {
  179. console.log("alonePurchase1111", alonePurchase)
  180. newAlonePurchase.push(item)
  181. }
  182. });
  183. alonePurchaseData.value = newAlonePurchase
  184. }
  185. })
  186. }
  187. function click(item) {
  188. // console.log("item.equityInfoItems[0].equityType", item.equityInfoItems[0].equityType)
  189. // if (item.equityInfoItems[0].equityType == 'ZFB') {
  190. // console.log("1")
  191. // uni.navigateTo({
  192. // url: `/subpackage/service/zfbqy/zfbqy`
  193. // })
  194. // } else {
  195. // console.log("2")
  196. // uni.navigateTo({
  197. // url: '/subpackage/service/equityInfo/equityInfo?singleEquityId=' + singleEquityId.value +
  198. // "&couponAgencyType=" + couponAgencyType.value + "&couponId=" + couponId.value,
  199. // })
  200. // }
  201. console.log("item",item)
  202. uni.navigateTo({
  203. url: '/subpackage/service/equityInfo/equityInfo?singleEquityId=' + item.singleEquityId +
  204. "&couponAgencyType=" + couponAgencyType.value + "&couponId=" + item.couponId,
  205. })
  206. }
  207. function functBackName(item) {
  208. return item.isUse == '0' && item.couponStatus == 'WAIT_GET' ? 'WAIT_USE' :
  209. item.isUse == '1' && item.couponStatus == 'WAIT_GET' ? 'WAIT_ACTIVATED' : item.couponStatus == 'USED' ?
  210. 'USED' : '';
  211. }
  212. function copyCode(e, start, items) {
  213. console.log("e====",e,start,items)
  214. let item = e;
  215. // // 复制兑换码到剪贴板
  216. if (item.equityType == 'ZFB') {
  217. uni.navigateTo({
  218. url: `/subpackage/service/zfbqy/zfbqy`
  219. })
  220. return
  221. }else{
  222. let code = e.redeemCode ? e.redeemCode : items.redeemCode;
  223. console.log(item, "===e===", e.equityType, items, start);
  224. if (start == 'WAIT_ACTIVATED') { //待激活
  225. uni.showModal({
  226. title: '温馨提示',
  227. content: "激活后,可领取卡卷",
  228. confirmText: "去激活",
  229. success: function(res) {
  230. if (res.confirm) {
  231. uni.navigateTo({
  232. url: '/subpackage/personal-center/install-activation-order',
  233. })
  234. } else if (res.cancel) {
  235. console.log('用户点击取消');
  236. }
  237. }
  238. });
  239. } else if (start == 'WAIT_USE') { //待领取使用
  240. uni.showModal({
  241. title: '温馨提示',
  242. content: "请在领取后120天内使用,超期失效",
  243. success: function(res) {
  244. if (res.confirm) {
  245. requestNew(couponActivate, {
  246. type: 2,
  247. data: {
  248. mobile: getItem('mobile') + "",
  249. notificationType: 'USE',
  250. cardIds: [items.id],
  251. couponId: couponId.value,
  252. equityId: item.singleEquityId,
  253. orderId: items.orderId ? items.orderId : items.purchasedEquityId
  254. },
  255. method: "POST",
  256. showLoading: true,
  257. }).then((item) => {
  258. // uni.setClipboardData({
  259. // data: code,
  260. // success: function() {
  261. // uni.showToast({
  262. // title: '已复制兑换码',
  263. // icon: 'success',
  264. // });
  265. // },
  266. // });
  267. loadExchangeCodes();
  268. uni.showToast({
  269. title: '领取成功',
  270. icon: 'success',
  271. });
  272. // uni.navigateBack();
  273. })
  274. } else if (res.cancel) {
  275. console.log('用户点击取消');
  276. }
  277. }
  278. });
  279. // 已使用 USED
  280. // 已过期 EXPIRED
  281. } else if (start == 'USED') { //已使用
  282. console.log("已复制兑换码1111", code)
  283. uni.setClipboardData({
  284. data: code,
  285. success: function() {
  286. console.log("已复制兑换码")
  287. uni.showToast({
  288. title: '已复制兑换码',
  289. icon: 'success',
  290. });
  291. },
  292. });
  293. } else if (start == 'EXPIRED') { //已过期
  294. }
  295. }
  296. }
  297. function desensitize(str) {
  298. if (typeof str !== 'string') return str;
  299. if (str.length <= 6) return str;
  300. return '*'.repeat(str.length - 4) + str.slice(-4);
  301. }
  302. function getStatusValue(key) {
  303. const statusMap = {
  304. WAIT_GET: "待领取",
  305. WAIT_ACTIVATED: "待激活",
  306. WAIT_USE: "待使用",
  307. USED: "已使用",
  308. EXPIRED: "已过期"
  309. };
  310. // 定义状态对象
  311. return statusMap[key] || "状态未知";
  312. }
  313. </script>
  314. <style lang='scss' scoped>
  315. .item{
  316. width: 95%;
  317. background: #FFFFFF;
  318. border-radius: 32rpx;
  319. padding: 24rpx;
  320. font-size: 26rpx;
  321. box-sizing: border-box;
  322. margin: 20rpx auto;
  323. }
  324. .btn{
  325. padding: 16rpx 24rpx;
  326. background-color:#01243A ;
  327. border-radius: 32rpx;
  328. color: white;
  329. }
  330. .activate{
  331. color: white;
  332. background-size: 100% 100%;
  333. background-repeat: no-repeat;
  334. width: 215rpx;
  335. height: 123rpx;
  336. text-align: center;
  337. display: flex;
  338. align-items: center;
  339. justify-content: center;
  340. background-image: var(--bgimg);
  341. position: absolute;
  342. right: -5px;
  343. top: -5px;
  344. }
  345. .car{
  346. width: 36rpx;
  347. height: 36rpx;
  348. }
  349. .top{
  350. border-bottom: 2rpx solid #E9EDF0;
  351. }
  352. .car-num{
  353. font-weight: 400;
  354. font-size: 30rpx;
  355. color: #111111;
  356. margin-left: 7rpx;
  357. }
  358. .youxiao{
  359. font-weight: 400;
  360. font-size: 26rpx;
  361. color: #999999;
  362. margin-left: 40rpx;
  363. line-height: 58rpx;
  364. }
  365. .go{
  366. display: flex;
  367. justify-content: space-between;
  368. align-items: center;
  369. }
  370. .go>view:first-child{
  371. width: 70%;
  372. margin-top: 10rpx;
  373. .title{
  374. margin-bottom: 10rpx;
  375. color: #545454;
  376. }
  377. }
  378. </style>