change code

This commit is contained in:
周源 2022-04-27 09:31:17 +08:00
parent 67d2a65c30
commit c776e7eb50
2 changed files with 223 additions and 204 deletions

View File

@ -1,215 +1,234 @@
<template>
<view style="">
<u-gap height="60" bgColor="#FFF"></u-gap>
<u--form :model="userInfo" ref="loginForm">
<view class="content_main">
<view class="copyright_iocn">
<image style="width: 80rpx; height: 60rpx;" src="../../static/icon10.png" mode=""></image>
<image style="width: 156rpx; height: 50rpx;margin-left: 16rpx;" src="../../static/icon11.png"
mode="">
</image>
</view>
<view style="">
<u-gap height="60" bgColor="#FFF"></u-gap>
<u--form :model="userInfo" ref="loginForm">
<view class="content_main">
<view class="copyright_iocn">
<image style="width: 80rpx; height: 60rpx;" src="../../static/icon10.png" mode=""></image>
<image style="width: 156rpx; height: 50rpx;margin-left: 16rpx;" src="../../static/icon11.png"
mode="">
</image>
</view>
<view class="tab_op">
<view :class="tab == 0?'choosed':'unchoosed'" @click="pwdLog()">
密码登录
</view>
<view :class="tab == 1?'choosed':'unchoosed'" @click="codeLog()">
验证码登录
</view>
</view>
<u-form-item prop="number" ref="item1" class="data_itm" v-if="tab == 0">
<u--input placeholder="请输入手机号" border="bottom" clearable v-model="userInfo.number"></u--input>
</u-form-item>
<u-form-item prop="pasw" ref="item1" class="data_itm" v-if="tab == 0">
<u--input type="password" placeholder="请输入密码" border="bottom" clearable v-model="userInfo.pasw">
</u--input>
</u-form-item>
<u-form-item prop="phone" ref="item1" class="data_itm" v-if="tab == 1">
<u--input placeholder="请输入手机号" border="bottom" clearable v-model="userInfo.phone"></u--input>
</u-form-item>
<u-form-item prop="code" ref="item1" class="data_itm" v-if="tab == 1">
<u-input placeholder="请输入验证码" border="bottom" clearable v-model="userInfo.code">
<template slot="suffix">
<u-code ref="uCode" @change="codeChange" seconds="60" changeText="X秒重新获取"></u-code>
<u-button @click="getCode" :text="tips" :hairline="false" plain style="border: 0px;">
</u-button>
</template>
</u-input>
</u-form-item>
<u-button text="登录" size="large" throttleTime=1000 color="#99241B" style="margin-top: 84rpx;"
@click="login()">
</u-button>
<view class="other_op">
<!-- <text @click="goRegist">注册账号</text> -->
<text @click="goRemeber">忘记密码</text>
</view>
</view>
</u--form>
</view>
<view class="tab_op">
<view :class="tab == 0?'choosed':'unchoosed'" @click="pwdLog()">
密码登录
</view>
<view :class="tab == 1?'choosed':'unchoosed'" @click="codeLog()">
验证码登录
</view>
</view>
<u-form-item prop="number" ref="item1" class="data_itm" v-if="tab == 0">
<u--input placeholder="请输入手机号" border="bottom" clearable v-model="userInfo.number"></u--input>
</u-form-item>
<u-form-item prop="pasw" ref="item1" class="data_itm" v-if="tab == 0">
<u--input type="password" placeholder="请输入密码" border="bottom" clearable v-model="userInfo.pasw">
</u--input>
</u-form-item>
<u-form-item prop="phone" ref="item1" class="data_itm" v-if="tab == 1">
<u--input placeholder="请输入手机号" border="bottom" clearable v-model="userInfo.phone"></u--input>
</u-form-item>
<u-form-item prop="code" ref="item1" class="data_itm" v-if="tab == 1">
<u-input placeholder="请输入验证码" border="bottom" clearable v-model="userInfo.code">
<template slot="suffix">
<u-code ref="uCode" @change="codeChange" seconds="60" changeText="X秒重新获取"></u-code>
<u-button @click="getCode" :text="tips" :hairline="false" plain style="border: 0px;">
</u-button>
</template>
</u-input>
</u-form-item>
<u-button text="登录" size="large" throttleTime=1000 color="#99241B" style="margin-top: 84rpx;"
@click="login()">
</u-button>
<view class="other_op">
<!-- <text @click="goRegist">注册账号</text> -->
<text @click="goRemeber">忘记密码</text>
</view>
</view>
</u--form>
</view>
</template>
<script>
export default {
data() {
return {
tips: '',
userInfo: {
number: null,
pasw: null,
phone: null,
code: null,
},
rules: {
'number': [{
type: 'number',
required: true,
message: '请填写账号',
trigger: ['blur']
}],
'pasw': [{
required: true,
message: '请填写密码',
trigger: ['blur']
}],
},
tab: 0,
};
},
methods: {
pwdLog() {
this.tab = 0
},
codeLog() {
this.tab = 1
},
goRegist() {
uni.navigateTo({
url: '/pages/Login/Register'
})
},
goRemeber() {
uni.navigateTo({
url: '/pages/Login/RemeberPW'
})
},
login() {
if(this.tab == 0){
this.http.request('/auth/loginByPwd', {
phone: this.userInfo.number,
pwd: this.userInfo.pasw
}, "POST").then(res => {
if (res.code == 200) {
uni.navigateTo({
url: '/pages/pageHome/pageHome'
})
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
})
}else if(this.tab == 1){
this.http.request('/auth/loginByPhone', {
phone: this.userInfo.phone,
code: this.userInfo.code
}, "POST").then(res => {
if (res.code == 200) {
uni.navigateTo({
url: '/pages/pageHome/pageHome'
})
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
})
}
},
codeChange(text) {
this.tips = text;
},
getCode() {
uni.hideKeyboard()
if (!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(this.userInfo.phone))) { //
uni.showToast({
title: '请填写正确手机号码',
icon: "none"
});
return false;
}
export default {
data() {
return {
tips: '',
userInfo: {
number: null,
pasw: null,
phone: null,
code: null,
},
rules: {
'number': [{
required: true,
message: '请填写账号',
trigger: ['blur']
}],
'phone': [{
type: 'number',
required: true,
message: '请填写手机号',
trigger: ['blur']
}, {
validator: (rule, value, callback) => {
return uni.$u.test.mobile(value);
},
message: '请输入格式正确的手机号',
trigger: ['change', 'blur'],
}],
'pasw': [{
required: true,
message: '请填写密码',
trigger: ['blur']
}],
'code': [{
required: true,
message: '请填写验证码',
trigger: ['blur']
}],
},
tab: 0,
};
},
methods: {
pwdLog() {
this.tab = 0
this.$refs.loginForm.clearValidate()
},
codeLog() {
this.tab = 1
this.$refs.loginForm.clearValidate()
},
goRegist() {
uni.navigateTo({
url: '/pages/Login/Register'
})
},
goRemeber() {
uni.navigateTo({
url: '/pages/Login/RemeberPW'
})
},
login() {
if (this.tab == 0) {
this.http.request('/auth/loginByPwd', {
phone: this.userInfo.number,
pwd: this.userInfo.pasw
}, "POST").then(res => {
if (res.code == 200) {
uni.navigateTo({
url: '/pages/pageHome/pageHome'
})
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
})
} else if (this.tab == 1) {
this.http.request('/auth/loginByPhone', {
phone: this.userInfo.phone,
code: this.userInfo.code
}, "POST").then(res => {
if (res.code == 200) {
uni.navigateTo({
url: '/pages/pageHome/pageHome'
})
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
})
}
if (this.$refs.uCode.canGetCode) {
//
uni.showLoading({
title: '正在获取验证码'
})
this.http.request('/auth/getCode?phone=' + this.userInfo.phone, {}, "GET").then(res => {
if (res.code == 200) {
uni.hideLoading();
uni.$u.toast('验证码已发送');
this.$refs.uCode.start();
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
})
} else {
uni.$u.toast('倒计时结束后再发送');
}
},
},
onReady() {
this.$refs.loginForm.setRules(this.rules);
},
}
},
codeChange(text) {
this.tips = text;
},
getCode() {
uni.hideKeyboard()
if (!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(this.userInfo.phone))) { //
uni.showToast({
title: '请填写正确手机号码',
icon: "none"
});
return false;
}
if (this.$refs.uCode.canGetCode) {
//
uni.showLoading({
title: '正在获取验证码'
})
this.http.request('/auth/getCode?phone=' + this.userInfo.phone, {}, "GET").then(res => {
if (res.code == 200) {
uni.hideLoading();
uni.$u.toast('验证码已发送');
this.$refs.uCode.start();
}
}).catch(e => {
uni.showToast({
title: e.data.message,
icon: "none",
});
})
} else {
uni.$u.toast('倒计时结束后再发送');
}
},
},
onReady() {
this.$refs.loginForm.setRules(this.rules);
},
}
</script>
<style lang="scss">
.content_main {
margin: 0rpx 76rpx;
.content_main {
margin: 0rpx 76rpx;
.copyright_iocn {
margin: 0rpx 0rpx 120rpx;
display: flex;
align-items: center;
justify-content: center;
}
.copyright_iocn {
margin: 0rpx 0rpx 120rpx;
display: flex;
align-items: center;
justify-content: center;
}
.other_op {
display: flex;
justify-content: space-between;
align-items: center;
padding: 24rpx 0rpx;
}
.other_op {
display: flex;
justify-content: space-between;
align-items: center;
padding: 24rpx 0rpx;
}
.tab_op {
height: 60rpx;
width: 100%;
height: 60rpx;
overflow: hidden;
font-size: 16px;
font-weight: 600;
.tab_op {
height: 60rpx;
width: 100%;
height: 60rpx;
overflow: hidden;
font-size: 16px;
font-weight: 600;
.choosed {
width: 200rpx;
text-align: center;
color: #99241B;
float: left;
font-size: 17px;
}
.choosed {
width: 200rpx;
text-align: center;
color: #99241B;
float: left;
font-size: 17px;
}
.unchoosed {
width: 200rpx;
text-align: center;
color: #32333B;
float: left;
}
}
}
.unchoosed {
width: 200rpx;
text-align: center;
color: #32333B;
float: left;
}
}
}
</style>

View File

@ -167,15 +167,15 @@
<view class="person_itm_sign" @click="goChangeInfo('地址','宁波象山县')">
<text class="person_itm_sign_tit">地址</text>
<view class="person_itm_sign_right">
<text>地址</text>
<text>宁波象山县</text>
<u-icon name="arrow-right"></u-icon>
</view>
</view>
<view class="person_itm_sign">
<view class="person_itm_sign" @click="goChangeInfo('实景照','照片url')">
<text class="person_itm_sign_tit">实景照</text>
<view class="person_itm_sign_right">
<!-- <text>地址</text> -->
<u-icon name="arrow-right"></u-icon>
</view>
</view>
@ -183,7 +183,7 @@
<view class="person_itm_sign">
<text class="person_itm_sign_tit">资质证</text>
<view class="person_itm_sign_right">
<!-- <text>地址</text> -->
<u-icon name="arrow-right"></u-icon>
</view>
</view>