pref: 小程序添加静默登录

This commit is contained in:
2026-04-28 10:31:54 +08:00
parent f07facd98b
commit e1a9d97596
3 changed files with 416 additions and 354 deletions

View File

@@ -86,18 +86,17 @@ const handleLogin = async () => {
icon: "none",
});
}
await doLogin();
};
async function doLogin() {
loading.value = true;
try {
const wxResult = await wxLogin();
const fileManager = uni.getFileSystemManager();
const avatarBase64 = fileManager.readFileSync(avatarUrl.value, "base64");
const base64Url = `data:image/png;base64,${avatarBase64}`;
const result = await loginAPI(
phone.value,
nickName.value,
base64Url,
wxResult.code
);
await loginAPI(phone.value, nickName.value, base64Url, wxResult.code);
const data = await getHomeData();
if (data.user) updateUser(data.user);
const devices = await getMyDevicesAPI();
@@ -139,6 +138,10 @@ const openPrivacyLink = () => {
onShow(() => {
loading.value = false;
agree.value = false;
phone.value = "";
avatarUrl.value = "";
nickName.value = "";
});
</script>