feat:登录
This commit is contained in:
@@ -12,8 +12,8 @@
|
||||
"type" : "uni-app:app-ios"
|
||||
},
|
||||
{
|
||||
"customPlaygroundType" : "device",
|
||||
"playground" : "standard",
|
||||
"customPlaygroundType" : "local",
|
||||
"playground" : "custom",
|
||||
"type" : "uni-app:app-ios_simulator"
|
||||
}
|
||||
]
|
||||
|
||||
+10
@@ -165,3 +165,13 @@ export function alipayLogin(params) {
|
||||
cha:1
|
||||
});
|
||||
}
|
||||
|
||||
// Apple一键登录
|
||||
export function appleLogin(params) {
|
||||
return request({
|
||||
url: "/auth/loginByApple",
|
||||
method: "post",
|
||||
data: params,
|
||||
cha:1
|
||||
});
|
||||
}
|
||||
|
||||
+2
-1
@@ -91,7 +91,8 @@
|
||||
"weixin" : {
|
||||
"appid" : "wx7a5902cd556d9396",
|
||||
"UniversalLinks" : "https://app.tbmall.xin/uni-universallinks/__UNI__4910728/"
|
||||
}
|
||||
},
|
||||
"apple" : {}
|
||||
},
|
||||
"share" : {
|
||||
"weixin" : {
|
||||
|
||||
+4
-1
@@ -516,7 +516,10 @@
|
||||
{
|
||||
"path": "login/login",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
"navigationStyle": "custom",
|
||||
"app-plus": {
|
||||
"softinputMode": "adjustResize"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -5,13 +5,15 @@
|
||||
<view class="setting-view">
|
||||
<view class="mid-view">
|
||||
<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">
|
||||
<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>
|
||||
<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">
|
||||
<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>
|
||||
@@ -32,14 +34,14 @@ import func from '@/utils/func.js';
|
||||
import AccountItem from './components/account-item.vue'
|
||||
|
||||
export default {
|
||||
components: { Header, TopSafe,MyBtn,AccountItem },
|
||||
components: { Header, TopSafe, MyBtn, AccountItem },
|
||||
data() {
|
||||
return {
|
||||
topText:'',
|
||||
type:0,
|
||||
account:'',
|
||||
name:'',
|
||||
wxCode:'',
|
||||
topText: '',
|
||||
type: 0,
|
||||
account: '',
|
||||
name: '',
|
||||
wxCode: '',
|
||||
inputCss: {
|
||||
"height": '80rpx',
|
||||
"background": "#F3F3F3FF",
|
||||
@@ -50,28 +52,28 @@ export default {
|
||||
};
|
||||
},
|
||||
onLoad(option) {
|
||||
if(option && option.type){
|
||||
if (option && option.type) {
|
||||
this.type = Number(option.type);
|
||||
this.init();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
if(this.type == 0 ){
|
||||
if (this.type == 0) {
|
||||
this.topText = '绑定支付宝账户';
|
||||
}else if(this.type == 1){
|
||||
} else if (this.type == 1) {
|
||||
this.topText = '绑定微信账户';
|
||||
}
|
||||
},
|
||||
setBindWithdraw(){
|
||||
if(!this.account){
|
||||
setBindWithdraw() {
|
||||
if (!this.account) {
|
||||
this.$refs.uToastRef.show({
|
||||
type: 'error',
|
||||
message: '账户不可为空',
|
||||
});
|
||||
return;
|
||||
}
|
||||
if(!this.name){
|
||||
if (!this.name) {
|
||||
this.$refs.uToastRef.show({
|
||||
type: 'error',
|
||||
message: '名字不可为空',
|
||||
@@ -79,15 +81,19 @@ export default {
|
||||
return;
|
||||
}
|
||||
let params = {
|
||||
platform:this.type + 1,
|
||||
accountNumber:this.account,
|
||||
accountName:this.name
|
||||
platform: this.type + 1,
|
||||
accountNumber: this.account,
|
||||
accountName: this.name
|
||||
}
|
||||
if(this.type == 1){
|
||||
if (this.type == 1) {
|
||||
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) {
|
||||
this.$refs.uToastRef.show({
|
||||
type: 'success',
|
||||
@@ -95,9 +101,9 @@ export default {
|
||||
});
|
||||
this.account = '';
|
||||
this.name = '';
|
||||
setTimeout(()=>{
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
},1000)
|
||||
}, 1000)
|
||||
} else {
|
||||
this.$refs.uToastRef.show({
|
||||
type: 'error',
|
||||
@@ -107,43 +113,44 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
onAdd(){
|
||||
if(this.type == 1){
|
||||
onAdd() {
|
||||
if (this.type == 1) {
|
||||
let _this = this;
|
||||
uni.login({
|
||||
provider: 'weixin',
|
||||
onlyAuthorize:true,
|
||||
success: function (loginRes) {
|
||||
_this.wxCode = loginRes.code;
|
||||
console.log('aaaaa',loginRes.code)
|
||||
console.log('bbbb',loginRes)
|
||||
_this.setBindWithdraw();
|
||||
},
|
||||
fail:(err)=>{
|
||||
console.log('login',err);
|
||||
}
|
||||
provider: 'weixin',
|
||||
onlyAuthorize: true,
|
||||
success: function (loginRes) {
|
||||
_this.wxCode = loginRes.code;
|
||||
console.log('aaaaa', loginRes.code)
|
||||
console.log('bbbb', loginRes)
|
||||
_this.setBindWithdraw();
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('login', err);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
} else {
|
||||
this.setBindWithdraw();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.bottom-btn{
|
||||
.bottom-btn {
|
||||
width: 100%;
|
||||
margin-bottom:92rpx;
|
||||
margin-bottom: 92rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 0 32rpx;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.setting-view {
|
||||
width: 100%;
|
||||
height: calc(100% - 88rpx - 92rpx - 88rpx - var(--status-bar-height));
|
||||
@@ -154,8 +161,9 @@ export default {
|
||||
padding: 0 32rpx;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
.mid-view{
|
||||
width:100%;
|
||||
|
||||
.mid-view {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow-y: auto;
|
||||
@@ -163,20 +171,21 @@ export default {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 48rpx 32rpx;
|
||||
margin-top:24rpx;
|
||||
.input-view{
|
||||
width:100%;
|
||||
height:100rpx;
|
||||
margin-top: 24rpx;
|
||||
|
||||
.input-view {
|
||||
width: 100%;
|
||||
height: 100rpx;
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 20rpx;
|
||||
margin-top:32rpx;
|
||||
margin-top: 32rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user