Blame view

pages/login/index.vue 10.1 KB
290144e9   易尊强   第一次
1
  <template>
044301aa   “wangming”   1
2
  
290144e9   易尊强   第一次
3
  	<view class="logo-v">
508a9ba2   “wangming”   1
4
5
6
  		<view
  			style="position: absolute; top: 0;text-align: center;width: 100%;padding-top: 5px;color: #000;z-index: 99;font-weight: bold;">
  			德阳高新区企业服务中心</view>
044301aa   “wangming”   1
7
8
9
10
11
12
  		<view class="t-login">
  			<!-- 页面装饰图片 -->
  			<image class="img-a" src="@/static/2.png"></image>
  			<image class="img-b" src="@/static/3.png"></image>
  			<!-- 标题 -->
  			<view class="t-b">
9b1c150c   “wangming”   1
13
  				<image src="../../static/logo_new.png" mode="widthFix" style="width: 90%;">
044301aa   “wangming”   1
14
  				</image>
290144e9   易尊强   第一次
15
  			</view>
9b1c150c   “wangming”   1
16
17
18
19
20
21
22
23
24
25
26
27
  			<!-- <view class="top">
  				<view class="supply" :style="show === 0 ? 'font-weight: bold;color: #E60012;' : '' " @click="toSupply()">
  					管理登录
  				</view>
  				<view class="demand" :style="show === 1 ? 'font-weight: bold;color: #E60012;' : '' " @click="toDemand()">
  					普通登录
  				</view>
  			</view> -->
  			<view class="shuju" style="margin-top: 60rpx;">
  				<view class="one">
  					<u-form :model="formData" :rules="rules" ref="dataForm" :errorType="['toast']" label-position="left"
  						label-width="150" label-align="left">
508a9ba2   “wangming”   1
28
  
9b1c150c   “wangming”   1
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  						<u-form-item prop="account">
  							<view class="t-a">
  								<image src="@/static/sj.png"></image>
  								<input placeholder="请输入帐号" v-model="formData.account" />
  							</view>
  						</u-form-item>
  						<u-form-item prop="password">
  							<view class="t-a">
  								<image src="@/static/yz.png"></image>
  								<input placeholder="请输入密码" type="password" v-model="formData.password" />
  							</view>
  						</u-form-item>
  					</u-form>
  					<u-button @click="login" type="primary" :loading="loading">{{ loading ? "登录中...":"登录"}}
  					</u-button>
508a9ba2   “wangming”   1
44
  					<view style="text-align: center;">投诉邮箱:263667024@qq.com</view>
9b1c150c   “wangming”   1
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
  				</view>
  				<!-- <view class="two" v-if="show === 1">
  					<u-form :model="formData" :rules="rules" ref="dataForm" :errorType="['toast']" label-position="left"
  						label-width="150" label-align="left">
  					
  						<u-form-item prop="account">
  							<view class="t-a">
  								<image src="@/static/sj.png"></image>
  								<input placeholder="请输入帐号" v-model="formData.account" />
  							</view>
  						</u-form-item>
  						<u-form-item prop="password">
  							<view class="t-a">
  								<image src="@/static/yz.png"></image>
  								<input placeholder="请输入密码" type="password" v-model="formData.password" />
  							</view>
  						</u-form-item>
  					</u-form>
  					<u-button @click="login1" type="primary" :loading="loading">{{ loading ? "登录中...":"登录"}}
  					</u-button>
  				</view> -->
  			</view>
044301aa   “wangming”   1
67
68
69
70
71
  
  			<!-- 	<view class="t-f"><text>————— 第三方账号登录 —————</text></view>
  			<view class="t-e cl">
  				<view class="t-g" @tap="wxLogin()">
  					<image src="@/static/wx.png"></image>
290144e9   易尊强   第一次
72
  				</view>
044301aa   “wangming”   1
73
74
75
76
  				<view class="t-g" @tap="zfbLogin()">
  					<image src="@/static/qq.png"></image>
  				</view>
  			</view> -->
290144e9   易尊强   第一次
77
  		</view>
044301aa   “wangming”   1
78
  
290144e9   易尊强   第一次
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
  	</view>
  </template>
  
  <script>
  	import {
  		login
  	} from '@/api/common.js'
  	import request from '../../utils/request.js'
  	import md5Libs from "uview-ui/libs/function/md5";
  	import resources from '@/libs/resources'
  
  	export default {
  		data() {
  			return {
  				loading: false,
508a9ba2   “wangming”   1
94
  				show: 0,
290144e9   易尊强   第一次
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
  				formData: {
  					account: "",
  					password: "",
  				},
  				rules: {
  					account: [{
  						required: true,
  						message: '请输入账号',
  						trigger: 'blur',
  					}],
  					password: [{
  						required: true,
  						message: '请输入密码',
  						trigger: 'blur',
  					}],
  				}
  			}
  		},
  		onReady() {
  			this.$refs.dataForm.setRules(this.rules);
  		},
508a9ba2   “wangming”   1
116
  		onShow() {
9b1c150c   “wangming”   1
117
118
  			plus.navigator.closeSplashscreen();
  		},
290144e9   易尊强   第一次
119
120
121
122
  		onLoad() {
  			this.formData.password = ''
  		},
  		methods: {
508a9ba2   “wangming”   1
123
124
  			toSupply() {
  				this.show = 0
9b1c150c   “wangming”   1
125
126
127
  				this.formData.account = ''
  				this.formData.password = ''
  			},
508a9ba2   “wangming”   1
128
  			toDemand() {
9b1c150c   “wangming”   1
129
130
131
132
  				this.show = 1
  				this.formData.account = ''
  				this.formData.password = ''
  			},
290144e9   易尊强   第一次
133
134
135
136
137
138
  			// 登录
  			login() {
  				let that = this
  				this.$refs.dataForm.validate(valid => {
  					if (valid) {
  						this.loading = true
9b1c150c   “wangming”   1
139
  						let password = this.$md5(this.formData.password)
508a9ba2   “wangming”   1
140
  						console.log('加密后', password)
290144e9   易尊强   第一次
141
142
  						let query = {
  							account: this.formData.account,
9b1c150c   “wangming”   1
143
  							password: password
290144e9   易尊强   第一次
144
145
146
147
148
149
150
151
152
153
  						}
  						// // #ifdef  APP-PLUS
  						// const clientId = plus.push.getClientInfo().clientid;
  						// query.clientId = clientId
  						// // #endif
  						// uni.showToast({
  						// 	title:'denglu',
  						// 	duration:'2000'
  						// })
  						request({
9b1c150c   “wangming”   1
154
  							url: '/api/oauth/Login',
044301aa   “wangming”   1
155
156
157
  							method: 'post',
  							data: query,
  							header: {
290144e9   易尊强   第一次
158
159
160
  								"Content-Type": "application/x-www-form-urlencoded"
  							}
  						}).then(res => {
044301aa   “wangming”   1
161
162
  							// this.API.userLogin(query).then(res => {
  							console.log('登录信息', res)
290144e9   易尊强   第一次
163
  							uni.showToast({
044301aa   “wangming”   1
164
165
  								title: 'denglu',
  								duration: '2000'
290144e9   易尊强   第一次
166
  							})
044301aa   “wangming”   1
167
168
  
  							if (res.code === 200) {
290144e9   易尊强   第一次
169
170
  								let token = res.data.token
  								// let user = res.data.user
044301aa   “wangming”   1
171
  								console.log('token', token)
290144e9   易尊强   第一次
172
173
174
  								this.$store.commit('user/SET_TOKEN', token)
  								uni.setStorageSync('AuthToken_KEY', token)
  								uni.setStorageSync('token', token)
044301aa   “wangming”   1
175
176
  
  								that.API.getUserInfo().then(res => {
290144e9   易尊强   第一次
177
  									console.log(res)
044301aa   “wangming”   1
178
  
290144e9   易尊强   第一次
179
  									let user = res.data
044301aa   “wangming”   1
180
181
  									uni.setStorageSync('user', user)
  									if (uni.getStorageSync('user')) {
290144e9   易尊强   第一次
182
183
  										this.loading = false
  										uni.showToast({
044301aa   “wangming”   1
184
185
  											icon: "success",
  											title: "登陆成功"
290144e9   易尊强   第一次
186
187
188
189
190
  										})
  										uni.switchTab({
  											url: '/pages/home/home'
  										});
  									}
044301aa   “wangming”   1
191
192
  
  
290144e9   易尊强   第一次
193
  								})
044301aa   “wangming”   1
194
195
  
  							} else {
290144e9   易尊强   第一次
196
  								uni.showToast({
044301aa   “wangming”   1
197
  									icon: "error",
0189b356   易尊强   登录问题
198
  									title: '返回数据不为200'
290144e9   易尊强   第一次
199
200
201
202
203
204
  								})
  								this.loading = false
  							}
  							// uni.navigateTo({
  							// 	url:'/pages/tbDrugIftForm/index'
  							// })
0189b356   易尊强   登录问题
205
  						}).catch((res) => {
508a9ba2   “wangming”   1
206
  							console.log(res);
0189b356   易尊强   登录问题
207
  							uni.showToast({
508a9ba2   “wangming”   1
208
209
  								icon: 'error',
  								title: `${res}`
0189b356   易尊强   登录问题
210
  							})
290144e9   易尊强   第一次
211
212
213
214
215
  							this.loading = false
  						})
  					}
  				});
  			},
9b1c150c   “wangming”   1
216
217
218
219
220
221
222
  			// 登录
  			login1() {
  				let that = this
  				this.$refs.dataForm.validate(valid => {
  					if (valid) {
  						this.loading = true
  						let password = this.$md5(this.formData.password)
508a9ba2   “wangming”   1
223
  						console.log('加密后', password)
9b1c150c   “wangming”   1
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
  						let login = {
  							account: this.formData.account,
  							password: password
  						}
  						// // #ifdef  APP-PLUS
  						// const clientId = plus.push.getClientInfo().clientid;
  						// query.clientId = clientId
  						// // #endif
  						// uni.showToast({
  						// 	title:'denglu',
  						// 	duration:'2000'
  						// })
  						request({
  							url: `/api/oauth/Login1`,
  							method: 'post',
  							data: login,
  							header: {
  								"Content-Type": "application/x-www-form-urlencoded"
  							}
  						}).then(res => {
  							// this.API.userLogin(query).then(res => {
  							console.log('登录信息', res)
  							uni.showToast({
  								title: 'denglu',
  								duration: '2000'
  							})
508a9ba2   “wangming”   1
250
  
9b1c150c   “wangming”   1
251
252
253
254
255
256
257
  							if (res.code === 200) {
  								let token = res.data.token
  								// let user = res.data.user
  								console.log('token', token)
  								this.$store.commit('user/SET_TOKEN', token)
  								uni.setStorageSync('AuthToken_KEY', token)
  								uni.setStorageSync('token', token)
508a9ba2   “wangming”   1
258
  
9b1c150c   “wangming”   1
259
260
  								that.API.getUserInfo().then(res => {
  									console.log(res)
508a9ba2   “wangming”   1
261
  
9b1c150c   “wangming”   1
262
263
264
265
266
267
268
269
270
271
272
273
  									let user = res.data
  									uni.setStorageSync('user', user)
  									if (uni.getStorageSync('user')) {
  										this.loading = false
  										uni.showToast({
  											icon: "success",
  											title: "登陆成功"
  										})
  										uni.switchTab({
  											url: '/pages/home/home'
  										});
  									}
508a9ba2   “wangming”   1
274
275
  
  
9b1c150c   “wangming”   1
276
  								})
508a9ba2   “wangming”   1
277
  
9b1c150c   “wangming”   1
278
279
280
281
282
283
284
285
286
287
288
289
  							} else {
  								uni.showToast({
  									icon: "error",
  									title: '返回数据不为200'
  								})
  								this.loading = false
  							}
  							// uni.navigateTo({
  							// 	url:'/pages/tbDrugIftForm/index'
  							// })
  						}).catch((res) => {
  							uni.showToast({
508a9ba2   “wangming”   1
290
291
  								icon: 'error',
  								title: `${res}`
9b1c150c   “wangming”   1
292
  							})
508a9ba2   “wangming”   1
293
  							console.log('错处了', res)
9b1c150c   “wangming”   1
294
295
296
297
298
  							this.loading = false
  						})
  					}
  				});
  			},
290144e9   易尊强   第一次
299
  		},
044301aa   “wangming”   1
300
  
290144e9   易尊强   第一次
301
302
303
304
  	}
  </script>
  
  <style lang="scss">
044301aa   “wangming”   1
305
  	.logo-v {}
290144e9   易尊强   第一次
306
  
044301aa   “wangming”   1
307
308
309
310
311
312
  	.img-a {
  		position: absolute;
  		width: 100%;
  		top: -280rpx;
  		right: -100rpx;
  	}
290144e9   易尊强   第一次
313
  
044301aa   “wangming”   1
314
315
316
317
318
319
320
  	.img-b {
  		position: absolute;
  		width: 50%;
  		bottom: 0;
  		left: -50rpx;
  		margin-bottom: -200rpx;
  	}
290144e9   易尊强   第一次
321
  
044301aa   “wangming”   1
322
323
324
325
326
327
  	.t-login {
  		width: 600rpx;
  		margin: 0 auto;
  		font-size: 28rpx;
  		color: #000;
  	}
290144e9   易尊强   第一次
328
  
044301aa   “wangming”   1
329
330
331
332
333
334
335
336
337
  	.t-login button {
  		font-size: 28rpx;
  		background: #ff0000;
  		color: #fff;
  		height: 90rpx;
  		line-height: 90rpx;
  		border-radius: 50rpx;
  		box-shadow: 0 5px 7px 0 rgba(86, 119, 252, 0.2);
  	}
290144e9   易尊强   第一次
338
  
044301aa   “wangming”   1
339
340
341
342
343
344
345
346
347
348
  	.t-login input {
  		padding: 0 20rpx 0 120rpx;
  		height: 90rpx;
  		line-height: 90rpx;
  		margin-bottom: 50rpx;
  		background: #f8f7fc;
  		border: 1px solid #e9e9e9;
  		font-size: 28rpx;
  		border-radius: 50rpx;
  	}
290144e9   易尊强   第一次
349
  
044301aa   “wangming”   1
350
351
352
353
  	.t-login .t-a {
  		position: relative;
  		width: 100%
  	}
290144e9   易尊强   第一次
354
  
044301aa   “wangming”   1
355
356
357
358
359
360
361
362
363
  	.t-login .t-a image {
  		width: 40rpx;
  		height: 40rpx;
  		position: absolute;
  		left: 40rpx;
  		top: 28rpx;
  		border-right: 2rpx solid #dedede;
  		padding-right: 20rpx;
  	}
290144e9   易尊强   第一次
364
  
044301aa   “wangming”   1
365
366
367
368
369
370
371
  	.t-login .t-b {
  		text-align: left;
  		font-size: 46rpx;
  		color: #000;
  		padding: 300rpx 0 40rpx 0;
  		font-weight: bold;
  	}
290144e9   易尊强   第一次
372
  
044301aa   “wangming”   1
373
374
375
376
377
378
379
380
381
382
383
384
  	.t-login .t-c {
  		position: absolute;
  		right: 22rpx;
  		top: 22rpx;
  		background: #ff0000;
  		color: #fff;
  		font-size: 24rpx;
  		border-radius: 50rpx;
  		height: 50rpx;
  		line-height: 50rpx;
  		padding: 0 25rpx;
  	}
290144e9   易尊强   第一次
385
  
044301aa   “wangming”   1
386
387
388
389
390
  	.t-login .t-d {
  		text-align: center;
  		color: #999;
  		margin: 80rpx 0;
  	}
290144e9   易尊强   第一次
391
  
044301aa   “wangming”   1
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
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
  	.t-login .t-e {
  		text-align: center;
  		width: 250rpx;
  		margin: 80rpx auto 0;
  	}
  
  	.t-login .t-g {
  		float: left;
  		width: 50%;
  	}
  
  	.t-login .t-e image {
  		width: 50rpx;
  		height: 50rpx;
  	}
  
  	.t-login .t-f {
  		text-align: center;
  		margin: 200rpx 0 0 0;
  		color: #666;
  	}
  
  	.t-login .t-f text {
  		margin-left: 20rpx;
  		color: #aaaaaa;
  		font-size: 27rpx;
  	}
  
  	.t-login .uni-input-placeholder {
  		color: #000;
  	}
  
  	.cl {
  		zoom: 1;
  	}
  
  	.cl:after {
  		clear: both;
  		display: block;
  		visibility: hidden;
  		height: 0;
  		content: '\20';
290144e9   易尊强   第一次
434
  	}
508a9ba2   “wangming”   1
435
436
  
  	.top {
9b1c150c   “wangming”   1
437
438
439
440
441
442
443
444
445
446
447
  		width: 100%;
  		height: 100rpx;
  		border-bottom: 1px solid gray;
  		display: flex;
  		justify-content: space-evenly;
  		align-items: center;
  		// position: fixed;
  		// top: 0;
  		background-color: white;
  		z-index: 2;
  	}
508a9ba2   “wangming”   1
448
449
  
  	.act {
9b1c150c   “wangming”   1
450
451
452
  		font-weight: bold;
  		color: #E60012;
  	}
508a9ba2   “wangming”   1
453
454
  
  	.supply {
9b1c150c   “wangming”   1
455
456
  		font-size: 35rpx;
  	}
508a9ba2   “wangming”   1
457
458
  
  	.demand {
9b1c150c   “wangming”   1
459
460
  		font-size: 35rpx;
  	}
044301aa   “wangming”   1
461
  </style>