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

View File

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