login.vue
4.2 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<template>
<!-- 登录页 -->
<view class="login">
<!-- 手机号登录 -->
<view class="phoneLogin">
<view class="phoneSize">
<p class="BigSize">手机号登录</p>
<view class="firstLogin">
首次登录享受新人福利
</view>
</view>
<u-field v-model="phone" label="手机号" placeholder="请填写手机号" :error-message="errorMessage" class="inpPhone"
@input="isPhone">
</u-field>
<!-- <input class="inputPhone" v-model="phone" type="text" placeholder="请输入手机号"> -->
<view class="btnCode" @click="gainCode">
获取验证码
</view>
<!-- <view class="NobtnCode" v-if="">
</view> -->
<view class="agreement">
<checkbox @click="consent=!consent" :checked="consent" />
我已阅读并同意<span @click="navAgreement">《幸运星球用户协议》</span>及<span @click="navPolicy">《幸运星球隐私政策》</span>
</view>
</view>
<!-- 提示框 -->
<u-toast ref="uToast" :duration="10" />
</view>
</template>
<script>
export default {
data() {
return {
// 手机号
phone: "",
// 手机号判断
phoneTrue: false,
// 错误提示
errorMessage: '',
// 协议
consent: true,
// 60秒内不能重新获取
// noRepetition:true
};
},
methods: {
//手机号码判断
isPhone(val) {
if (val == "") {
this.errorMessage = "此为必填项"
this.phoneTrue = false
} else {
let re = /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/;
if (re.test(val)) {
this.errorMessage = ""
this.phoneTrue = true
} else {
this.errorMessage = "手机号码不正确"
this.phoneTrue = false
}
}
},
// 获取验证码
async gainCode() {
if (!this.phoneTrue) {
this.$refs.uToast.show({
title: '请填写手机号',
type: 'error'
})
} else if (!this.consent) {
this.$refs.uToast.show({
title: '请勾选协议',
type: 'error'
})
} else {
// this.$Router.replace({
// name: "codeLogin",
// params: {
// phone: this.phone,
// redirect: this.$Route.query.redirect,
// }
// })
try{
await this.$store.dispatch("gainCode",this.phone)
this.$Router.replace({
name:"codeLogin",
params:{
phone:this.phone,
redirect:this.$Route.query.redirect
}
})
}catch(e){
this.$refs.uToast.show({
title: '不能重复获取',
type: 'error'
})
}
}
},
// 跳转用户协议
navAgreement() {
this.$Router.push("/pages/my/agreement/agreement")
},
// 跳转隐私政策
navPolicy() {
this.$Router.push("/pages/my/policy/policy")
},
}
}
</script>
<style lang="scss">
// 登录页
* {
margin: 0;
padding: 0;
}
// 登录
.login {
width: 750rpx;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
// background-color: red;
// 手机号登录
.phoneLogin {
width: 680rpx;
height: 700rpx;
margin-top: 150rpx;
// background-color: red;
display: flex;
flex-direction: column;
align-items: center;
// 字体
.phoneSize {
width: 290rpx;
height: 160rpx;
margin-bottom: 60rpx;
align-self: flex-start;
.BigSize {
font-size: 27px;
font-weight: 550;
margin-bottom: 15rpx;
}
.firstLogin {
color: white;
background-color: blue;
border-radius: 10rpx;
text-align: center;
padding: 3rpx;
}
}
// 手机号输入框
.inpPhone {
width: 650rpx !important;
font-size: 15px !important;
}
// 验证码登录
.btnCode {
width: 650rpx;
height: 80rpx;
background: linear-gradient(129deg, #FFB193 15%, #F72934 100%);
border-radius: 15rpx;
margin: 50rpx 0;
text-align: center;
line-height: 80rpx;
color: white;
font-size: 16px;
}
// 用户协议
.agreement {
width: 500rpx;
font-size: 12px;
span {
color: red;
}
}
}
}
</style>