cardToken.vue
2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<template>
<div>
<nav-bar>
<div slot="left" class="back">
<img src="../../assets/img/back.png" alt="" @click="goBack" />
</div>
</nav-bar>
<div class="token_content">
<img src="../../assets/img/logo2.png" alt="" class="content_logo"/>
<div class="content_input display-flex-between">
<input type="text" placeholder="请输入账号" v-model="idcard" />
</div>
<div class="content_input display-flex-between">
<input :type="islook?'text':'password'" maxlength="20" placeholder="请输入6-12位数(英文字母/数字)" v-model="password" />
<div @click="islook=!islook">
<img :src="islook?require('../../assets/img/eye2.png'):require('../../assets/img/look.png')" alt="" class="content_input_eye"/>
</div>
</div>
<div class="button_token" :class="isclick?'':'opacity'" @click="token">登录</div>
<div class="tip display-flex-between">
<router-link style="color: #A7A6B3;" to="/forget">忘记密码</router-link>
<router-link style="color: #257CFF;" to="/phone">手机号登录</router-link>
</div>
</div>
</div>
</template>
<script>
import '@/assets/style/token.css'
export default {
name: 'cardToken',
data () {
return {
idcard: '',
password: '',
islook: false
}
},
computed: {
isclick: {
set: function () {},
get: function () {
return this.idcard !== '' && this.password !== ''
}
}
},
mounted () {
// localStorage.removeItem('token')
// localStorage.removeItem('userinfo')
// localStorage.removeItem('indexCurrent')
// localStorage.removeItem('postname')
// localStorage.removeItem('pId')
},
methods: {
goBack () {
this.$router.go(-1)
},
async token () {
const that = this
if (that.isclick) {
const params = {
account: that.idcard,
password: that.password
}
console.log(params)
const reslist = await that.api.cardtoken(params)
if (reslist.code === 1) {
localStorage.setItem('token', reslist.data.userinfo.token)
const userinfo = reslist.data.userinfo
localStorage.setItem('postname', userinfo.pos_name)
localStorage.setItem('pId', userinfo.pos_id)
localStorage.setItem('userinfo', userinfo)
localStorage.setItem('indexCurrent', 0)
that.$router.push('/home')
} else {
that.$toast(reslist.msg)
}
}
}
}
}
</script>
<style lang="scss" scoped>
</style>