新增注册,找回密码功能页面
This commit is contained in:
@ -15,6 +15,7 @@ export function resourceSmsCode(params) {
|
||||
data: params
|
||||
})
|
||||
}
|
||||
|
||||
// 退出登录
|
||||
export function Logout(data) {
|
||||
return request({
|
||||
@ -24,7 +25,38 @@ export function Logout(data) {
|
||||
})
|
||||
}
|
||||
|
||||
// 注册
|
||||
export function register(data) {
|
||||
return request({
|
||||
url: '/app/auth/register',
|
||||
method: 'POST',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 用户注册短信验证码
|
||||
export function registerSmsCode(data) {
|
||||
return request({
|
||||
url: '/app/auth/registerSmsCode',
|
||||
method: 'GET',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 忘记密码短信验证码
|
||||
export function forgetPasswordSmsCode(data) {
|
||||
return request({
|
||||
url: '/app/auth/forgetPasswordSmsCode',
|
||||
method: 'GET',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 找回密码登录
|
||||
export function forgetPassword(data) {
|
||||
return request({
|
||||
url: '/app/auth/forgetPassword',
|
||||
method: 'POST',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
6
package-lock.json
generated
6
package-lock.json
generated
@ -6,6 +6,7 @@
|
||||
"": {
|
||||
"dependencies": {
|
||||
"axios": "^1.9.0",
|
||||
"blueimp-md5": "^2.19.0",
|
||||
"cordova-sqlite-storage": "^7.0.0",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"mescroll-uni": "^1.3.7",
|
||||
@ -29,6 +30,11 @@
|
||||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/blueimp-md5": {
|
||||
"version": "2.19.0",
|
||||
"resolved": "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz",
|
||||
"integrity": "sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w=="
|
||||
},
|
||||
"node_modules/call-bind-apply-helpers": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"axios": "^1.9.0",
|
||||
"blueimp-md5": "^2.19.0",
|
||||
"cordova-sqlite-storage": "^7.0.0",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"mescroll-uni": "^1.3.7",
|
||||
|
||||
23
pages.json
23
pages.json
@ -1,12 +1,26 @@
|
||||
{
|
||||
"pages": [
|
||||
|
||||
// 登录
|
||||
{
|
||||
"path": "pages/common/login/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
// 注册
|
||||
{
|
||||
"path": "pages/common/register/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
// 忘记密码
|
||||
{
|
||||
"path": "pages/common/forgotPassword/index",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"path": "pages/common/index/index",
|
||||
@ -276,10 +290,9 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/670/History",
|
||||
"style" :
|
||||
{
|
||||
"navigationBarTitleText" : "历史记录"
|
||||
"path": "pages/670/History",
|
||||
"style": {
|
||||
"navigationBarTitleText": "历史记录"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
431
pages/common/forgotPassword/index.vue
Normal file
431
pages/common/forgotPassword/index.vue
Normal file
@ -0,0 +1,431 @@
|
||||
<template>
|
||||
<view class="pageContent">
|
||||
<image src="/static/images/common/login.png" mode="" class="login-bg"></image>
|
||||
<view class="content_con">
|
||||
找回密码
|
||||
</view>
|
||||
<view class="content">
|
||||
<view class='ver_item'>
|
||||
<input type="number" v-model="phone" :maxlength="11" placeholder="请输入手机号" class="input" />
|
||||
</view>
|
||||
<view class='ver_item'>
|
||||
<input type="number" v-model="code" :maxlength="6" placeholder="请输入验证码" class="input" />
|
||||
<button :class="showView?' get_phone_number blue':'get_phone_number grad'"
|
||||
@click="getPhoneCode">{{ isCounting ? `${countdown}s后重新获取` : '获取验证码' }}</button>
|
||||
</view>
|
||||
<view class='ver_item'>
|
||||
<input type="password" v-model="password" placeholder="请设置新密码(6—20个数字或字母)" class="input" />
|
||||
</view>
|
||||
<!-- 登录按钮 -->
|
||||
<button class="login-btn" @click="handleLogin">
|
||||
确定
|
||||
</button>
|
||||
<view class="login-title">已有账号?<text class="gologin" @click="goLogin">去登录</text></view>
|
||||
<!-- 协议勾选 -->
|
||||
<view class="agreement">
|
||||
<view class="custom-checkbox" @click="toggleCheck">
|
||||
<view class="checkbox-icon" :class="{ checked: isChecked }">
|
||||
<uni-icons v-if="isChecked" type="checkmarkempty" size="8" color="#fff"></uni-icons>
|
||||
</view>
|
||||
<text class="checkbox-label">我已认真阅读,理解并同意<a class="agreeT"
|
||||
@click.stop="goToPage('agreement')">《用户服务协议》</a>及<a class="agreeT"
|
||||
@click.stop="goToPage('privacy')">《隐私政策》</a></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 弹框 -->
|
||||
<view class="agreement-mask" v-if="showAgreement">
|
||||
<!-- 协议弹窗 -->
|
||||
<view class="agreement-popup" @click.stop>
|
||||
<!-- 标题 -->
|
||||
<view class="popup-title">服务协议及隐私政策</view>
|
||||
<!-- 协议内容 -->
|
||||
<view class="popup-content">
|
||||
为了更好的保障您的合法权益,请您阅读并同意以下协议
|
||||
<text class="protocol-link" @click="openProtocol('user')">《用户服务协议》</text>
|
||||
<text class="protocol-link" @click="openProtocol('privacy')">《隐私政策》</text>
|
||||
</view>
|
||||
<!-- 按钮组 -->
|
||||
<view class="popup-buttons">
|
||||
<button class="btn disagree" @click="handleDisagree">不同意</button>
|
||||
<button class="btn agree" @click="handleAgree">同意</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import md5 from 'blueimp-md5'
|
||||
import {
|
||||
forgetPassword,
|
||||
forgetPasswordSmsCode
|
||||
} from '@/api/common/login.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
showView: false,
|
||||
phone: '13800138002', //手机号码
|
||||
code: "123456", //验证码
|
||||
password: '', //密码
|
||||
agreed: false,
|
||||
isCounting: false,
|
||||
countdown: 0,
|
||||
isChecked: true,
|
||||
showAgreement: false, // 控制弹窗显示
|
||||
}
|
||||
},
|
||||
onLoad() {},
|
||||
methods: {
|
||||
// 获取验证码
|
||||
async getPhoneCode() {
|
||||
const phoneNumber = this.phone
|
||||
const myreg = /^1[3456789]\d{9}$/;
|
||||
if (!phoneNumber) {
|
||||
uni.showToast({
|
||||
title: '手机号不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
return false;
|
||||
} else if (!myreg.test(phoneNumber)) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
const res = await forgetPasswordSmsCode({
|
||||
phonenumber: this.phone
|
||||
})
|
||||
if (res.code == 200) {
|
||||
// 更新倒计时状态
|
||||
this.isCounting = true;
|
||||
this.showView = true;
|
||||
this.countdown = 60
|
||||
const timer = setInterval(() => {
|
||||
this.countdown--
|
||||
if (this.countdown <= 0) {
|
||||
clearInterval(timer)
|
||||
this.isCounting = false;
|
||||
this.showView = false;
|
||||
}
|
||||
}, 1000)
|
||||
uni.showToast({
|
||||
title: '验证码已发送',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
} catch (error) {}
|
||||
},
|
||||
// 勾选同意
|
||||
toggleCheck() {
|
||||
this.isChecked = !this.isChecked
|
||||
},
|
||||
// 登录
|
||||
goLogin() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/login/index'
|
||||
})
|
||||
},
|
||||
// 登录
|
||||
async handleLogin() {
|
||||
if (this.phone == '') {
|
||||
uni.showToast({
|
||||
title: '手机号不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
} else if (this.code == '') {
|
||||
uni.showToast({
|
||||
title: '验证码不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
}
|
||||
if (!this.password) {
|
||||
uni.showToast({
|
||||
title: '请设置新密码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
return false
|
||||
}
|
||||
if (!this.isChecked) {
|
||||
this.showAgreement = true
|
||||
return false
|
||||
}
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
})
|
||||
// 调用忘记密码接口
|
||||
const res = await forgetPassword({
|
||||
phonenumber: this.phone,
|
||||
smsCode: this.code,
|
||||
tenantId: '894078', //租户ID
|
||||
password: md5(this.password)
|
||||
})
|
||||
if (res.code == 200) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '密码修改成功',
|
||||
icon: 'success'
|
||||
})
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/login/index'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('捕获错误:', error);
|
||||
uni.showToast({
|
||||
title: error.msg || '登录失败',
|
||||
icon: 'none'
|
||||
});
|
||||
uni.hideLoading()
|
||||
}
|
||||
},
|
||||
// 跳转到协议页面
|
||||
goToPage(type) {
|
||||
const url = type === 'agreement' ?
|
||||
'/pages/common/userAgreement/index' // 服务协议
|
||||
:
|
||||
'/pages/common/privacyAgreement/index'; // 隐私政策
|
||||
uni.navigateTo({
|
||||
url: url
|
||||
});
|
||||
},
|
||||
|
||||
// 不同意
|
||||
handleDisagree() {
|
||||
this.showAgreement = false
|
||||
},
|
||||
// 同意
|
||||
handleAgree() {
|
||||
this.isChecked = !this.isChecked
|
||||
this.showAgreement = false
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.pageContent {
|
||||
background: rgb(26, 26, 26);
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.login-bg {
|
||||
background-size: 100% 100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.content {
|
||||
height: 70%;
|
||||
width: 100%;
|
||||
background: rgb(26, 26, 26);
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
border-radius: 60px 60px 0px 0px;
|
||||
box-sizing: border-box;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.content_con {
|
||||
position: absolute;
|
||||
top: 220rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
left: 30rpx;
|
||||
font-size: 60rpx;
|
||||
}
|
||||
|
||||
.input {
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
height: 80rpx;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
margin-top: 50rpx;
|
||||
}
|
||||
|
||||
.ver_item {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.get_phone_number {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
color: #999;
|
||||
top: 1rpx;
|
||||
background: rgb(26, 26, 26);
|
||||
border: none;
|
||||
text-align: right;
|
||||
font-size: 28rpx;
|
||||
font-family: PingFangSC-Medium, PingFang SC;
|
||||
}
|
||||
|
||||
.grad {
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.blue {
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.agreement {
|
||||
margin: 50rpx 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
position: absolute;
|
||||
bottom: 8rpx
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
margin-top: 90rpx;
|
||||
background-color: rgb(187, 230, 0);
|
||||
color: rgb(35, 35, 35);
|
||||
border-radius: 50rpx;
|
||||
}
|
||||
|
||||
.login-btn[disabled] {
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
|
||||
.gologin {
|
||||
color: rgba(187, 230, 0, 1);
|
||||
}
|
||||
|
||||
.custom-checkbox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.checkbox-icon {
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
border: 1px solid rgba(255, 255, 255, 0.87);
|
||||
border-radius: 50rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.checkbox-icon.checked {
|
||||
background-color: #07C160;
|
||||
border-color: #07C160;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.checkbox-label {
|
||||
font-size: 24rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
}
|
||||
|
||||
.agreeT {
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
/* 遮罩层 */
|
||||
.agreement-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
/* 弹窗主体 */
|
||||
.agreement-popup {
|
||||
width: 80%;
|
||||
background-color: rgba(42, 42, 42);
|
||||
border-radius: 16rpx;
|
||||
padding: 40rpx;
|
||||
box-sizing: border-box;
|
||||
border: 1rpx solid rgba(187, 230, 0, 0.3)
|
||||
}
|
||||
|
||||
/* 标题 */
|
||||
.popup-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
margin-bottom: 30rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
}
|
||||
|
||||
/* 内容文本 */
|
||||
.popup-content {
|
||||
font-size: 30rpx;
|
||||
line-height: 1.6;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
margin-bottom: 50rpx;
|
||||
}
|
||||
|
||||
/* 协议链接 */
|
||||
.protocol-link {
|
||||
color: rgb(187, 230, 0);
|
||||
margin: 0 10rpx;
|
||||
}
|
||||
|
||||
/* 按钮容器 */
|
||||
.popup-buttons {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
/* 通用按钮样式 */
|
||||
.btn {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
font-size: 32rpx;
|
||||
margin: 0 20rpx;
|
||||
}
|
||||
|
||||
/* 不同意按钮 */
|
||||
.disagree {
|
||||
background-color: transparent;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
border: 1px solid rgb(255, 255, 255);
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
/* 同意按钮 */
|
||||
.agree {
|
||||
background-color: rgb(187, 230, 0);
|
||||
color: #232323;
|
||||
border: none;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
</style>
|
||||
@ -8,11 +8,26 @@
|
||||
<view class='ver_item'>
|
||||
<input type="number" v-model="phone" :maxlength="11" placeholder="请输入手机号" class="input" />
|
||||
</view>
|
||||
<view class='ver_item'>
|
||||
<view class='ver_item' v-if="isCodeLogin">
|
||||
<input type="number" v-model="code" :maxlength="6" placeholder="请输入验证码" class="input" />
|
||||
<button :class="showView?' get_phone_number blue':'get_phone_number grad'"
|
||||
@click="getPhoneCode">{{ isCounting ? `${countdown}s后重新获取` : '获取验证码' }}</button>
|
||||
</view>
|
||||
<view class='ver_item' v-else>
|
||||
<input type="password" v-model="password" placeholder="请输入密码" class="input" />
|
||||
</view>
|
||||
<view class="switch-flex">
|
||||
<view class="switch-login" @click="switchLogin">
|
||||
{{ isCodeLogin ? '密码登录' : '验证码登录' }}
|
||||
</view>
|
||||
<view v-if="!isCodeLogin" @click="forgotPassword">忘记密码</view>
|
||||
</view>
|
||||
<!-- 登录按钮 -->
|
||||
<button class="login-btn" @click="handleLogin">
|
||||
登录
|
||||
</button>
|
||||
<view class="login-title">没有账号?<text class="gologin" @click="goLogin">去注册</text></view>
|
||||
|
||||
<!-- 协议勾选 -->
|
||||
<view class="agreement">
|
||||
<view class="custom-checkbox" @click="toggleCheck">
|
||||
@ -24,10 +39,6 @@
|
||||
@click.stop="goToPage('privacy')">《隐私政策》</a></text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 登录按钮 -->
|
||||
<button class="login-btn" @click="handleLogin">
|
||||
登录
|
||||
</button>
|
||||
</view>
|
||||
<!-- 弹框 -->
|
||||
<view class="agreement-mask" v-if="showAgreement">
|
||||
@ -52,6 +63,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import md5 from 'blueimp-md5'
|
||||
import {
|
||||
login,
|
||||
resourceSmsCode
|
||||
@ -62,37 +74,48 @@
|
||||
showView: false,
|
||||
phone: '13800138002', //手机号码
|
||||
code: "123456", //验证码
|
||||
password: "",
|
||||
agreed: false,
|
||||
isCounting: false,
|
||||
countdown: 0,
|
||||
isChecked: true,
|
||||
showAgreement: false, // 控制弹窗显示
|
||||
isCodeLogin: false,
|
||||
}
|
||||
},
|
||||
onLoad(){
|
||||
if(uni.getStorageSync("token") && uni.getStorageSync("clientID")){//免登陆
|
||||
onLoad() {
|
||||
if (uni.getStorageSync("token") && uni.getStorageSync("clientID")) { //免登陆
|
||||
let time = uni.getStorageSync("tokenTime");
|
||||
if (!time) {
|
||||
time = 0;
|
||||
}
|
||||
let currTime = new Date().getTime();
|
||||
if (currTime < time) {
|
||||
console.log("登陆过,并且没过期,自动进入设备页");
|
||||
uni.switchTab({
|
||||
url: '/pages/common/index/index'
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
//token过期了
|
||||
uni.removeStorageSync("token")
|
||||
uni.removeStorageSync("clientID")
|
||||
uni.removeStorageSync("tokenTime")
|
||||
}
|
||||
|
||||
let time=uni.getStorageSync("tokenTime");
|
||||
if(!time){
|
||||
time=0;
|
||||
}
|
||||
let currTime=new Date().getTime();
|
||||
if(currTime<time){
|
||||
console.log("登陆过,并且没过期,自动进入设备页");
|
||||
uni.switchTab({
|
||||
url: '/pages/common/index/index'
|
||||
});
|
||||
return;
|
||||
}else{
|
||||
//token过期了
|
||||
uni.removeStorageSync("token")
|
||||
uni.removeStorageSync("clientID")
|
||||
uni.removeStorageSync("tokenTime")
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 验证码密码切换
|
||||
switchLogin() {
|
||||
this.isCodeLogin = !this.isCodeLogin;
|
||||
// 切换时重置相关输入和状态
|
||||
this.code = "";
|
||||
this.password = "";
|
||||
this.isCounting = false;
|
||||
this.countdown = 0;
|
||||
this.showView = false;
|
||||
},
|
||||
// 获取验证码
|
||||
async getPhoneCode() {
|
||||
const phoneNumber = this.phone
|
||||
@ -146,6 +169,18 @@
|
||||
toggleCheck() {
|
||||
this.isChecked = !this.isChecked
|
||||
},
|
||||
// 去登录
|
||||
goLogin() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/register/index'
|
||||
})
|
||||
},
|
||||
// 忘记密码
|
||||
forgotPassword() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/forgotPassword/index'
|
||||
})
|
||||
},
|
||||
// 登录
|
||||
async handleLogin() {
|
||||
if (this.phone == '') {
|
||||
@ -155,13 +190,25 @@
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
} else if (this.code == '') {
|
||||
uni.showToast({
|
||||
title: '验证码不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
}
|
||||
if (this.isCodeLogin) {
|
||||
if (this.code == '') {
|
||||
uni.showToast({
|
||||
title: '验证码不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
if (this.password == '') {
|
||||
uni.showToast({
|
||||
title: '密码不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
if (!this.isChecked) {
|
||||
this.showAgreement = true
|
||||
@ -171,17 +218,25 @@
|
||||
uni.showLoading({
|
||||
title: '登录中...'
|
||||
})
|
||||
// 调用登录接口
|
||||
const res = await login({
|
||||
let loginParams = {
|
||||
phonenumber: this.phone,
|
||||
smsCode: this.code,
|
||||
tenantId: '894078' //租户ID
|
||||
})
|
||||
tenantId: '894078' // 租户ID
|
||||
};
|
||||
if (this.isCodeLogin) {
|
||||
loginParams.smsCode = this.code;
|
||||
//登录方式 1:手机验证码登录 2:密码登录
|
||||
loginParams.loginType=1
|
||||
} else {
|
||||
loginParams.loginPassword = md5(this.password);
|
||||
loginParams.loginType=2
|
||||
}
|
||||
// 调用登录接口
|
||||
const res = await login(loginParams)
|
||||
if (res.code == 200) {
|
||||
uni.hideLoading()
|
||||
uni.setStorageSync('token', res.data.access_token) // 缓存token
|
||||
uni.setStorageSync('clientID', res.data.client_id) // 缓存token
|
||||
uni.setStorageSync('tokenTime',new Date().getTime()+86400000);//过期时间
|
||||
uni.setStorageSync('tokenTime', new Date().getTime() + 86400000); //过期时间
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'success'
|
||||
@ -271,6 +326,20 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.switch-flex {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-top: 40rpx;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
}
|
||||
|
||||
.switch-login {
|
||||
color: rgb(187, 230, 0);
|
||||
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
|
||||
.get_phone_number {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
@ -297,10 +366,12 @@
|
||||
align-items: center;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
position: absolute;
|
||||
bottom: 8rpx
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
margin-top: 150rpx;
|
||||
margin-top: 90rpx;
|
||||
background-color: rgb(187, 230, 0);
|
||||
color: rgb(35, 35, 35);
|
||||
border-radius: 50rpx;
|
||||
@ -310,6 +381,16 @@
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
|
||||
.gologin {
|
||||
color: rgba(187, 230, 0, 1);
|
||||
}
|
||||
|
||||
.custom-checkbox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
433
pages/common/register/index.vue
Normal file
433
pages/common/register/index.vue
Normal file
@ -0,0 +1,433 @@
|
||||
<template>
|
||||
<view class="pageContent">
|
||||
<image src="/static/images/common/login.png" mode="" class="login-bg"></image>
|
||||
<view class="content_con">
|
||||
欢迎注册
|
||||
</view>
|
||||
<view class="content">
|
||||
<view class='ver_item'>
|
||||
<input type="number" v-model="phone" :maxlength="11" placeholder="请输入手机号" class="input" />
|
||||
</view>
|
||||
<view class='ver_item'>
|
||||
<input type="number" v-model="code" :maxlength="6" placeholder="请输入验证码" class="input" />
|
||||
<button :class="showView?' get_phone_number blue':'get_phone_number grad'"
|
||||
@click="getPhoneCode">{{ isCounting ? `${countdown}s后重新获取` : '获取验证码' }}</button>
|
||||
</view>
|
||||
<view class='ver_item'>
|
||||
<input type="password" v-model="password" placeholder="请设置密码(6—20个数字或字母)" class="input" />
|
||||
|
||||
</view>
|
||||
|
||||
|
||||
<!-- 登录按钮 -->
|
||||
<button class="login-btn" @click="handleLogin">
|
||||
注册
|
||||
</button>
|
||||
<view class="login-title">已有账号?<text class="gologin" @click="goLogin">去登录</text></view>
|
||||
<!-- 协议勾选 -->
|
||||
<view class="agreement">
|
||||
<view class="custom-checkbox" @click="toggleCheck">
|
||||
<view class="checkbox-icon" :class="{ checked: isChecked }">
|
||||
<uni-icons v-if="isChecked" type="checkmarkempty" size="8" color="#fff"></uni-icons>
|
||||
</view>
|
||||
<text class="checkbox-label">我已认真阅读,理解并同意<a class="agreeT"
|
||||
@click.stop="goToPage('agreement')">《用户服务协议》</a>及<a class="agreeT"
|
||||
@click.stop="goToPage('privacy')">《隐私政策》</a></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 弹框 -->
|
||||
<view class="agreement-mask" v-if="showAgreement">
|
||||
<!-- 协议弹窗 -->
|
||||
<view class="agreement-popup" @click.stop>
|
||||
<!-- 标题 -->
|
||||
<view class="popup-title">服务协议及隐私政策</view>
|
||||
<!-- 协议内容 -->
|
||||
<view class="popup-content">
|
||||
为了更好的保障您的合法权益,请您阅读并同意以下协议
|
||||
<text class="protocol-link" @click="openProtocol('user')">《用户服务协议》</text>
|
||||
<text class="protocol-link" @click="openProtocol('privacy')">《隐私政策》</text>
|
||||
</view>
|
||||
<!-- 按钮组 -->
|
||||
<view class="popup-buttons">
|
||||
<button class="btn disagree" @click="handleDisagree">不同意</button>
|
||||
<button class="btn agree" @click="handleAgree">同意</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import md5 from 'blueimp-md5'
|
||||
import {
|
||||
register,
|
||||
registerSmsCode
|
||||
} from '@/api/common/login.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
showView: false,
|
||||
phone: '13800138006', //手机号码
|
||||
code: "", //验证码
|
||||
password: '', //密码
|
||||
agreed: false,
|
||||
isCounting: false,
|
||||
countdown: 0,
|
||||
isChecked: true,
|
||||
showAgreement: false, // 控制弹窗显示
|
||||
}
|
||||
},
|
||||
onLoad() {},
|
||||
methods: {
|
||||
// 获取验证码
|
||||
async getPhoneCode() {
|
||||
const phoneNumber = this.phone
|
||||
const myreg = /^1[3456789]\d{9}$/;
|
||||
if (!phoneNumber) {
|
||||
uni.showToast({
|
||||
title: '手机号不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
return false;
|
||||
} else if (!myreg.test(phoneNumber)) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
const res = await registerSmsCode({
|
||||
phonenumber: this.phone
|
||||
})
|
||||
if (res.code == 200) {
|
||||
// 更新倒计时状态
|
||||
this.isCounting = true;
|
||||
this.showView = true;
|
||||
this.countdown = 60
|
||||
const timer = setInterval(() => {
|
||||
this.countdown--
|
||||
if (this.countdown <= 0) {
|
||||
clearInterval(timer)
|
||||
this.isCounting = false;
|
||||
this.showView = false;
|
||||
}
|
||||
}, 1000)
|
||||
uni.showToast({
|
||||
title: '验证码已发送',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
} catch (error) {}
|
||||
},
|
||||
// 勾选同意
|
||||
toggleCheck() {
|
||||
this.isChecked = !this.isChecked
|
||||
},
|
||||
// 登录
|
||||
goLogin() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/login/index'
|
||||
})
|
||||
},
|
||||
// 登录
|
||||
async handleLogin() {
|
||||
if (this.phone == '') {
|
||||
uni.showToast({
|
||||
title: '手机号不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
} else if (this.code == '') {
|
||||
uni.showToast({
|
||||
title: '验证码不能为空',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return false
|
||||
} else if (!this.password) {
|
||||
uni.showToast({
|
||||
title: '请设置密码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
return false
|
||||
}
|
||||
if (!this.isChecked) {
|
||||
this.showAgreement = true
|
||||
return false
|
||||
}
|
||||
try {
|
||||
uni.showLoading({
|
||||
title: '注册中...'
|
||||
})
|
||||
// 调用登录接口
|
||||
const res = await register({
|
||||
phonenumber: this.phone,
|
||||
smsCode: this.code,
|
||||
tenantId: '894078', //租户ID
|
||||
password: md5(this.password)
|
||||
})
|
||||
if (res.code == 200) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '注册成功',
|
||||
icon: 'success'
|
||||
})
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/login/index'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg || '服务器异常,请稍后重试',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('捕获错误:', error);
|
||||
uni.showToast({
|
||||
title: error.msg || '登录失败',
|
||||
icon: 'none'
|
||||
});
|
||||
uni.hideLoading()
|
||||
}
|
||||
},
|
||||
// 跳转到协议页面
|
||||
goToPage(type) {
|
||||
const url = type === 'agreement' ?
|
||||
'/pages/common/userAgreement/index' // 服务协议
|
||||
:
|
||||
'/pages/common/privacyAgreement/index'; // 隐私政策
|
||||
uni.navigateTo({
|
||||
url: url
|
||||
});
|
||||
},
|
||||
|
||||
// 不同意
|
||||
handleDisagree() {
|
||||
this.showAgreement = false
|
||||
},
|
||||
// 同意
|
||||
handleAgree() {
|
||||
this.isChecked = !this.isChecked
|
||||
this.showAgreement = false
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.pageContent {
|
||||
background: rgb(26, 26, 26);
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.login-bg {
|
||||
background-size: 100% 100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.content {
|
||||
height: 70%;
|
||||
width: 100%;
|
||||
background: rgb(26, 26, 26);
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
border-radius: 60px 60px 0px 0px;
|
||||
box-sizing: border-box;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.content_con {
|
||||
position: absolute;
|
||||
top: 220rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
left: 30rpx;
|
||||
font-size: 60rpx;
|
||||
}
|
||||
|
||||
.input {
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
height: 80rpx;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
margin-top: 50rpx;
|
||||
}
|
||||
|
||||
.ver_item {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.get_phone_number {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
color: #999;
|
||||
top: 1rpx;
|
||||
background: rgb(26, 26, 26);
|
||||
border: none;
|
||||
text-align: right;
|
||||
font-size: 28rpx;
|
||||
font-family: PingFangSC-Medium, PingFang SC;
|
||||
}
|
||||
|
||||
.grad {
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.blue {
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.agreement {
|
||||
margin: 50rpx 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
position: absolute;
|
||||
bottom: 8rpx
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
margin-top: 90rpx;
|
||||
background-color: rgb(187, 230, 0);
|
||||
color: rgb(35, 35, 35);
|
||||
border-radius: 50rpx;
|
||||
}
|
||||
|
||||
.login-btn[disabled] {
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
.login-title {
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
|
||||
.gologin {
|
||||
color: rgba(187, 230, 0, 1);
|
||||
}
|
||||
|
||||
.custom-checkbox {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.checkbox-icon {
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
border: 1px solid rgba(255, 255, 255, 0.87);
|
||||
border-radius: 50rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.checkbox-icon.checked {
|
||||
background-color: #07C160;
|
||||
border-color: #07C160;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.checkbox-label {
|
||||
font-size: 24rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
}
|
||||
|
||||
.agreeT {
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
/* 遮罩层 */
|
||||
.agreement-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
/* 弹窗主体 */
|
||||
.agreement-popup {
|
||||
width: 80%;
|
||||
background-color: rgba(42, 42, 42);
|
||||
border-radius: 16rpx;
|
||||
padding: 40rpx;
|
||||
box-sizing: border-box;
|
||||
border: 1rpx solid rgba(187, 230, 0, 0.3)
|
||||
}
|
||||
|
||||
/* 标题 */
|
||||
.popup-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
margin-bottom: 30rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
}
|
||||
|
||||
/* 内容文本 */
|
||||
.popup-content {
|
||||
font-size: 30rpx;
|
||||
line-height: 1.6;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
margin-bottom: 50rpx;
|
||||
}
|
||||
|
||||
/* 协议链接 */
|
||||
.protocol-link {
|
||||
color: rgb(187, 230, 0);
|
||||
margin: 0 10rpx;
|
||||
}
|
||||
|
||||
/* 按钮容器 */
|
||||
.popup-buttons {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
/* 通用按钮样式 */
|
||||
.btn {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
border-radius: 40rpx;
|
||||
font-size: 32rpx;
|
||||
margin: 0 20rpx;
|
||||
}
|
||||
|
||||
/* 不同意按钮 */
|
||||
.disagree {
|
||||
background-color: transparent;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
border: 1px solid rgb(255, 255, 255);
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
/* 同意按钮 */
|
||||
.agree {
|
||||
background-color: rgb(187, 230, 0);
|
||||
color: #232323;
|
||||
border: none;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
</style>
|
||||
@ -1,5 +1,5 @@
|
||||
import config from '../config/index.js';
|
||||
const env = 'production'; //production development //开发of线上 改这里就行
|
||||
const env = 'development'; //production development //开发of线上 改这里就行
|
||||
const BASE = config[env];
|
||||
const request = (options) => {
|
||||
console.log("options"+JSON.stringify(options),BASE.BASE_URL)
|
||||
|
||||
@ -16,6 +16,11 @@ axios@^1.9.0:
|
||||
form-data "^4.0.0"
|
||||
proxy-from-env "^1.1.0"
|
||||
|
||||
blueimp-md5@^2.19.0:
|
||||
version "2.19.0"
|
||||
resolved "https://registry.npmjs.org/blueimp-md5/-/blueimp-md5-2.19.0.tgz"
|
||||
integrity sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w==
|
||||
|
||||
call-bind-apply-helpers@^1.0.1, call-bind-apply-helpers@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz"
|
||||
|
||||
Reference in New Issue
Block a user