<template>
	<view class="page" :style="themeColor">
		<view class="flex benben-position-layout flex flex-wrap align-center registerLogin_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between flex-sub registerLogin_fd0_0'>
				<view class='flex flex-wrap align-center' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
					<text class='fu-iconfont2  registerLogin_fd0_0_c0_c0' @tap.stop="handleJumpDiy" data-type="back"
						data-url="1">&#xE794;</text>
				</view>
				<view class='flex flex-wrap align-stretch justify-center flex-sub'>
				</view>
				<view class='flex flex-wrap align-center registerLogin_fd0_0_c2'>
				</view>
			</view>

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<!---flex布局flex布局开始-->
		<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout registerLogin_flex_1">
			<view class='flex flex-wrap align-center registerLogin_fd1_0'>
				<text class='registerLogin_fd1_0_c0'>欢迎来到萬家商超</text>
			</view>
			<view class='flex flex-direction flex-wrap align-stretch registerLogin_fd1_1'>
				<text class='registerLogin_fd1_1_c0'>账号</text>
				<view class='flex flex-wrap align-center justify-between'>
					<input type="number" placeholder="请输入手机号" confirm-type="done" :maxlength="11"
						placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="mobile" />
				</view>
			</view>
			<view class='flex flex-direction flex-wrap align-stretch registerLogin_fd1_2'>
				<text class='registerLogin_fd1_2_c0'>验证码</text>
				<view class='flex flex-wrap align-center justify-between'>
					<input type="number" class="flex-sub" placeholder="请输入验证码" confirm-type="done" :maxlength="4"
						placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="code" />
					<benben-send-verification-code class='flex  registerLogin_fd1_2_c1_c1' after-text='后重新获取'
						before-text='获取验证码' type='1' :phone="mobile"></benben-send-verification-code>
				</view>
			</view>
			<view class='flex flex-direction flex-wrap align-stretch registerLogin_fd1_3'>
				<text class='registerLogin_fd1_3_c0'>密码</text>
				<view class='flex flex-wrap align-center justify-between'>
					<benben-flex-password-diy v-model="password"
						class-name="flex flex align-center registerLogin_fd1_3_c1_c0" :placeholder="'请输入密码(6~12位字母+数字)'"
						:maxlength="12" :default-type='true' placeholder-style="color:#999;font-size:32rpx">
						<template #show>
							<text class='fu-iconfont2  registerLogin_fd1_3_c1_c0_icon1' data-type="show">&#xE837;</text>
						</template>
						<template #hide>
							<text class='fu-iconfont2  registerLogin_fd1_3_c1_c0_icon2' data-type="hide">&#xEBCC;</text>
						</template>
					</benben-flex-password-diy>
				</view>
			</view>
			<view class='flex flex-wrap align-center registerLogin_fd1_4'>
				<button class='flex-sub registerLogin_fd1_4_c0' @tap.stop="registeAccountFunc()">注册</button>
			</view>
			<view class='flex flex-wrap align-center justify-center registerLogin_fd1_5'>
				<benben-flex-switch-new class-name='flex flex registerLogin_fd1_5_c0' v-model="is_tick"
					:disabled='false' :auto='true'>
					<template v-slot:checked>

						<view class='flex flex position-relative align-center'>
							<image class='registerLogin_checkfd1_5_c0_c0_c0' mode="aspectFit"
								:src='STATIC_URL+"122.png"'></image>
						</view>

					</template>
					<template v-slot:unchecked>

						<view class='flex flex position-relative justify-end align-center'>
							<image class='registerLogin_noCheckfd1_5_c0_c1_c0' mode="aspectFit"
								:src='STATIC_URL+"123.png"'></image>
						</view>

					</template>
				</benben-flex-switch-new>
				<text class='registerLogin_fd1_5_c1'>已阅读并同意</text>
				<text class='registerLogin_fd1_5_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
					:data-url="`/pages/dl/agreementPolicy/agreementPolicy?type=8`">《用户注册协议》</text>
				<text class='registerLogin_fd1_5_c3'>与</text>
				<text class='registerLogin_fd1_5_c4' @tap.stop="handleJumpDiy" data-type="navigateTo"
					:data-url="`/pages/dl/agreementPolicy/agreementPolicy?type=16`">《隐私政策》</text>
			</view>
		</view>

		<!---flex布局flex布局结束-->


	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},


		data() {
			return {
				"mobile": "",
				"code": "",
				"password": "",
				"is_tick": false
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			Get5d8b062aefc08(userinfo) {
				let clientId = '565656565656';
				let appSystem = 'appSystem';
				// #ifdef APP-PLUS
				clientId = plus.push.getClientInfo().clientid || '';
				console.log('getClientInfo', plus.push.getClientInfo());
				appSystem = uni.getSystemInfoSync().platform == 'ios' ? 1 : 2;
				// #endif
				this.$api.post(global.apiUrls.Get5d8b062aefc08, {
					client_id: clientId
				}).then(res => {
					if (res.data.code == 1) {
						this.$store.commit("updateUserInfo", userinfo);
						global.token = userinfo.user_token
						global.userInfo = userinfo
						uni.setStorageSync('USER_INFO', userinfo)
						uni.setStorageSync('USER_TOKEN', userinfo.user_token)
						uni.$emit('loginSuccess')
						setTimeout(() => {
							uni.navigateBack({
								delta: 2
							})
						}, 1000)
					}
				})
			},
			//注册账号
			registeAccountFunc() {
				if (this.is_tick === false) {
					this.$message.info('请先阅读并同意《用户注册协议》与《隐私政策》');
					return false;
				}
				if (!validate(this.mobile, 'require')) {
					this.$message.info('手机号不能为空');
					return false;
				}
				if (!validate(this.mobile, 'phone')) {
					this.$message.info('请输入正确的手机号');
					return false;
				}
				if (!validate(this.code, 'require')) {
					this.$message.info('验证码不能为空');
					return false;
				}
				if (!validate(this.code, 'captcha')) {
					this.$message.info('请输入正确的验证码');
					return false;
				}
				if (!validate(this.password, 'require')) {
					this.$message.info('密码不能为空');
					return false;
				}
				if (!validate(this.password, 'password')) {
					this.$message.info('请输入6~12位字母+数字的密码');
					return false;
				}
				this.$api.post(global.apiUrls.postRegister, {
						mobile: this.mobile,
						password: this.password,
						code: this.code,
						type: 1
					})
					.then(res => {
						console.log('res', res);
						console.log(res.data.data.userinfo);
						this.$message.info(res.data.msg)
						if (res.data.code == 1) {

							global.user_token = res.data.data.userinfo.user_token
							this.Get5d8b062aefc08(res.data.data.userinfo)
							return
							this.$store.commit("updateUserInfo", res.data.data.userinfo);
							global.token = res.data.data.userinfo.user_token
							global.userInfo = res.data.data.userinfo
							uni.setStorageSync('USER_INFO', res.data.data.userinfo)
							uni.setStorageSync('USER_TOKEN', res.data.data.userinfo.user_token)
							setTimeout(() => {
								uni.navigateBack({
									delta: 2
								})
							}, 1000)
							// uni.reLaunch({
							//   url:'/pages/tabBar/guide/index'
							// })
						}
					});
				// this.$urouter.navigateTo(`/pages/tabBar/passwordLogin/passwordLogin`);
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: url(https://lvtai-files.oss-cn-beijing.aliyuncs.com/mini/117.png) no-repeat, rgba(255, 255, 255, 1);
		background-size: 100% auto !important;
	}

	.registerLogin_flex_0 {
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
	}

	.registerLogin_fd0_0_c2 {
		width: 32rpx;
		height: 32rpx;
	}

	.registerLogin_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
		line-height: 88rpx;
	}

	.registerLogin_fd0_0 {
		margin: 0rpx 32rpx 0rpx 32rpx;
	}

	.registerLogin_flex_1 {
		padding: 88rpx 75rpx 0rpx 75rpx;
	}

	.registerLogin_fd1_5_c4 {
		color: #59A6F4;
		font-size: 22rpx;
		font-weight: 400;
		line-height: 32rpx;
	}

	.registerLogin_fd1_5_c3 {
		color: rgba(102, 102, 102, 1);
		font-size: 22rpx;
		font-weight: 400;
		line-height: 32rpx;
	}

	.registerLogin_fd1_5_c2 {
		color: #59A6F4;
		font-size: 22rpx;
		font-weight: 400;
		line-height: 32rpx;
	}

	.registerLogin_fd1_5_c1 {
		color: rgba(102, 102, 102, 1);
		font-size: 22rpx;
		font-weight: 400;
		line-height: 32rpx;
	}

	.registerLogin_noCheckfd1_5_c0_c1_c0 {
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		width: 24rpx;
		height: 24rpx;
	}

	.registerLogin_checkfd1_5_c0_c0_c0 {
		width: 24rpx;
		height: 24rpx;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
	}

	::v-deep .registerLogin_fd1_5_c0 {
		margin: 0rpx 8rpx 0rpx 0rpx;
	}

	.registerLogin_fd1_5 {
		padding: 32rpx 0rpx 0rpx 0rpx;
	}

	.registerLogin_fd1_4_c0 {
		background: rgba(255, 147, 0, 1);
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: #fff;
		height: 80rpx;
		line-height: 80rpx;
	}

	.registerLogin_fd1_4 {
		padding: 88rpx 0rpx 0rpx 0rpx;
	}

	.registerLogin_fd1_3_c1_c0_icon2 {
		width: 88rpx;
		line-height: 88rpx;
		text-align: center;
		font-size: 40rpx;
	}

	.registerLogin_fd1_3_c1_c0_icon1 {
		width: 88rpx;
		line-height: 88rpx;
		text-align: center;
		font-size: 40rpx;
	}

	::v-deep .registerLogin_fd1_3_c1_c0 {
		width: 600rpx;
		font-size: 32rpx;
		height: 50rpx;
	}

	.registerLogin_fd1_3_c0 {
		margin: 0rpx 0rpx 24rpx 0rpx;
		color: #333333;
		font-size: 30rpx;
		font-weight: 600;
		line-height: 32rpx;
	}

	.registerLogin_fd1_3 {
		border-bottom: 1px solid #eee;
		padding: 40rpx 0rpx 20rpx 0rpx;
	}

	.registerLogin_fd1_2_c1_c1 {
		min-width: 120rpx;
		line-height: 32rpx;
		text-align: center;
		font-size: 24rpx;
		color: #FF7F1E;
		font-weight: 400;
	}

	.registerLogin_fd1_2_c0 {
		margin: 0rpx 0rpx 24rpx 0rpx;
		color: #333333;
		font-size: 30rpx;
		font-weight: 600;
		line-height: 32rpx;
	}

	.registerLogin_fd1_2 {
		border-bottom: 1px solid #eee;
		padding: 40rpx 0rpx 20rpx 0rpx;
	}

	.registerLogin_fd1_1_c0 {
		margin: 0rpx 0rpx 24rpx 0rpx;
		color: #333333;
		font-size: 30rpx;
		font-weight: 600;
		line-height: 32rpx;
	}

	.registerLogin_fd1_1 {
		border-bottom: 1px solid #eee;
		padding: 40rpx 0rpx 20rpx 0rpx;
	}

	.registerLogin_fd1_0_c0 {
		color: #333333;
		font-size: 50rpx;
		font-weight: 600;
		line-height: 50rpx;
	}

	.registerLogin_fd1_0 {
		margin: 0rpx 0rpx 24rpx 0rpx;
	}
</style>