|
@@ -7,14 +7,14 @@
|
|
|
<u-subsection @change="sectionChange" :list="list" :current="current" active-color="#007AFF" inactive-color="#ffffff" bg-color="rgba(255,255,255,0.52)"></u-subsection>
|
|
|
</view>
|
|
|
<view class="login_box">
|
|
|
- <u-form :model="form" ref="uForm" v-if="current==0">
|
|
|
- <u-form-item ><u-input type="idcard" v-model="form.account" placeholder="手机号/学员身份证"/></u-form-item>
|
|
|
- <u-form-item ><u-input v-model="form.pwd" type="password" placeholder="登录密码"/></u-form-item>
|
|
|
+ <u-form :model="form" ref="uForm1" v-show="current==0">
|
|
|
+ <u-form-item prop="account" ><u-input type="idcard" v-model="form.account" placeholder-style="color:#999999" placeholder="手机号/学员身份证"/></u-form-item>
|
|
|
+ <u-form-item prop="pwd" ><u-input class="password" v-model="form.pwd" placeholder-style="color:#999999" type="password" placeholder="登录密码"/></u-form-item>
|
|
|
</u-form>
|
|
|
- <u-form :model="form" ref="uForm" v-if="current==1">
|
|
|
- <u-form-item ><u-input type="number" maxlength="11" v-model="form.tel" placeholder="手机号"/></u-form-item>
|
|
|
- <u-form-item >
|
|
|
- <u-input v-model="form.code" type="number" placeholder="验证码"/>
|
|
|
+ <u-form :model="form" ref="uForm2" v-show="current==1">
|
|
|
+ <u-form-item prop="tel" ref="tel"><u-input type="number" maxlength="11" placeholder-style="color:#999999" v-model="form.tel" placeholder="手机号"/></u-form-item>
|
|
|
+ <u-form-item prop="code" >
|
|
|
+ <u-input v-model="form.code" type="number" placeholder-style="color:#999999" placeholder="验证码"/>
|
|
|
<u-button slot="right" size="mini" @click="getCode">{{codeTips}}</u-button>
|
|
|
</u-form-item>
|
|
|
</u-form>
|
|
@@ -61,6 +61,50 @@ export default {
|
|
|
name: '短信登录'
|
|
|
}
|
|
|
],
|
|
|
+ rules: {
|
|
|
+ tel: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请输入手机号',
|
|
|
+ // 可以单个或者同时写两个触发验证方式
|
|
|
+ trigger: ['change','blur'],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ // 上面有说,返回true表示校验通过,返回false表示不通过
|
|
|
+ // this.$u.test.mobile()就是返回true或者false的
|
|
|
+ return this.$u.test.mobile(value);
|
|
|
+ },
|
|
|
+ message: '手机号码格式不正确',
|
|
|
+ // 触发器可以同时用blur和change
|
|
|
+ trigger: ['change','blur'],
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ account: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请输入手机号/学员身份证',
|
|
|
+ // 可以单个或者同时写两个触发验证方式
|
|
|
+ trigger: ['change','blur'],
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ pwd: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请输入密码',
|
|
|
+ // 可以单个或者同时写两个触发验证方式
|
|
|
+ trigger: ['change','blur'],
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ code: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请输入验证码',
|
|
|
+ // 可以单个或者同时写两个触发验证方式
|
|
|
+ trigger: ['change','blur'],
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ },
|
|
|
current: 0,
|
|
|
codeTips: '',
|
|
|
isUse:false,
|
|
@@ -68,6 +112,8 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
onLoad(option) {
|
|
|
+ this.$refs.uForm1.setRules(this.rules)
|
|
|
+ this.$refs.uForm2.setRules(this.rules)
|
|
|
if(option.isBack){
|
|
|
this.isBack = option.isBack;
|
|
|
}
|
|
@@ -96,57 +142,62 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
sms_login(){
|
|
|
- let that = this
|
|
|
- if(!this.form.tel){
|
|
|
- this.$u.toast('请输入手机号码');
|
|
|
- return
|
|
|
- }
|
|
|
- if(!this.form.code){
|
|
|
- this.$u.toast('请输入验证码');
|
|
|
- return
|
|
|
- }
|
|
|
- that.isUse = true
|
|
|
- let datas = {
|
|
|
- tel:this.form.tel,
|
|
|
- code:this.form.code
|
|
|
- }
|
|
|
- that.$api.smsLogin(datas).then(
|
|
|
- res => {
|
|
|
- that.isUse = false
|
|
|
- if (res.data.code == 200) {
|
|
|
- if(res.data.data.full_info){
|
|
|
- //信息完善,直接进入页面
|
|
|
- uni.setStorageSync('user_account', res.data.data.user_account);
|
|
|
- uni.setStorageSync('token', res.data.data.token);
|
|
|
- that.$api.getInfo().then(resdata => {
|
|
|
- if(resdata.data.code == 200){
|
|
|
- that.$store.state.userInfo = resdata.data.data;
|
|
|
-
|
|
|
- if(!that.isBack){
|
|
|
- uni.reLaunch({
|
|
|
- url:'/pages/index/index'
|
|
|
- })
|
|
|
- }else{
|
|
|
- uni.navigateBack();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
- }else{
|
|
|
- //未完善信息,存为临时信息
|
|
|
- uni.setStorageSync('user_account_temp', res.data.data.user_account);
|
|
|
- uni.setStorageSync('token_temp', res.data.data.token);
|
|
|
- that.$navTo.togo('/pages2/register/bind');
|
|
|
- }
|
|
|
- } else {
|
|
|
- that.$u.toast(res.data.msg);
|
|
|
+ this.$refs.uForm2.validate(valid => {
|
|
|
+ if(valid) {
|
|
|
+ let that = this
|
|
|
+ if(!this.form.tel){
|
|
|
+ this.$u.toast('请输入手机号码');
|
|
|
+ return
|
|
|
}
|
|
|
- },
|
|
|
- err => {
|
|
|
- that.isUse = false
|
|
|
+ if(!this.form.code){
|
|
|
+ this.$u.toast('请输入验证码');
|
|
|
+ return
|
|
|
+ }
|
|
|
+ that.isUse = true
|
|
|
+ let datas = {
|
|
|
+ tel:this.form.tel,
|
|
|
+ code:this.form.code
|
|
|
+ }
|
|
|
+ that.$api.smsLogin(datas).then(
|
|
|
+ res => {
|
|
|
+ that.isUse = false
|
|
|
+ if (res.data.code == 200) {
|
|
|
+ if(res.data.data.full_info){
|
|
|
+ //信息完善,直接进入页面
|
|
|
+ uni.setStorageSync('user_account', res.data.data.user_account);
|
|
|
+ uni.setStorageSync('token', res.data.data.token);
|
|
|
+ that.$api.getInfo().then(resdata => {
|
|
|
+ if(resdata.data.code == 200){
|
|
|
+ that.$store.state.userInfo = resdata.data.data;
|
|
|
+
|
|
|
+ if(!that.isBack){
|
|
|
+ uni.reLaunch({
|
|
|
+ url:'/pages/index/index'
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ uni.navigateBack();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ }else{
|
|
|
+ //未完善信息,存为临时信息
|
|
|
+ uni.setStorageSync('user_account_temp', res.data.data.user_account);
|
|
|
+ uni.setStorageSync('token_temp', res.data.data.token);
|
|
|
+ that.$navTo.togo('/pages2/register/bind');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ that.$u.toast(res.data.msg);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ err => {
|
|
|
+ that.isUse = false
|
|
|
+ }
|
|
|
+ );
|
|
|
}
|
|
|
- );
|
|
|
+ })
|
|
|
+
|
|
|
},
|
|
|
fakeLogin(){
|
|
|
uni.setStorageSync('user_account', '123');
|
|
@@ -211,26 +262,28 @@ export default {
|
|
|
// 获取验证码
|
|
|
getCode() {
|
|
|
let that = this
|
|
|
- if(that.$refs.uCode.canGetCode) {
|
|
|
- if(!this.form.tel){
|
|
|
- this.$u.toast('请输入手机号码');
|
|
|
- return
|
|
|
- }
|
|
|
- let datas = {tel:this.form.tel}
|
|
|
- that.$api.loginSms(datas).then(
|
|
|
- res => {
|
|
|
- if (res.data.code == 200) {
|
|
|
- that.$u.toast('验证码已发送');
|
|
|
- // 通知验证码组件内部开始倒计时
|
|
|
- that.$refs.uCode.start();
|
|
|
- } else {
|
|
|
- that.$u.toast(res.data.msg);
|
|
|
+ if(that.$refs.uCode.canGetCode) {
|
|
|
+ if(that.$refs.tel.validateState == 'success') {
|
|
|
+ let datas = {tel:this.form.tel}
|
|
|
+ that.$api.loginSms(datas).then(
|
|
|
+ res => {
|
|
|
+ if (res.data.code == 200) {
|
|
|
+ that.$u.toast('验证码已发送');
|
|
|
+ // 通知验证码组件内部开始倒计时
|
|
|
+ that.$refs.uCode.start();
|
|
|
+ } else {
|
|
|
+ that.$u.toast(res.data.msg);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ err => {
|
|
|
+ console.log(err);
|
|
|
}
|
|
|
- },
|
|
|
- err => {
|
|
|
- console.log(err);
|
|
|
- }
|
|
|
- );}
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ this.$refs.tel.onFieldBlur()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
sectionChange(index) {
|
|
|
this.current = index;
|
|
@@ -347,6 +400,16 @@ export default {
|
|
|
border-radius: 24rpx;
|
|
|
margin-top: 30rpx;
|
|
|
padding:40rpx 35rpx;
|
|
|
+
|
|
|
+
|
|
|
+ .password {
|
|
|
+ /deep/.uicon-eye-fill {
|
|
|
+ &::before{
|
|
|
+ color:#007AFF;
|
|
|
+ content:"\e613";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
/deep/ .u-item-bg{
|
|
|
border-radius: 32px !important;
|