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

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