Compare commits

...

7 Commits

Author SHA1 Message Date
kk b1924e2623 userId 改为依赖 this.userInfo.user_id
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 47s
2026-07-11 20:29:00 +08:00
kk e12663052f 查询用户信息接口增加open_id参数
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 47s
2026-07-11 20:21:58 +08:00
kk 842defea21 注册成功后保存用户id与手机号
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 44s
2026-07-11 18:30:16 +08:00
kk d392ff98b7 apiBaseUrl改成https
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 41s
2026-07-11 18:22:44 +08:00
kk 18870f3e7d 注册成功后保存user_info
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 46s
2026-07-11 18:05:45 +08:00
kk 878778f8f9 解决code被重复使用的问题
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 41s
2026-07-11 17:52:33 +08:00
kk eac66c965b 修复bug
Uni-app H5 Deploy (Prod + Staging) / deploy (release) Successful in 41s
2026-07-11 17:22:41 +08:00
5 changed files with 61 additions and 30 deletions
+1 -2
View File
@@ -213,8 +213,7 @@ export default {
this.step = 'closed'; this.step = 'closed';
} else if (latestStatus === 201) { } else if (latestStatus === 201) {
this.step = 'complete'; this.step = 'complete';
const orderId = ret.data[0].order_id || ''; this.fetchOrder(flowId);
this.fetchOrder(orderId);
return; return;
} }
} }
+1 -1
View File
@@ -3,7 +3,7 @@
*/ */
const prod = { const prod = {
// 业务 API 地址(vms-api // 业务 API 地址(vms-api
apiBaseUrl: 'http://101.200.86.98:4000', apiBaseUrl: 'https://vmsapi.arklinksmart.cn',
// 网关地址(vms-gateway)— 用户授权、短信等接口走网关 // 网关地址(vms-gateway)— 用户授权、短信等接口走网关
apiGatewayUrl: 'https://gateway.arklinksmart.cn', apiGatewayUrl: 'https://gateway.arklinksmart.cn',
+35 -13
View File
@@ -72,6 +72,9 @@ export default {
* 发起 OAuth 授权(静默授权,只获取 openid) * 发起 OAuth 授权(静默授权,只获取 openid)
*/ */
async startAuth() { async startAuth() {
// 清除上次使用的 code 标记
uni.removeStorageSync('__used_auth_code');
const platform = detectPlatform(); const platform = detectPlatform();
const appNo = getAppNo(platform); const appNo = getAppNo(platform);
@@ -140,6 +143,20 @@ export default {
return; return;
} }
// 防止 code 重复提交:先检查再标记
const usedCode = uni.getStorageSync('__used_auth_code');
if (usedCode === code) {
console.warn('[loading] code 已使用过,跳过');
return;
}
uni.setStorageSync('__used_auth_code', code);
// 立即清除 URL 中的 code 参数,避免刷新重复处理
const url = new URL(window.location.href);
url.searchParams.delete('code');
url.searchParams.delete('state');
window.history.replaceState({}, '', url.toString());
try { try {
this.statusText = '正在验证身份...'; this.statusText = '正在验证身份...';
@@ -165,12 +182,6 @@ export default {
return; return;
} }
// 清除 URL 中的 code 参数,避免刷新重复处理
const url = new URL(window.location.href);
url.searchParams.delete('code');
url.searchParams.delete('state');
window.history.replaceState({}, '', url.toString());
// 存储 openid // 存储 openid
uni.setStorageSync('openid', openid); uni.setStorageSync('openid', openid);
@@ -219,6 +230,9 @@ export default {
* 发起非静默授权获取用户信息(snsapi_userinfo,弹窗确认) * 发起非静默授权获取用户信息(snsapi_userinfo,弹窗确认)
*/ */
async startUserInfoAuth() { async startUserInfoAuth() {
// 清除上次使用的 code 标记
uni.removeStorageSync('__used_auth_code');
const platform = detectPlatform(); const platform = detectPlatform();
const appNo = getAppNo(platform); const appNo = getAppNo(platform);
@@ -288,16 +302,24 @@ export default {
return; return;
} }
// 防止 code 重复提交
const usedCode = uni.getStorageSync('__used_auth_code');
if (usedCode === code) {
console.warn('[loading] code 已使用过,跳过');
return;
}
uni.setStorageSync('__used_auth_code', code);
// 立即清除 URL 中的 code/action 参数,避免刷新重复处理
const url = new URL(window.location.href);
url.searchParams.delete('code');
url.searchParams.delete('state');
url.searchParams.delete('action');
window.history.replaceState({}, '', url.toString());
try { try {
this.statusText = '正在获取用户信息...'; this.statusText = '正在获取用户信息...';
// 清除 URL 中的 code/action 参数,避免刷新重复处理
const url = new URL(window.location.href);
url.searchParams.delete('code');
url.searchParams.delete('state');
url.searchParams.delete('action');
window.history.replaceState({}, '', url.toString());
// 用 code 调用 POST /api/v1/user/info 获取用户信息(必须用 POST,GET 是另一个端点) // 用 code 调用 POST /api/v1/user/info 获取用户信息(必须用 POST,GET 是另一个端点)
console.log('[loading] 请求 POST user/info, app_no:', appNo, 'code:', code); console.log('[loading] 请求 POST user/info, app_no:', appNo, 'code:', code);
const res = await gatewayPost('/api/v1/user/info', { const res = await gatewayPost('/api/v1/user/info', {
+6 -5
View File
@@ -181,7 +181,7 @@ export default {
loading: false, loading: false,
categoryList: [], categoryList: [],
activeCategory: 'all', activeCategory: 'all',
userInfo: { nickname: '', phone: '', avatar: '' }, userInfo: { user_id: '', nickname: '', phone: '', avatar: '' },
avatarClickCount: 0, avatarClickCount: 0,
avatarClickTimer: null, avatarClickTimer: null,
fromPage: '', // 记录从哪个页面跳转过来的 fromPage: '', // 记录从哪个页面跳转过来的
@@ -199,8 +199,7 @@ export default {
}, },
computed: { computed: {
userId() { userId() {
const info = getCachedUserInfo(); return this.userInfo.user_id || '';
return (info && info.user_id) || '';
}, },
canGoBack() { canGoBack() {
// 有上一页,或者从 tab 切换过来的,都可以返回 // 有上一页,或者从 tab 切换过来的,都可以返回
@@ -304,7 +303,7 @@ export default {
if (cached) { if (cached) {
this.userInfo = { ...this.userInfo, ...cached }; this.userInfo = { ...this.userInfo, ...cached };
} else { } else {
this.userInfo = { nickname: '', phone: '', avatar: '' }; this.userInfo = { user_id: '', nickname: '', phone: '', avatar: '' };
} }
console.log('[index] this.userInfo:', JSON.stringify(this.userInfo, null, 2)); console.log('[index] this.userInfo:', JSON.stringify(this.userInfo, null, 2));
}, },
@@ -317,6 +316,7 @@ export default {
this.userInfo = { ...this.userInfo, ...cached }; this.userInfo = { ...this.userInfo, ...cached };
} else { } else {
this.userInfo = { this.userInfo = {
user_id: config.mockUser.user_info.user_id || '',
nickname: config.mockUser.user_info.nickname || '', nickname: config.mockUser.user_info.nickname || '',
phone: config.mockUser.user_info.phone || '', phone: config.mockUser.user_info.phone || '',
avatar: config.mockUser.user_info.avatar || '', avatar: config.mockUser.user_info.avatar || '',
@@ -415,7 +415,8 @@ export default {
// 检查用户信息,若缓存中没有则调接口获取 // 检查用户信息,若缓存中没有则调接口获取
if (!this.userId) { if (!this.userId) {
try { try {
const infoRes = await gatewayGet('/api/v1/user/info', {}); const openId = uni.getStorageSync('openid') || '';
const infoRes = await gatewayGet('/api/v1/user/info', { open_id: openId });
const infoData = (infoRes.data || {}).data || {}; const infoData = (infoRes.data || {}).data || {};
if (infoData.user_id) { if (infoData.user_id) {
const existing = getCachedUserInfo() || {}; const existing = getCachedUserInfo() || {};
+18 -9
View File
@@ -183,23 +183,32 @@ export default {
}); });
const ret = res.data || {}; const ret = res.data || {};
console.log('[register] 注册响应:', JSON.stringify(ret, null, 2));
if (ret.code === 0 && ret.data) { if (ret.code === 0 && ret.data) {
// 保存 token // 保存 token
uni.setStorageSync('token', ret.data.token); uni.setStorageSync('token', ret.data.token);
// Mock 模式下,合并真实注册信息和 mock 配置 // 存储 user_info(接口返回 user_info.user_id 和 phone
const existing = uni.getStorageSync('user_info') || {};
const apiUserInfo = ret.data.user_info || {};
const userInfo = {
user_id: apiUserInfo.user_id || existing.user_id || '',
phone: apiUserInfo.phone || this.phone || existing.phone || '',
nickname: existing.nickname || '',
avatar: existing.avatar || '',
};
// Mock 模式下补充 mock 数据
if (config.mockWechatLogin) { if (config.mockWechatLogin) {
const mockInfo = config.mockUser.user_info; const mockInfo = config.mockUser.user_info;
const userInfo = { userInfo.nickname = userInfo.nickname || mockInfo.nickname;
user_id: ret.data.user_id || mockInfo.user_id, userInfo.avatar = userInfo.avatar || mockInfo.avatar;
phone: this.phone, // 使用真实注册的手机号
nickname: mockInfo.nickname,
avatar: mockInfo.avatar,
};
uni.setStorageSync('user_info', userInfo);
console.log('[register] Mock 模式,合并用户信息:', userInfo);
} }
uni.setStorageSync('user_info', userInfo);
console.log('[register] 存储 user_info:', userInfo);
// 清除临时数据 // 清除临时数据
uni.removeStorageSync('temp_token'); uni.removeStorageSync('temp_token');
uni.removeStorageSync('auth_info'); uni.removeStorageSync('auth_info');