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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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="click">
  12. <view style="display: flex;flex-direction: row;flex: 1;">
  13. <view style="display: flex;flex-direction: column;margin: 10px;">
  14. <text>权益名称:{{item.couponName}}</text>
  15. <text style="margin-top: 10rpx;">状态:{{item.getStatus}}</text>
  16. <text style="margin-top: 10rpx;">领取时间:{{item.getStatus}}</text>
  17. <text style="margin-top: 10rpx;">有效期:{{item.validEndTime}}</text>
  18. <view
  19. style="display: flex;justify-content: flex-start;flex-direction: row;width: 100%;margin-top: 10rpx;">
  20. <text class="code">券码:{{ item.redeemCodeStr}}</text>
  21. </view>
  22. </view>
  23. <view
  24. style="border-radius: 0 8px 8px 0 ;justify-content: center;text-align: center; display: flex;flex-direction: column;background: white;flex: 1;">
  25. <text class="text-w"
  26. :style="{color: item.status == 'WAIT_ACTIVATED' ? '#023F8F' : item.status == 'WAIT_USE' ? 'orange' : item.status == 'USED' ? 'green' : 'gray'}">{{item.status == 'WAIT_ACTIVATED' ? '待激活' : item.status == 'WAIT_USE' ? '待领取' :
  27. item.status == 'USED' ? '已领取' : '已失效'}}</text>
  28. <button v-if="item.status != 'EXPIRED'"
  29. :style="{backgroundColor: item.status == 'WAIT_ACTIVATED' ? '#023F8F' : item.status == 'WAIT_USE' ? 'orange' : item.status == 'USED' ? 'green' : 'gray'}"
  30. class="copy-btn" :data-code="item" @click="copyCode">
  31. {{item.status == 'WAIT_ACTIVATED' ? '去激活' : item.status == 'WAIT_USE' ? '立即领取' :
  32. item.status == 'USED' ? '复制' : ''}}</button>
  33. </view>
  34. </view>
  35. </view>
  36. </scroll-view>
  37. </view>
  38. </view>
  39. <!-- <view style="width: 100%; text-align: center;margin-top: 20rpx; ">暂无更多数据内容!</view> -->
  40. </view>
  41. </template>
  42. <script setup lang='ts'>
  43. import {
  44. ref
  45. } from 'vue';
  46. import {
  47. request
  48. } from "@/utils/network/request.js";
  49. import {
  50. onLoad
  51. } from '@dcloudio/uni-app'
  52. import {
  53. getItem
  54. } from "@/utils/storage";
  55. let singleEquityId = ref('')
  56. let couponAgencyType = ref('')
  57. let couponId = ref('')
  58. let exchangeCodes: any = ref('')
  59. let page = ref('')
  60. onLoad((options) => {
  61. //卡券渠道类型获取单项权益列表
  62. request("bbce0fdfba9b41dabfcb2f19f9a35c97", {
  63. type: 2,
  64. data: {
  65. mobile: getItem('mobile'),
  66. loginSource: '69af303ba2eb4608a099163f0d2a5dbd',
  67. singleEquityId: options.singleEquityId,
  68. couponAgencyType: options.couponAgencyType,
  69. couponId: options.couponId
  70. },
  71. method: "POST",
  72. showLoading: true,
  73. }).then((item) => {
  74. let res = JSON.parse(item.bizContent)
  75. console.log(res, '=========');
  76. let newCodes = res.data;
  77. if (newCodes) {
  78. newCodes.forEach(item => {
  79. item.getStatus = getStatusValue(item.status)
  80. item.redeemCodeStr = desensitize(item.redeemCode)
  81. item.validEndTime = item.validEndTime.replace(/T/g, " ");
  82. });
  83. exchangeCodes.value = exchangeCodes.value.concat(newCodes)
  84. page.value = page.value + 1
  85. }
  86. })
  87. })
  88. function click() {
  89. let that = this
  90. wx.navigateTo({
  91. url: '/subpackage/service/equityInfo/equityInfo?singleEquityId=' + that.data.singleEquityId +
  92. "&couponAgencyType=" + that.data.couponAgencyType + "&couponId=" + that.data.couponId,
  93. })
  94. }
  95. function copyCode(e) {
  96. console.log(e.currentTarget);
  97. let item = e.currentTarget.dataset.code;
  98. // 复制兑换码到剪贴板
  99. let code = e.currentTarget.dataset.code.redeemCode;
  100. if (item.status == 'WAIT_ACTIVATED') { //待激活
  101. wx.showModal({
  102. title: '温馨提示',
  103. content: "激活后,可领取卡卷",
  104. confirmText: "去激活",
  105. success: function(res) {
  106. if (res.confirm) {
  107. wx.navigateTo({
  108. url: '/pages/etc/explain/index',
  109. })
  110. } else if (res.cancel) {
  111. console.log('用户点击取消');
  112. }
  113. }
  114. });
  115. } else if (item.status == 'WAIT_USE') { //待领取使用
  116. wx.showModal({
  117. title: '温馨提示',
  118. content: "自卡卷领取后,有效期截止一年后失效",
  119. success: function(res) {
  120. if (res.confirm) {
  121. request("a6bd3d8c855548eb8015655ea8d9287b", {
  122. type: 2,
  123. data: {
  124. mobile: "18385442054",
  125. notificationType: 'USE',
  126. cardIds: [item.id]
  127. },
  128. method: "POST",
  129. showLoading: true,
  130. }).then((item) => {
  131. uni.setClipboardData({
  132. data: code,
  133. success: function() {
  134. uni.showToast({
  135. title: '已复制兑换码',
  136. icon: 'success',
  137. });
  138. },
  139. });
  140. })
  141. } else if (res.cancel) {
  142. console.log('用户点击取消');
  143. }
  144. }
  145. });
  146. // 已使用 USED
  147. // 已过期 EXPIRED
  148. } else if (item.status == 'USED') { //已使用
  149. uni.setClipboardData({
  150. data: code,
  151. success: function() {
  152. uni.showToast({
  153. title: '已复制兑换码',
  154. icon: 'success',
  155. });
  156. },
  157. });
  158. } else if (item.status == 'EXPIRED') { //已过期
  159. }
  160. }
  161. function desensitize(str) {
  162. if (typeof str !== 'string') return str;
  163. if (str.length <= 6) return str;
  164. return '*'.repeat(str.length - 4) + str.slice(-4);
  165. }
  166. function getStatusValue(key) {
  167. const statusMap = {
  168. WAIT_GET: "待领取",
  169. WAIT_ACTIVATED: "待激活",
  170. WAIT_USE: "待使用",
  171. USED: "已使用",
  172. EXPIRED: "已过期"
  173. };
  174. // 定义状态对象
  175. return statusMap[key] || "状态未知";
  176. }
  177. </script>
  178. <style lang='scss' scoped>
  179. /* index.wxss */
  180. .container {
  181. width: 100%;
  182. height: 96vh;
  183. }
  184. .item {
  185. display: flex;
  186. margin-top: 10px;
  187. width: 100%;
  188. align-items: center;
  189. justify-content: space-around;
  190. /* background-color: rgba(204, 204, 204, 0.2); 淡灰色,透明度为 50% */
  191. background-color: white;
  192. /* 淡灰色,透明度为 50% */
  193. border-bottom: 1rpx solid #e0e0e0;
  194. border-radius: 8px;
  195. font-size: 14px;
  196. }
  197. .code {
  198. flex: 1;
  199. height: 100%;
  200. color: #333;
  201. }
  202. .copy-btn {
  203. background-color: #4caf50;
  204. color: #fff;
  205. border: none;
  206. min-width: 120rpx;
  207. margin-top: 20px;
  208. border-radius: 10rpx;
  209. font-size: 24rpx;
  210. /* 调整字体大小 */
  211. box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.2);
  212. }
  213. .copy-btn:hover {
  214. background-color: #388e3c;
  215. }
  216. .text-w {
  217. font-weight: bold;
  218. }
  219. </style>