Compare commits

...

7 Commits

Author SHA1 Message Date
kk 1b9602f66b 总数量显示订单总数
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 46s
2026-07-20 11:50:41 +08:00
kk a071f760d3 授权回调code支持auth_code
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 48s
2026-07-20 10:30:59 +08:00
kk 445d428d8b 授权获取用户信息scope是auth_user
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 1m12s
2026-07-17 17:45:24 +08:00
kk bbbd386e1e 修改scope
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 41s
2026-07-17 17:19:35 +08:00
kk fd3cd58123 scope参数问题处理
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 40s
2026-07-17 16:22:57 +08:00
kk 97d4be5772 支付宝防止重复调用
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 45s
2026-07-17 15:35:31 +08:00
kk b2b92ec6b4 防止重复跳转
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 45s
2026-07-17 15:13:13 +08:00
3 changed files with 50 additions and 4 deletions
+2 -2
View File
@@ -42,8 +42,8 @@
} }
} }
// 3. 检查 URL 中是否有授权回调的 code // 3. 检查 URL 中是否有授权回调的 code(支付宝用 auth_code,微信用 code
const code = urlParams.get('code'); const code = urlParams.get('code') || urlParams.get('auth_code');
if (code) { if (code) {
// 有 code → 进入授权 Loading 页处理 // 有 code → 进入授权 Loading 页处理
+47 -1
View File
@@ -16,6 +16,7 @@ export default {
statusText: '正在登录...', statusText: '正在登录...',
deviceId: '', deviceId: '',
action: '', action: '',
navigating: false, // 防止重复跳转
}; };
}, },
onLoad(options) { onLoad(options) {
@@ -91,7 +92,19 @@ export default {
* 发起 OAuth 授权(静默授权,只获取 openid) * 发起 OAuth 授权(静默授权,只获取 openid)
*/ */
async startAuth() { async startAuth() {
// 清除上次使用的 code 标记 // 防止重复调用(实例级 + storage 级双重保护)
if (this.navigating) {
console.log('[Auth] 已在跳转中,忽略重复 startAuth');
return;
}
// handleCallback 正在处理中或已完成,禁止发起新授权
if (uni.getStorageSync('__auth_callback_done')) {
console.log('[Auth] 回调处理中/已完成,跳过 startAuth');
return;
}
this.navigating = true;
// 清除上次使用的 code 标记(仅在发起新授权时清除,不在 handleCallback 流程中)
uni.removeStorageSync('__used_auth_code'); uni.removeStorageSync('__used_auth_code');
const platform = detectPlatform(); const platform = detectPlatform();
@@ -151,6 +164,15 @@ export default {
* 处理授权回调(用 code 换 openid,再用 openid 登录) * 处理授权回调(用 code 换 openid,再用 openid 登录)
*/ */
async handleCallback(code) { async handleCallback(code) {
// 防止重复调用(实例级 + storage 级双重保护)
if (this.navigating) {
console.log('[Auth] 已在跳转中,忽略重复 handleCallback');
return;
}
this.navigating = true;
// storage 级保护:跨页面实例生效,防止支付宝整页重载后重复执行
uni.setStorageSync('__auth_callback_done', '1');
const appNo = uni.getStorageSync('app_no') || getAppNo(detectPlatform()); const appNo = uni.getStorageSync('app_no') || getAppNo(detectPlatform());
if (!appNo) { if (!appNo) {
@@ -163,6 +185,7 @@ export default {
const usedCode = uni.getStorageSync('__used_auth_code'); const usedCode = uni.getStorageSync('__used_auth_code');
if (usedCode === code) { if (usedCode === code) {
console.warn('[loading] code 已使用过,跳过'); console.warn('[loading] code 已使用过,跳过');
this.navigating = false;
return; return;
} }
uni.setStorageSync('__used_auth_code', code); uni.setStorageSync('__used_auth_code', code);
@@ -247,6 +270,17 @@ export default {
* 发起非静默授权获取用户信息(snsapi_userinfo,弹窗确认) * 发起非静默授权获取用户信息(snsapi_userinfo,弹窗确认)
*/ */
async startUserInfoAuth() { async startUserInfoAuth() {
// 防止重复调用(实例级 + storage 级双重保护)
if (this.navigating) {
console.log('[Auth] 已在跳转中,忽略重复 startUserInfoAuth');
return;
}
if (uni.getStorageSync('__auth_callback_done')) {
console.log('[Auth] 回调处理中/已完成,跳过 startUserInfoAuth');
return;
}
this.navigating = true;
// 清除上次使用的 code 标记 // 清除上次使用的 code 标记
uni.removeStorageSync('__used_auth_code'); uni.removeStorageSync('__used_auth_code');
@@ -308,6 +342,14 @@ export default {
* 处理用户信息授权回调(用 code 调 /api/v1/user/info 获取头像昵称) * 处理用户信息授权回调(用 code 调 /api/v1/user/info 获取头像昵称)
*/ */
async handleUserInfoCallback(code) { async handleUserInfoCallback(code) {
// 防止重复调用(实例级 + storage 级双重保护)
if (this.navigating) {
console.log('[Auth] 已在跳转中,忽略重复 handleUserInfoCallback');
return;
}
this.navigating = true;
uni.setStorageSync('__auth_callback_done', '1');
const appNo = uni.getStorageSync('app_no') || getAppNo(detectPlatform()); const appNo = uni.getStorageSync('app_no') || getAppNo(detectPlatform());
if (!appNo) { if (!appNo) {
@@ -319,6 +361,7 @@ export default {
const usedCode = uni.getStorageSync('__used_auth_code'); const usedCode = uni.getStorageSync('__used_auth_code');
if (usedCode === code) { if (usedCode === code) {
console.warn('[loading] code 已使用过,跳过'); console.warn('[loading] code 已使用过,跳过');
this.navigating = false;
return; return;
} }
uni.setStorageSync('__used_auth_code', code); uni.setStorageSync('__used_auth_code', code);
@@ -379,6 +422,7 @@ export default {
: '/pages/index/index?action=mine'; : '/pages/index/index?action=mine';
localStorage.removeItem('__auth_device_id'); localStorage.removeItem('__auth_device_id');
localStorage.removeItem('__auth_action'); localStorage.removeItem('__auth_action');
uni.removeStorageSync('__auth_callback_done');
uni.redirectTo({ url }); uni.redirectTo({ url });
}, },
@@ -388,6 +432,7 @@ export default {
? `/pages/index/index?device_id=${deviceId}` ? `/pages/index/index?device_id=${deviceId}`
: '/pages/index/index'; : '/pages/index/index';
localStorage.removeItem('__auth_device_id'); localStorage.removeItem('__auth_device_id');
uni.removeStorageSync('__auth_callback_done');
uni.redirectTo({ url }); uni.redirectTo({ url });
}, },
@@ -403,6 +448,7 @@ export default {
const url = this.deviceId const url = this.deviceId
? `/pages/register/register?device_id=${this.deviceId}` ? `/pages/register/register?device_id=${this.deviceId}`
: '/pages/register/register'; : '/pages/register/register';
uni.removeStorageSync('__auth_callback_done');
uni.redirectTo({ url }); uni.redirectTo({ url });
}, },
+1 -1
View File
@@ -30,7 +30,7 @@
<!-- 数量统计和筛选 --> <!-- 数量统计和筛选 -->
<view class="filter-bar"> <view class="filter-bar">
<text class="total-count">总数量: {{ filteredOrders.length }}</text> <text class="total-count">总数量: {{ total }}</text>
<view class="search-btn" @click="showFilterSidebar = true"> <view class="search-btn" @click="showFilterSidebar = true">
<text class="search-icon">🔍</text> <text class="search-icon">🔍</text>
</view> </view>