Files
spring-festival-greetings/utils/login.js
2026-02-11 09:11:56 +08:00

54 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export const wxLogin = () => {
return new Promise((resolve, reject) => {
wx.login({
success: (res) => {
if (res.code) {
resolve(res.code);
} else {
reject("登录失败code为空");
}
},
fail: (err) => {
reject(err);
},
});
});
};
export const alipayLogin = () => {
return new Promise((resolve, reject) => {
// #ifdef MP-ALIPAY
my.getAuthCode({
scopes: "auth_user",
success: (res) => {
if (res.authCode) {
resolve(res.authCode);
} else {
reject("登录失败authCode为空");
}
},
fail: (err) => {
reject(err);
},
});
// #endif
// #ifndef MP-ALIPAY
reject("当前非支付宝环境");
// #endif
});
};
export const wxGetUserProfile = () => {
return new Promise((resolve, reject) => {
wx.getUserProfile({
desc: "用于完善用户信息",
success: (res) => {
resolve(res);
},
fail: (err) => {
reject(err);
},
});
});
};