feat:apple登录
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
<view class="login_info_item">
|
||||
<up-input placeholder="请输入手机号/账户名称" border="surround" v-model="form.name" :customStyle="inputCss"
|
||||
:adjust-position="false" @change="checkNameParam"></up-input>
|
||||
<qiaobao-assistant page-key="pages/login_package/login/login" title="账户登录" />
|
||||
</view>
|
||||
<qiaobao-assistant page-key="pages/login_package/login/login" title="账户登录" />
|
||||
</view>
|
||||
<!-- 密码登录 -->
|
||||
<view class="login_info_item" v-if="loginWay === 'password'">
|
||||
<up-input placeholder="请输入密码" border="surround" v-model="form.password" :customStyle="inputCss"
|
||||
@@ -81,7 +81,7 @@
|
||||
<view class="login_other_item" @click="wechatOneLogin(1)">
|
||||
<up-image src="/pages/login_package/static/login/WXICON.png" width="44" height="44"
|
||||
bgColor="#f1f6ff00"></up-image>
|
||||
微信登录11
|
||||
微信登录
|
||||
</view>
|
||||
</view>
|
||||
<view class="login_other_icon">
|
||||
@@ -524,57 +524,75 @@ export default {
|
||||
}
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
uni.login({
|
||||
provider: 'apple',
|
||||
success: async (loginRes) => {
|
||||
console.log('Apple 登录成功:', loginRes);
|
||||
const authResult = loginRes.authResult || {};
|
||||
const params = {
|
||||
identityToken: authResult.identityToken,
|
||||
openId: authResult.user,
|
||||
fullName: authResult.fullName ? `${authResult.fullName.familyName || ''}${authResult.fullName.givenName || ''}` : '',
|
||||
authorizationCode: authResult.authorizationCode
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await appleLogin(params);
|
||||
if (response && response.bizcode === 100) {
|
||||
if (response.data && response.data.userId) {
|
||||
this.loginWay = "apple";
|
||||
this.loginFun(response);
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: `/pages/login_package/bind-phone/bind-phone?token=${response.data.token}&type=3`,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.$refs.uToastRef.show({
|
||||
type: "error",
|
||||
message: response?.msg || "Apple登录失败",
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Apple登录异常:", error);
|
||||
uni.getProvider({
|
||||
service: 'oauth',
|
||||
success: (provRes) => {
|
||||
if (!provRes.provider || !provRes.provider.includes('apple')) {
|
||||
this.loading = false;
|
||||
this.$refs.uToastRef.show({
|
||||
type: "error",
|
||||
message: "Apple登录异常,请重试",
|
||||
message: "当前运行环境或自定义基座未支持 Apple 登录",
|
||||
});
|
||||
} finally {
|
||||
this.loading = false;
|
||||
return;
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
this.loading = false;
|
||||
console.error('Apple登录授权失败:', err);
|
||||
this.$refs.uToastRef.show({
|
||||
type: "error",
|
||||
message: "Apple登录授权失败",
|
||||
uni.login({
|
||||
provider: 'apple',
|
||||
success: async (loginRes) => {
|
||||
console.log('Apple 登录成功:', loginRes);
|
||||
const authResult = loginRes.appleInfo || {};
|
||||
const params = {
|
||||
identityToken: authResult.identityToken,
|
||||
// openId: authResult.user,
|
||||
// fullName: authResult.fullName ? `${authResult.fullName.familyName || ''}${authResult.fullName.givenName || ''}` : '',
|
||||
// authorizationCode: authResult.authorizationCode
|
||||
};
|
||||
|
||||
console.log("Apple 登录成功-0:", params)
|
||||
try {
|
||||
const response = await appleLogin(params);
|
||||
console.log("Apple 登录成功-1:", response)
|
||||
if (response && response.bizcode === 100) {
|
||||
|
||||
if (response.data && response.data.userId) {
|
||||
this.loginWay = "apple";
|
||||
this.loginFun(response);
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: `/pages/login_package/bind-phone/bind-phone?token=${response.data.token}&type=3`,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log("Apple 登录成功-2:", response)
|
||||
this.$refs.uToastRef.show({
|
||||
type: "error",
|
||||
message: response?.msg || "Apple登录失败",
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Apple登录异常:", error);
|
||||
this.$refs.uToastRef.show({
|
||||
type: "error",
|
||||
message: "Apple登录异常,请重试",
|
||||
});
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
this.loading = false;
|
||||
console.error('Apple登录授权失败:', err);
|
||||
this.$refs.uToastRef.show({
|
||||
type: "error",
|
||||
message: "Apple登录授权失败",
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// #endif
|
||||
},
|
||||
// #endif
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
isIOS() {
|
||||
// #ifdef APP-PLUS
|
||||
|
||||
Reference in New Issue
Block a user