You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

420 lines
10 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<view class="loginBack">
<view class="loginForm">
<view class="welcomeLogin">注册</view>
<view class="tip">yoga</view>
<view class="formregion">
<uni-forms :model="form" ref="uForm">
<uni-forms-item prop="phonenumber" >
<uni-easyinput type="number" placeholder="请输入手机号码" v-model="form.phonenumber" @blur="zhhandleBlur" :inputBorder="false" :clearable="false" :placeholderStyle="placeholderStyle"/>
</uni-forms-item>
<uni-forms-item prop="password" >
<uni-easyinput type="password" placeholder="请输入密码" v-model="form.password" @blur="mmhandleBlur" :inputBorder="false" :clearable="false" :placeholderStyle="placeholderStyle"/>
</uni-forms-item>
<uni-forms-item prop="passwordSecond" >
<uni-easyinput type="password" placeholder="请再次输入密码" v-model="form.passwordSecond" @blur="mmhandleBlur" :inputBorder="false" :clearable="false" :placeholderStyle="placeholderStyle"/>
</uni-forms-item>
<uni-forms-item prop="code" >
<uni-easyinput type="text" placeholder="请输入验证码" v-model.trim="form.code" :inputBorder="false" :clearable="false" :placeholderStyle="placeholderStyle"/>
<image :src="checkimg" class="checkimg" mode="scaleToFill"></image>
<view class="codebtn" @click="getcode">看不清?</view>
</uni-forms-item>
<button type="primary" class="logincla" @click="loginpwdDo">注册</button>
<view v-if="iflogin" class="loginno">注册中..</view>
<view class="regcon">
<view class="regtxtr" @click="gotologin">?</view>
</view>
</uni-forms>
</view>
<u-toast ref="uToast" />
</view>
</view>
</template>
<script>
//#ifdef APP-PLUS
// const jpushModule = uni.requireNativePlugin('JG-JPush');
//#endif
import {myCache} from '../../utils/utils.js';
export default {
data() {
return {
checkimg: require("@/static/image/check.jpg"),
placeholderStyle:"font-size: 28rpx;color: #c3c4c6; text",
form: {
phonenumber:"",
miniAppCode:"",
passwordSecond:"",
password:"",
code:"",
uuid:""
},
iflogin:false,
gcj02:"1",
address:'',
longitude:'', // 经度
latitude:'', // 维度
}
},
onLoad(){
// 获取验证码
this.getcheckImg();
this.getsystemInfo();
},
methods: {
gotologin() {
// 注册账号
uni.navigateTo({
url: `/pages/login/login`
});
},
async getcheckImg(){
// 验证图片信息
const {data: res} = await uni.$http.get('/captchaImage');
if (res&&res.img&&res.uuid) {
this.checkimg= 'data:image/png;base64,'+res.img;
this.form.uuid=res.uuid;
this.$forceUpdate();
}
},
// 判断密码是否合规
mmhandleBlur(e){
console.log(e)
if(e.detail.value&&e.detail.value.length<6){
// if(e.detail.value&&!this.checkMM(e.detail.value)){
// '6-20',
// '8-203'
this.$refs.uToast.show({
title: "6-202",
type: 'error',
duration: 2000
});
}
},
//
checkMM(mm) {
// if (!(/^(?!([a-zA-Z]+|\d+)$)[a-zA-Z\d]{6,20}$/.test(mm))) {
// // if (!(/((^(?=.*[a-z])(?=.*[A-Z])(?=.*[^A-Za-z0-9])[\da-zA-Z_\W]{8,20}$)|(^(?=.*\d)(?=.*[A-Z])(?=.*[^A-Za-z0-9])[\da-zA-Z_\W]{8,20}$)|(^(?=.*\d)(?=.*[a-z])(?=.*[^A-Za-z0-9])[\da-zA-Z_\W]{8,20}$)|(^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[\da-zA-Z_\W]{8,20}$))/.test(mm))) {
// return false;
// }
return true;
},
//
zhhandleBlur(e){
console.log(e)
//
if(!this.$u.test.mobile(e.detail.value)){
this.$refs.uToast.show({
title: '',
type: 'warning',
duration: 2000
});
}
},
async getcode(){
uni.showLoading({
title: '...'
});
const {data: res} = await uni.$http.get('/captchaImage');
console.log(res);
if(res&&res.img&&res.uuid){
this.checkimg= 'data:image/png;base64,'+res.img;
this.form.uuid=res.uuid;
this.$forceUpdate();
}
else{
this.$refs.uToast.show({
title: "",
type: 'error',
duration: 2000
});
}
},
//
checkPhone(phone) {
if (!(/^1[3456789]\d{9}$/.test(phone))) {
return false;
}
return true;
},
//
getsystemInfo(){
const info = uni.getSystemInfoSync();
const platform = info.platform; //
if (info.platform === 'ios') {
// ios
console.log('iOS :', info.deviceId);
}
else{
//
console.log('ID:',info.deviceId);
}
this.form.miniAppCode=info.deviceId;
this.$forceUpdate();
// const iosApp = info.platform;
console.log('iOS :', info.model);
console.log('iOS :', info.system);
console.log('iOS :', info.deviceId);
console.log('iOS :', info.devicePixelRatio);
console.log('iOS :', info.screenWidth);
console.log('iOS :', info.screenHeight);
console.log('iOS :', info.deviceOrientation);
// uni.showModal({
// title: '',
// content: info.deviceId,
// success(res) {
// if (res.confirm) {
// console.log('');
// } else if (res.cancel) {
// console.log('');
// }
// }
// });
},
login() {
this.loginpwdDo();
},
//
async loginpwdDo(){
//
if(!this.form.phonenumber){
this.$refs.uToast.show({
title: "",
type: 'warn',
duration: 2000
});
return false;
}
if(!this.form.password){
this.$refs.uToast.show({
title: "",
type: 'warn',
duration: 2000
});
return false;
}
if(!this.form.phonenumber){
this.$refs.uToast.show({
title: "",
type: 'warn',
duration: 2000
});
return false;
}
if(this.form.password !== this.form.passwordSecond){
this.$refs.uToast.show({
title: "",
type: 'warn',
duration: 2000
});
return false;
}
if(!this.form.code){
this.$refs.uToast.show({
title: "",
type: 'warn',
duration: 2000
});
return false;
}
uni.showLoading({
title: '...'
});
uni.setStorageSync('iftoken', "1");
const {data: res} = await uni.$http.post('/api/register',this.form);
console.log(res);
if(res&&res.success){
this.$refs.uToast.show({
title: '',
type: 'success',
isTab: false,
duration: 2000,
url: '/pages/login/login'
});
}
else{
this.$refs.uToast.show({
title: res.msg?res.msg: "",
type: 'error',
duration: 2000
});
}
}
}
}
</script>
<style>
</style>
<style lang="scss" scoped>
::v-deep .u-checkbox__label{
color:#bdbfc1
}
::v-deep .uni-easyinput__content-input {
width: 500rpx;
height: 80rpx;
background: #fff;
box-shadow: 0rpx 12rpx 64rpx 2rpx rgba(137, 150, 95, 0.3);
border-radius: 254rpx 254rpx 254rpx 254rpx;
}
::v-deep .uni-easyinput__content{
border-radius: 254rpx 254rpx 254rpx 254rpx;
text-indent: 20rpx;
}
.lttxt{
font-size: 30rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color:#333333;
line-height: 38rpx;
height: 45rpx;
margin: 30rpx auto;
text-align: center;
}
.timetxt{
position: absolute;
top:20rpx;
right: 28rpx;
display: block;
font-size: 36rpx;
color:#00a89b;
line-height: 38rpx;
height: 45rpx;
margin-left: 50rpx;
}
.checkimg{
position: absolute;
top:14rpx;
right: 130rpx;
width: 150rpx;
height: 50rpx;
}
.codebtn{
position: absolute;
top:12rpx;
right: 20rpx;
display: block;
color:#00a89b;
height: 60rpx;
line-height: 60rpx;
font-size: 26rpx;
padding: 0 10rpx;
}
.regcon{
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
margin-top: 36rpx;
.regtxt{
color:#00a89b;
font-size: 28rpx;
display: flex;
align-items: center;
}
.regtxtl{
color:#00a89b;
width: 2rpx;
height: 26rpx;
font-size: 26rpx;
margin-left: 10rpx;
margin-right: 10rpx;
border-right: 1rpx solid #00a89b;
display: flex;
align-items: center;
}
.regtxtr{
color:#00a89b;
height: 28rpx;
font-size: 28rpx;
display: flex;
align-items: center;
margin-right: 10rpx;
}
}
.loginno{
display: block;
background-color:rgba(137, 150, 95, 0.3);
width: 100%;
line-height: 2;
margin-top: 30rpx;
border-radius:12rpx;
font-size: 30rpx;
text-align: center;
box-sizing:border-box;
}
.logincla{
display: block;
background-color:#00A99A;
width: 100%;
line-height: 2;
}
.loginBack {
color: #fff;
height: 100vh;
padding:60rpx 50rpx 200rpx 50rpx;
width: 100%;
overflow: hidden;
background-size: 100% 100%;
background-image: url('../../static/image/lgbg.jpg');
.inpuIcon {
width: 46rpx;
height: 46rpx;
margin-right: 30rpx;
}
.formregion {
width: 100%;
padding: 30px 50rpx;
background-color: #fff;
border-radius: 10px;
margin-top: 20rpx;
position: relative;
display: block;
overflow: hidden;
.logo{
position: absolute;
top: -20rpx;
left: 0;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.define {
width: 120rpx;
height: 120rpx;
}
}
}
.welcomeLogin {
font-size: 30rpx;
letter-spacing: 2rpx;
padding: 20rpx 0 10rpx;
margin: 0 auto;
width: 100%;
}
.tip{
font-weight: 600;
font-size: 42rpx;
letter-spacing: 4rpx;
padding: 0 0 40rpx 0;
width: 100%;
}
</style>