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

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