Skip to content

Commit

Permalink
添加空数据判断
Browse files Browse the repository at this point in the history
  • Loading branch information
suvvm committed Dec 4, 2019
1 parent a2330cf commit 30690f2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 31 deletions.
27 changes: 9 additions & 18 deletions pages/index/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,13 @@
<view class="content">
<image class="logo" src="/static/logo.png"></image>
<van-cell-group class="uinfoGroup">
<van-field
v-model="username"
required
clearable
label="用户名"
right-icon="question-o"
placeholder="请输入用户名"
<van-field v-model="username" required clearable label="用户名"
right-icon="question-o" placeholder="请输入用户名"
@click-right-icon="$toast('可输入用户名手机号或邮箱')"
rows="1"
autosize
/>
rows="1" autosize />
</van-cell-group>
<van-cell-group class="uinfoGroup">
<van-field
v-model="password"
type="password"
label="密 码"
placeholder="请输入密码"
required
/>
<van-field v-model="password" type="password" label="密 码" placeholder="请输入密码" required />
</van-cell-group>
<van-cell-group class="btnGroup">
<van-button plain class="submit" type="primary" size="large" @click="toRegister" hairline >立刻注册</van-button>
Expand Down Expand Up @@ -65,7 +52,11 @@
message: '登录中'
});
if(this.username == '' || this.password == ''){
this.$toast.clear();
this.$toast.fail('请输入必填信息');
return;
}
var rp = require('request-promise');
var options = {
Expand Down
7 changes: 6 additions & 1 deletion pages/loginFV/loginFV.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/>
</van-cell-group>
<van-uploader :after-read="afterRead">
<van-button class="submit" icon="photo" type="primary" size="large" >人脸识别登录</van-button>
<van-button class="submit" icon="photo" type="primary" size="large" capture="camera">人脸识别登录</van-button>
</van-uploader>
<van-button class="submit" plain hairline size="large" @click="toRegister" type="primary">立刻注册</van-button>
</view>
Expand Down Expand Up @@ -44,6 +44,11 @@
forbidClick: true, // 禁用背景点击
message: '识别中'
});
if(this.pnum == '') {
this.$toast.clear();
this.$toast.fail('请输入必填信息');
return;
}
// 压缩图片
lrz(file.file, {
quality: 0.7
Expand Down
30 changes: 19 additions & 11 deletions pages/register/register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
this.$toast.fail("上传失败")
})
this.avatar = file.content.slice(23);
console.log(file.content.slice(23));
// console.log(file.content.slice(23));
},
afterReadFace(file) {
Expand All @@ -159,7 +159,7 @@
this.$toast.fail("上传失败")
})
this.imgfile = file.content.slice(23);
console.log(file.content.slice(23));
// console.log(file.content.slice(23));
},
sentIdentify() {
// 发送验证码按钮倒计时
Expand Down Expand Up @@ -204,7 +204,7 @@
}
}).catch(err => {
// POST 失败
console.log(err);
// console.log(err);
this.$toast.fail('发送失败,请检查网络连接');
});
},
Expand All @@ -215,11 +215,19 @@
message: '注册中'
});
// if(this.sms != this.identifyCode || this.sms == ''){
// this.$toast.clear();
// this.$toast.fail('验证码错误,请准确填写验证码!');
// return;
// }
if(this.sms == '' || this.username == '' || this.password == '' || this.name == '' ||
this.pnum == '' || this.email == '' || this.avatar == '' || this.imgfile == '') {
this.$toast.clear();
this.$toast.fail('请填写必填信息');
return;
}
if(this.sms != this.identifyCode){
this.$toast.clear();
this.$toast.fail('验证码错误,请准确填写验证码!');
return;
}
// console.log("username:" + this.username + "password:"
// + this.password + " name:" + this.name + " pnum:" + this.pnum
Expand Down Expand Up @@ -252,20 +260,20 @@
var userInfo = {"username":user.username,"name":user.name,"pnum":user.pnum,
"email":user.email,"gender":user.gender,"power":user.power,"id":user.id};
console.log(userInfo);
// console.log(userInfo);
// 存cookies
this.$cookies.set("userInfo", userInfo, 60 * 60 * 24 * 7);
// 跳转到角色选择页
this.$router.push({
path: '/pages/register/registerRole',
})
console.log(res)
// console.log(res);
}).catch(err => {
this.$toast.clear();
this.$toast.fail('注册失败,请检查网络连接!');
// POST failed...
console.log(err)
// console.log(err);
});
}
}
Expand Down
13 changes: 12 additions & 1 deletion pages/register/registerCompany.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@
message: '提交中'
});
if(this.name == '' || this.forms == '' || this.domain == '' || this.description == '') {
this.$toast.clear();
this.$toast.fail('请填写必填信息');
return;
}
if(this.userInfo == null) {
this.$toast.clear();
this.$toast.fail('为找到用户');
return;
}
var rp = require('request-promise');
var options = {
method: 'POST',
Expand All @@ -82,7 +93,7 @@
this.$cookies.set("userInfo", this.userInfo, 60 * 60 * 24 * 7);
this.$toast.success('提交成功');
this.$router.push({
path: '/pages/user/user',
path: '/pages/register/registerCompleted',
});
console.log(res)
}).catch(err => {
Expand Down

0 comments on commit 30690f2

Please sign in to comment.