<template>
	<view>
		<view class="form_body" style="">
			<view class="form_body_title">欢迎登录星云台</view>
			<view class="form_body_input">
				<view style="color: #999999;">+86</view>
				<input type="number" v-model="phone" placeholder="请输入手机号" class="form_input" />
			</view>
			<view class="form_body_footer">
				<view class="form_body_footer_text">
					<view>
						<uni-data-checkbox multiple v-model="value" :localdata="range" @change="change">
						</uni-data-checkbox>
					</view>
					阅读并同意 <text style="color: #2A67FE;">《用户隐私政策》</text> 和 <text
						style="color: #2A67FE;">《星油能源注册服务协议》</text>
				</view>
				<button @tap="sumit" style="margin-top:26rpx; " class="form_body_butten">登录</button>
			</view>
		</view>
		<uni-popup ref="popup" type="center">
			<view class="popup">
				<view class="popup_title">为了更好地使用服务<br /><text style="margin-top: 15rpx;">登录前请先阅读并同意下方协议</text></view>
				<view class="popup_text">《用户隐私政策》和《星油能源注册服务协议》</view>
				<view  class="popup_footer">
					<view @tap="ishowFn(0)" class="popup_footer_butteno">不同意</view>
					<view @tap="ishowFn(1)" class="popup_footer_buttent">同意并继续</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import tool from '@/utils/tool'
	export default {
		data() {
			return {
				phone:'',
				value: [],
				range: [{
					"value": 0,
					"text": ""
				}]
			}
		},
		methods: {
			ishowFn(e){
				if(e){
					this.value.push(0)
					this.$refs.popup.close()
				}else{
					 this.$refs.popup.close()
				}
			},
			sumit() {
				if (this.value.length == 0) {
					this.$refs.popup.open('center')
					return
				}
				if(this.phone==''){
					uni.showToast({
						title:'手机号不能为空',
						icon:'none'
					})
					return
				}
				let checkPage = {
					phone:{
						custom:/^[1][3,4,5,7,8,9][0-9]{9}$/,
						WrongText:'请输入正确手机号码'
					}
				}
				let check = tool.checkFn({phone:this.phone},[],checkPage)
				if(!check.result){
					uni.showToast({
						title:check.WrongText,
						icon:'error'
					})
					return
				}
				let that = this
				uni.$emit('state',{
					state:1,
					phone:that.phone
				})
			},
			change(e) {
				console.log(this.value)
			}
		}
	}
</script>

<style>

</style>
