185 lines
4.8 KiB
Vue
Raw Normal View History

2024-04-18 13:44:38 +08:00
<template>
<div class="login-wrapper">
<div class="login-container">
<div class="title-container">
<h1 class="title margin-no">登录到</h1>
<h1 class="title" v-if="info!=''">{{info.association_name}}</h1>
<h1 class="title" v-if="info==''">智慧云商协后台管理系统</h1>
</div>
<t-form
ref="form"
:class="['item-container', `login-login`]"
:data="formData"
:rules="FORM_RULES"
label-width="0"
@submit="onSubmit"
>
<template>
<t-form-item name="zhanghu">
<t-input v-model="formData.zhanghu" size="large" placeholder="请输入账号admin">
<template #prefix-icon>
<user-icon/>
</template>
</t-input>
</t-form-item>
<t-form-item name="password">
<t-input
v-model="formData.password"
size="large"
type="password"
clearable
key="password"
placeholder="请输入登录密码admin"
>
<template #prefix-icon>
<lock-on-icon/>
</template>
<template #suffix-icon>
<browse-icon v-if="showPsw" @click="showPsw = !showPsw" key="browse"/>
<browse-off-icon v-else @click="showPsw = !showPsw" key="browse-off"/>
</template>
</t-input>
</t-form-item>
<div class="check-container remember-pwd">
<t-checkbox>记住账号</t-checkbox>
<div style="color: var(--td-brand-color)">
<span @click="openUrl(0)">会员注册</span>
<span style="margin-left: 20px" @click="openUrl(1)">会员登录</span>
</div>
</div>
</template>
<t-form-item class="btn-container">
<t-button block size="large" type="submit"> 登录</t-button>
</t-form-item>
</t-form>
</div>
<footer class="copyright">Copyright @ 2021-2022 Tencent. All Rights Reserved</footer>
</div>
</template>
<script>
import {UserIcon, LockOnIcon} from 'tdesign-icons-vue';
export default {
components: {
UserIcon,
LockOnIcon,
},
data() {
return {
formData: {
zhanghu: 'admin',
password: 'qinze731344.',
},
FORM_RULES: {
zhanghu: [{required: true, message: '账号必填', type: 'error'}],
password: [{required: true, message: '密码必填', type: 'error'}],
},
showPsw: false,
countDown: 0,
intervalTimer: null,
id:0,
info:''
};
},
mounted() {
console.log(this.$route.query.id);
if(typeof (this.$route.query.id)!='undefined'){
this.id=this.$route.query.id;
this.getInfo();
}
},
methods: {
openUrl(type){
if(this.id===0){
if(type==0){
this.$message.error('后台注册链接有误,请联系管理员或者后台链接!',);
}else{
this.$message.error('后台登录链接有误,请联系管理员或者后台链接!',);
}
}else{
if(type==0){
this.$router.push('/register?id='+this.id);
}else{
this.$router.push('/land?id='+this.id);
}
}
},
getInfo(){
this.$request
.post("/association/find",{association_id:this.id})
.then( (res) => {
console.log(res);
if(res.code==1){
this.info=res.data;
}
})
.catch((e) => {
console.log(e);
});
},
async onSubmit({ validateResult }) {
if (validateResult === true) {
this.$request
.post("/login/login",this.formData)
.then( (res) => {
console.log(res);
if(res.code === 0){
this.$message.error('帐号或密码错误!');
}else{
this.$store.dispatch('user/login', res.data);
this.$message.success('登录成功');
setTimeout(() => {
this.$router.push('/dashboard/base');
}, 1000);
}
})
.catch((e) => {
console.log(e);
});
}
},
},
};
</script>
<style lang="less">
@import url('./index.less');
.login-header {
height: var(--td-comp-size-xxxl);
padding: 0 24px;
display: flex;
justify-content: space-between;
align-items: center;
backdrop-filter: blur(5px);
color: var(--td-text-color-primary);
.logo {
width: 188px;
height: var(--td-comp-size-xxxl);
}
.operations-container {
display: flex;
align-items: center;
.t-button {
margin-left: 16px;
}
.icon {
height: 20px;
width: 20px;
padding: 6px;
box-sizing: content-box;
&:hover {
cursor: pointer;
}
}
}
}
</style>