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
+2 -2
View File
@@ -12,8 +12,8 @@
"type" : "uni-app:app-ios" "type" : "uni-app:app-ios"
}, },
{ {
"customPlaygroundType" : "device", "customPlaygroundType" : "local",
"playground" : "standard", "playground" : "custom",
"type" : "uni-app:app-ios_simulator" "type" : "uni-app:app-ios_simulator"
} }
] ]
+10
View File
@@ -165,3 +165,13 @@ export function alipayLogin(params) {
cha:1 cha:1
}); });
} }
// Apple一键登录
export function appleLogin(params) {
return request({
url: "/auth/loginByApple",
method: "post",
data: params,
cha:1
});
}
+2 -1
View File
@@ -91,7 +91,8 @@
"weixin" : { "weixin" : {
"appid" : "wx7a5902cd556d9396", "appid" : "wx7a5902cd556d9396",
"UniversalLinks" : "https://app.tbmall.xin/uni-universallinks/__UNI__4910728/" "UniversalLinks" : "https://app.tbmall.xin/uni-universallinks/__UNI__4910728/"
} },
"apple" : {}
}, },
"share" : { "share" : {
"weixin" : { "weixin" : {
+4 -1
View File
@@ -516,7 +516,10 @@
{ {
"path": "login/login", "path": "login/login",
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom",
"app-plus": {
"softinputMode": "adjustResize"
}
} }
}, },
{ {
+108 -13
View File
@@ -12,23 +12,24 @@
<view class="login_info"> <view class="login_info">
<view class="login_info_item"> <view class="login_info_item">
<up-input placeholder="请输入手机号/账户名称" border="surround" v-model="form.name" :customStyle="inputCss" <up-input placeholder="请输入手机号/账户名称" border="surround" v-model="form.name" :customStyle="inputCss"
@change="checkNameParam"></up-input> :adjust-position="false" @change="checkNameParam"></up-input>
</view> </view>
<!-- 密码登录 --> <!-- 密码登录 -->
<view class="login_info_item" v-if="loginWay === 'password'"> <view class="login_info_item" v-if="loginWay === 'password'">
<up-input placeholder="请输入密码" border="surround" v-model="form.password" :customStyle="inputCss" <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"> <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" <up-image v-if="isShow" src="/pages/login_package/static/login/show.png" width="20" height="20"
@click="isShow = false"></up-image> 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" <up-image v-else src="/pages/login_package/static/login/hidden.png" width="20" height="20"
@click="isShow = true"></up-image> bgColor="#f1f6ff00" @click="isShow = true"></up-image>
</template> </template>
</up-input> </up-input>
</view> </view>
<!-- 验证码登录 --> <!-- 验证码登录 -->
<view class="login_info_item" v-else> <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"> <template #suffix style="margin-right: 10rpx">
<view v-if="countdown" class="code-warp"> <view v-if="countdown" class="code-warp">
<up-count-down :time="60 * 1000" format="ss" @finish="countdown = false"></up-count-down> <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="other_login">其他登录方式</view>
<view class="login_other_icon"> <view class="login_other_icon">
<view class="login_other_item" @click="wechatOneLogin"> <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>
<!-- <view class="login_other_item" @click="aa"> --> <!-- <view class="login_other_item" @click="aa"> -->
<view v-if="!isIOS" class="login_other_item" @click="alipayOneLogin"> <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>
<!-- <view v-if="isIOS" class="login_other_item" @click="appleOneLogin">
<up-icon name="apple-fill" size="44" color="#000000"></up-icon>
Apple登录
</view> -->
</view> </view>
<!-- #endif --> <!-- #endif -->
@@ -71,7 +78,8 @@
<view class="other_login">其他登录方式</view> <view class="other_login">其他登录方式</view>
<!-- <view class="login_other_icon"> <!-- <view class="login_other_icon">
<view class="login_other_item" @click="wechatOneLogin"> <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>
</view> --> </view> -->
@@ -123,7 +131,8 @@ import {
loginbysms, loginbysms,
loginbypw, loginbypw,
wechatLogin, wechatLogin,
alipayLogin alipayLogin,
appleLogin
} from "@/api/auth.js"; } from "@/api/auth.js";
import { import {
setStorageFun, setStorageFun,
@@ -337,12 +346,13 @@ export default {
const then = this; const then = this;
this.loading = true; this.loading = true;
console.log("微信登录--1", this.isPolicy)
// 检查是否同意协议 // 检查是否同意协议
if (!this.isPolicy) { if (!this.isPolicy) {
uni.showModal({ uni.showModal({
title: '温馨提示', title: '温馨提示',
content: '请您阅读并同意《服务协议》与《隐私政策》', content: '请您阅读并同意《服务协议》与《隐私政策》',
confirmText: "同意并登录", confirmText: "同意登录",
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
this.isPolicy = true; this.isPolicy = true;
@@ -350,6 +360,10 @@ export default {
} else { } else {
this.loading = false; this.loading = false;
} }
},
fail: (err) => {
this.loading = false;
console.log('showModal error:', err);
} }
}); });
return; return;
@@ -427,7 +441,7 @@ export default {
uni.showModal({ uni.showModal({
title: '温馨提示', title: '温馨提示',
content: '请您阅读并同意《服务协议》与《隐私政策》', content: '请您阅读并同意《服务协议》与《隐私政策》',
confirmText: "同意并登录", confirmText: "同意登录",
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
this.isPolicy = true; this.isPolicy = true;
@@ -435,6 +449,10 @@ export default {
} else { } else {
this.loading = false; this.loading = false;
} }
},
fail: (err) => {
this.loading = false;
console.log('showModal error:', err);
} }
}); });
return; return;
@@ -477,6 +495,83 @@ export default {
this.isPolicy = true; this.isPolicy = true;
this.loginFun(); 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: { computed: {
isIOS() { isIOS() {
+61 -52
View File
@@ -5,13 +5,15 @@
<view class="setting-view"> <view class="setting-view">
<view class="mid-view"> <view class="mid-view">
<text class="text-gray text-32" v-if="type == 1">注:请与当前登录微信信息一致</text> <text class="text-gray text-32" v-if="type == 1">注:请与当前登录微信信息一致</text>
<text class="text-gray text-32 mt-24">{{type == 0 ? '支付宝账号' : '微信账号'}}</text> <text class="text-gray text-32 mt-24">{{ type == 0 ? '支付宝账号' : '微信账号' }}</text>
<view class="input-view"> <view class="input-view">
<up-input :placeholder="`请输入${type == 0 ? '支付宝' : '微信'}账号`" border="surround" v-model="account" :customStyle="inputCss"></up-input> <up-input :placeholder="`请输入${type == 0 ? '支付宝' : '微信'}账号`" border="surround" v-model="account"
:customStyle="inputCss"></up-input>
</view> </view>
<text class="text-gray text-32 mt-48">{{type == 0 ? '支付宝姓名' : '微信姓名'}}</text> <text class="text-gray text-32 mt-48">{{ type == 0 ? '支付宝姓名' : '微信姓名' }}</text>
<view class="input-view"> <view class="input-view">
<up-input :placeholder="`请输入${type == 0 ? '支付宝' : '微信真实'}姓名`" border="surround" v-model="name" :customStyle="inputCss"></up-input> <up-input :placeholder="`请输入${type == 0 ? '支付宝' : '微信真实'}姓名`" border="surround" v-model="name"
:customStyle="inputCss"></up-input>
</view> </view>
</view> </view>
</view> </view>
@@ -32,14 +34,14 @@ import func from '@/utils/func.js';
import AccountItem from './components/account-item.vue' import AccountItem from './components/account-item.vue'
export default { export default {
components: { Header, TopSafe,MyBtn,AccountItem }, components: { Header, TopSafe, MyBtn, AccountItem },
data() { data() {
return { return {
topText:'', topText: '',
type:0, type: 0,
account:'', account: '',
name:'', name: '',
wxCode:'', wxCode: '',
inputCss: { inputCss: {
"height": '80rpx', "height": '80rpx',
"background": "#F3F3F3FF", "background": "#F3F3F3FF",
@@ -50,28 +52,28 @@ export default {
}; };
}, },
onLoad(option) { onLoad(option) {
if(option && option.type){ if (option && option.type) {
this.type = Number(option.type); this.type = Number(option.type);
this.init(); this.init();
} }
}, },
methods: { methods: {
init() { init() {
if(this.type == 0 ){ if (this.type == 0) {
this.topText = '绑定支付宝账户'; this.topText = '绑定支付宝账户';
}else if(this.type == 1){ } else if (this.type == 1) {
this.topText = '绑定微信账户'; this.topText = '绑定微信账户';
} }
}, },
setBindWithdraw(){ setBindWithdraw() {
if(!this.account){ if (!this.account) {
this.$refs.uToastRef.show({ this.$refs.uToastRef.show({
type: 'error', type: 'error',
message: '账户不可为空', message: '账户不可为空',
}); });
return; return;
} }
if(!this.name){ if (!this.name) {
this.$refs.uToastRef.show({ this.$refs.uToastRef.show({
type: 'error', type: 'error',
message: '名字不可为空', message: '名字不可为空',
@@ -79,15 +81,19 @@ export default {
return; return;
} }
let params = { let params = {
platform:this.type + 1, platform: this.type + 1,
accountNumber:this.account, accountNumber: this.account,
accountName:this.name accountName: this.name
} }
if(this.type == 1){ if (this.type == 1) {
params['code'] = this.wxCode; params['code'] = this.wxCode;
} }
console.log('wxCode',params)
bindWithdraw(params).then(res=>{ // #ifdef MP-WEIXIN
params.platform = 3;
// #endif
console.log('wxCode', params)
bindWithdraw(params).then(res => {
if (res.bizcode === 100) { if (res.bizcode === 100) {
this.$refs.uToastRef.show({ this.$refs.uToastRef.show({
type: 'success', type: 'success',
@@ -95,9 +101,9 @@ export default {
}); });
this.account = ''; this.account = '';
this.name = ''; this.name = '';
setTimeout(()=>{ setTimeout(() => {
uni.navigateBack(); uni.navigateBack();
},1000) }, 1000)
} else { } else {
this.$refs.uToastRef.show({ this.$refs.uToastRef.show({
type: 'error', type: 'error',
@@ -107,43 +113,44 @@ export default {
} }
}) })
}, },
onAdd(){ onAdd() {
if(this.type == 1){ if (this.type == 1) {
let _this = this; let _this = this;
uni.login({ uni.login({
provider: 'weixin', provider: 'weixin',
onlyAuthorize:true, onlyAuthorize: true,
success: function (loginRes) { success: function (loginRes) {
_this.wxCode = loginRes.code; _this.wxCode = loginRes.code;
console.log('aaaaa',loginRes.code) console.log('aaaaa', loginRes.code)
console.log('bbbb',loginRes) console.log('bbbb', loginRes)
_this.setBindWithdraw(); _this.setBindWithdraw();
}, },
fail:(err)=>{ fail: (err) => {
console.log('login',err); console.log('login', err);
} }
}); });
}else{ } else {
this.setBindWithdraw(); this.setBindWithdraw();
} }
} }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.bottom-btn{ .bottom-btn {
width: 100%; width: 100%;
margin-bottom:92rpx; margin-bottom: 92rpx;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
padding: 0 32rpx; padding: 0 32rpx;
box-sizing: border-box; box-sizing: border-box;
position: relative; position: relative;
} }
.setting-view { .setting-view {
width: 100%; width: 100%;
height: calc(100% - 88rpx - 92rpx - 88rpx - var(--status-bar-height)); height: calc(100% - 88rpx - 92rpx - 88rpx - var(--status-bar-height));
@@ -154,8 +161,9 @@ export default {
padding: 0 32rpx; padding: 0 32rpx;
box-sizing: border-box; box-sizing: border-box;
position: relative; position: relative;
.mid-view{
width:100%; .mid-view {
width: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
overflow-y: auto; overflow-y: auto;
@@ -163,20 +171,21 @@ export default {
background-color: #fff; background-color: #fff;
border-radius: 16rpx; border-radius: 16rpx;
padding: 48rpx 32rpx; padding: 48rpx 32rpx;
margin-top:24rpx; margin-top: 24rpx;
.input-view{
width:100%; .input-view {
height:100rpx; width: 100%;
height: 100rpx;
background-color: #f5f5f5; background-color: #f5f5f5;
border-radius: 20rpx; border-radius: 20rpx;
margin-top:32rpx; margin-top: 32rpx;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
} }
} }
} }
</style> </style>