Commit 71b9983e by tang

feat: 注册登录调试,

parent 2f2e7205
......@@ -9,6 +9,18 @@ const login = (params = {}) => {
return POST(`${Prefix}/office/loglogin/authApi/login`, params)
}
// 用户注册
const register = (params = {}) => {
return POST(`${Prefix}/office/member/api/userRegistered`, params)
}
// 注册获取验证码
const code = (params = {}) => {
return POST(`${Prefix}/office/timescoderegi/api/getVerificationCode`, params)
}
export default {
login,
register,
code,
}
<template>
<div class="header-btn move-btn">
<el-button type="primary" style="padding: 9px 30px;margin-right: 6px" size="small" @click="handleToLogin">注册/登录
<el-button v-if="!user" type="primary" style="padding: 9px 30px;margin-right: 6px" size="small" @click="handleToLogin">注册/登录
</el-button>
<el-button v-else type="primary" style="padding: 9px 30px;margin-right: 6px" size="small" @click="handleExit">退出登录
</el-button>
<!-- Toggler -->
......@@ -21,17 +23,32 @@
<script>
export default {
name: "HeaderBtn",
data() {
return {
user: null
}
},
methods: {
handleToLogin() {
this.$router.push({path: "/login"});
},
handleExit(){
localStorage.removeItem('loginInfo')
localStorage.removeItem('TOKEN')
localStorage.removeItem('gs-user')
this.$router.push({path: "/"});
this.user = null
}
},
created() {
this.user = localStorage.getItem('loginInfo') ? JSON.parse(localStorage.getItem('loginInfo')) : null
},
}
</script>
<style lang="scss">
.header-btn{
button{
&:hover{
.header-btn {
button {
&:hover {
background: #CC3C0F;
}
}
......
......@@ -28,7 +28,7 @@
v-model="search.result"
class="w40"
></el-input>
<a href="http://www.ancc.org.cn/Knowledge/BarcodeArticle.aspx?id=301" style="margin-left: 20px"
<a href="/Knowledge" style="margin-left: 20px"
target="_blank" class="hover">检验码计算方法</a>
</div>
</el-form-item>
......@@ -42,7 +42,7 @@
<p>
1.请根据下列提示,输入商品的包装指示符和商品条码,系统会自动计算出它的校验码。欲了解校验码的计算规则,请点击
<a
href="http://www.ancc.org.cn/Knowledge/goodsGln.aspx"
href="/Knowledge"
target="_blank"
style="color: #5ac8fa"
>了解更多 >></a
......
......@@ -20,11 +20,11 @@
</el-form-item>
<el-form-item class="validate-append"
prop="verification"
prop="captcha"
:rules="[{ required: true, message: '请输入验证码', trigger: 'blur' }]"
>
<el-input
v-model="userForm.verification"
v-model="userForm.captcha"
placeholder="请输入验证码"
>
<template slot="append"><img :src="captchaPath" style="cursor: pointer" @click="getCaptcha" alt="">
......@@ -69,11 +69,10 @@ export default {
userForm: {
userName: '',
passWord: '',
verification: ''
captcha: ''
},
captchaPath: '',
uuid: '',
captcha: '',
errorMsg: '',
}
},
......@@ -113,12 +112,14 @@ export default {
// this.showUserLoginError = true;
// }
this.$api.user.login({
...this.userForm
...this.userForm,
uuid: this.uuid
}).then(res => {
console.log(res, !res.success)
if (!res.success) {
this.userLoginError = res.returnMsg || '用户名或密码不正确!'
this.showUserLoginError = true;
this.getCaptcha();
} else {
localStorage.setItem('loginInfo', JSON.stringify(res.data))
localStorage.setItem('TOKEN', res.data.token)
......@@ -136,26 +137,11 @@ export default {
})
} else {
console.log('error submit!!');
this.getCaptcha()
return false;
}
});
},
sendValidateCode() {
if (this.mobileForm.mobile === '') {
this.$message({type: 'error', message: '请输入手机号码'});
} else {
this.hasSent = true;
this.timer = setInterval(() => {
this.time -= 1;
if (this.time === 0) {
clearInterval(this.timer);
this.time = 60;
this.hasSent = false;
}
}, 1000);
}
}
},
}
</script>
......
......@@ -116,13 +116,40 @@ export default {
},
methods: {
register() {
this.$refs['ruleForm'].validate((valid) => {
if (valid) {
this.$api.user.register({
"userName": this.form.userName,
"e-miail": this.form.email,
"phone": this.form.mobile,
"subjoin": this.form.validate,
"passWord": this.form.password,
"passWord_repeat": this.form.rePassword,
}).then(res => {
if(res.success){
this.$message({type: 'success', message: '注册成功'});
}else{
this.$message({type: 'error', message: res.returnMsg || '注册失败,请联系管理员'});
}
}).catch(err => {
console.log(err)
this.$message({type: 'error', message: '网络繁忙,请联系管理员'});
})
}
})
},
sendValidateCode() {
if (this.form.mobile === '') {
this.$message({type: 'error', message: '请输入手机号码'});
if (this.form.mobile === '' || this.form.userName === '') {
this.$message({type: 'error', message: '手机号码和用户名不能为空'});
} else {
this.$api.user.code({
"userName": this.form.userName,
"phone": this.form.mobile,
}).then(res => {
console.log(res)
if(res.success){
this.$message({type: 'success', message: '发送成功'});
this.hasSent = true;
this.timer = setInterval(() => {
this.time -= 1;
......@@ -132,6 +159,13 @@ export default {
this.hasSent = false;
}
}, 1000);
}else{
}
}).catch(err => {
console.log(err)
this.$message({type: 'error', message: '验证码发送失败,请联系管理员'});
})
}
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment