index.vue 10.1 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 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 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 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461
<template>

	<view class="logo-v">
		<view
			style="position: absolute; top: 0;text-align: center;width: 100%;padding-top: 5px;color: #000;z-index: 99;font-weight: bold;">
			德阳高新区企业服务中心</view>
		<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_new.png" mode="widthFix" style="width: 90%;">
				</image>
			</view>
			<!-- <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">

						<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>
					<view style="text-align: center;">投诉邮箱:263667024@qq.com</view>
				</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>

			<!-- 	<view class="t-f"><text>————— 第三方账号登录 —————</text></view>
			<view class="t-e cl">
				<view class="t-g" @tap="wxLogin()">
					<image src="@/static/wx.png"></image>
				</view>
				<view class="t-g" @tap="zfbLogin()">
					<image src="@/static/qq.png"></image>
				</view>
			</view> -->
		</view>

	</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,
				show: 0,
				formData: {
					account: "",
					password: "",
				},
				rules: {
					account: [{
						required: true,
						message: '请输入账号',
						trigger: 'blur',
					}],
					password: [{
						required: true,
						message: '请输入密码',
						trigger: 'blur',
					}],
				}
			}
		},
		onReady() {
			this.$refs.dataForm.setRules(this.rules);
		},
		onShow() {
			plus.navigator.closeSplashscreen();
		},
		onLoad() {
			this.formData.password = ''
		},
		methods: {
			toSupply() {
				this.show = 0
				this.formData.account = ''
				this.formData.password = ''
			},
			toDemand() {
				this.show = 1
				this.formData.account = ''
				this.formData.password = ''
			},
			// 登录
			login() {
				let that = this
				this.$refs.dataForm.validate(valid => {
					if (valid) {
						this.loading = true
						let password = this.$md5(this.formData.password)
						console.log('加密后', password)
						let query = {
							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/Login',
							method: 'post',
							data: query,
							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'
							})

							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)

								that.API.getUserInfo().then(res => {
									console.log(res)

									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'
										});
									}


								})

							} else {
								uni.showToast({
									icon: "error",
									title: '返回数据不为200'
								})
								this.loading = false
							}
							// uni.navigateTo({
							// 	url:'/pages/tbDrugIftForm/index'
							// })
						}).catch((res) => {
							console.log(res);
							uni.showToast({
								icon: 'error',
								title: `${res}`
							})
							this.loading = false
						})
					}
				});
			},
			// 登录
			login1() {
				let that = this
				this.$refs.dataForm.validate(valid => {
					if (valid) {
						this.loading = true
						let password = this.$md5(this.formData.password)
						console.log('加密后', password)
						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'
							})

							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)

								that.API.getUserInfo().then(res => {
									console.log(res)

									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'
										});
									}


								})

							} else {
								uni.showToast({
									icon: "error",
									title: '返回数据不为200'
								})
								this.loading = false
							}
							// uni.navigateTo({
							// 	url:'/pages/tbDrugIftForm/index'
							// })
						}).catch((res) => {
							uni.showToast({
								icon: 'error',
								title: `${res}`
							})
							console.log('错处了', res)
							this.loading = false
						})
					}
				});
			},
		},

	}
</script>

<style lang="scss">
	.logo-v {}

	.img-a {
		position: absolute;
		width: 100%;
		top: -280rpx;
		right: -100rpx;
	}

	.img-b {
		position: absolute;
		width: 50%;
		bottom: 0;
		left: -50rpx;
		margin-bottom: -200rpx;
	}

	.t-login {
		width: 600rpx;
		margin: 0 auto;
		font-size: 28rpx;
		color: #000;
	}

	.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);
	}

	.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;
	}

	.t-login .t-a {
		position: relative;
		width: 100%
	}

	.t-login .t-a image {
		width: 40rpx;
		height: 40rpx;
		position: absolute;
		left: 40rpx;
		top: 28rpx;
		border-right: 2rpx solid #dedede;
		padding-right: 20rpx;
	}

	.t-login .t-b {
		text-align: left;
		font-size: 46rpx;
		color: #000;
		padding: 300rpx 0 40rpx 0;
		font-weight: bold;
	}

	.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;
	}

	.t-login .t-d {
		text-align: center;
		color: #999;
		margin: 80rpx 0;
	}

	.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';
	}

	.top {
		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;
	}

	.act {
		font-weight: bold;
		color: #E60012;
	}

	.supply {
		font-size: 35rpx;
	}

	.demand {
		font-size: 35rpx;
	}
</style>