Login.vue
3.6 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<template>
<div class="register">
<h2 @click="back1"><</h2>
<div class="header">
<img src="../assets/01.png" alt="">
</div>
<div class="center" type=">
<form action="" method="post" onsubmit="return checkForm(this)">
<input id="p_tel" type="text" name="p_tel" v-model="loginForm.mobile" placeholder="请输入手机号"/><hr/>
<input id="p_cardid" type="text" name="p_cardid" v-model="loginForm.password" placeholder="请输入密码" /><hr/>
<div class="footer">
<p @click="goForget">忘记密码</p><p @click="goRegister">注册</p>
</div>
<button type="submit" @click="goLoginSuccessful">登录</button>
</form>
</div>
</div>
</template>
<script>
import { mapMutations } from 'vuex'
export default {
name: 'register',
components: {
},
data () {
return {
loginForm: {
mobile: '',
password: ''
}
}
},
mounted: function () {
},
methods: {
back1 () {
this.$router.go(-1)
},
goForget () {
this.$router.push('/forget')
},
goRegister () {
this.$router.push('/register')
},
...mapMutations(['changeLogin']),
goLoginSuccessful () {
this.$router.push('/loginSuccessful')
let _this = this
if (this.loginForm.mebile === '' || this.loginForm.passeord === '') {
alert('手机号和密码不能为空')
} else {
_this.$axios({
method: 'post',
url: 'api/Login/login',
data: _this.loginForm
}).then(res => {
console.log(res.data)
_this.userToken = 'token' + res.data.data.body.token
_this.changeLogin({ Authorization: _this.userToken })
localStorage.removeItem('Authorization')
_this.$router.push('/loginSuccessful')
alert('登录成功')
}).catch(error => {
alert('手机号或密码错误')
console.log(error)
})
}
}
}
}
</script>
<style lang="scss" scoped>
.register{
width:100%;
height:100%;
background:#11A7FC;
padding-top:5%;
padding-left:5%;
h2{
font-size:.2rem;
color:#fff;
margin-bottom:.5rem;
}
.van-dialog .bar{
width:90%;
height:1.2rem;background:rgba(217,241,255,1);;
margin-left:5%;
border-radius:.2rem;
padding-top:.2rem;
margin-bottom:.2rem;
margin-top:.2rem;
p{
color:#11A7FC;
text-align:center;
margin-bottom:.2rem;
}
span{
color:#11A7FC;
text-align:center;
display:inline-block;
}
}
p{
text-align:center;
// margin-top:0.2rem;
}
.header{
width:60%;
height:.4rem;
margin-left:25%;
}
.center{
width:80%;
margin-top:.7rem;
margin-left:7%;
input{
width:100%;
height:.5rem;
font-size:.2rem;
display:block;
background-color:#11A7FC;
border:none;
color:#fff;
padding-left:4%;
}
hr{
color:#fff;
opacity:0.3;
}
.footer{
width:100%;
height:0.6rem;
display:flex;
justify-content:space-between;
p{
font-size:.2rem;
color:#fff;
line-height:.6rem;
}
}
button{
width:100%;
height:.5rem;
font-size:0.2rem;
border-radius:.2rem;
color:#11A7FC;
font-weight:bold;
border:none;
}
}
}
</style>