213
This commit is contained in:
parent
738d66c016
commit
8bff2ca405
|
|
@ -415,13 +415,14 @@ export default {
|
|||
margin: 30rpx auto 0;
|
||||
width: 686rpx;
|
||||
height: 84rpx;
|
||||
background: url($imgurl + "common/payBtn.png") no-repeat 0 0 / 100% 100%;
|
||||
background: #03D8F4;
|
||||
border-radius: 14rpx;
|
||||
display: flex;
|
||||
margin-bottom: 90rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: 500;
|
||||
color: #cdef27;
|
||||
color: #404040;
|
||||
|
||||
>text:nth-child(1) {
|
||||
font-size: 28rpx;
|
||||
|
|
|
|||
|
|
@ -511,15 +511,14 @@
|
|||
margin: 30rpx auto 0;
|
||||
width: 686rpx;
|
||||
height: 84rpx;
|
||||
// background: url($imgurl + "common/payBtn.png") no-repeat 0 0 / 100% 100%;
|
||||
background-color: #424242;
|
||||
background: #03D8F4;
|
||||
border-radius: 14rpx;
|
||||
display: flex;
|
||||
margin-bottom: 90rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: 500;
|
||||
color: #FFED94;
|
||||
color: #404040;
|
||||
|
||||
>text:nth-child(1) {
|
||||
font-size: 28rpx;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
"path": "pages/user/login",
|
||||
"style": {
|
||||
"navigationBarTitleText": "登录",
|
||||
"navigationBarBackgroundColor": "#FFFFFF",
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTextStyle": "black"
|
||||
}
|
||||
},
|
||||
|
|
@ -72,7 +72,7 @@
|
|||
"path": "pages/user/bangding",
|
||||
"style": {
|
||||
"navigationBarTitleText": "绑定手机号",
|
||||
"navigationBarBackgroundColor": "#FFFFFF",
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTextStyle": "black"
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,28 +1,26 @@
|
|||
<template>
|
||||
<view style="background-color: white; width: 100%; min-height: 100vh;">
|
||||
<!-- <uni-popup ref="popup" type="bottom"> -->
|
||||
<view class="header">
|
||||
<image :src="$img1('common/logo.png?x=1')"></image>
|
||||
<view class="bindphone-page">
|
||||
<!-- 返回按钮 -->
|
||||
<view class="nav-back" @click="back">
|
||||
<text class="back-icon">‹</text>
|
||||
</view>
|
||||
<view class="" style="width: 676rpx; height: 2rpx; background-color: #E8E8E8; margin-left: 38rpx;">
|
||||
|
||||
</view>
|
||||
<view class="content">
|
||||
<view>申请获取以下权限</view>
|
||||
<text style="color: #979797;">获得您的手机号</text>
|
||||
</view>
|
||||
<!-- type='primary' -->
|
||||
<view class="flex center column" style="width: 100%;">
|
||||
<button class="bottom flex center" withCredentials="true" lang="zh_CN" open-type="getPhoneNumber"
|
||||
@getphonenumber="getPhoneNumber">
|
||||
授权手机号
|
||||
|
||||
<!-- 页面标题 -->
|
||||
<view class="nav-title">绑定手机号</view>
|
||||
|
||||
<!-- 占位区域,背景图已包含Logo和欢迎语 -->
|
||||
<view class="logo-section"></view>
|
||||
|
||||
<!-- 底部绑定区域 -->
|
||||
<view class="bindphone-bottom">
|
||||
<!-- 小程序授权手机号按钮 -->
|
||||
<button class="bind-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
|
||||
绑定手机号
|
||||
</button>
|
||||
|
||||
<view class="quxiao" @click="back()">取消</view>
|
||||
|
||||
<!-- 跳过按钮 -->
|
||||
<view class="skip-btn" @click="back()">取消</view>
|
||||
</view>
|
||||
|
||||
|
||||
<!-- </uni-popup> -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -31,129 +29,127 @@ import { bindMobileByWx } from '@/common/server/auth.js';
|
|||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
z_imgPath: this.$z_img2
|
||||
}
|
||||
},
|
||||
created() {
|
||||
//默认加载
|
||||
// this.login();
|
||||
return {}
|
||||
},
|
||||
methods: {
|
||||
back() {
|
||||
// 尝试返回上一页
|
||||
let that = this;
|
||||
uni.navigateBack({
|
||||
fail: function() {
|
||||
// 如果返回失败,表示没有上一页,则跳转到首页
|
||||
that.$customRouter.navigateTo('/pages/user/index', {}, 'reLaunch');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
async getPhoneNumber(e) {
|
||||
// console.log(e)
|
||||
let that = this
|
||||
if (!e.detail.code) {
|
||||
return uni.showToast({ title: '授权失败,请重试', icon: 'none' });
|
||||
}
|
||||
|
||||
let that = this;
|
||||
uni.login({
|
||||
async success(res) {
|
||||
// console.log(res)
|
||||
uni.checkSession({
|
||||
async success() {
|
||||
const result = await bindMobileByWx(e.detail.code);
|
||||
if (result.status == 1) {
|
||||
if(result.data!=null&&result.data.token!=null){
|
||||
uni.setStorageSync('token', result.data.token);
|
||||
}
|
||||
uni.showToast({
|
||||
title: '绑定成功~',
|
||||
icon: 'success',
|
||||
success() {
|
||||
// var pageurl = uni.getStorageSync(
|
||||
// 'page');
|
||||
setTimeout(() => {
|
||||
// 返回上一页而不是跳转到首页
|
||||
uni.navigateBack({
|
||||
fail: function() {
|
||||
// 如果返回失败,表示没有上一页,则跳转到首页
|
||||
that.$customRouter.navigateTo('/pages/user/index', {}, 'reLaunch');
|
||||
}
|
||||
});
|
||||
}, 1000)
|
||||
try {
|
||||
const result = await bindMobileByWx(e.detail.code);
|
||||
if (result.status == 1) {
|
||||
if (result.data?.token) {
|
||||
uni.setStorageSync('token', result.data.token);
|
||||
}
|
||||
})
|
||||
uni.showToast({
|
||||
title: '绑定成功~',
|
||||
icon: 'success',
|
||||
success() {
|
||||
setTimeout(() => {
|
||||
uni.navigateBack({
|
||||
fail: function() {
|
||||
that.$customRouter.navigateTo('/pages/user/index', {}, 'reLaunch');
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uni.showToast({ title: result.msg || '绑定失败', icon: 'none' });
|
||||
}
|
||||
} catch (error) {
|
||||
uni.showToast({ title: '绑定失败,请重试', icon: 'none' });
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* .box {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
} */
|
||||
|
||||
.header {
|
||||
padding-top: 90rpx;
|
||||
/* padding: 90rpx 0 90rpx 50rpx; */
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
height: 300rpx;
|
||||
line-height: 450rpx;
|
||||
}
|
||||
|
||||
.header image {
|
||||
width: 200rpx; height: 200rpx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.content {
|
||||
margin-top: 68rpx;
|
||||
margin-left: 50rpx;
|
||||
margin-bottom: 90rpx;
|
||||
color: #333333;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.content text {
|
||||
display: block;
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
|
||||
.bottom {
|
||||
/* border-radius: 80rpx; */
|
||||
width: 416rpx;
|
||||
height: 80rpx;
|
||||
margin: 70rpx 50rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
button::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
button {
|
||||
background: #333333;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
color: #CDEF27;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.quxiao {
|
||||
background-color: #CDEF27;
|
||||
width: 416rpx;
|
||||
height: 80rpx;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 16rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
color: #333333;
|
||||
}
|
||||
</style>
|
||||
<style lang="scss" scoped>
|
||||
.bindphone-page {
|
||||
min-height: 100vh;
|
||||
background: url('https://youdas-1308826010.cos.ap-shanghai.myqcloud.com/static/web/static/common/bj.png') no-repeat center top / 100% auto;
|
||||
background-color: #FFFFFF;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.nav-back {
|
||||
position: absolute;
|
||||
top: 88rpx;
|
||||
left: 32rpx;
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.back-icon {
|
||||
font-size: 40rpx;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
.nav-title {
|
||||
position: absolute;
|
||||
top: 88rpx;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
font-size: 34rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.logo-section {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.bindphone-bottom {
|
||||
padding: 0 48rpx 80rpx;
|
||||
|
||||
.bind-btn {
|
||||
width: 100%;
|
||||
height: 96rpx;
|
||||
background: #03D8F4;
|
||||
border-radius: 48rpx;
|
||||
font-size: 32rpx;
|
||||
color: #FFFFFF;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
.skip-btn {
|
||||
margin-top: 32rpx;
|
||||
text-align: center;
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,100 +1,64 @@
|
|||
<template>
|
||||
<view class="all">
|
||||
<!-- 小程序登录界面 -->
|
||||
<view v-if="isCanUse && isMpWeixin">
|
||||
<view>
|
||||
<view class="header">
|
||||
<image :src="$img1('common/logo.jpg?x=1')"></image>
|
||||
<view class="login-page">
|
||||
<!-- 返回按钮 -->
|
||||
<view class="nav-back" @click="navigateBack">
|
||||
<text class="back-icon">‹</text>
|
||||
</view>
|
||||
|
||||
<!-- 页面标题 -->
|
||||
<view class="nav-title">登录</view>
|
||||
|
||||
<!-- 占位区域,背景图已包含Logo和欢迎语 -->
|
||||
<view class="logo-section"></view>
|
||||
|
||||
<!-- 底部登录区域 -->
|
||||
<view class="login-bottom">
|
||||
<!-- 小程序一键登录按钮 -->
|
||||
<button v-if="isMpWeixin" class="login-btn" @click="getUserProfile">
|
||||
一键注册/登录
|
||||
</button>
|
||||
|
||||
<!-- H5手机号登录按钮 -->
|
||||
<button v-else class="login-btn" @click="showPhoneLogin = true">
|
||||
一键注册/登录
|
||||
</button>
|
||||
|
||||
<!-- 协议勾选 -->
|
||||
<view class="agree-section" @click="isAgree = !isAgree">
|
||||
<view class="check-icon">
|
||||
<image v-if="isAgree" :src="$img1('common/check_act.png')"></image>
|
||||
<image v-else :src="$img1('common/check.png')"></image>
|
||||
</view>
|
||||
<view class="content">
|
||||
<view>申请获取以下权限</view>
|
||||
<text style="color: #979797;">获得你的公开信息</text>
|
||||
</view>
|
||||
|
||||
<view @click="isAgree = !isAgree" class="agree">
|
||||
<view class="icon">
|
||||
<image v-if="isAgree" :src="$img1('common/check_act.png')" lazy-load></image>
|
||||
|
||||
<image v-else :src="$img1('common/check.png')" lazy-load></image>
|
||||
</view>
|
||||
|
||||
<view class="agree-r">
|
||||
我已阅读并同意
|
||||
<text @click.stop="$customRouter.navigateTo('/pages/guize/guize', {type: 4})">
|
||||
《用户协议》
|
||||
</text>
|
||||
和
|
||||
<text @click.stop="$customRouter.navigateTo('/pages/guize/guize', {type: 5})">
|
||||
《隐私政策》
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="btn-list">
|
||||
<view @click="navigateBack()" class="cancel">
|
||||
拒绝
|
||||
</view>
|
||||
<button class="bottom center" type="primary" withCredentials="true" lang="zh_CN"
|
||||
@click="getUserProfile">
|
||||
<text>授权登录</text>
|
||||
</button>
|
||||
</view>
|
||||
<view style="font-size: 20rpx;color: #979797;position: fixed;bottom: 20rpx;right:47rpx;">version:v1.0.3
|
||||
<view class="agree-text">
|
||||
注册即同意<text class="link" @click.stop="goAgreement(4)">《用户协议》</text>和<text class="link" @click.stop="goAgreement(5)">《隐私政策》</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- H5手机号登录界面 -->
|
||||
<view v-if="isCanUse && !isMpWeixin">
|
||||
<view>
|
||||
<view class="header">
|
||||
<image :src="$img1('common/logo.png?x=1')"></image>
|
||||
|
||||
<!-- H5手机号登录弹窗 -->
|
||||
<uni-popup ref="phonePopup" type="bottom" v-if="!isMpWeixin">
|
||||
<view class="phone-login-popup">
|
||||
<view class="popup-header">
|
||||
<text class="popup-title">手机号登录</text>
|
||||
<view class="popup-close" @click="$refs.phonePopup.close()">×</view>
|
||||
</view>
|
||||
|
||||
<view class="h5-login-form">
|
||||
<view class="input-item">
|
||||
<input type="number" v-model="mobile" placeholder="请输入手机号" maxlength="11" class="phone-input" />
|
||||
|
||||
<view class="phone-form">
|
||||
<view class="input-row">
|
||||
<input type="number" v-model="mobile" placeholder="请输入手机号" maxlength="11" />
|
||||
</view>
|
||||
|
||||
<view class="input-item code-item">
|
||||
<input type="number" v-model="verifyCode" placeholder="请输入验证码" maxlength="6"
|
||||
class="code-input" />
|
||||
<view @click="sendVerifyCode" class="send-code-btn" :class="{ disabled: countdown > 0 }">
|
||||
{{ countdown > 0 ? countdown + '秒' : '发送验证码' }}
|
||||
|
||||
<view class="input-row code-row">
|
||||
<input type="number" v-model="verifyCode" placeholder="请输入验证码" maxlength="6" />
|
||||
<view class="send-btn" :class="{ disabled: countdown > 0 }" @click="sendVerifyCode">
|
||||
{{ countdown > 0 ? countdown + 's' : '获取验证码' }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view @click="isAgree = !isAgree" class="agree">
|
||||
<view class="icon">
|
||||
<image v-if="isAgree" :src="$img1('common/check_act.png')" lazy-load></image>
|
||||
<image v-else :src="$img1('common/check.png')" lazy-load></image>
|
||||
</view>
|
||||
<view class="agree-r">
|
||||
我已阅读并同意
|
||||
<text @click.stop="$platform.getUserAgreement()">
|
||||
《用户协议》
|
||||
</text>
|
||||
和
|
||||
<text @click.stop="$platform.getPrivacyAgreement()">
|
||||
《隐私政策》
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="btn-list">
|
||||
<view @click="navigateBack()" class="cancel">
|
||||
拒绝
|
||||
</view>
|
||||
<view class="bottom center" @click="phoneLogin">
|
||||
<text>登录</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view style="font-size: 20rpx;color: #979797;position: fixed;bottom: 20rpx;right:47rpx;">version:v1.0.3
|
||||
|
||||
<button class="submit-btn" @click="phoneLogin">登录</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
|
@ -105,105 +69,79 @@
|
|||
export default {
|
||||
data() {
|
||||
return {
|
||||
z_imgPath: this.$z_img2,
|
||||
SessionKey: '',
|
||||
OpenId: '',
|
||||
nickName: null,
|
||||
avatarUrl: null,
|
||||
isCanUse: uni.getStorageSync('isCanUse') || true, //默认为true
|
||||
code: '',
|
||||
isAgree: false,
|
||||
// H5手机号登录相关数据
|
||||
isMpWeixin: false, // 是否为小程序环境
|
||||
mobile: '', // 手机号
|
||||
verifyCode: '', // 验证码
|
||||
countdown: 0, // 发送验证码倒计时
|
||||
timer: null, // 倒计时定时器
|
||||
codeSent: false // 是否已发送验证码
|
||||
isMpWeixin: false,
|
||||
showPhoneLogin: false,
|
||||
mobile: '',
|
||||
verifyCode: '',
|
||||
countdown: 0,
|
||||
timer: null,
|
||||
codeSent: false
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
// 判断当前环境
|
||||
onLoad() {
|
||||
// #ifdef MP
|
||||
this.isMpWeixin = true;
|
||||
// #endif
|
||||
|
||||
//默认加载
|
||||
if (option != null) {
|
||||
if (option.code != null) {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
onUnload() {
|
||||
// 清除定时器
|
||||
if (this.timer) {
|
||||
clearInterval(this.timer);
|
||||
this.timer = null;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
showPhoneLogin(val) {
|
||||
if (val && this.$refs.phonePopup) {
|
||||
this.$refs.phonePopup.open();
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
//返回上一页
|
||||
navigateBack() {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
fail: () => {
|
||||
// 如果没有上一页,则跳转到首页
|
||||
this.$customRouter.navigateTo('/pages/shouye/index', {}, 'switchTab');
|
||||
}
|
||||
});
|
||||
},
|
||||
//第一授权获取用户信息===》按钮触发
|
||||
getUserProfile(e) {
|
||||
if (!this.isAgree) {
|
||||
return uni.showToast({
|
||||
title: '请阅读并同意《用户协议》和《隐私政策》',
|
||||
icon: 'none'
|
||||
});
|
||||
|
||||
goAgreement(type) {
|
||||
// #ifdef MP
|
||||
this.$customRouter.navigateTo('/pages/guize/guize', { type });
|
||||
// #endif
|
||||
// #ifndef MP
|
||||
if (type === 4) {
|
||||
this.$platform.getUserAgreement();
|
||||
} else {
|
||||
this.$platform.getPrivacyAgreement();
|
||||
}
|
||||
// #endif
|
||||
},
|
||||
|
||||
getUserProfile() {
|
||||
if (!this.isAgree) {
|
||||
return uni.showToast({ title: '请先同意用户协议和隐私政策', icon: 'none' });
|
||||
}
|
||||
|
||||
// #ifdef MP
|
||||
this.wxUserProfile();
|
||||
// #endif
|
||||
},
|
||||
// 发送验证码
|
||||
|
||||
async sendVerifyCode() {
|
||||
// 如果正在倒计时,不允许重复发送
|
||||
if (this.countdown > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否同意协议
|
||||
if (!this.isAgree) {
|
||||
return uni.showToast({
|
||||
title: '请阅读并同意《用户协议》和《隐私政策》',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
|
||||
// 验证手机号
|
||||
if (this.countdown > 0) return;
|
||||
|
||||
if (!this.mobile || !/^1\d{10}$/.test(this.mobile)) {
|
||||
return uni.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
icon: 'none'
|
||||
});
|
||||
return uni.showToast({ title: '请输入正确的手机号', icon: 'none' });
|
||||
}
|
||||
|
||||
// 发送验证码请求
|
||||
|
||||
try {
|
||||
const res = await sendSms(this.mobile);
|
||||
|
||||
if (res.status == 1) {
|
||||
uni.showToast({
|
||||
title: '验证码已发送',
|
||||
icon: 'none'
|
||||
});
|
||||
|
||||
// 标记已发送验证码(仅当前会话有效)
|
||||
uni.showToast({ title: '验证码已发送', icon: 'none' });
|
||||
this.codeSent = true;
|
||||
|
||||
// 开始倒计时,使用接口返回的时间
|
||||
this.countdown = res.data || 60; // 使用返回的秒数,默认60秒
|
||||
this.countdown = res.data || 60;
|
||||
this.timer = setInterval(() => {
|
||||
this.countdown--;
|
||||
if (this.countdown <= 0) {
|
||||
|
|
@ -212,212 +150,98 @@
|
|||
}
|
||||
}, 1000);
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg || '发送失败,请稍后重试',
|
||||
icon: 'none'
|
||||
});
|
||||
uni.showToast({ title: res.msg || '发送失败', icon: 'none' });
|
||||
}
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
title: '发送验证码失败,请稍后重试',
|
||||
icon: 'none'
|
||||
});
|
||||
console.error('发送验证码失败:', error);
|
||||
uni.showToast({ title: '发送失败,请稍后重试', icon: 'none' });
|
||||
}
|
||||
},
|
||||
// 手机号登录
|
||||
|
||||
async phoneLogin() {
|
||||
// 验证表单
|
||||
if (!this.isAgree) {
|
||||
return uni.showToast({
|
||||
title: '请阅读并同意《用户协议》和《隐私政策》',
|
||||
icon: 'none'
|
||||
});
|
||||
return uni.showToast({ title: '请先同意用户协议和隐私政策', icon: 'none' });
|
||||
}
|
||||
|
||||
if (!this.mobile || !/^1\d{10}$/.test(this.mobile)) {
|
||||
return uni.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
icon: 'none'
|
||||
});
|
||||
return uni.showToast({ title: '请输入正确的手机号', icon: 'none' });
|
||||
}
|
||||
|
||||
if (!this.verifyCode) {
|
||||
return uni.showToast({
|
||||
title: '请输入验证码',
|
||||
icon: 'none'
|
||||
});
|
||||
return uni.showToast({ title: '请输入验证码', icon: 'none' });
|
||||
}
|
||||
|
||||
// 检查当前会话中是否发送过验证码
|
||||
// if (!this.codeSent) {
|
||||
// return uni.showToast({
|
||||
// title: '请先发送验证码',
|
||||
// icon: 'none'
|
||||
// });
|
||||
// }
|
||||
|
||||
// 发送登录请求
|
||||
|
||||
try {
|
||||
const res = await mobileLogin(this.mobile, this.verifyCode, uni.getStorageSync('pid'));
|
||||
|
||||
if (res.status == 1) {
|
||||
// 使用新的Token存储方法,支持双Token格式
|
||||
saveLoginTokens(res.data);
|
||||
this.$c.msg("登录成功");
|
||||
|
||||
// 检查重定向URL
|
||||
const redirectUrl = uni.getStorageSync('redirect');
|
||||
|
||||
if (redirectUrl) {
|
||||
// 清除重定向信息
|
||||
uni.removeStorageSync('redirect');
|
||||
// 使用公共方法处理重定向
|
||||
this.handleRedirect(redirectUrl);
|
||||
} else {
|
||||
// 无重定向页面,检查是否需要绑定手机号
|
||||
setTimeout(() => {
|
||||
this.getdata();
|
||||
}, 1000);
|
||||
}
|
||||
this.handleLoginSuccess();
|
||||
} else {
|
||||
this.$c.msg("登录失败!" + res.msg);
|
||||
this.$c.msg("登录失败: " + res.msg);
|
||||
}
|
||||
} catch (error) {
|
||||
// this.$c.msg("登录请求失败,请稍后重试");
|
||||
console.error('登录失败:', error);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 处理登录成功后的重定向逻辑
|
||||
* @param {String} redirectUrl 重定向URL
|
||||
*/
|
||||
handleRedirect(redirectUrl) {
|
||||
let that = this;
|
||||
|
||||
// 获取当前页面栈
|
||||
const pages = getCurrentPages();
|
||||
|
||||
// 检查是否有上一页,以及redirect URL是否与上一页相同
|
||||
if (pages.length > 1) {
|
||||
const prevPage = pages[pages.length - 2];
|
||||
// 构建完整的上一页路径(带参数)
|
||||
let prevPageUrl = '/' + prevPage.route;
|
||||
if (prevPage.options && Object.keys(prevPage.options).length > 0) {
|
||||
const paramStr = Object.keys(prevPage.options)
|
||||
.map(key => `${key}=${prevPage.options[key]}`)
|
||||
.join('&');
|
||||
prevPageUrl += '?' + paramStr;
|
||||
}
|
||||
|
||||
// 比较redirect URL和上一页URL
|
||||
const redirectUrlPath = redirectUrl.split('?')[0];
|
||||
const prevPageUrlPath = prevPageUrl.split('?')[0];
|
||||
|
||||
if (redirectUrlPath === prevPageUrlPath) {
|
||||
// 如果路径相同,直接返回上一页
|
||||
console.log('重定向URL与上一页相同,直接返回');
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 1000);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 重定向到指定URL
|
||||
setTimeout(() => {
|
||||
that.$customRouter.navigateTo(redirectUrl).catch(err => {
|
||||
console.error('重定向跳转失败:', err)
|
||||
// 失败时跳转到首页
|
||||
that.$customRouter.navigateTo('/pages/user/index')
|
||||
})
|
||||
}, 1000);
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
async wxUserProfile() {
|
||||
try {
|
||||
const profileRes = await new Promise((resolve, reject) => {
|
||||
await new Promise((resolve, reject) => {
|
||||
uni.getUserProfile({
|
||||
desc: '用于向用户发送商品',
|
||||
desc: '用于完善用户资料',
|
||||
lang: 'zh_CN',
|
||||
success: resolve,
|
||||
fail: reject,
|
||||
complete: (e) => {
|
||||
console.log(e, '用于向用户发送商品');
|
||||
}
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
|
||||
try {
|
||||
const loginRes = await new Promise((resolve, reject) => {
|
||||
uni.login({
|
||||
provider: 'weixin',
|
||||
success: resolve,
|
||||
fail: (e) => {
|
||||
this.$c.msg("登录失败,网络错误!" + e.msg);
|
||||
console.log(e, '登录失败', e);
|
||||
reject(e);
|
||||
},
|
||||
complete: (e) => {
|
||||
console.log(e, '登录');
|
||||
}
|
||||
});
|
||||
|
||||
const loginRes = await new Promise((resolve, reject) => {
|
||||
uni.login({
|
||||
provider: 'weixin',
|
||||
success: resolve,
|
||||
fail: reject
|
||||
});
|
||||
|
||||
try {
|
||||
const res = await wxLogin({
|
||||
code: loginRes.code,
|
||||
nickname: '',
|
||||
headimg: '',
|
||||
pid: uni.getStorageSync('pid')
|
||||
});
|
||||
console.log(res, '登录成功');
|
||||
|
||||
if (res.status == 1) {
|
||||
// 使用新的Token存储方法,支持双Token格式
|
||||
saveLoginTokens(res.data);
|
||||
this.$c.msg("登录成功");
|
||||
|
||||
// 检查重定向URL
|
||||
const redirectUrl = uni.getStorageSync('redirect');
|
||||
|
||||
if (redirectUrl) {
|
||||
// 清除重定向信息
|
||||
uni.removeStorageSync('redirect');
|
||||
|
||||
// 使用公共方法处理重定向
|
||||
this.handleRedirect(redirectUrl);
|
||||
} else {
|
||||
// 无重定向页面,检查是否需要绑定手机号
|
||||
setTimeout(() => {
|
||||
this.getdata();
|
||||
}, 1000);
|
||||
}
|
||||
} else {
|
||||
this.$c.msg("登录失败!" + res.msg);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('请求登录失败:', error);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('微信登录失败:', error);
|
||||
});
|
||||
|
||||
const res = await wxLogin({
|
||||
code: loginRes.code,
|
||||
nickname: '',
|
||||
headimg: '',
|
||||
pid: uni.getStorageSync('pid')
|
||||
});
|
||||
|
||||
if (res.status == 1) {
|
||||
saveLoginTokens(res.data);
|
||||
this.$c.msg("登录成功");
|
||||
this.handleLoginSuccess();
|
||||
} else {
|
||||
this.$c.msg("登录失败: " + res.msg);
|
||||
}
|
||||
} catch (error) {
|
||||
this.$c.msg("登录失败,申请获取微信用户数据失败");
|
||||
console.log(error, '获取微信用户数据失败');
|
||||
this.$c.msg("登录失败,请重试");
|
||||
console.error('微信登录失败:', error);
|
||||
}
|
||||
},
|
||||
async getdata() {
|
||||
|
||||
async handleLoginSuccess() {
|
||||
const redirectUrl = uni.getStorageSync('redirect');
|
||||
if (redirectUrl) {
|
||||
uni.removeStorageSync('redirect');
|
||||
setTimeout(() => {
|
||||
this.$customRouter.navigateTo(redirectUrl).catch(() => {
|
||||
this.$customRouter.navigateTo('/pages/user/index');
|
||||
});
|
||||
}, 1000);
|
||||
} else {
|
||||
setTimeout(() => this.checkUserMobile(), 1000);
|
||||
}
|
||||
},
|
||||
|
||||
async checkUserMobile() {
|
||||
try {
|
||||
const res = await getUser();
|
||||
if (res.status == 1 && res.data.userinfo != null && res.data.userinfo.mobile_is == 0) {
|
||||
console.log("判断用户有没有手机号", res.data.userinfo.mobile_is);
|
||||
// 使用新的路由守卫方法跳转到绑定页面
|
||||
this.$customRouter.navigateTo('/pages/user/bangding', {}, 'navigateTo');
|
||||
if (res.status == 1 && res.data.userinfo?.mobile_is == 0) {
|
||||
this.$customRouter.navigateTo('/pages/user/bangding');
|
||||
} else {
|
||||
// 使用新的路由守卫方法跳转到用户首页
|
||||
this.$customRouter.navigateTo('/pages/user/index', {}, 'navigateTo');
|
||||
this.$customRouter.navigateTo('/pages/user/index');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取用户数据失败:', error);
|
||||
|
|
@ -427,142 +251,169 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.all {
|
||||
<style lang="scss" scoped>
|
||||
.login-page {
|
||||
min-height: 100vh;
|
||||
background: url($imgurl+'common/bj.png') no-repeat center top / 100% auto;
|
||||
background-color: #FFFFFF;
|
||||
// background: url($imgurl+'common/pageBg1.png') no-repeat 0 0 / 100% auto;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.header {
|
||||
margin: 0 0 90rpx 50rpx;
|
||||
padding: 90rpx 0 0;
|
||||
border-bottom: 1px solid #E8E8E8;
|
||||
text-align: center;
|
||||
width: 650rpx;
|
||||
height: 300rpx;
|
||||
line-height: 450rpx;
|
||||
|
||||
.nav-back {
|
||||
position: absolute;
|
||||
top: 88rpx;
|
||||
left: 32rpx;
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.back-icon {
|
||||
font-size: 40rpx;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
.header image {
|
||||
width: 200rpx;
|
||||
height: 200rpx;
|
||||
border-radius: 25%;
|
||||
|
||||
.nav-title {
|
||||
position: absolute;
|
||||
top: 88rpx;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
font-size: 34rpx;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.content {
|
||||
margin-left: 50rpx;
|
||||
margin-bottom: 90rpx;
|
||||
color: #333333;
|
||||
|
||||
.logo-section {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.content text {
|
||||
display: block;
|
||||
margin-top: 28rpx;
|
||||
}
|
||||
|
||||
// H5登录表单样式
|
||||
.h5-login-form {
|
||||
padding: 0 50rpx;
|
||||
|
||||
.input-item {
|
||||
height: 90rpx;
|
||||
border-bottom: 1px solid #E8E8E8;
|
||||
margin-bottom: 40rpx;
|
||||
|
||||
input {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
font-size: 28rpx;
|
||||
|
||||
.login-bottom {
|
||||
padding: 0 48rpx 80rpx;
|
||||
|
||||
.login-btn {
|
||||
width: 100%;
|
||||
height: 96rpx;
|
||||
background: #03D8F4;
|
||||
border-radius: 48rpx;
|
||||
font-size: 32rpx;
|
||||
color: #FFFFFF;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
.code-item {
|
||||
|
||||
.agree-section {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.code-input {
|
||||
flex: 1;
|
||||
justify-content: center;
|
||||
margin-top: 32rpx;
|
||||
|
||||
.check-icon {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
margin-right: 12rpx;
|
||||
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.send-code-btn {
|
||||
width: 200rpx;
|
||||
height: 70rpx;
|
||||
background-color: #333333;
|
||||
color: #CDEF27;
|
||||
|
||||
.agree-text {
|
||||
font-size: 24rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 12rpx;
|
||||
|
||||
&.disabled {
|
||||
background-color: #cccccc;
|
||||
color: #ffffff;
|
||||
color: #999;
|
||||
|
||||
.link {
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.agree {
|
||||
display: flex;
|
||||
padding: 0 50rpx;
|
||||
margin: 40rpx 0;
|
||||
|
||||
.icon {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
|
||||
// 手机号登录弹窗
|
||||
.phone-login-popup {
|
||||
background: #FFFFFF;
|
||||
border-radius: 32rpx 32rpx 0 0;
|
||||
padding: 40rpx 48rpx 80rpx;
|
||||
|
||||
.popup-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: relative;
|
||||
margin-bottom: 48rpx;
|
||||
|
||||
.popup-title {
|
||||
font-size: 34rpx;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.popup-close {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
font-size: 48rpx;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
||||
.agree-r {
|
||||
flex: 1;
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
padding-left: 20rpx;
|
||||
line-height: 32rpx;
|
||||
|
||||
font-size: 20rpx;
|
||||
color: #999999;
|
||||
|
||||
text {
|
||||
color: #333333;
|
||||
|
||||
.phone-form {
|
||||
.input-row {
|
||||
height: 100rpx;
|
||||
border-bottom: 1rpx solid #EEEEEE;
|
||||
margin-bottom: 32rpx;
|
||||
|
||||
input {
|
||||
height: 100%;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.code-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
input {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.send-btn {
|
||||
padding: 16rpx 24rpx;
|
||||
background: #333;
|
||||
color: #CDEF27;
|
||||
font-size: 26rpx;
|
||||
border-radius: 12rpx;
|
||||
|
||||
&.disabled {
|
||||
background: #CCC;
|
||||
color: #FFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.submit-btn {
|
||||
width: 100%;
|
||||
height: 96rpx;
|
||||
background: linear-gradient(90deg, #5CE1E6, #38D9A9);
|
||||
border-radius: 48rpx;
|
||||
font-size: 32rpx;
|
||||
color: #FFFFFF;
|
||||
margin-top: 48rpx;
|
||||
border: none;
|
||||
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.btn-list {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
padding: 50rpx 0 0;
|
||||
|
||||
.cancel {
|
||||
width: 200rpx;
|
||||
height: 80rpx;
|
||||
box-sizing: border-box;
|
||||
border-radius: 16rpx;
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #CDEF27;
|
||||
// filter: grayscale(1);
|
||||
}
|
||||
|
||||
.bottom {
|
||||
background: #333333;
|
||||
margin: 0;
|
||||
width: 416rpx;
|
||||
height: 80rpx;
|
||||
text-align: center;
|
||||
box-sizing: border-box;
|
||||
border-radius: 16rpx;
|
||||
font-size: 28rpx;
|
||||
color: #CDEF27;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user