Blame view

ceres-uniapp-master/pages_category_page2/userModule/login.vue 13.7 KB
3f535f30   杨鑫   '初始'
1
  <template>
e65c626a   杨鑫   '改bug'
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
  	<!-- 登录 -->
  	<view class="container flex-items-plus flex-column" :style="{backgroundImage:`url(${$imgUrl('/homePhoto.png')})`}">
  		<global-loading />
  		<view style="height: 100vh;width: 100%;position: fixed;bottom: 0;left: 0;">
  			<view style="width: 45%;margin: 0 auto;margin-top: 15vh;">
  				<image src="../../static/login/logo1.png" style="width: 100%;" mode="widthFix"></image>
  			</view>
  
  			<view style="width:60%;margin: 0 auto;">
  				<image src="../../static/login/logo2.png" style="width: 100%;" mode="widthFix"></image>
  			</view>
  			<!-- 填写区 -->
  			<view class="input-info" style="margin-top: 5vh;">
  				<view class="info">
  					<view class="info-icon">
  						<image src="../../static/login/icon1.png" mode="heightFix"></image>
  					</view>
  					<input v-model="loginQuery.account" type="tel" maxlength='11' placeholder="请输入您的手机号" />
  					<view class="more"></view>
  				</view>
  				<view class="info">
  					<view class="info-icon">
  						<image src="../../static/login/icon2.png" mode="heightFix"></image>
  					</view>
  
  					<input v-model="loginQuery.code" :maxlength="6" type="tel" placeholder="请输入验证码" />
  					<view class="more">
  						<text class="mo" v-if="!disabled" @click="codede">获取验证码</text>
  						<text class="mo" v-else>{{text}}</text>
  						<!-- <view :class="disabled === true ? 'no' : ''" :disabled="disabled" class="getcode"
  							@click="codede">{{ text }}
  						</view> -->
  					</view>
  				</view>
  			</view>
  			<!-- 按钮 -->
  			<view class="btn-info">
  				<view class="btn" @click="login">
  					<text>登录</text>
  				</view>
  			</view>
  	<!-- 		<view class="iphoneNum-box flex-row-plus flex-items">
  				<view style="margin-right: 30rpx">
  					<image class="loginIcon"
  						src="https://jy.scjysm.asia:18086/cdwlMall/questionnaire/file/static/images/phone.png"></image>
  				</view>
  				<view>
  					<input v-model="loginQuery.account" placeholder-class="iphoneNum-input" type="number" maxlength='11'
  						placeholder="请输入您的手机号" />
  				</view>
  			</view>
  			<view class="flex-row-plus">
  				<view class="code-box">
  					<view style="margin-right: 30rpx">
  						<image class="loginIcon"
  							src="https://jy.scjysm.asia:18086/cdwlMall/questionnaire/file/static/images/code.png">
  						</image>
  					</view>
  					<view>
  						<input v-model="loginQuery.code" :maxlength="6" placeholder-class="codeNum-input"
  							placeholder="请输入验证码" />
  					</view>
  				</view>
  				<view :class="disabled === true ? 'on' : ''" :disabled="disabled" class="getcode" @click="codede">
  					{{ text }}
  				</view>
  			</view> -->
  			<!-- <view class="mar-top-60">
  				<view class="registerBut mar-top-100" @click="login">登录
  				</view>
  			</view> -->
  			<view class="agreement">
de5fce08   杨鑫   '最新'
74
75
76
77
  				<u-checkbox-group @change="checkboxGroupChange" shape="circle" :label-disabled="true">
  					<u-checkbox active-color="#3f9b6a" v-model="agreement" name="true">
  					</u-checkbox>
  				</u-checkbox-group>
e65c626a   杨鑫   '改bug'
78
79
80
  				<text class="font-color-999">登录即代表同意</text>
  				<text style="color: #3f9b6a;" @click="protocol('app_user_agreement')">《APP用户服务协议》</text>和
  				<text style="color: #3f9b6a;" @click="protocol('app_privacy_agreement')">《APP个人隐私协议》</text>
de5fce08   杨鑫   '最新'
81
82
83
  				<!-- <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> -->
  			
e65c626a   杨鑫   '改bug'
84
  			</view>
3f535f30   杨鑫   '初始'
85
  		</view>
3f535f30   杨鑫   '初始'
86
87
88
89
  	</view>
  </template>
  
  <script>
e65c626a   杨鑫   '改bug'
90
91
  	import sendVerifyCode from "@/mixins/SendVerifyCode";
  
3f535f30   杨鑫   '初始'
92
93
94
95
96
  	const NET = require('../../utils/request')
  	const API = require('../../config/api')
  	export default {
  		data() {
  			return {
e65c626a   杨鑫   '改bug'
97
98
99
100
101
102
103
104
  				loginQuery: {
  					account: '',
  					code: '',
  					salesId: '',
  				},
  				// 获取验证码
  				VerifyQuery: {
  					phone: ""
3f535f30   杨鑫   '初始'
105
  				},
e65c626a   杨鑫   '改bug'
106
107
108
109
110
111
112
113
  				agreement: false,
  				inviteSpell: {},
  				inviteSpelltype: false,
  				beforePage: undefined,
  				doubleBeforePage: undefined,
  				text: '获取验证码',
  				disabled: false,
  				remainingTime: 0, // 剩余倒计时时间
3f535f30   杨鑫   '初始'
114
115
  			}
  		},
e65c626a   杨鑫   '改bug'
116
  		mixins: [sendVerifyCode],
3f535f30   杨鑫   '初始'
117
  		onLoad(options) {
e65c626a   杨鑫   '改bug'
118
119
120
121
122
123
124
125
126
127
128
  			if (options.inviteSpell == 1) {
  				this.inviteSpelltype = true
  				this.inviteSpell = uni.getStorageSync('inviteSpell');
  			}
  			this.loginQuery.salesId = uni.getStorageSync('salesId');
  			var pages = getCurrentPages()
  			if (pages.length >= 2) {
  				this.beforePage = pages[pages.length - 2]
  			}
  			if (pages.length >= 3) {
  				this.doubleBeforePage = pages[pages.length - 3]
3f535f30   杨鑫   '初始'
129
  			}
3f535f30   杨鑫   '初始'
130
131
  		},
  		methods: {
de5fce08   杨鑫   '最新'
132
133
134
135
136
137
138
139
  			checkboxGroupChange(val) {
  				if(val[0] == 'true'){
  					this.agreement = true
  				}else{
  				this.agreement = false	
  				}
  				
  			},
e65c626a   杨鑫   '改bug'
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
  			login() {
  				let phoneCodeVerification = /^[1][3-9][0-9]{9}$/;
  				if (this.loginQuery.account == '') {
  					uni.showToast({
  						title: '请输入手机号!',
  						duration: 2000,
  						icon: 'none'
  					});
  				} else if (!phoneCodeVerification.test(this.loginQuery.account)) {
  					uni.showToast({
  						title: '请输入正确的手机号!',
  						duration: 2000,
  						icon: 'none'
  					});
  				} else if (this.loginQuery.code == '') {
  					uni.showToast({
  						title: '请获取验证码!',
  						duration: 2000,
  						icon: 'none'
  					})
  				} else if (!this.agreement) {
  					uni.showToast({
  						title: '请先阅读并同意《用户服务协议和个人隐私协议》',
  						duration: 2000,
  						icon: 'none'
  					});
  				} else {
  					const that = this
  					// uni.showLoading({
  					//   mask: true,
  					//   title: '正在登录...',
  					//   duration: 2000,
  					// });
  					NET.request(API.Login, {
  						phone: this.loginQuery.account,
  						verificationCode: this.loginQuery.code
  					}, 'POST').then(res => {
3f535f30   杨鑫   '初始'
177
  						uni.hideLoading()
e65c626a   杨鑫   '改bug'
178
179
180
181
182
183
184
185
186
  						const item = res.data
  						uni.setStorageSync('storage_key', item);
  						if (uni.getStorageSync("salesId")) {
  							let salesId = uni.getStorageSync("salesId")
  							let shopId = uni.getStorageSync("shopId")
  							this.bindSalesCustomer(salesId, shopId)
  							uni.removeStorageSync('salesId');
  							uni.removeStorageSync('shopId');
  						}
3f535f30   杨鑫   '初始'
187
  
e65c626a   杨鑫   '改bug'
188
189
190
191
192
193
194
195
196
197
198
199
200
  						// 购物车右上角数量
  						NET.request(API.ShoppingCart, {}, 'GET').then(resCart => {
  							let cartNum = 0
  							resCart.data.forEach(shopItem => {
  								shopItem.skus.forEach(goodsItem => {
  									cartNum += goodsItem.number
  								})
  							})
  							if (cartNum > 0) {
  								uni.setTabBarBadge({
  									index: 2,
  									text: cartNum.toString()
  								})
3f535f30   杨鑫   '初始'
201
  							}
e65c626a   杨鑫   '改bug'
202
203
  							console.log(cartNum)
  							uni.setStorageSync('allCartNum', cartNum)
3f535f30   杨鑫   '初始'
204
  						})
e65c626a   杨鑫   '改bug'
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
  						if (this.inviteSpelltype == true) {
  							setTimeout(function() {
  								uni.reLaunch({
  									url: '../../pages_category_page1/goodsModule/inviteSpell?collageId=' +
  										this.inviteSpell.collageId + '&orderId=' + this.inviteSpell
  										.orderId + '&type=0' + '&productId=' + this.inviteSpell
  										.productId + '&skuId=' + this.inviteSpell.skuId
  								})
  								uni.removeStorageSync('inviteSpell');
  							}, 2000)
  						} else {
  							if (that.beforePage && that.beforePage.route !==
  								'pages_category_page2/userModule/accountLogin' &&
  								that.beforePage.route !== 'pages_category_page2/userModule/login' &&
  								that.beforePage.route !== 'pages_category_page2/userModule/register') {
  								console.log(19)
  								uni.navigateBack({
  									delta: 1
  								})
  							} else if (that.doubleBeforePage && that.doubleBeforePage.route !==
  								'pages_category_page2/userModule/accountLogin' &&
  								that.doubleBeforePage.route !== 'pages_category_page2/userModule/login' &&
  								that.doubleBeforePage.route !== 'pages_category_page2/userModule/register') {
  								uni.navigateBack({
  									delta: 2
  								})
  							} else {
  								NET.request(API.GetUser, {}, 'GET').then(res => {
  									let MsgList = {
  										username: res.data.name,
  										userId: res.data.buyerUserId,
  										phoneNumber: res.data.phone,
  										createTime: this.getCurrentDateTime(),
  									}
  									NET.request(API.DengJi, MsgList, 'POST').then(res => {
  
  									})
  								})
  								setTimeout(function() {
  									uni.switchTab({
  										url: '../../pages/tabbar/user/index'
  									})
  								}, 600)
  							}
  						}
  					}).catch(res => {
  						console.log('Login failed')
3f535f30   杨鑫   '初始'
252
  						console.dir(res)
e65c626a   杨鑫   '改bug'
253
  						uni.hideLoading()
3f535f30   杨鑫   '初始'
254
  						uni.showToast({
e65c626a   杨鑫   '改bug'
255
256
257
  							title: res.data.message,
  							duration: 2000,
  							icon: 'none',
3f535f30   杨鑫   '初始'
258
  						});
3f535f30   杨鑫   '初始'
259
  					})
e65c626a   杨鑫   '改bug'
260
261
  				}
  
3f535f30   杨鑫   '初始'
262
  			},
e65c626a   杨鑫   '改bug'
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
  			// 获取时间
  			getCurrentDateTime() {
  				const now = new Date();
  				const year = now.getFullYear();
  				const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份是从0开始的,所以需要+1
  				const day = String(now.getDate()).padStart(2, '0');
  				const hours = String(now.getHours()).padStart(2, '0');
  				const minutes = String(now.getMinutes()).padStart(2, '0');
  				const seconds = String(now.getSeconds()).padStart(2, '0');
  
  				return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  			},
  			// 获取验证码
  			codede() {
  				if (this.disabled) return
  				this.getVerify()
  
3f535f30   杨鑫   '初始'
280
  			},
e65c626a   杨鑫   '改bug'
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
  			getVerify() {
  				let phoneCodeVerification = /^[1][3-9][0-9]{9}$/;
  				if (this.loginQuery.account === '') {
  					uni.showToast({
  						title: '请输入手机号!',
  						duration: 2000,
  						icon: 'none'
  					});
  				} else if (!phoneCodeVerification.test(this.loginQuery.account)) {
  					uni.showToast({
  						title: '请输入正确的手机号!',
  						duration: 2000,
  						icon: 'none'
  					});
  				} else {
  					this.disabled = true;
  					this.remainingTime = 60;
  					this.text = `${this.remainingTime}s后重试`;
  
  					const timer = setInterval(() => {
  						this.remainingTime--;
  						if (this.remainingTime > 0) {
  							this.text = `${this.remainingTime}s后重试`;
  						} else {
  							clearInterval(timer);
  							this.disabled = false; // 倒计时结束,启用按钮
  							this.text = '获取验证码';
3f535f30   杨鑫   '初始'
308
  						}
e65c626a   杨鑫   '改bug'
309
  					}, 1000);
3f535f30   杨鑫   '初始'
310
  
e65c626a   杨鑫   '改bug'
311
  					this.VerifyQuery.phone = this.loginQuery.account;
3f535f30   杨鑫   '初始'
312
  
e65c626a   杨鑫   '改bug'
313
314
315
316
317
318
319
320
321
322
323
324
325
  					NET.request(API.verification, {
  						phone: this.VerifyQuery.phone
  					}, 'POST').then(res => {
  						// 如果 sendCode 方法有实际用途,需要定义该方法
  						// this.sendCode(); 
  						console.log(res);
  					}).catch(res => {
  						uni.showToast({
  							title: res.data.message,
  							duration: 1000,
  							icon: 'none'
  						});
  					});
3f535f30   杨鑫   '初始'
326
327
  				}
  			},
e65c626a   杨鑫   '改bug'
328
329
330
331
  			//绑定关系
  			bindSalesCustomer(salesId, storeId) {
  				if (salesId && storeId) {
  					//如果已登录,静默绑定客户关系,否则跳转到登录页面
3f535f30   杨鑫   '初始'
332
  					NET.request(API.BindSalesCustomer, {
e65c626a   杨鑫   '改bug'
333
  						shopId: storeId,
3f535f30   杨鑫   '初始'
334
335
  						distributorId: salesId
  					}, 'POST').then(res => {
e65c626a   杨鑫   '改bug'
336
337
338
339
340
341
342
343
344
  						uni.showToast({
  							title: "绑定成功",
  							icon: "none"
  						})
  					}).catch(res => {
  						uni.showToast({
  							title: res.data.message,
  							icon: "none"
  						})
3f535f30   杨鑫   '初始'
345
  					})
e65c626a   杨鑫   '改bug'
346
  
3f535f30   杨鑫   '初始'
347
  				}
e65c626a   杨鑫   '改bug'
348
349
350
351
352
353
354
  			},
  			// 多商户用户协议
  			protocol(type) {
  				uni.navigateTo({
  					url: 'protocol?type=' + type
  				})
  			},
3f535f30   杨鑫   '初始'
355
356
357
358
359
360
  		}
  	}
  </script>
  
  <style lang="scss">
  	.container {
e65c626a   杨鑫   '改bug'
361
362
363
364
365
366
  		position: absolute;
  		left: 0;
  		top: 0;
  		width: 100%;
  		height: 100%;
  		background-size: cover;
3f535f30   杨鑫   '初始'
367
  		background-color: #FFFFFF;
3f535f30   杨鑫   '初始'
368
369
  
  		.login-logoBox {
e65c626a   杨鑫   '改bug'
370
  			margin-top: -300rpx;
3f535f30   杨鑫   '初始'
371
372
  
  			.login-logo {
e65c626a   杨鑫   '改bug'
373
374
  				width: 234rpx;
  				height: 193rpx;
3f535f30   杨鑫   '初始'
375
376
377
  			}
  		}
  
e65c626a   杨鑫   '改bug'
378
  		.iphoneNum-box {
3f535f30   杨鑫   '初始'
379
  			margin-top: 100rpx;
e65c626a   杨鑫   '改bug'
380
381
382
  			border-bottom: 1rpx solid #DDDDDD;
  			height: 100rpx;
  			width: 600rpx;
3f535f30   杨鑫   '初始'
383
  
e65c626a   杨鑫   '改bug'
384
385
386
387
  			.loginIcon {
  				width: 40rpx;
  				height: 53rpx;
  			}
3f535f30   杨鑫   '初始'
388
  
e65c626a   杨鑫   '改bug'
389
390
391
392
  			.iphoneNum-input {
  				color: #999999;
  				font-size: 28rpx;
  				font-weight: 400;
3f535f30   杨鑫   '初始'
393
394
395
  			}
  		}
  
e65c626a   杨鑫   '改bug'
396
397
398
  		.passwordNum-box {
  			border-bottom: 1rpx solid #DDDDDD;
  			height: 100rpx;
3f535f30   杨鑫   '初始'
399
  			width: 600rpx;
e65c626a   杨鑫   '改bug'
400
401
402
403
404
405
406
  
  			.passwordNum-input {
  				color: #999999;
  				font-size: 28rpx;
  				font-weight: 400;
  				width: 346rpx;
  			}
3f535f30   杨鑫   '初始'
407
408
  		}
  
e65c626a   杨鑫   '改bug'
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
  		.code-box {
  			border-bottom: 1rpx solid #DDDDDD;
  			height: 100rpx;
  			width: 360rpx;
  			display: flex;
  			flex-direction: row;
  			justify-content: space-between;
  			align-items: center;
  
  			.loginIcon {
  				width: 44rpx;
  				height: 50rpx;
  			}
  
  			.code-lab {
  				width: 200rpx;
  			}
  
  			.codeNum-input {
  				color: #999999;
  				font-size: 28rpx;
  				font-weight: 400;
  			}
  		}
  
  		.getcode {
  			background-color: #39be7a;
  			height: 100rpx;
  			width: 230rpx;
  			display: flex;
  			flex-direction: row;
  			justify-content: center;
  			align-items: center;
  			margin-left: 20rpx;
  			color: #FFFFFF;
  		}
  
  		.registerBut {
  			background: #3f9b6a;
3f535f30   杨鑫   '初始'
448
  			color: #FFEBC4;
e65c626a   杨鑫   '改bug'
449
  			height: 100rpx;
3f535f30   杨鑫   '初始'
450
451
  			width: 600rpx;
  			text-align: center;
e65c626a   杨鑫   '改bug'
452
  			line-height: 100rpx;
3f535f30   杨鑫   '初始'
453
454
455
  			margin-top: 30rpx;
  		}
  
e65c626a   杨鑫   '改bug'
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
  		.agreement {
  			margin: 100rpx 50rpx;
  			line-height: 50rpx;
  
  			image {
  				width: 34rpx;
  				height: 34rpx;
  				margin-right: 15upx;
  			}
  		}
  	}
  	/* 填写 */
  	.input-info{
  	  padding: 0 6%;
  	  // margin: 80rpx 0 40rpx 0;
  	  .info{
  	    display: flex;
  	    align-items:center;
  	    justify-content: space-between;
  	    width: 100%;
  	    height: 100rpx;
  		background-color: #fff;
  		border-radius: 32rpx;
  		margin-bottom: 40rpx;
  		padding: 0 30rpx 0 40rpx;
  		border: 2rpx solid rgba(15,187,89,0.1804);
  	    input{
  	      width: 70%;
  	      height: 100%;
  	      font-size: 26rpx;
  	      color: #222222;
  	    }
  		.info-icon {
  			image {
  				width: 28rpx;
  				height: 28rpx;
  				margin-right: 20rpx;
  			}
3f535f30   杨鑫   '初始'
494
  		}
e65c626a   杨鑫   '改bug'
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
  	    .more{
  	      display: flex;
  	      align-items: center;
  	      justify-content: flex-end;
  	      width: 32%;
  	      height: 100%;
  	      .iconfont{
  	        font-size: 34rpx;
  	      }
  	      .mo{
  	        font-size: 26rpx;
  	        padding-left: 20rpx;
  	        // margin-left: 10rpx;
  	        border-left: 2rpx solid #ccc;
  	      }
  	    }
  	  }
3f535f30   杨鑫   '初始'
512
  	}
e65c626a   杨鑫   '改bug'
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
  	/* 按钮 */
  	.btn-info{
  	  display: flex;
  	  align-items: center;
  	  justify-content: center;
  	  width: 100%;
  	  .btn{
  	    display: flex;
  	    align-items: center;
  	    justify-content: center;
  	    width: 88%;
  	    height: 90rpx;
  	    background-color:#0FBB59;
  	    border-radius: 32rpx;
  	    color: #FFFFFF;
  	    font-size: 32rpx;
  	  }
3f535f30   杨鑫   '初始'
530
  	}
e65c626a   杨鑫   '改bug'
531
  </style>