2020-11-06 15:33:50 +08:00

82 lines
2.1 KiB
Vue

<!-- -->
<template>
<div>
<router-view></router-view>
<div @dblclick="handleClick" class="hide">
</div>
<div v-if="!islzmanagement && isShow" class="login">
<el-input
style="width:400px;"
placeholder="请输入内容"
v-model="input"
clearable>
</el-input>
<el-button @click="handleLogin" type="primary"> </el-button>
<div style="margin:20px 0;">token : {{token}}</div>
</div>
</div>
</template>
<script>
import { apiLogin, apiSendSMS, apiUserInfo } from '@/api/data'
import { mapMutations } from 'vuex'
let hostList = 'lzmanagement.ldxinyong.com'
let thostList = 'tlzmanagement.ldxinyong.com'
const islzmanagement = window.location.host.indexOf('hostList') > -1 && window.location.host.indexOf('hostList') < 0
export default {
data () {
return {
isShow: true,
islzmanagement,
input: localStorage.getItem('input'),
verify: '888888',
token: this.$cookies.get('token')
}
},
computed: {},
beforeMount () {},
mounted () {},
methods: {
...mapMutations(['SET_USER_INFO']),
handleClick () {
this.isShow = !this.isShow
},
// async handleVerify () {
// const params = {'userName': this.input, 'password': 'admin', 'uuid': '', 'verify': this.verify, 'verifyCode': this.verify}
// let res = await apiSendSMS(params)
// console.log('res: ', res)
// },
async handleLogin () {
localStorage.setItem('input', this.input)
const params = {'userName': this.input, 'password': 'admin', 'uuid': '', 'verify': this.verify, 'verifyCode': this.verify}
let res = await apiLogin(params)
if (res.code === 200) {
this.token = res.token
this.$cookies.set('token', res.token, res.expire)
let ress = await apiUserInfo()
if (ress.code === 200) {
this.SET_USER_INFO(ress.user)
}
console.log('ress: ', ress)
location.reload()
}
}
},
watch: {}
}
</script>
<style lang='less' scoped>
.login{
margin: 20px 0;
}
.hide{
width: 100px;
height: 100px;
}
</style>