TraceabilityAPP/pages/Login/resgier.vue

278 lines
6.4 KiB
Vue
Raw Normal View History

2023-11-25 16:18:54 +08:00
<template>
<view class="box">
2023-12-17 20:52:19 +08:00
<view class="" style="height: var(--status-bar-height);">
2023-12-20 23:41:00 +08:00
2023-12-17 20:52:19 +08:00
</view>
<view class="" style="margin-left: 20rpx;float: left;" @click="back">
2023-12-20 23:41:00 +08:00
<u-icon name="arrow-left" color="white" size="20"></u-icon>
2023-12-17 20:52:19 +08:00
</view>
<Myindex style="float: right;"></Myindex>
2023-11-25 16:18:54 +08:00
<view class="content">
2023-12-13 15:57:20 +08:00
<view class="tit" style="margin-bottom: 10rpx;">
您好
</view>
2023-11-25 16:18:54 +08:00
<view class="tit">
欢迎进入吟龙土壤墒情监测溯系统!
</view>
2023-12-13 15:57:20 +08:00
<view class="input-card" style="color: #7A7A7A;">
<view class="login-type" style="color: black;font-weight: bold;">
注册
2023-11-25 16:18:54 +08:00
<view class="line" />
</view>
<view class="" style="margin: 30rpx 0;">
2023-12-13 15:57:20 +08:00
<view class="" style="display: flex;margin-bottom: 10rpx;">
<up-image :src="u('sj')" width="30rpx" height="44rpx"
style="margin-right: 20rpx;"></up-image>
</view>
2023-11-25 16:18:54 +08:00
<u-input placeholder="请输入账号"
customStyle="background:#F5F5F5;height:80rpx;padding-left:40rpx;border:none" shape='circle'
border="surround" v-model="formData.mobile"></u-input>
</view>
2024-01-02 18:18:57 +08:00
<view class="" style="display: flex;margin-top: 30rpx;margin-bottom: 10rpx;">
2023-12-13 15:57:20 +08:00
<up-image :src="u('yzm')" width="30rpx" height="44rpx" style="margin-right: 20rpx;"></up-image>
</view>
<view class="" style="position: relative;">
<u-input type="number" shape='circle'
customStyle="background:#F5F5F5;height:80rpx;padding-left:40rpx;border:none;margin-bottom:15rpx"
2024-01-02 18:18:57 +08:00
placeholder="请输入验证码" border="surround" v-model="formData.verify_code"></u-input>
2023-11-25 16:18:54 +08:00
2024-01-03 19:11:45 +08:00
<view class="get-code" :style="{color: countDown?'#ADADAD':''}" @click="getCode"><text
2023-12-13 15:57:20 +08:00
class="lineY"></text>
2024-01-09 18:17:29 +08:00
验证码 <text v-if='countDown'>{{countDown}}s</text> </view>
2024-01-02 18:18:57 +08:00
</view>
2023-12-13 15:57:20 +08:00
2023-11-25 16:18:54 +08:00
<view class="" style="margin: 30rpx 0;">
2023-12-13 15:57:20 +08:00
<view class="" style="display: flex;margin-top: 30rpx;margin-bottom: 10rpx;">
<up-image :src="u('mm')" width="30rpx" height="44rpx" style="margin-right: 20rpx;"></up-image>
</view>
2023-11-30 17:51:39 +08:00
<u-input :password="!pwdShow" shape='circle'
2023-11-25 16:18:54 +08:00
customStyle="background:#F5F5F5;height:80rpx;;padding-left:40rpx;border:none"
2023-11-30 17:51:39 +08:00
placeholder="请输入密码" border="surround" v-model="formData.password">
2023-12-13 15:57:20 +08:00
2023-12-07 09:34:25 +08:00
</u-input>
2023-11-25 16:18:54 +08:00
</view>
2023-12-13 15:57:20 +08:00
<!-- <view class="">
2023-11-30 17:51:39 +08:00
<u-input :password="!pwdShow1" shape='circle'
2023-11-25 16:18:54 +08:00
customStyle="background:#F5F5F5;height:80rpx;;padding-left:40rpx;border:none"
2023-11-30 17:51:39 +08:00
placeholder="请确认密码" border="surround" v-model="formData.password_confirm">
<template #suffix>
<u-icon :name="pwdShow1?'eye-off':'eye-fill'" size="25"
@click="pwdShow1=!pwdShow1"></u-icon>
</template>
2023-12-07 09:34:25 +08:00
</u-input>
2023-12-13 15:57:20 +08:00
</view> -->
2023-11-25 16:18:54 +08:00
<view class="sub-btn">
2023-12-13 15:57:20 +08:00
<u-button @click="submitFn" type="primary"
customStyle="border:none;height:90rpx;border-radius: 100rpx;" color="#34D190"
text="注册"></u-button>
2023-11-25 16:18:54 +08:00
</view>
</view>
</view>
</view>
</template>
<script setup>
2023-12-17 20:52:19 +08:00
import Myindex from '@/components/return/index.vue';
2023-11-25 16:18:54 +08:00
import {
2024-01-02 18:18:57 +08:00
logregister,
registerCode
} from '@/api/api.js';
2023-11-25 16:18:54 +08:00
import {
reactive,
ref
} from 'vue';
2023-12-07 09:34:25 +08:00
const pwdShow = ref(false)
const pwdShow1 = ref(false)
2023-11-25 16:18:54 +08:00
const formData = reactive({
2024-01-02 18:18:57 +08:00
mobile: "19130550023",
verify_code: "",
2023-11-25 16:18:54 +08:00
password: "",
password_confirm: "",
})
2023-12-13 15:57:20 +08:00
const countDown = ref(0)
const u = (name) => {
return `/static/main/login/${name}.png`
}
2024-01-02 18:18:57 +08:00
//倒计时
const startCountDown = () => {
countDown.value = 60
const timer = setInterval(() => {
countDown.value -= 1; // 更新倒计时秒数
if (countDown.value <= 0) {
clearInterval(timer); // 倒计时结束,清除定时器
}
}, 1000);
};
2023-12-13 15:57:20 +08:00
const getCode = () => {
2023-11-25 16:18:54 +08:00
2023-12-13 15:57:20 +08:00
if (countDown.value) return
2023-11-25 16:18:54 +08:00
2024-01-02 18:18:57 +08:00
if (!formData.mobile) return uni.$u.toast('账号不能为空');
2023-12-13 15:57:20 +08:00
let data = {
2024-01-02 18:18:57 +08:00
mobile: formData.mobile,
scene: 'YZMDL'
2023-12-13 15:57:20 +08:00
}
2024-01-02 18:18:57 +08:00
registerCode(data).then((res) => {
2023-11-25 16:18:54 +08:00
2023-12-13 15:57:20 +08:00
if (res.code == 1) {
uni.$u.toast('验证码已发送');
// 通知验证码组件内部开始倒计时
startCountDown()
}
})
}
2023-11-25 16:18:54 +08:00
const submitFn = () => {
2023-12-13 15:57:20 +08:00
var pattern = /^(?=.*[a-zA-Z])(?=.*\d).+$/;
2023-11-25 16:18:54 +08:00
if (!formData.mobile) return uni.$u.toast('账号不能为空');
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(formData.mobile)) return uni.$u.toast(
'请输入正确的手机号码'
);
if (!formData.password)
return uni.$u.toast('密码不能为空')
2023-12-13 15:57:20 +08:00
if (formData.password.length < 6)
return uni.$u.toast('密码长度至少在6-25位之间')
if (!pattern.test(formData.password)) return uni.$u.toast('密码要包含数字与英文')
formData.password_confirm = formData.password
2023-11-25 16:18:54 +08:00
logregister(formData).then((res) => {
if (res.code == 1) {
uni.navigateBack({
delta: 1
2023-11-25 16:18:54 +08:00
})
2023-12-07 09:34:25 +08:00
uni.$u.toast('注册成功');
2023-12-13 15:57:20 +08:00
} else {
if (res.data && res.data.has_register == 1) {
2023-12-07 11:53:21 +08:00
uni.redirectTo({
2023-12-13 15:57:20 +08:00
url: '/pages/Login/login'
2023-12-07 11:53:21 +08:00
})
}
2023-11-25 16:18:54 +08:00
}
})
}
2023-12-20 23:41:00 +08:00
const back = () => {
2023-12-17 20:52:19 +08:00
uni.navigateBack()
}
2023-11-25 16:18:54 +08:00
</script>
<style lang="scss" scoped>
.box {
width: 100vw;
height: 100vh;
background-color: $theme-main-color;
position: relative;
}
.content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
2023-12-13 15:57:20 +08:00
// border-radius: 100rpx;
2023-11-25 16:18:54 +08:00
width: 700rpx;
.tit {
color: white;
font-size: 45rpx;
margin-bottom: 30rpx;
}
.input-card {
2023-12-13 15:57:20 +08:00
width: 700rpx;
2023-11-25 16:18:54 +08:00
background-color: #fff;
height: auto;
padding: 40rpx;
border-radius: 30rpx;
.login-type {
display: flex;
2023-12-13 15:57:20 +08:00
// margin-right: 50rpx;
2023-11-25 16:18:54 +08:00
flex-direction: column;
2023-12-13 15:57:20 +08:00
align-items: center;
// justify-content: flex-start;
margin: 0 auto;
text-align: center;
2023-11-25 16:18:54 +08:00
.line {
border-top: 3px solid #34D190;
margin-top: 10rpx;
width: 60rpx;
}
}
.yanzm {
display: flex;
justify-content: space-between;
.u-input {
margin-right: 60rpx;
}
}
.code {
width: 120rpx;
height: 80rpx;
background-color: #34D190;
line-height: 80rpx;
text-align: center;
border-radius: 20rpx 20rpx;
font-size: 20rpx;
padding: 0rpx 20rpx;
color: #fff;
}
.sub-btn {
margin-top: 30rpx;
}
.resgiter {
font-size: 20rpx;
margin-top: 40rpx;
}
}
}
2023-12-13 15:57:20 +08:00
.get-code {
color: $theme-main-color;
font-size: 28rpx;
position: absolute;
right: 30rpx;
top: 20rpx;
.lineY {
width: 1px;
height: 20rpx;
background-color: $theme-main-color;
display: inline-block;
margin-right: 10rpx;
}
}
2023-11-25 16:18:54 +08:00
</style>