register.vue
7.44 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<!-- 注册 -->
<template>
<view class="container flex-items flex-column">
<global-loading />
<view class="login-logoBox">
<text style="color:#3f9b6a;font-weight:bold;font-size:30px;">锦江公园</text>
<!-- <image class="login-logo" src="@/static/logo.png"></image> -->
</view>
<view>
<view class="iphoneNum-box flex-row-plus flex-items">
<view>
<image class="loginIcon" src="https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/file/static/images/phone.png"></image>
</view>
<view style="margin-left: 40rpx;">
<input v-model="phone" class="iphoneNum-inputbox" placeholder-class="iphoneNum-input" type="number"
maxlength="11" placeholder="请输入您的手机号" />
</view>
</view>
<view class="flex-row-plus">
<view class="code-box">
<view>
<image class="loginIcon" src="https://zhgw-uat.028wlkj.com/cdwlMall/zsfwzxt/file/static/images/code.png"></image>
</view>
<view style="margin-left: 40rpx;">
<input v-model="RegisterQuery.code" :maxlength="4" class="codeNum-inputbox" placeholder-class="codeNum-input"
placeholder="请输入验证码" />
</view>
</view>
<view :class="disabled === true ? 'on' : ''" :disabled="disabled" class="getcode" @click="codede">
{{text}}
</view>
</view>
</view>
<view class="registerBut" @click="onregister">注册</view>
<view class="flex-row-plus mar-top-30">
<text class="font-color-C5AA7B">已有账号,</text>
<view class="font-color-C5AA7B" @click="gologin">去登录</view>
</view>
<view class="agreement">
<image v-if="!agreement" src="../../static/images/none.png" mode="" @click="agreement=true"></image>
<image v-else src="../../static/images/solid.png" mode="" @click="agreement=false"></image>
<text class="font-color-999">注册即代表同意</text>
<text class="font-color-C5AA7B" @click="protocol('app_user_agreement')">《APP用户服务协议》</text>和
<text class="font-color-C5AA7B" @click="protocol('app_privacy_agreement')">《APP个人隐私协议》</text>
</view>
</view>
</template>
<script>
import sendVerifyCode from "@/mixins/SendVerifyCode";
const NET = require('../../utils/request')
const API = require('../../config/api')
export default {
data() {
return {
getCodeisWaiting: false,
// 注册
phone: '',
RegisterQuery: {
account: "",
code: "",
},
// 获取验证码
VerifyQuery: {
phone: "",
type: ""
},
agreement: false
}
},
mixins: [sendVerifyCode],
onLoad() {
},
methods: {
// 注册账号
getRegister() {
let phoneCodeVerification = /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/;
if (this.phone == '') {
uni.showToast({
title: '请输入手机号!',
duration: 2000,
icon: 'none'
});
} else if (!phoneCodeVerification.test(this.phone)) {
uni.showToast({
title: '请输入正确的手机号!',
duration: 2000,
icon: 'none'
});
} else if (this.RegisterQuery.code == '') {
uni.showToast({
title: '请获取验证码!',
duration: 2000,
icon: 'none'
});
} else if(!this.agreement){
uni.showToast({
title: '请先阅读并同意《用户服务协议和个人隐私协议》',
duration: 2000,
icon: 'none'
});
} else {
// uni.showLoading({
// mask: true,
// title: '正在注册...',
// duration: 2000,
// })
NET.request(API.Login, {
type: 1,
phone: this.phone,
verificationCode: this.RegisterQuery.code,
}, 'POST').then(res => {
uni.hideLoading()
uni.showToast({
title: '注册成功!',
duration: 2000,
icon: 'none'
});
const item = res.data
uni.setStorageSync('storage_key', item);
setTimeout(function() {
uni.switchTab({
url: '../../pages/tabbar/user/index'
})
}, 600)
// uni.navigateTo({
// url: 'accountLogin'
// })
}).catch(res => {
uni.showToast({
title: res.data.message,
duration: 2000,
icon: 'none',
});
})
}
},
// 获取验证码
getVerify() {
let phoneCodeVerification = /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/;
if (this.phone == '') {
uni.showToast({
title: '请输入手机号!',
duration: 2000,
icon: 'none'
});
} else if (!phoneCodeVerification.test(this.phone)) {
uni.showToast({
title: '请输入正确的手机号!',
duration: 2000,
icon: 'none'
});
} else {
this.VerifyQuery.phone = this.phone
NET.request(API.Verify, {
phone: this.VerifyQuery.phone,
}, 'GET').then(res => {
this.sendCode()
}).catch(res => {
uni.showToast({
title: res.data.message,
icon: 'none',
duration: 1000
});
})
}
},
// 注册
onregister() {
this.getRegister()
},
// 获取验证码
codede() {
this.getVerify()
},
getCode() {
uni.hideKeyboard()
if (this.getCodeisWaiting) {
return;
}
if (this.phone == "" || this.phone == null) {
uni.showToast({
title: '手机号不能为空',
icon: 'none'
})
return false;
} else if (!(/^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/.test(this.phone))) {
uni.showToast({
title: '输入的手机号错误',
icon: 'none'
})
return false;
}
this.getCodeisWaiting = true;
},
// 跳转登录
gologin() {
uni.navigateTo({
url: 'login'
})
},
// 多商户用户协议
protocol(type) {
uni.navigateTo({
url: 'protocol?type=' + type
})
},
}
}
</script>
<style lang="scss" scoped>
.container {
background-color: #FFFFFF;
.login-logoBox {
margin: 100rpx 0;
.login-logo {
width: 200rpx;
height: 166rpx;
}
}
.iphoneNum-box {
border-bottom: 1rpx solid #F3F4F5;
height: 100rpx;
width: 600rpx;
.loginIcon {
width: 40rpx;
height: 53rpx;
}
input {
font-size: 28rpx;
}
.iphoneNum-input {
color: #999999;
font-size: 28rpx;
font-weight: 400;
}
.iphoneNum-inputbox {
width: 400rpx;
}
}
.code-box {
border-bottom: 1rpx solid #F3F4F5;
height: 100rpx;
width: 350rpx;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
.loginIcon {
width: 44rpx;
height: 50rpx;
}
input {
font-size: 28rpx;
}
.code-lab {
width: 200rpx;
}
.codeNum-input {
color: #999999;
font-size: 28rpx;
font-weight: 400;
width: 300rpx;
}
.codeNum-inputbox {
width: 300rpx;
}
}
.getcode {
background-color: #C5AA7B;
height: 100rpx;
width: 230rpx;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
margin-left: 20rpx;
color: #FFFFFF;
}
.getcodeActive {
background-color: #DDDDDD;
height: 100rpx;
width: 220rpx;
border-radius: 44rpx;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
margin-left: 20rpx;
color: #39be7a;
}
.registerBut {
background: #39be7a;
color: #FFFFFF;
height: 88rpx;
width: 600rpx;
text-align: center;
line-height: 88rpx;
margin-top: 140rpx;
}
.agreement {
margin: 100rpx 50rpx;
line-height: 50rpx;
image{
width: 34rpx;
height: 34rpx;
margin-right: 15upx;
}
}
}
</style>