From 796977e24baa7c1d3a333e2c1c8e06ca73fd9a56 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期三, 19 十一月 2025 18:08:35 +0800
Subject: [PATCH] 优惠劵
---
pages/order/claim-coupon/claim-coupon.vue | 52 ++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 42 insertions(+), 10 deletions(-)
diff --git a/pages/order/claim-coupon/claim-coupon.vue b/pages/order/claim-coupon/claim-coupon.vue
index c7de317..0f7a359 100644
--- a/pages/order/claim-coupon/claim-coupon.vue
+++ b/pages/order/claim-coupon/claim-coupon.vue
@@ -2,8 +2,8 @@
<view class="container">
<!-- 椤堕儴鏍囬 -->
<view class="header">
- <text class="title">浼樻儬鍒搁鍙�</text>
- <text class="subtitle">棰嗗彇鎮ㄧ殑涓撳睘浼樻儬鍒�</text>
+ <text class="title">鍟嗗搧鍏戞崲鍒搁鍙�</text>
+ <text class="subtitle">棰嗗彇鎮ㄧ殑涓撳睘鍟嗗搧鍏戞崲鍒�</text>
</view>
<!-- 鍗曚釜浼樻儬鍒稿睍绀� -->
@@ -89,8 +89,12 @@
couponInfo: null, // 鍗曚釜浼樻儬鍒镐俊鎭�
loading: false,
showShoppingModal: false ,// 鎺у埗鍘昏喘鐗╁脊绐楁樉绀�
- couponId:''
+ couponId:'',
+ cardId:''
}
+ },
+ onShow() {
+ this.loadCouponInfo(this.cardId);
},
onLoad(options) {
// 閫氳繃鍙傛暟浼犻�掍紭鎯犲埜ID
@@ -98,16 +102,44 @@
this.couponId = ''
if (options.id) {
+ this.cardId = options.id
this.loadCouponInfo(options.id);
- } else {
+ }else if(options.q) {
+ // 鍙岄噸瑙g爜锛氬井淇″URL杩涜浜嗕袱娆$紪鐮�
+ const decodedUrl = decodeURIComponent(decodeURIComponent(options.q));
+ console.log('鍘熷URL:', decodedUrl);
+
+ // 瑙f瀽URL涓殑鏌ヨ鍙傛暟
+ const params = this.parseUrlParams(decodedUrl);
+ this.cardId = params.id;
+ this.loadCouponInfo(this.cardId);
+ }
+ else {
// 濡傛灉娌℃湁浼犻�扞D锛屾樉绀虹┖鐘舵��
uni.showToast({
- title: '缂哄皯浼樻儬鍒窱D鍙傛暟',
+ title: '缂哄皯鍏戞崲鍒窱D鍙傛暟',
icon: 'none'
});
}
},
methods: {
+ // 瑙f瀽URL鍙傛暟
+ parseUrlParams(url) {
+ const params = {};
+ // 澶勭悊鍙兘瀛樺湪鐨刪ash锛堝鏋滄湁鐨勮瘽锛�
+ const cleanUrl = url.split('#')[0];
+ const queryStr = cleanUrl.split('?')[1] || '';
+
+ queryStr.split('&').forEach(pair => {
+ const [key, value] = pair.split('=');
+ if (key) {
+ // 濡傛灉鍊煎瓨鍦紝鍒欒В鐮侊紝鍚﹀垯璁句负绌哄瓧绗︿覆
+ params[key] = value ? decodeURIComponent(value) : '';
+ }
+ });
+
+ return params;
+ },
// 鍔犺浇鎸囧畾ID鐨勪紭鎯犲埜淇℃伅
async loadCouponInfo(id) {
if (this.loading) return;
@@ -120,12 +152,12 @@
if (res.data.code===200) {
this.couponInfo = res.data.data;
} else {
- throw new Error(res.message || '鑾峰彇浼樻儬鍒稿け璐�');
+ throw new Error(res.message || '鑾峰彇鍏戞崲鍒稿け璐�');
}
} catch (err) {
- console.error('鑾峰彇浼樻儬鍒镐俊鎭け璐�:', err);
+ console.error('鑾峰彇鍏戞崲鍒镐俊鎭け璐�:', err);
uni.showToast({
- title: err.message || '鑾峰彇浼樻儬鍒稿け璐�',
+ title: err.message || '鑾峰彇鍏戞崲鍒稿け璐�',
icon: 'none'
});
} finally {
@@ -137,7 +169,7 @@
async claimCoupon() {
if (!this.couponInfo || this.couponInfo.claimStatus === 'CLAIM') {
uni.showToast({
- title: '璇ヤ紭鎯犲埜宸查鍙�',
+ title: '璇ュ厬鎹㈠埜宸查鍙�',
icon: 'none'
});
return;
@@ -169,7 +201,7 @@
}
} catch (err) {
uni.hideLoading();
- console.error('棰嗗彇浼樻儬鍒稿け璐�:', err);
+ console.error('棰嗗彇鍏戞崲鍒稿け璐�:', err);
uni.showToast({
title: err.message || '棰嗗彇澶辫触',
icon: 'none'
--
Gitblit v1.8.0