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