<template>
	<view class="content">

		<view class="loginbg">
			<view class="statues_bar"></view>
			<view class="logobox">
				<image src="/static/logo.png" mode="aspectFill"></image>
			</view>
		</view>

		<view class="checkbox flex1">
			<view class="business " @click="checked=0" :class="checked==0 ? 'bnesper' : 'actbnes' ">业务人员</view>
			<view class="business " @click="checked=1" :class="checked==1 ? 'applyper' : 'actapp' ">供应商</view>
		</view>
		<view class="acountbox">
			<view class="inacount">
				<text class="acoutitle">账户</text>
				<input type="text" v-model="form.account" class="checkword" placeholder="请输入您的账户"
					placeholder-style="font-size:30rpx;color:#BEBDBB" />
			</view>
			<view class="inacount">
				<text class="acoutitle">密码</text>
				<input type="text" v-model="form.password" :password="true" class="checkword" placeholder="至少6位数的字母数字组合"
					placeholder-style="font-size:30rpx;color:#BEBDBB" />
			</view>
		</view>
		<view class="otherbt flex2">
			<text class="regbt" @click="registerNew">新用户注册</text>
			<text @click="show = true">忘记密码？</text>
		</view>
		<view class="logininbtn" @click="loginIn">
			<text>登陆</text>
		</view>
		<view class="flex1 checkag">
			<u-checkbox-group @change="checkboxChange">
				<u-checkbox name="gou" activeColor="#D8AB5A">
				</u-checkbox>
			</u-checkbox-group>

			<text>我已阅读并同意</text><text style="color: #D05C39;" @click="moveAgreement">用户协议</text><text>和</text><text
				style="color: #D05C39;" @click="privacyPolicy">隐私政策</text>
		</view>
		<u-popup :show="show" @close="close" @open="open" mode="center">
			<view class="forgetbox">
				<!-- <view class="ciclebg">
					<image src="../../static/img/forpwdbg.png" mode="aspectFill"></image>
				</view> -->
				<view class="keybox">
					<image src="../../static/img/foricon.png" mode="aspectFill"></image>
				</view>
				<text class="keytitle">忘记密码</text>
				<text class="remindtitle">请电联系管理员，进行密码确定</text>
				<view class="surebtn" @click="close()">好的</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					account: '',
					password: '',

				},
				checked: 0,
				show: false,
				gou:false,
			}
		},
		onLoad() {

		},
		methods: {
			checkboxChange(n){
				if(n.length>0){
					this.gou=true
				}else{
					this.gou=false
				}
			},
			close() {
				this.show = false
			},
			open(){
				this.show = true
			},
			loginIn() {
				if(!this.gou){
					this.$toast("清先阅读用户协议和隐私协议")
					return
				}
				let form=this.form
				form.loginType=this.checked+1
				uni.showLoading({
					title:'加载中',
					icon:'none'
				})
				uni.$u.http.post('/api/Account/login',
					form
				, {
					custom: {
						auth: true
					}
				}).then((res) => {
					uni.hideLoading()
					uni.setStorageSync('token', res.token)
					uni.setStorageSync('supplierId', res.userInfo.id)
					uni.hideLoading()
					this.$toast("登陆成功")
					this.$store.commit("getAdmin", this.checked)
					setTimeout(() => {
						uni.reLaunch({
							url: "/pages/index/index"
						})
					}, 500)
				}).catch((err) => {
					uni.hideLoading()
					this.$toast(err.msg)
				})
			

			},
			moveAgreement(){
				uni.navigateTo({
					url:"/pages/bsinessadmin/useragreement"
				})
			},
			privacyPolicy(){
				uni.navigateTo({
					url:"/pages/bsinessadmin/privacypolicy"
				})
			},
			registerNew() {
				if (this.checked == 0) {
					uni.navigateTo({
						url: "/pages/bsinessadmin/register?checked=" + this.checked
					})
				} else {
					uni.navigateTo({
						url: "/pages/bsinessadmin/supplierges"
					})
				}

			}
		}
	}
</script>

<style lang="scss" scoped>
	/* uni.scss */
	@import 'uview-ui/theme.scss';

	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

	}

	.loginbg {
		background-image: url("https://t39.9026.com/web/uploads/thumbs/mall10000/20220629/e01b927c95ee1f05364f5e456f281388.png");
		height: 559rpx;
		width: 750rpx;
		background-size: 100% 100%;

		// display: flex;
		// align-items: center;
		// justify-content: center;
	}

	.logo {
		margin: 0 auto;
		height: 200rpx;
		width: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}

	.logobox {
		margin: 0 auto;
		margin-top: 212rpx;
		width: 269rpx;
		height: 191rpx;
		// background-color: #F1F1F1;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.checkbox {}

	.business {
		width: 305rpx;
		height: 90rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		text-align: center;
		// background-color: #D8AB5A;
		border-raotherdius: 20rpx;
		color: #FFFFFF;
		margin-top: 57rpx;
	}

	.bnesper {
		background-size: 100%;
		background-image: url("@/static/img/loginbtn4.png");
		padding-top: 10rpx;
		color: #FFF1D8;
		line-height: 90rpx;
	}

	.applyper {
		background-image: url("@/static/img/loginbt1.png");
		background-size: 100%;
		padding-top: 10rpx;
		color: #FFF1D8;
	}

	.actapp {
		background-image: url("@/static/img/loginbtn3.png");
		background-size: 100%;
		color: #D05C39;
	}

	.actbnes {
		background-image: url("@/static/img/loginbt2.png");
		background-size: 100%;
		color: #D05C39;
	}

	.acountbox {
		.inacount {
			display: flex;
			padding: 35rpx 20rpx;
			box-sizing: border-box;
			width: 606rpx;
			margin-top: 40rpx;
			background-color: #F6F6F6;
			border-radius: 20rpx;
			font-size: 30rpx;
			color: #1F242A;

			input {
				width: 360rpx;
			}
		}

		.acoutitle {
			font-weight: 600;
		}

		.checkword {
			padding-left: 20rpx;
			color: #1F242A;
			font-size: 30rpx;
		}
	}

	.otherbt {
		width: 606rpx;
		display: flex;
		justify-content: space-between;
		font-size: 24rpx;
		padding-top: 30rpx;
	}

	.regbt {
		color: $uni-all-theme;
	}

	.logininbtn {
		box-sizing: border-box;
		margin-top: 80rpx;
		width: 606rpx;
		border-radius: 20rpx;
		background: linear-gradient(to right, #FFE1AD, #D07539);
		height: 100rpx;
		text-align: center;
		color: #fff;
		line-height: 100rpx;
	}

	.checkag {
		margin-top: 200rpx;
		font-size: 28rpx;
		padding-bottom: 130rpx;

	}

	.forgetbox {
		width: 600rpx;
		height: 600rpx;
		background-color: #fff;
		display: flex;
		flex-direction: column;
		align-items: center;
		position: relative;
		background-image: url("@/static/img/forpwdbg.png");
		background-repeat: no-repeat;
		background-position: right 0 top 0;
		background-size: 367rpx 225rpx;

		.ciclebg {
			position: relative;
			right: 0;
			top: 0;
			width: 367rpx;
			height: 225rpx;

		}

		.keybox {
			margin-top: 84rpx;
			width: 196rpx;
			height: 161rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.keytitle {
			color: #1F242A;
			padding-top: 50rpx;
			font-size: 36rpx;
			font-weight: 600;
		}

		.remindtitle {
			color: #68625B;
			font-size: 28rpx;
			padding-top: 30rpx;
		}

		.surebtn {
			width: 314rpx;
			height: 84rpx;
			line-height: 84rpx;
			border-radius: 43rpx;
			background: linear-gradient(to right, #FFE1AD, #D8AB5A);
			color: #412900;
			margin-top: 86rpx;
			text-align: center;
		}
	}
</style>
