<template>
	<view>
		<view class="head">
			<image class="head-immg" src="https://qufang.oss-cn-beijing.aliyuncs.com/zkgj/xcx/login.png" mode=""></image>
		</view>
		<view class="input">
			<view class="cwjs-cells item-flex">
				<view class="cwjs-item center">
					<input type="text" v-model="username" placeholder="请输入手机号码" maxlength="11"
						placeholder-style='color:#AAAAAA' />
				</view>
			</view>
			<view class="textbox">
				<view class="textbox-1" @tap="bindVerification">密码登录</view>
				<view class="textbox-2"></view>
				<view class="textbox-11"></view>
			</view>
		</view>
		<view class="button" @tap="bindWxBLogin">获取验证码</view>
	</view>
</template>

<script>
	var util = require("../../utils/util.js");
	var config = require("../../config");
	var app = getApp();
	export default {
		data() {
			return {
				username: '',
				role: ''
			};
		},
		onLoad: function(options) {
			this.role=options.role;
		},
		methods: {
			//账号密码登录
			bindVerification() {
				uni.navigateTo({
					url: '/pages/login/index',
				})
			},
			//获取验证码
			bindWxBLogin: function(e) {
				if (!(/^1[34578]\d{9}$/.test(this.username))) {
					util.showNone("手机号码错误");
					this.username='';
					return false;
				} else {
					uni.request({
						url: config.service.sendCode + "?mobile=" + this.username,
						method: "GET",
						header: {
							'content-type': 'application/json',
							'Access-Token': uni.getStorageSync('weapp_session_login_data').token
						},
						success: (data) => {
							console.log(data)
							// 成功地响应会话信息
							if (data.data.code == 10000) {
								util.showSuccess('发送成功');
								if(this.role==1){
									uni.navigateTo({
										url: '/pages/login/yinzhongmalogin?username=' + this.username +
											'&role=' + this.role,
									})
								}else{
									uni.navigateTo({
										url: '/pages/login/Verifythelogin?username=' + this.username +
											'&role=' + this.role,
									})
								}
								// 没有正确响应会话信息
							} else {
								util.showNone(data.data.message);
								return false;
							}
						},
					})	
				}
			},
		}
	};
</script>
<style lang="scss">
	.cwjs-logo {
		display: block;
		width: 219rpx;
		height: 158rpx;
		margin: 54rpx auto 66rpx;
	}

	.cwjs-tips {
		font-size: 24rpx;
		padding: 80rpx 0;
		color: #8a8a8a;
	}

	.cwjs-form {
		position: relative;
		margin: 0;
		background-color: #fff;
		border-radius: 10px;
		padding: 20rpx 40rpx 113rpx;
	}

	.cwjs-cells {
		width: 569rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		margin: 0 auto;
		height: 88rpx;
		overflow: hidden;
		border-bottom: 1rpx solid #BFC7D3;
		position: relative;
	}

	.center {
		flex: 1;
	}

	.cwjs-input {
		height: 48rpx;
		line-height: 48rpx;
		padding: 23rpx 23rpx 23rpx 78rpx;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		color: #000;
	}

	.images {
		display: block;
		width: 40rpx;
		height: 21rpx;
		margin-right: 30rpx;
		margin-top: 33.5rpx;
	}







	/* 头部 */

	.head {
		width: 750rpx;
		height: 500rpx;
		position: relative;
		.head-immg{
			width: 118rpx;
			height: 61rpx;
			position: absolute;
			top: 300rpx;
			left: 100rpx;
		}
	}

	.logo {
		width: 248upx;
		height: 248upx;
		display: block;
		position: absolute;
		top: 134rpx;
		left: 240.5rpx;
	}



	/* 输入框 */
	.input {
		width: 100%;
		height: auto;
		padding: 0 105rpx;
		box-sizing: border-box;
	}

	.logo_input {
		width: 34rpx;
		height: 38rpx;
		position: absolute;
		top: 25rpx;
		left: 0;
	}

	/* 登录 */
	.button {
		width: 630rpx;
		height: 86rpx;
		background: #2671E2;
		box-shadow: 0px 2rpx 20rpx 0px rgba(38, 113, 226, 0.5);
		border-radius: 49rpx;
		text-align: center;
		line-height: 89rpx;
		color: #fff;
		margin: 0 auto;
		margin-top: 239rpx;
		font-size: 34rpx;
	}

	.login {
		text-decoration: underline;
		text-align: center;
		margin-top: 40px;
		color: #88909E;
		font-size: 28rpx;
	}

	.textbox {
		width: 569rpx;
		display: flex;
		margin-top: 40rpx;
	}

	.textbox-1 {
		width: 30%;
		font-size: 30rpx;
		color: #999999;
	}

	.textbox-11 {
		width: 30%;
		text-align: right;
		font-size: 30rpx;
		color: #999999;
	}

	.textbox-2 {
		width: 40%;
	}
</style>
