Blame view

pages/login/index.vue 5.74 KB
290144e9   易尊强   第一次
1
  <template>
044301aa   “wangming”   1
2
  
290144e9   易尊强   第一次
3
  	<view class="logo-v">
044301aa   “wangming”   1
4
5
6
7
8
9
10
11
  		<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">
  				<image src="../../static/logo.png" mode="widthFix" style="width: 90%;">
  				</image>
290144e9   易尊强   第一次
12
  			</view>
044301aa   “wangming”   1
13
14
15
16
17
18
19
20
21
22
23
24
25
  			<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" />
290144e9   易尊强   第一次
26
  					</view>
044301aa   “wangming”   1
27
28
29
30
31
32
33
34
35
  				</u-form-item>
  			</u-form>
  			<u-button @click="login" type="primary" :loading="loading">{{ loading ? "登录中...":"登录"}}
  			</u-button>
  
  			<!-- 	<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   易尊强   第一次
36
  				</view>
044301aa   “wangming”   1
37
38
39
40
  				<view class="t-g" @tap="zfbLogin()">
  					<image src="@/static/qq.png"></image>
  				</view>
  			</view> -->
290144e9   易尊强   第一次
41
  		</view>
044301aa   “wangming”   1
42
  
290144e9   易尊强   第一次
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
  	</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,
  				formData: {
  					account: "",
  					password: "",
  				},
  				rules: {
  					account: [{
  						required: true,
  						message: '请输入账号',
  						trigger: 'blur',
  					}],
  					password: [{
  						required: true,
  						message: '请输入密码',
  						trigger: 'blur',
  					}],
  				}
  			}
  		},
  		onReady() {
  			this.$refs.dataForm.setRules(this.rules);
  		},
  		onLoad() {
  			this.formData.password = ''
  		},
  		methods: {
  			// 登录
  			login() {
  				let that = this
  				this.$refs.dataForm.validate(valid => {
  					if (valid) {
  						this.loading = true
  						let query = {
  							account: this.formData.account,
  							password: this.formData.password
  						}
  						// // #ifdef  APP-PLUS
  						// const clientId = plus.push.getClientInfo().clientid;
  						// query.clientId = clientId
  						// // #endif
  						// uni.showToast({
  						// 	title:'denglu',
  						// 	duration:'2000'
  						// })
  						request({
044301aa   “wangming”   1
102
103
104
105
  							url: '/api/oauth/Login1',
  							method: 'post',
  							data: query,
  							header: {
290144e9   易尊强   第一次
106
107
108
  								"Content-Type": "application/x-www-form-urlencoded"
  							}
  						}).then(res => {
044301aa   “wangming”   1
109
110
  							// this.API.userLogin(query).then(res => {
  							console.log('登录信息', res)
290144e9   易尊强   第一次
111
  							uni.showToast({
044301aa   “wangming”   1
112
113
  								title: 'denglu',
  								duration: '2000'
290144e9   易尊强   第一次
114
  							})
044301aa   “wangming”   1
115
116
  
  							if (res.code === 200) {
290144e9   易尊强   第一次
117
118
  								let token = res.data.token
  								// let user = res.data.user
044301aa   “wangming”   1
119
  								console.log('token', token)
290144e9   易尊强   第一次
120
121
122
  								this.$store.commit('user/SET_TOKEN', token)
  								uni.setStorageSync('AuthToken_KEY', token)
  								uni.setStorageSync('token', token)
044301aa   “wangming”   1
123
124
  
  								that.API.getUserInfo().then(res => {
290144e9   易尊强   第一次
125
  									console.log(res)
044301aa   “wangming”   1
126
  
290144e9   易尊强   第一次
127
  									let user = res.data
044301aa   “wangming”   1
128
129
  									uni.setStorageSync('user', user)
  									if (uni.getStorageSync('user')) {
290144e9   易尊强   第一次
130
131
  										this.loading = false
  										uni.showToast({
044301aa   “wangming”   1
132
133
  											icon: "success",
  											title: "登陆成功"
290144e9   易尊强   第一次
134
135
136
137
138
  										})
  										uni.switchTab({
  											url: '/pages/home/home'
  										});
  									}
044301aa   “wangming”   1
139
140
  
  
290144e9   易尊强   第一次
141
  								})
044301aa   “wangming”   1
142
143
  
  							} else {
290144e9   易尊强   第一次
144
  								uni.showToast({
044301aa   “wangming”   1
145
146
  									icon: "error",
  									title: res.msg
290144e9   易尊强   第一次
147
148
149
150
151
152
153
154
155
156
157
158
159
  								})
  								this.loading = false
  							}
  							// uni.navigateTo({
  							// 	url:'/pages/tbDrugIftForm/index'
  							// })
  						}).catch(() => {
  							this.loading = false
  						})
  					}
  				});
  			},
  		},
044301aa   “wangming”   1
160
  
290144e9   易尊强   第一次
161
162
163
164
  	}
  </script>
  
  <style lang="scss">
044301aa   “wangming”   1
165
  	.logo-v {}
290144e9   易尊强   第一次
166
  
044301aa   “wangming”   1
167
168
169
170
171
172
  	.img-a {
  		position: absolute;
  		width: 100%;
  		top: -280rpx;
  		right: -100rpx;
  	}
290144e9   易尊强   第一次
173
  
044301aa   “wangming”   1
174
175
176
177
178
179
180
  	.img-b {
  		position: absolute;
  		width: 50%;
  		bottom: 0;
  		left: -50rpx;
  		margin-bottom: -200rpx;
  	}
290144e9   易尊强   第一次
181
  
044301aa   “wangming”   1
182
183
184
185
186
187
  	.t-login {
  		width: 600rpx;
  		margin: 0 auto;
  		font-size: 28rpx;
  		color: #000;
  	}
290144e9   易尊强   第一次
188
  
044301aa   “wangming”   1
189
190
191
192
193
194
195
196
197
  	.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   易尊强   第一次
198
  
044301aa   “wangming”   1
199
200
201
202
203
204
205
206
207
208
  	.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   易尊强   第一次
209
  
044301aa   “wangming”   1
210
211
212
213
  	.t-login .t-a {
  		position: relative;
  		width: 100%
  	}
290144e9   易尊强   第一次
214
  
044301aa   “wangming”   1
215
216
217
218
219
220
221
222
223
  	.t-login .t-a image {
  		width: 40rpx;
  		height: 40rpx;
  		position: absolute;
  		left: 40rpx;
  		top: 28rpx;
  		border-right: 2rpx solid #dedede;
  		padding-right: 20rpx;
  	}
290144e9   易尊强   第一次
224
  
044301aa   “wangming”   1
225
226
227
228
229
230
231
  	.t-login .t-b {
  		text-align: left;
  		font-size: 46rpx;
  		color: #000;
  		padding: 300rpx 0 40rpx 0;
  		font-weight: bold;
  	}
290144e9   易尊强   第一次
232
  
044301aa   “wangming”   1
233
234
235
236
237
238
239
240
241
242
243
244
  	.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   易尊强   第一次
245
  
044301aa   “wangming”   1
246
247
248
249
250
  	.t-login .t-d {
  		text-align: center;
  		color: #999;
  		margin: 80rpx 0;
  	}
290144e9   易尊强   第一次
251
  
044301aa   “wangming”   1
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
  	.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   易尊强   第一次
294
  	}
044301aa   “wangming”   1
295
  </style>