Commit 71b9983e by tang

feat: 注册登录调试,

parent 2f2e7205
...@@ -9,6 +9,18 @@ const login = (params = {}) => { ...@@ -9,6 +9,18 @@ const login = (params = {}) => {
return POST(`${Prefix}/office/loglogin/authApi/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 { export default {
login, login,
register,
code,
} }
<template> <template>
<div class="header-btn move-btn"> <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> </el-button>
<!-- Toggler --> <!-- Toggler -->
...@@ -21,17 +23,32 @@ ...@@ -21,17 +23,32 @@
<script> <script>
export default { export default {
name: "HeaderBtn", name: "HeaderBtn",
data() {
return {
user: null
}
},
methods: { methods: {
handleToLogin() { handleToLogin() {
this.$router.push({path: "/login"}); 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> </script>
<style lang="scss"> <style lang="scss">
.header-btn{ .header-btn {
button{ button {
&:hover{ &:hover {
background: #CC3C0F; background: #CC3C0F;
} }
} }
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
v-model="search.result" v-model="search.result"
class="w40" class="w40"
></el-input> ></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> target="_blank" class="hover">检验码计算方法</a>
</div> </div>
</el-form-item> </el-form-item>
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<p> <p>
1.请根据下列提示,输入商品的包装指示符和商品条码,系统会自动计算出它的校验码。欲了解校验码的计算规则,请点击 1.请根据下列提示,输入商品的包装指示符和商品条码,系统会自动计算出它的校验码。欲了解校验码的计算规则,请点击
<a <a
href="http://www.ancc.org.cn/Knowledge/goodsGln.aspx" href="/Knowledge"
target="_blank" target="_blank"
style="color: #5ac8fa" style="color: #5ac8fa"
>了解更多 >></a >了解更多 >></a
......
...@@ -20,11 +20,11 @@ ...@@ -20,11 +20,11 @@
</el-form-item> </el-form-item>
<el-form-item class="validate-append" <el-form-item class="validate-append"
prop="verification" prop="captcha"
:rules="[{ required: true, message: '请输入验证码', trigger: 'blur' }]" :rules="[{ required: true, message: '请输入验证码', trigger: 'blur' }]"
> >
<el-input <el-input
v-model="userForm.verification" v-model="userForm.captcha"
placeholder="请输入验证码" placeholder="请输入验证码"
> >
<template slot="append"><img :src="captchaPath" style="cursor: pointer" @click="getCaptcha" alt=""> <template slot="append"><img :src="captchaPath" style="cursor: pointer" @click="getCaptcha" alt="">
...@@ -69,11 +69,10 @@ export default { ...@@ -69,11 +69,10 @@ export default {
userForm: { userForm: {
userName: '', userName: '',
passWord: '', passWord: '',
verification: '' captcha: ''
}, },
captchaPath: '', captchaPath: '',
uuid: '', uuid: '',
captcha: '',
errorMsg: '', errorMsg: '',
} }
}, },
...@@ -113,12 +112,14 @@ export default { ...@@ -113,12 +112,14 @@ export default {
// this.showUserLoginError = true; // this.showUserLoginError = true;
// } // }
this.$api.user.login({ this.$api.user.login({
...this.userForm ...this.userForm,
uuid: this.uuid
}).then(res => { }).then(res => {
console.log(res, !res.success) console.log(res, !res.success)
if (!res.success) { if (!res.success) {
this.userLoginError = res.returnMsg || '用户名或密码不正确!' this.userLoginError = res.returnMsg || '用户名或密码不正确!'
this.showUserLoginError = true; this.showUserLoginError = true;
this.getCaptcha();
} else { } else {
localStorage.setItem('loginInfo', JSON.stringify(res.data)) localStorage.setItem('loginInfo', JSON.stringify(res.data))
localStorage.setItem('TOKEN', res.data.token) localStorage.setItem('TOKEN', res.data.token)
...@@ -136,26 +137,11 @@ export default { ...@@ -136,26 +137,11 @@ export default {
}) })
} else { } else {
console.log('error submit!!'); console.log('error submit!!');
this.getCaptcha()
return false; 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> </script>
......
...@@ -116,22 +116,56 @@ export default { ...@@ -116,22 +116,56 @@ export default {
}, },
methods: { methods: {
register() { 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() { sendValidateCode() {
if (this.form.mobile === '') { if (this.form.mobile === '' || this.form.userName === '') {
this.$message({type: 'error', message: '请输入手机号码'}); this.$message({type: 'error', message: '手机号码和用户名不能为空'});
} else { } else {
this.hasSent = true; this.$api.user.code({
this.timer = setInterval(() => { "userName": this.form.userName,
this.time -= 1; "phone": this.form.mobile,
if (this.time === 0) { }).then(res => {
clearInterval(this.timer); console.log(res)
this.time = 60; if(res.success){
this.hasSent = false; this.$message({type: 'success', message: '发送成功'});
this.hasSent = true;
this.timer = setInterval(() => {
this.time -= 1;
if (this.time === 0) {
clearInterval(this.timer);
this.time = 60;
this.hasSent = false;
}
}, 1000);
}else{
} }
}, 1000); }).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