Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

equity.vue 11KB

1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
1 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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" style="display: flex;flex-direction: column; justify-content: center;padding: 20px 40px;">
  7. <view style="margin-bottom: 20px;font-size: 38rpx; text-align: center;font-family: Microsoft Yahei;">
  8. 我的权益</view>
  9. <!-- <view v-if="exchangeCodes.length > 0" style="text-align: center;">暂无权益内容</view> @scrolltolower="loadMore" -->
  10. <scroll-view scroll-y="true">
  11. <view v-for="(item, index) in exchangeCodes" :key="index" class="item" @click.stop="click(item)">
  12. <view style="display: flex;flex-direction: column;flex: 1;margin: 10px;">
  13. <view style="display: flex;flex-direction: column;">
  14. <text style="margin-top: 10rpx;">车牌号:{{item.vehiclePlate}}</text>
  15. <text v-if="item.drawTime" style="margin-top: 10rpx;">领取时间:{{item.drawTime}}</text>
  16. <text style="margin-top: 10rpx;">领取时间:{{item.getStatus}}</text>
  17. <text style="margin-top: 10rpx;">有效期:{{ item.periodOfValidity }}</text>
  18. <view
  19. style="display: flex;justify-content: flex-start;flex-direction: row;width: 100%;margin-top: 10rpx;">
  20. <text v-if="item.redeemCodeStr" class="code">券码:{{ item.redeemCodeStr}}</text>
  21. </view>
  22. </view>
  23. <view v-for="(list, index) in item.equityInfoItems">
  24. <view v-if="list.equityType == 'COUPONS'">
  25. <div class="horizontal-line"></div>
  26. <view style="display: flex;flex-direction: column;">
  27. <text style="width: 100%;">权益名称:{{list.productName}}</text>
  28. <view
  29. style="display: flex;flex-direction: row;min-height: 60rpx;justify-content: space-between;text-align: baseline;">
  30. <text class="text-w"
  31. style="flex: 1;margin-top: 5rpx;"
  32. :style="item.status == 'WAIT_ACTIVATED' ? 'color: #023F8F;' : item.status == 'WAIT_USE' ? 'color: orange;' : item.status == 'USED' ? 'color: green;' : 'color: gray;'">卡卷状态:{{item.status == 'WAIT_ACTIVATED' ? '待激活' : item.status == 'WAIT_USE' ? '待领取' : item.status == 'USED' ? '已领取' : '已失效'}}</text>
  33. <button v-if="item.status != 'EXPIRED' && list && list.equityType !='ZFB'"
  34. :style="item.status == 'WAIT_ACTIVATED' ? 'background-color: #023F8F;' : item.status == 'WAIT_USE' ? 'background-color: orange;' : item.status == 'USED' ? 'background-color: green;' : 'background-color: gray;'"
  35. class="copy-btn" data-code="{{item}}" @click.stop="copyCode(list)">
  36. {{item.status == 'WAIT_ACTIVATED' ? '去激活' : item.status == 'WAIT_USE' ? '立即领取' :
  37. item.status == 'USED' ? '复制' : '已失效'}}</button>
  38. </view>
  39. </view>
  40. </view>
  41. <view v-if="list.equityType == 'ZFB'">
  42. <div class="horizontal-line"></div>
  43. <view style="display: flex;flex-direction: column;">
  44. <text style="width: 100%;">权益名称:{{list.productName}}</text>
  45. <view
  46. style="display: flex;flex-direction: row;min-height: 60rpx;justify-content: space-between;text-align: baseline;">
  47. <text class="text-w" style="flex: 1;margin-top: 5rpx;color: #4caf50;">
  48. 卡卷状态:正常
  49. </text>
  50. <button style="background-color: #4caf50;" class="copy-btn"
  51. data-code="{{item}}" @click.stop="copyCode(list)">
  52. 去使用
  53. </button>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </scroll-view>
  61. </view>
  62. </view>
  63. <!-- <view style="width: 100%; text-align: center;margin-top: 20rpx; ">暂无更多数据内容!</view> -->
  64. </view>
  65. </template>
  66. <script setup lang='ts'>
  67. import {
  68. ref
  69. } from 'vue';
  70. import {
  71. request
  72. } from "@/utils/network/request.js";
  73. import {
  74. onLoad
  75. } from '@dcloudio/uni-app'
  76. import {
  77. getItem
  78. } from "@/utils/storage";
  79. let singleEquityId = ref('')
  80. let couponAgencyType = ref('')
  81. let couponId = ref('')
  82. let exchangeCodes: any = ref([])
  83. let page = ref('')
  84. onLoad((options) => {
  85. couponId.value = options.couponId
  86. singleEquityId.value = options.singleEquityId
  87. couponAgencyType.value = options.couponAgencyType
  88. loadExchangeCodes();
  89. })
  90. function loadExchangeCodes() {
  91. //卡券渠道类型获取单项权益列表
  92. request("bbce0fdfba9b41dabfcb2f19f9a35c97", {
  93. type: 2,
  94. data: {
  95. mobile: getItem('mobile') + "",
  96. loginSource: getItem("loginSource"),
  97. singleEquityId: singleEquityId.value,
  98. equityId: singleEquityId.value,
  99. couponAgencyType: couponAgencyType.value,
  100. couponId: couponId.value
  101. },
  102. method: "POST",
  103. showLoading: true,
  104. }).then((item) => {
  105. let res = JSON.parse(item.bizContent)
  106. let newCodes = res.data.orderItems;
  107. if (newCodes) {
  108. console.log(res, '111=========', newCodes);
  109. newCodes.forEach(item => {
  110. //1 不能领取 0 可以领取 1(不能领取原因 notUseCase)
  111. // item.equityInfoItems[0].equityType
  112. // WAIT_GET
  113. item.status =
  114. item.equityInfoItems[0].isUse == '0' && item.equityInfoItems[0].couponStatus ==
  115. 'WAIT_GET' ? 'WAIT_USE' :
  116. item.equityInfoItems[0].isUse == '1' && item.equityInfoItems[0].couponStatus ==
  117. 'WAIT_GET' ? 'WAIT_ACTIVATED' :
  118. item.equityInfoItems[0].couponStatus == 'USED' ? 'USED' : '';
  119. //WAIT_ACTIVATED(待激活) WAIT_USE(待领取使用) USED(已使用) EXPIRED(已过期) OUINGSYNREE
  120. console.log(item.equityInfoItems[0].periodOfValidity,
  121. item.equityInfoItems[0].isUse, item.equityInfoItems[0].notUseCase,
  122. item.status, item.equityInfoItems[0].couponStatus, '=================',
  123. item.vehiclePlate);
  124. // item.status = item.equityInfoItems[0].couponStatus == 'WAIT_GET' ? 'WAIT_ACTIVATED' : item.equityInfoItems[0].couponStatus
  125. item.getStatus = getStatusValue(item.status)
  126. item.redeemCodeStr = item.equityInfoItems[0].couponInfoItem && desensitize(item
  127. .equityInfoItems[0].couponInfoItem.redeemCode)
  128. item.periodOfValidity = item.equityInfoItems[0].periodOfValidity ? item
  129. .equityInfoItems[0].periodOfValidity.split('T')[0] : '激活领取后展示'
  130. item.redeemCode = item.equityInfoItems[0].couponInfoItem && item
  131. .equityInfoItems[0].couponInfoItem.redeemCode
  132. item.drawTime = item.equityInfoItems[0].drawTime && item.equityInfoItems[0]
  133. .drawTime.split('T')[0]
  134. // item.periodOfValidity = item.equityInfoItems[0].periodOfValidity.replace(/T/g, " ");
  135. // item.periodOfValidity = item.equityInfoItems[0].periodOfValidity.split('T')[0]
  136. });
  137. exchangeCodes.value = newCodes
  138. console.log("exchangeCodes.value", exchangeCodes.value);
  139. }
  140. })
  141. }
  142. function click(item) {
  143. // console.log("item.equityInfoItems[0].equityType", item.equityInfoItems[0].equityType)
  144. // if (item.equityInfoItems[0].equityType == 'ZFB') {
  145. // console.log("1")
  146. // uni.navigateTo({
  147. // url: `/subpackage/service/zfbqy/zfbqy`
  148. // })
  149. // } else {
  150. // console.log("2")
  151. // uni.navigateTo({
  152. // url: '/subpackage/service/equityInfo/equityInfo?singleEquityId=' + singleEquityId.value +
  153. // "&couponAgencyType=" + couponAgencyType.value + "&couponId=" + couponId.value,
  154. // })
  155. // }
  156. uni.navigateTo({
  157. url: '/subpackage/service/equityInfo/equityInfo?singleEquityId=' + singleEquityId.value +
  158. "&couponAgencyType=" + couponAgencyType.value + "&couponId=" + couponId.value,
  159. })
  160. }
  161. function copyCode(e) {
  162. let item = e;
  163. // // 复制兑换码到剪贴板
  164. let code = e.redeemCode;
  165. console.log("===e===", e.equityType);
  166. if (item.equityType == 'ZFB') {
  167. uni.navigateTo({
  168. url: `/subpackage/service/zfbqy/zfbqy`
  169. })
  170. return
  171. }
  172. if (item.status == 'WAIT_ACTIVATED') { //待激活
  173. uni.showModal({
  174. title: '温馨提示',
  175. content: "激活后,可领取卡卷",
  176. confirmText: "去激活",
  177. success: function(res) {
  178. if (res.confirm) {
  179. uni.navigateTo({
  180. url: '/subpackage/personal-center/install-activation-order',
  181. })
  182. } else if (res.cancel) {
  183. console.log('用户点击取消');
  184. }
  185. }
  186. });
  187. } else if (item.status == 'WAIT_USE') { //待领取使用
  188. uni.showModal({
  189. title: '温馨提示',
  190. content: "请在领取后120天内使用,超期失效",
  191. success: function(res) {
  192. if (res.confirm) {
  193. request("a6bd3d8c855548eb8015655ea8d9287b", {
  194. type: 2,
  195. data: {
  196. mobile: getItem('mobile') + "",
  197. notificationType: 'USE',
  198. cardIds: [item.id],
  199. couponId: couponId.value,
  200. equityId: item.equityId,
  201. orderId: item.orderId
  202. },
  203. method: "POST",
  204. showLoading: true,
  205. }).then((item) => {
  206. // uni.setClipboardData({
  207. // data: code,
  208. // success: function() {
  209. // uni.showToast({
  210. // title: '已复制兑换码',
  211. // icon: 'success',
  212. // });
  213. // },
  214. // });
  215. loadExchangeCodes();
  216. uni.showToast({
  217. title: '领取成功',
  218. icon: 'success',
  219. });
  220. })
  221. } else if (res.cancel) {
  222. console.log('用户点击取消');
  223. }
  224. }
  225. });
  226. // 已使用 USED
  227. // 已过期 EXPIRED
  228. } else if (item.status == 'USED') { //已使用
  229. uni.setClipboardData({
  230. data: code,
  231. success: function() {
  232. uni.showToast({
  233. title: '已复制兑换码',
  234. icon: 'success',
  235. });
  236. },
  237. });
  238. } else if (item.status == 'EXPIRED') { //已过期
  239. }
  240. }
  241. function desensitize(str) {
  242. if (typeof str !== 'string') return str;
  243. if (str.length <= 6) return str;
  244. return '*'.repeat(str.length - 4) + str.slice(-4);
  245. }
  246. function getStatusValue(key) {
  247. const statusMap = {
  248. WAIT_GET: "待领取",
  249. WAIT_ACTIVATED: "待激活",
  250. WAIT_USE: "待使用",
  251. USED: "已使用",
  252. EXPIRED: "已过期"
  253. };
  254. // 定义状态对象
  255. return statusMap[key] || "状态未知";
  256. }
  257. </script>
  258. <style lang='scss' scoped>
  259. .container {
  260. width: 100%;
  261. height: 96vh;
  262. }
  263. .item {
  264. display: flex;
  265. margin-top: 10px;
  266. width: 100%;
  267. align-items: center;
  268. justify-content: space-around;
  269. background-color: white;
  270. /* 淡灰色,透明度为 50% */
  271. border-bottom: 1rpx solid #e0e0e0;
  272. border-radius: 8px;
  273. font-size: 14px;
  274. }
  275. .code {
  276. flex: 1;
  277. height: 100%;
  278. color: #333;
  279. }
  280. .copy-btn {
  281. background-color: #4caf50;
  282. color: #fff;
  283. border: none;
  284. min-width: 120rpx;
  285. border-radius: 10rpx;
  286. font-size: 24rpx;
  287. height: 60rpx;
  288. box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.2);
  289. text-align: center;
  290. display: inline-block;
  291. line-height: 60rpx;
  292. }
  293. .copy-btn:hover {
  294. background-color: #388e3c;
  295. }
  296. .text-w {
  297. font-weight: bold;
  298. }
  299. .horizontal-line {
  300. width: 100%;
  301. /* 设置横线的宽度 */
  302. height: 1px;
  303. /* 设置横线的高度 */
  304. background-color: #9ACDFA;
  305. /* 设置横线的颜色 */
  306. margin: 10px 0;
  307. /* 可以根据需要调整横线与周围内容的间距 */
  308. }
  309. </style>