<template>
	<view class="content">
		<image src="../../static/011.png" class="bg" mode="scaleToFill"></image>
		<!--  -->
		<view class="ts">
			<view class="mb-5">欢迎登录</view>
			<view>智造团资源共享数据库平台</view>
		</view>
		<view class="edit">
			<image src="../../static/logo.png" class="logo" mode="widthFix"></image>
			<view class="editem">
				<view class="input">
					<icon class="iconfont icon-gerenzhongxin1 mr-10"></icon>
					<input class="uni-input input100" v-model="account" placeholder="请输入账号" />
				</view>
				<view class="input">
					<icon class="iconfont icon-icon-test5 mr-10"></icon>
					<input type="password" class="uni-input" v-model="password" placeholder="请输入密码" />
				</view>
				<view class="tips size12" @click="$store.commit('changeSecratary', true)">
					如忘记密码，请联系秘书处修改重置
				</view>
			</view>
			<view class="btnlogin" @click="handleTelLogin">登录</view>
			<view class="wxbtn" @click="handleAdd">
				<text>没有账号，我要加入智造团</text>
			</view>
			<view class="xieyi">
				<checkbox-group @change="checkboxChange">
					<checkbox :value="1" style="transform:scale(0.8)" />勾选同意智造团<text @click="handlexieyi "
						class="bluecolor">《个人信息保护政策》</text>
				</checkbox-group>
			</view>
		</view>
		<!-- 秘书处弹框 -->
		<secratary></secratary>

	</view>
</template>

<script>
	import {
		mapState
	} from "vuex";
	export default {
		data() {
			return {
				value: 0,
				sessionid: "",
				account: "",
				password: "",
			}
		},
		computed: {
			...mapState(["HomeContent"]),
		},
		async onLoad() {
			let that = this
			that.sessionid = uni.getStorageSync('sessionid')
			console.log("sessionid", that.sessionid)
			if (!that.sessionid) {
				await that.$store.dispatch('getsessionId')
			}

		},
		methods: {
			// 登录、
			handleTelLogin() {
				let that = this
				if (!that.account) {
					that.$tools.msg("请输入账号")
					return
				}
				if (!that.password) {
					that.$tools.msg("请输入密码")
					return
				}
				if (that.password.length < 6) {
					that.$tools.msg("密码长度不能小于6位数")
					return
				}
				if (this.value == 0) {
					this.$tools.msg("请先勾选同意智造团《个人信息保护政策》")
					return
				}
				this.$model.getlogin({
					account: that.account,
					password: that.password,
					sessionId: uni.getStorageSync('sessionid'),
				}).then(res => {
					if (res.code != 0) {
						that.$tools.msg(res.message)
						return
					}
					uni.setStorageSync('token', res.data.token)
					uni.setStorageSync('refreshtoken', res.data.refreshtoken)
					uni.setStorageSync('sessionid', res.data.sessionid)
					uni.reLaunch({
						url: "/pages/index/index"
					})
				}).catch(err => {})
			},
			// 
			handleAdd() {
				uni.navigateTo({
					url: "/pageTwo/login/add"
				})
			},
			checkboxChange(e) {
				this.value = e.detail.value.length ? e.detail.value[0] : "0"
				console.log(e.detail, e.detail.value)
			},
			handlexieyi() {
				uni.navigateTo({
					url: "/pageTwo/index/detail?content=1"
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		// display: flex;
		overflow: hidden;
		flex-wrap: wrap;
		padding: 0 !important;
		justify-content: space-between;
	}

	.bg {
		width: 100%;
		height: 100vh;
		position: absolute;
		top: 0;
	}

	.ts {
		font-size: 20px;
		font-weight: bold;
		text-align: left;
		color: #fff;
		width: 100%;
		position: relative;
		margin-top: 200rpx;
		left: 20px;
		height: 150rpx;
	}

	.edit {
		margin: 40rpx auto 0;
		width: calc(82% - 30px);
		position: relative;
		background: #fff;
		border-radius: 10px;
		padding: 15px;
		text-align: center;
		background-color: rgba(255, 255, 255, 0.8);
		max-height: 780rpx;

		.logo {
			width: 260rpx;
			height: 90rpx;
			margin-top: 15px;
		}

		.tips {
			width: 100%;
			text-align: right;
		}

		.editem {
			margin-top: 28px;
			display: flex;
			align-items: center;
			font-size: 28upx;
			justify-content: space-between;
			flex-wrap: wrap;
		}

		.input {
			width: 100%;
			padding: 0 10px;
			height: 40px;
			line-height: 40px;
			margin-bottom: 15px;
			display: flex;
			position: relative;
			text-align: left;
			background-color: #fff;
			border-radius: 5px;

			icon {
				color: #666;
				font-size: 22px;
			}

			input {
				height: 40px;
				line-height: 40px;
				position: absolute;
				left: 35px;
				right: 0px;
				z-index: 88;
			}
		}

		.btnlogin {
			width: 100%;
			margin: 40rpx 0 20px;
			height: 38px;
			line-height: 38px;
			background: $blue;
			font-weight: 700;
			border-radius: 10px;
			text-align: center;
			color: #fff !important;
		}

		.code {
			width: 110px;
			background: #dfdfdf;
			font-size: 12px;
			margin: 0;
			border-radius: 10px;
			text-align: center;
			position: absolute;
			right: 2.5px;
			top: 2.5px;
			z-index: 99;
		}
	}

	.wxbtn {
		width: 100%;
		text-align: center;
		color: $blue;
		display: flex;
		align-items: flex-end;
		justify-content: center;

		text {
			border-bottom: 1px solid $blue;
		}
	}

	.xieyi {
		font-size: 12px;
		color: #333;
		width: 100%;
		text-align: center;
		display: flex;
		align-items: flex-end;
		margin-top: 40rpx;

		checkbox-group {
			text-align: left;
		}

		text {
			border-bottom: 1px solid #333;
		}
	}
</style>