<template>
<view class="">
	<customNav :shownav="true" :title="$t('user.zhuce')" tinColor="#386EF5" jiantou="0"></customNav>
	<view class="contentV">
		<view class="yzmctV">
			<input class="noinputVcode" type="nickname" :placeholder="$t('user.qsrzhanghao')"  @input="dengluzhangh">
		</view>
		<view class="yzmctV">
			<input class="noinputVcode" password type="text" :placeholder="$t('user.qingshurmim')" :password="true"  @input="denglumimaA">
		</view>
		<view class="yzmctV">
			<input class="noinputVcode" password type="text" :placeholder="$t('user.qingzaisryc')" :password="true"  @input="denglumimaB">
		</view>
		<view class="yzmctV">
			<view class="xialakuangct" @click="popgjm">
				<text>{{guojiadaima}}</text>
				<image style="width: 36rpx;height: 36rpx;padding-right: 16rpx;" src="/static/imags/xiala@3x.png" mode="scaleToFill"></image>
			</view>
			<input class="noinputV" type="number" :placeholder="$t('user.qsrshouihao')" @input="phoneinput">
		</view>
		<!-- <view class="yzmctV noinputVcode">
			<input class="" type="text" :placeholder="$t('user.yanzhengma')"  @input="smsCodeinput">
			<label class="yzmbt" @click="getSMScode">{{yanzmnote}}</label>
		</view> -->
		
		<view class="yzmctV">
			<view class="contentInRowL xiahuax" style="align-items: center;" @click="liucheng">
				<uni-icons custom-prefix="custom-icon" color="black" type="info-filled" size="26"  @click="leftbuttonsel(4)"></uni-icons>
				<text style="margin-left: 8rpx;">{{$t('RegisterView.zucelc')}}</text>
			</view>
		</view>
		
		<view class="yzmctV">
			<label class="querenBt" @click="loginAC">{{$t('user.zhuce')}}</label>
		</view>
		<view class="contentColumnC" style="margin-top: 50rpx;" @click="yueduyszc">
			<label class="linktext">{{$t('index.yuedu')}}{{$t('index.yinsizc')}}</label>
		</view>
	</view>
	<popViewGG :tips="$t('index.gjqhxz')" :show="showpop" :maskClosable="true" :isCancel="true" @chooseCancel="chooseCancel">
		<picker-view :indicator-style="indicatorStyle" :value="pvalue" @change="bindChange" class="picker-view">
		    <picker-view-column>
		        <view class="item" v-for="(item,index) in range" :key="index">{{item}}</view>
		    </picker-view-column>
		</picker-view>
	</popViewGG>
</view>
</template>

<script>	
	import api from "@/pages/api/api.js"
	import { encrypt,decrypt } from '@/common/jsencrypt.js'
	
	export default {
		
		data() {
			return {// paotui123    123456
				zhanghao:'',
				mimaA:'',
				mimaB:'',
				phone:'',
				smCode:'',
				cid:'',
				cryptform:'',
				guojiadaima:'+886',
				pvalue: [0],
				indicatorStyle: `height: 50px;`,
				range: ["+886","+86"],
				showpop:false,
				yanzmnote:this.$t('user.huoquyanzhegm'),
				timer:'',
				timeCall:0,
			}
		},
		onShow() {
			var that=this;
			uni.getPushClientId({
			    success: (res) => {
			     that.cid =  res.cid;
			     //console.log('客户端推送标识:',that.cid)
				 uni.setStorageSync("cid",that.cid);
			    },
			    fail(err) {
			     console.log(err)
			    }
			   });
			   //this.UpdataToken();
		},
		methods: {
			yueduyszc(){
				uni.navigateTo({
					url:'/pages/index/yinszhengc'
				})
			},
			dengluzhangh(event){
				this.zhanghao = event.target.value;
			},
			
			denglumimaA(event){
				this.mimaA = event.target.value;
			},
			denglumimaB(event){
				this.mimaB = event.target.value;
			},
			
			phoneinput(event){
				this.phone = event.target.value;
			},
			smsCodeinput(event){
				this.smCode = event.target.value;
			},
			bindChange (e) {
				var val = e.detail.value[0];
				this.guojiadaima=this.range[val];
			},
			popgjm(){
				this.showpop=true;
			},
			chooseCancel(){
				this.showpop=false;
			},
			getSMScode(){
				if(this.phone.length<1){
					uni.showToast({
					    title: this.$t('user.qsrshouihao'),
					    icon: 'none',
					    duration: 3500
					})
					return;
				}
				
				var top = this.phone.substring(0,1);
				if(top=='0'){
					this.phone=this.phone.slice(1);
				}
				console.log(this.phone)
				
				if(this.timeCall==0){
					this.getSMScodeact();
					this.timeCall=60;
				}
				else{
					return;
				}
				var that = this;
				this.timer = setInterval(() => {
					that.timeCall=that.timeCall-1;
					if(that.timeCall==0){
						clearInterval(that.timer);
						that.yanzmnote = that.$t('user.huoquyanzhegm');
					}
					else{
						that.yanzmnote =that.$t('user.chongxinhq')+'('+that.timeCall+')';
					}
				}, 1000);
			},
			getSMScodeact(){
				api('smsCode',{
					phone:this.guojiadaima+this.phone
				},res=>{
					console.log(res)
					uni.showToast({
					    title: res.data.msg,
					    icon: 'none',
					    duration: 1500
					})
				},failc=>{
					//console.log('getadvertis----',failc)
				})
				
			},
			loginAC(){
				if(this.zhanghao.length<=0){
					uni.showToast({
					    title: this.$t('user.qsrzhanghao'),
					    icon: 'none',
					    duration: 1500
					})
					return
				}
				if(this.mimaA.length==0||this.mimaB.length==0||this.mimaA!=this.mimaB){
					uni.showToast({
					    title: this.$t('user.qingshurmim'),
					    icon: 'none',
					    duration: 1500
					})
					return;
				}
				if(this.phone.length<1){
					uni.showToast({
					    title: this.$t('user.qsrshouihao'),
					    icon: 'none',
					    duration: 1500
					})
					return
				}
				var top = this.phone.substring(0,1);
				if(top=='0'){
					this.phone=this.phone.slice(1);
				}
				console.log(this.phone)
				// if(this.smCode.length<=0){
				// 	uni.showToast({
				// 	    title: this.$t('user.yanzhengma'),
				// 	    icon: 'none',
				// 	    duration: 1500
				// 	})
				// 	return
				// }
				this.loginUp();
			},
			loginUp(){
				var that = this;
				api('addshanghu',{
					userName:this.zhanghao,
					password:encrypt(this.mimaA),
					telPhone:this.guojiadaima+this.phone, //手机号码
					code:"8888",//this.smCode, //手机验证码
					cid:this.cid
				},res=>{
					console.log(res)
					if(res.data.code==200){
						plus.nativeUI.toast(this.$t('user.zhucechengg'), {
							icon : "none",// eg. "/img/add.png"
							duration : "long",// 持续3.5s，short---2s
							align : "center",// 水平居中
							verticalAlign : "bottom"// 垂直底部
						});
						uni.navigateBack();
						return;
					}
					if(res.data.code==500){
						uni.showToast({
						    title: res.data.msg,
						    icon: 'none',
						    duration: 3500
						})
						return;
					}
					uni.showToast({
					    title: res.data.msg,
					    icon: 'none',
					    duration: 3500
					})
				},failc=>{
					//console.log('getadvertis----',failc)
					uni.showToast({
					    title: that.$t('user.shezhishibai'),
					    icon: 'none',
					    duration: 2500
					})
				});
			},
			liucheng(){
				uni.navigateTo({
					url:'/pages/index/Openwebview?url='+'https://cityexpress168.com.vn/doi-tac-nha-hang'
				})
			},
		}
	}
</script>

<style lang="scss">
	page{
		background-color:white;
	}
.topimag{
	width: 100%;
}

.contentVB{
	position: fixed;
	flex-direction: row;
	justify-content: center;
	align-items: center;
	bottom: 30rpx;
	width: 100%;
}
.contentV{
	display: flex;
	width: 92%;
	margin-left: 4%;
	flex-direction: column;
	justify-content: flex-start;
}
.titlev{
	width: 100%;
	height: 60rpx;
	line-height: 60rpx;
	font-size: 40rpx;
	font-weight: bold;
	text-align: left;
}
.yzmctV{
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content:flex-start;
	margin-top: 30rpx;
	width: 100%;
}
.yzmctVS{
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content:space-between;
	margin-top: 30rpx;
	width: 100%;
}
.noinputV{
	width: 73%;
	height: 80rpx;
	line-height: 80rpx;
	border-radius: 10rpx;
	border: 2rpx solid #F2F3F7;
	background-color: #F2F3F7;
}

.noinputVcode{
	width: 100%;
	height: 80rpx;
	line-height: 80rpx;
	border-radius: 10rpx;
	border: 2rpx solid #F2F3F7;
	background-color: #F2F3F7;
}


.yzmbt{
	color: white;
	font-size: 26rpx;
	width: 170rpx;
	height: 60rpx;
	line-height: 60rpx;
	text-align: center;
	margin-left: auto;
	margin-right: 10rpx;
	border-radius: 2rpx;
	background-color:#60BA63;
}

.yzmdl{
	color: white;
	font-size: 26rpx;
	width: 170rpx;
	height: 60rpx;
	line-height: 60rpx;
	text-align: center;
	margin-top: 26rpx;
	border-radius: 2rpx;
	background-color:#40AE36;
}

.querenBt{
	margin-top: 30rpx;
	width: 100%;
	height: 60rpx;
	line-height: 60rpx;
	padding: 10rpx;
	border-radius: 20rpx;
	text-align: center;
	justify-content: center;
	background-color: #40AE36;
	color: white;
	box-shadow: 0px 0rpx 10rpx 0rpx #40AE36;
}
.linktext{
	font-size: 24rpx;
	color:skyblue;
	text-decoration:underline;
}

.notetext{
	color: darkgray;
	font-size: 24rpx;
	text-align: center;
}
	
.xialakuangct{
	
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content:space-between;
	
	padding-left: 16rpx;
	margin-right: 20rpx;
	width: 140rpx;
	height: 80rpx;
	line-height: 80rpx;
	border-radius: 10rpx;
	border: 2rpx solid #F2F3F7;
	background-color: #F2F3F7;
}

.xialakuang{
	width: 100%;
}


.lineview{
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: center;
	background-color: whitesmoke;
	border: solid darkgray;
	border-width: 0px 0px 1rpx 0px;
	width: 80%;
	margin-bottom: 12rpx;
}

.picker-view {
	width: 750rpx;
	height: 300rpx;
	margin-top: 10rpx;
}
.item {
	line-height: 90rpx;
	text-align: center;
}
.duoyuyanctv{
	margin-top: 20rpx;
	padding: 30rpx;
	border: solid lavender;
	border-width: 0px 0px 1rpx 0px;
}
.duoyuyIcon{
	width: 40rpx;
	height: 40rpx;
}
.picker-view {
	width: 750rpx;
	height: 300rpx;
	margin-top: 10rpx;
}
.item {
	line-height: 100rpx;
	text-align: center;
}
.noinputVcode{
	width: 100%;
	height: 80rpx;
	line-height: 80rpx;
	border-radius: 10rpx;
	border: 2rpx solid #F2F3F7;
	background-color: #F2F3F7;
}

.xiahuax{
	border: solid darkgray;
	border-width: 0px 0px 2rpx 0px;
}

</style>


