From 00830f0d160943e29999875d13b19edacbf198c6 Mon Sep 17 00:00:00 2001 From: peng <peng.com> Date: 星期四, 18 九月 2025 14:24:36 +0800 Subject: [PATCH] 虚拟商品移除加入购物车入口 --- pages/order/claim-coupon/claim-coupon.vue | 45 ++++++++++++++++++++++++++++++++++++--------- 1 files changed, 36 insertions(+), 9 deletions(-) diff --git a/pages/order/claim-coupon/claim-coupon.vue b/pages/order/claim-coupon/claim-coupon.vue index 4e26ca6..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> <!-- 鍗曚釜浼樻儬鍒稿睍绀� --> @@ -104,15 +104,42 @@ 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; @@ -125,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 { @@ -142,7 +169,7 @@ async claimCoupon() { if (!this.couponInfo || this.couponInfo.claimStatus === 'CLAIM') { uni.showToast({ - title: '璇ヤ紭鎯犲埜宸查鍙�', + title: '璇ュ厬鎹㈠埜宸查鍙�', icon: 'none' }); return; @@ -174,7 +201,7 @@ } } catch (err) { uni.hideLoading(); - console.error('棰嗗彇浼樻儬鍒稿け璐�:', err); + console.error('棰嗗彇鍏戞崲鍒稿け璐�:', err); uni.showToast({ title: err.message || '棰嗗彇澶辫触', icon: 'none' -- Gitblit v1.8.0