You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
785 B

11 months ago
import { getWxId } from "../apis/api.js";
//登录获取、持久化 id token
export function wxLogin() {
uni.login({
success(res) {
if (res.code) {
getWxId({
code: res.code,
}).then((wxInfo: any) => {
if (wxInfo.success) {
uni.setStorageSync("token", wxInfo.token);
uni.setStorageSync("id", wxInfo.id);
} else {
uni.showToast({
icon: "fail",
title: "用户信息获取失败!",
});
}
});
} else {
uni.showToast({
icon: "fail",
title: "登录失败!",
});
}
},
fail() {
uni.showToast({
icon: "fail",
title: "登录失败!",
});
},
});
}