fix: 后端接口改为java,联调接口修改。

This commit is contained in:
tianyongbao
2026-01-12 00:36:05 +08:00
parent 7e10c62cf9
commit b2f7f5fe1e
21 changed files with 550 additions and 259 deletions

View File

@@ -141,12 +141,27 @@ function wxLoginCheck() {
/** 微信登录 */
function wxLogin(e) {
isLoading.value = true;
console.log('获取手机号返回:', e.detail);
// 用户拒绝授权
if (!e.detail.code) {
state.msg = "获取手机号失败,请允许授权";
state.show = true;
isLoading.value = false;
return;
}
if (e.detail.code) {
Taro.login({
success: function (res) {
console.log('微信登录返回:', res);
if (res.code) {
loginWxToPhone({ code: e.detail.code, js_code: res.code })
const params = { code: e.detail.code, js_code: res.code };
console.log('调用登录接口参数:', params);
loginWxToPhone(params)
.then((res) => {
console.log('登录接口返回:', res);
if (res.statusCode == 200) {
Taro.setStorageSync(
"ReTime",
@@ -169,27 +184,32 @@ function wxLogin(e) {
url: "/pages/main/home",
});
return;
} else {
state.msg = `登录失败:${res.data?.msg || '服务器返回异常'}`;
state.show = true;
}
})
.catch((err) => {
console.error('登录接口错误:', err);
state.msg = `登录失败:${err.data?.msg || err.errMsg || '网络错误'}`;
state.show = true;
})
.finally(() => {
isLoading.value = false;
});
} else {
state.msg = "登录失败";
state.msg = "微信登录失败,请重试";
state.show = true;
isLoading.value = false;
}
},
fail: function () {
state.msg = "登录失败";
fail: function (err) {
console.error('微信登录失败:', err);
state.msg = `微信登录失败:${err.errMsg || '未知错误'}`;
state.show = true;
isLoading.value = false;
},
});
} else {
state.msg = "登录失败";
state.show = true;
isLoading.value = false;
}
}
/** 查看用户协议 */