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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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. newCodes.forEach(item => {
  111. //1 不能领取 0 可以领取 1(不能领取原因 notUseCase)
  112. // item.equityInfoItems[0].equityType
  113. // WAIT_GET
  114. item.status =
  115. item.equityInfoItems[0].isUse == '0' && item.equityInfoItems[0].couponStatus ==
  116. 'WAIT_GET' ? 'WAIT_USE' :
  117. item.equityInfoItems[0].isUse == '1' && item.equityInfoItems[0].couponStatus ==
  118. 'WAIT_GET' ? 'WAIT_ACTIVATED' : item.equityInfoItems[0].couponStatus == 'USED' ?
  119. 'USED' : '';
  120. //WAIT_ACTIVATED(待激活) WAIT_USE(待领取使用) USED(已使用) EXPIRED(已过期) OUINGSYNREE
  121. console.log(item.equityInfoItems[0].periodOfValidity,
  122. item.equityInfoItems[0].isUse, item.equityInfoItems[0].notUseCase,
  123. item.status, item.equityInfoItems[0].couponStatus, '=================',
  124. item.vehiclePlate);
  125. // functBackName(list) = item.equityInfoItems[0].couponStatus == 'WAIT_GET' ? 'WAIT_ACTIVATED' : item.equityInfoItems[0].couponStatus
  126. item.getStatus = getStatusValue(item.status)
  127. item.redeemCodeStr = item.equityInfoItems[0].couponInfoItem && desensitize(item
  128. .equityInfoItems[0].couponInfoItem.redeemCode)
  129. item.periodOfValidity = item.equityInfoItems[0].periodOfValidity ? item
  130. .equityInfoItems[0].periodOfValidity.split('T')[0] : '激活领取后展示'
  131. item.redeemCode = item.equityInfoItems[0].couponInfoItem && item
  132. .equityInfoItems[0].couponInfoItem.redeemCode
  133. item.drawTime = item.equityInfoItems[0].drawTime && item.equityInfoItems[0]
  134. .drawTime.split('T')[0]
  135. // item.periodOfValidity = item.equityInfoItems[0].periodOfValidity.replace(/T/g, " ");
  136. // item.periodOfValidity = item.equityInfoItems[0].periodOfValidity.split('T')[0]
  137. });
  138. exchangeCodes.value = newCodes
  139. console.log("exchangeCodes.value", exchangeCodes.value);
  140. }
  141. })
  142. }
  143. function click(item) {
  144. // console.log("item.equityInfoItems[0].equityType", item.equityInfoItems[0].equityType)
  145. // if (item.equityInfoItems[0].equityType == 'ZFB') {
  146. // console.log("1")
  147. // uni.navigateTo({
  148. // url: `/subpackage/service/zfbqy/zfbqy`
  149. // })
  150. // } else {
  151. // console.log("2")
  152. // uni.navigateTo({
  153. // url: '/subpackage/service/equityInfo/equityInfo?singleEquityId=' + singleEquityId.value +
  154. // "&couponAgencyType=" + couponAgencyType.value + "&couponId=" + couponId.value,
  155. // })
  156. // }
  157. uni.navigateTo({
  158. url: '/subpackage/service/equityInfo/equityInfo?singleEquityId=' + singleEquityId.value +
  159. "&couponAgencyType=" + couponAgencyType.value + "&couponId=" + couponId.value,
  160. })
  161. }
  162. function functBackName(item) {
  163. return item.isUse == '0' && item.couponStatus == 'WAIT_GET' ? 'WAIT_USE' :
  164. item.isUse == '1' && item.couponStatus == 'WAIT_GET' ? 'WAIT_ACTIVATED' : item.couponStatus == 'USED' ?
  165. 'USED' : '';
  166. }
  167. function copyCode(e, start,items) {
  168. let item = e;
  169. // // 复制兑换码到剪贴板
  170. let code = e.redeemCode;
  171. console.log(item, "===e===", e.equityType, items);
  172. if (item.equityType == 'ZFB') {
  173. uni.navigateTo({
  174. url: `/subpackage/service/zfbqy/zfbqy`
  175. })
  176. return
  177. }
  178. if (start == 'WAIT_ACTIVATED') { //待激活
  179. uni.showModal({
  180. title: '温馨提示',
  181. content: "激活后,可领取卡卷",
  182. confirmText: "去激活",
  183. success: function(res) {
  184. if (res.confirm) {
  185. uni.navigateTo({
  186. url: '/subpackage/personal-center/install-activation-order',
  187. })
  188. } else if (res.cancel) {
  189. console.log('用户点击取消');
  190. }
  191. }
  192. });
  193. } else if (start == 'WAIT_USE') { //待领取使用
  194. uni.showModal({
  195. title: '温馨提示',
  196. content: "请在领取后120天内使用,超期失效",
  197. success: function(res) {
  198. if (res.confirm) {
  199. request("a6bd3d8c855548eb8015655ea8d9287b", {
  200. type: 2,
  201. data: {
  202. mobile: getItem('mobile') + "",
  203. notificationType: 'USE',
  204. cardIds: [items.id],
  205. couponId: couponId.value,
  206. equityId: item.singleEquityId,
  207. orderId: items.orderId
  208. },
  209. method: "POST",
  210. showLoading: true,
  211. }).then((item) => {
  212. // uni.setClipboardData({
  213. // data: code,
  214. // success: function() {
  215. // uni.showToast({
  216. // title: '已复制兑换码',
  217. // icon: 'success',
  218. // });
  219. // },
  220. // });
  221. uni.showToast({
  222. title: '领取成功',
  223. icon: 'success',
  224. });
  225. loadExchangeCodes();
  226. uni.navigateBack();
  227. })
  228. } else if (res.cancel) {
  229. console.log('用户点击取消');
  230. }
  231. }
  232. });
  233. // 已使用 USED
  234. // 已过期 EXPIRED
  235. } else if (start == 'USED') { //已使用
  236. uni.setClipboardData({
  237. data: code,
  238. success: function() {
  239. uni.showToast({
  240. title: '已复制兑换码',
  241. icon: 'success',
  242. });
  243. },
  244. });
  245. } else if (start == 'EXPIRED') { //已过期
  246. }
  247. }
  248. function desensitize(str) {
  249. if (typeof str !== 'string') return str;
  250. if (str.length <= 6) return str;
  251. return '*'.repeat(str.length - 4) + str.slice(-4);
  252. }
  253. function getStatusValue(key) {
  254. const statusMap = {
  255. WAIT_GET: "待领取",
  256. WAIT_ACTIVATED: "待激活",
  257. WAIT_USE: "待使用",
  258. USED: "已使用",
  259. EXPIRED: "已过期"
  260. };
  261. // 定义状态对象
  262. return statusMap[key] || "状态未知";
  263. }
  264. </script>
  265. <style lang='scss' scoped>
  266. .container {
  267. width: 100%;
  268. height: 96vh;
  269. }
  270. .item {
  271. display: flex;
  272. margin-top: 10px;
  273. width: 100%;
  274. align-items: center;
  275. justify-content: space-around;
  276. background-color: white;
  277. /* 淡灰色,透明度为 50% */
  278. border-bottom: 1rpx solid #e0e0e0;
  279. border-radius: 8px;
  280. font-size: 14px;
  281. }
  282. .code {
  283. flex: 1;
  284. height: 100%;
  285. color: #333;
  286. }
  287. .copy-btn {
  288. background-color: #4caf50;
  289. color: #fff;
  290. border: none;
  291. min-width: 120rpx;
  292. border-radius: 10rpx;
  293. font-size: 24rpx;
  294. height: 60rpx;
  295. box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.2);
  296. text-align: center;
  297. display: inline-block;
  298. line-height: 60rpx;
  299. }
  300. .copy-btn:hover {
  301. background-color: #388e3c;
  302. }
  303. .text-w {
  304. font-weight: bold;
  305. }
  306. .horizontal-line {
  307. width: 100%;
  308. /* 设置横线的宽度 */
  309. height: 1px;
  310. /* 设置横线的高度 */
  311. background-color: #9ACDFA;
  312. /* 设置横线的颜色 */
  313. margin: 10px 0;
  314. /* 可以根据需要调整横线与周围内容的间距 */
  315. }
  316. </style>