feat:登录

This commit is contained in:
2026-07-31 10:55:02 +08:00
parent 4b9e5a3cc1
commit 8225be60c6
6 changed files with 187 additions and 69 deletions
+108 -13
View File
@@ -12,23 +12,24 @@
<view class="login_info">
<view class="login_info_item">
<up-input placeholder="请输入手机号/账户名称" border="surround" v-model="form.name" :customStyle="inputCss"
@change="checkNameParam"></up-input>
:adjust-position="false" @change="checkNameParam"></up-input>
</view>
<!-- 密码登录 -->
<view class="login_info_item" v-if="loginWay === 'password'">
<up-input placeholder="请输入密码" border="surround" v-model="form.password" :customStyle="inputCss"
:type="isShow ? 'text' : 'password'" @change="checkParam">
:type="isShow ? 'text' : 'password'" :adjust-position="false" @change="checkParam">
<template #suffix style="margin-right: 10rpx">
<up-image v-if="isShow" src="/pages/login_package/static/login/show.png" width="20" height="20" bgColor="#f1f6ff00"
@click="isShow = false"></up-image>
<up-image v-else src="/pages/login_package/static/login/hidden.png" width="20" height="20" bgColor="#f1f6ff00"
@click="isShow = true"></up-image>
<up-image v-if="isShow" src="/pages/login_package/static/login/show.png" width="20" height="20"
bgColor="#f1f6ff00" @click="isShow = false"></up-image>
<up-image v-else src="/pages/login_package/static/login/hidden.png" width="20" height="20"
bgColor="#f1f6ff00" @click="isShow = true"></up-image>
</template>
</up-input>
</view>
<!-- 验证码登录 -->
<view class="login_info_item" v-else>
<up-input placeholder="请输入验证码" border="surround" v-model="form.code" :customStyle="inputCss">
<up-input placeholder="请输入验证码" border="surround" v-model="form.code" :customStyle="inputCss"
:adjust-position="false">
<template #suffix style="margin-right: 10rpx">
<view v-if="countdown" class="code-warp">
<up-count-down :time="60 * 1000" format="ss" @finish="countdown = false"></up-count-down>
@@ -56,14 +57,20 @@
<view class="other_login">其他登录方式</view>
<view class="login_other_icon">
<view class="login_other_item" @click="wechatOneLogin">
<up-image src="/pages/login_package/static/login/WXICON.png" width="44" height="44" bgColor="#f1f6ff00"></up-image>
<up-image src="/pages/login_package/static/login/WXICON.png" width="44" height="44"
bgColor="#f1f6ff00"></up-image>
微信登录
</view>
<!-- <view class="login_other_item" @click="aa"> -->
<view v-if="!isIOS" class="login_other_item" @click="alipayOneLogin">
<up-image src="/pages/login_package/static/login/ZFB.png" width="44" height="44" bgColor="#f1f6ff00"></up-image>
<up-image src="/pages/login_package/static/login/ZFB.png" width="44" height="44"
bgColor="#f1f6ff00"></up-image>
支付宝登录
</view>
<!-- <view v-if="isIOS" class="login_other_item" @click="appleOneLogin">
<up-icon name="apple-fill" size="44" color="#000000"></up-icon>
Apple登录
</view> -->
</view>
<!-- #endif -->
@@ -71,7 +78,8 @@
<view class="other_login">其他登录方式</view>
<!-- <view class="login_other_icon">
<view class="login_other_item" @click="wechatOneLogin">
<up-image src="/pages/login_package/static/login/WXICON.png" width="44" height="44" bgColor="#f1f6ff00"></up-image>
<up-image src="/pages/login_package/static/login/WXICON.png" width="44" height="44"
bgColor="#f1f6ff00"></up-image>
微信登录
</view>
</view> -->
@@ -123,7 +131,8 @@ import {
loginbysms,
loginbypw,
wechatLogin,
alipayLogin
alipayLogin,
appleLogin
} from "@/api/auth.js";
import {
setStorageFun,
@@ -337,12 +346,13 @@ export default {
const then = this;
this.loading = true;
console.log("微信登录--1", this.isPolicy)
// 检查是否同意协议
if (!this.isPolicy) {
uni.showModal({
title: '温馨提示',
content: '请您阅读并同意《服务协议》与《隐私政策》',
confirmText: "同意并登录",
confirmText: "同意登录",
success: (res) => {
if (res.confirm) {
this.isPolicy = true;
@@ -350,6 +360,10 @@ export default {
} else {
this.loading = false;
}
},
fail: (err) => {
this.loading = false;
console.log('showModal error:', err);
}
});
return;
@@ -427,7 +441,7 @@ export default {
uni.showModal({
title: '温馨提示',
content: '请您阅读并同意《服务协议》与《隐私政策》',
confirmText: "同意并登录",
confirmText: "同意登录",
success: (res) => {
if (res.confirm) {
this.isPolicy = true;
@@ -435,6 +449,10 @@ export default {
} else {
this.loading = false;
}
},
fail: (err) => {
this.loading = false;
console.log('showModal error:', err);
}
});
return;
@@ -477,6 +495,83 @@ export default {
this.isPolicy = true;
this.loginFun();
},
// Apple 登录 (仅 App iOS 端)
async appleOneLogin() {
this.loading = true;
// 检查是否同意协议
if (!this.isPolicy) {
uni.showModal({
title: '温馨提示',
content: '请您阅读并同意《服务协议》与《隐私政策》',
confirmText: "同意登录",
success: (res) => {
if (res.confirm) {
this.isPolicy = true;
this.appleOneLogin();
} else {
this.loading = false;
}
},
fail: (err) => {
this.loading = false;
console.log('showModal error:', err);
}
});
return;
}
// #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);
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
},
},
computed: {
isIOS() {