|
@@ -6,9 +6,9 @@
|
|
|
<el-form ref="form" :model="form" label-width="80px" :label-position="labelPosition">
|
|
|
<el-form-item label="角色" prop="radio">
|
|
|
<el-radio-group v-model="form.radio" v-on:change="judegAccount">
|
|
|
- <el-radio label="1" border>管理员</el-radio>
|
|
|
- <el-radio label="2" border>商家</el-radio>
|
|
|
- <el-radio label="3" border>买家</el-radio>
|
|
|
+ <el-radio label="0" border>管理员</el-radio>
|
|
|
+ <el-radio label="1" border>商家</el-radio>
|
|
|
+ <el-radio label="2" border>买家</el-radio>
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="用户名" prop="name">
|
|
@@ -35,7 +35,7 @@ export default {
|
|
|
msg: '欢迎来到《私人定制》个性化商品网站',
|
|
|
labelPosition: 'top',
|
|
|
form: {
|
|
|
- radio: '1',
|
|
|
+ radio: '0',
|
|
|
name: '',
|
|
|
password: ''
|
|
|
}
|
|
@@ -49,20 +49,17 @@ export default {
|
|
|
if(this.form.name==""){
|
|
|
return;
|
|
|
}
|
|
|
- var accountArr = [];
|
|
|
- var accountName = [];
|
|
|
- switch(this.form.radio){
|
|
|
- case "1":accountArr=this.$store.state.adminAccount;break;
|
|
|
- case "2":accountArr=this.$store.state.shopAccount;break;
|
|
|
- default:accountArr=this.$store.state.buyerAccount;
|
|
|
- }
|
|
|
- for(var i=0,arrLength=accountArr.length;i<arrLength;i++){
|
|
|
- accountName.push(accountArr[i].name);
|
|
|
- }
|
|
|
- if(accountName.indexOf(this.form.name)==-1){
|
|
|
- this.showText('用户名输入错误,请重新输入');
|
|
|
- this.form.name = '';
|
|
|
- }
|
|
|
+ this.axios.post(this.Api.judegAccount,{
|
|
|
+ radio:this.form.radio,
|
|
|
+ name:this.form.name
|
|
|
+ }).then((res)=>{
|
|
|
+ if(res.data==-1){
|
|
|
+ this.showText('用户名输入错误,请重新输入');
|
|
|
+ this.form.name="";
|
|
|
+ }
|
|
|
+ }).catch((err)=>{
|
|
|
+ console.log("judegAccount:"+err);
|
|
|
+ });
|
|
|
},
|
|
|
resetForm(formName) {//重置
|
|
|
this.$refs[formName].resetFields();
|
|
@@ -72,23 +69,26 @@ export default {
|
|
|
this.showText('请输入用户名和密码');
|
|
|
return;
|
|
|
}
|
|
|
- let accountArr = [];
|
|
|
- var type = "";
|
|
|
- switch(this.form.radio){
|
|
|
- case "1":accountArr=this.$store.state.adminAccount;type="admin";break;
|
|
|
- case "2":accountArr=this.$store.state.shopAccount;type="shop";break;
|
|
|
- default:accountArr=this.$store.state.buyerAccount;type="buyer";
|
|
|
- }
|
|
|
- for(var i=0,arrLength=accountArr.length;i<arrLength;i++){
|
|
|
- if(this.form.name==accountArr[i].name&&this.form.password!=accountArr[i].password){
|
|
|
+ this.axios.post(this.Api.login,this.form).then((res)=>{
|
|
|
+ if(res.data.code==200){
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '登陆成功!'
|
|
|
+ });
|
|
|
+ if(this.form.radio=='0'){
|
|
|
+ this.$router.push({path: '/admin'});
|
|
|
+ }else if(this.form.radio=='1'){
|
|
|
+ this.$router.push({path: '/shop'});
|
|
|
+ }else{
|
|
|
+ this.$router.push({path: '/buyer'});
|
|
|
+ }
|
|
|
+ }else{
|
|
|
this.showText('密码输入错误,请重新输入');
|
|
|
- this.form.password = '';
|
|
|
- return;
|
|
|
- }else if(this.form.name==accountArr[i].name&&this.form.password==accountArr[i].password){
|
|
|
- this.$store.commit('login',{userMess:accountArr[i].mess,loginState:this.form.radio})
|
|
|
- this.$router.push({path:`/${type}`});
|
|
|
+ this.form.password="";
|
|
|
}
|
|
|
- }
|
|
|
+ }).catch((err)=>{
|
|
|
+ console.log("login:"+err);
|
|
|
+ });
|
|
|
},
|
|
|
showText(mess){//错误提示
|
|
|
this.$alert(mess, '错了哦', {
|