Compare commits
No commits in common. "dad6a4734360624e5b7049c5d4cfb640eb9d7b25" and "3d23e69749858e9f2eb946d8bfee2b436b363776" have entirely different histories.
dad6a47343
...
3d23e69749
@ -10,17 +10,10 @@ export const goBack = () => uni.navigateBack({ delta: 1 });
|
||||
|
||||
// 登录逻辑
|
||||
export const onLogin = async (e) => {
|
||||
console.info("onLogin code: ", e.detail);
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
// 判断用户拒绝
|
||||
if (e.detail.errno === 104) {
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
|
||||
await loginAuth(e).then(async () => {
|
||||
return new Promise(async (resolve) => {
|
||||
await loginAuth().then(async () => {
|
||||
const { code } = e.detail;
|
||||
console.info("onLogin code: ", code);
|
||||
|
||||
// 绑定手机号
|
||||
const params = { wechatPhoneCode: code, clientId: clientId };
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
export const getWeChatAuthCode = (e) => {
|
||||
export const getWeChatAuthCode = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 条件编译微信小程序、抖音小程序
|
||||
let provider = "";
|
||||
@ -10,16 +10,10 @@ export const getWeChatAuthCode = (e) => {
|
||||
provider = "toutiao";
|
||||
// #endif
|
||||
|
||||
// 判断用户拒绝授权
|
||||
if (e.detail.errMsg === "getPhoneNumber:fail user deny") {
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
|
||||
uni.login({
|
||||
provider,
|
||||
onlyAuthorize: true,
|
||||
success: (res) => {
|
||||
console.log("微信登录成功", res);
|
||||
resolve(res.code);
|
||||
},
|
||||
fail: (err) => {
|
||||
|
||||
@ -8,13 +8,13 @@ import { useAppStore } from "@/store";
|
||||
import { clientId } from "@/constant/base";
|
||||
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
||||
|
||||
const loginAuth = (e) => {
|
||||
const loginAuth = () => {
|
||||
uni.setStorageSync("token", "");
|
||||
const appStore = useAppStore();
|
||||
appStore.setHasToken(false);
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const openIdCode = await getWeChatAuthCode(e);
|
||||
const openIdCode = await getWeChatAuthCode();
|
||||
console.log("获取到的微信授权code:", openIdCode);
|
||||
const params = {
|
||||
openIdCode: [openIdCode],
|
||||
|
||||
@ -111,7 +111,12 @@ const getPhoneNumber = (e) => {
|
||||
});
|
||||
goBack();
|
||||
})
|
||||
.catch(() => {});
|
||||
.catch(() => {
|
||||
uni.showToast({
|
||||
title: "登录失败",
|
||||
icon: "none",
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// 处理同意协议点击事件
|
||||
|
||||
Loading…
Reference in New Issue
Block a user