<template>
<view class="">
	<customNav :shownav="true" :title="$t('index.dengluzhuce')" titledetl=""></customNav>
	
	<view class="contentV" style="margin-top: 100rpx;">
		<label class="titlev">{{$t('index.huanying')}}</label>
		
		<view class="yzmctV">
			<input class="noinputV" type="text"  :placeholder="$t('index.qsrzhanghao')" @input="phoneinput">
		</view>
		<view class="yzmctV">
			<input class="noinputV" password type="text"  :placeholder="$t('index.qsrmima')"  @input="smsCodeinput">
		</view>
		<view class="yzmctV">
			<label class="querenBt" @click="loginAC">{{$t('index.dengluzhuce')}}</label>
		</view>
		<view class="contentInRowR" style="margin-top: 40rpx;align-items: center;">
			<text class="textfontB5" style="padding-right: 20rpx;color: darkgray;">{{$t('user.meiyouzhanghao')}}</text>
			<text class="zhuceBt" @click="registerAC">{{$t('user.zhuce')}}</text>
		</view>
		<view class="contentInRowC" style="margin-top: 40rpx;" @click="yueduyszc">
			<label class="linktext">{{$t('index.yuedu')}}{{$t('index.yinsizc')}}</label>
		</view>
	</view>
	<view style="height: 50rpx;"></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 {
				pvalue: [0],
				indicatorStyle: `height: 50px;`,
				range: ["+84","+886","+86"],
				showpop:false,
				phone:'',
				smsCode:'',
				guojiadaima:'+84',
				cid:''
			}
		},
		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: {
			bindChange (e) {
				var val = e.detail.value[0];
				this.guojiadaima=this.range[val];
			},
			popgjm(){
				this.showpop=true;
			},
			chooseCancel(){
				this.showpop=false;
			},
			duoyuyan(){
				uni.navigateTo({
					url:'/pages/UserCenter/yonghushezhi/duoyuyan'
				})
			},
			phoneinput(event){
				this.phone = event.target.value;
			},
			smsCodeinput(event){
				this.smsCode = event.target.value;
			},
			yueduyszc(){
				uni.navigateTo({
					url:'/pages/index/mindex/yinszhengc'
				})
			},
			
			loginAC(){
				if(this.phone.length<=0){
					uni.showToast({
					    title: this.$t('user.qsrzhanghao'),
					    icon: 'none',
					    duration: 1500
					})
					return;
				}
				if(this.smsCode.length<=0){
					uni.showToast({
					    title: this.$t('user.qingshurmim'),
					    icon: 'none',
					    duration: 1500
					})
					return;
				}
				this.loginUp();
			},
			loginUp(){
				
				var that = this;
				api('loginByzhmm',{
					userName:this.phone,
					password:encrypt(this.smsCode),
					cid:this.cid
				},res=>{
					console.log(res)
					if(res.data.code==200){
						plus.nativeUI.toast(this.$t('api.dengluchengg'), {
							icon : "none",// eg. "/img/add.png"
							duration : "long",// 持续3.5s，short---2s
							align : "center",// 水平居中
							verticalAlign : "bottom"// 垂直底部
						});
						uni.setStorageSync("token",res.data.token);
						getApp().globalData.token = res.data.token;
						uni.setStorageSync("userId",res.data.data.userId);
						let items = JSON.stringify(res.data.data);
						uni.setStorageSync('userInfo',items);
						uni.navigateBack();
						return;
					}
					if(res.data.code==500){
						uni.showToast({
						    title:res.data.msg,
						    icon: 'none',
						    duration: 3500
						})
						return;
					}
					uni.showToast({
					    title: that.$t('api.denglusb'),
					    icon: 'none',
					    duration: 3500
					})
				},failc=>{
					//console.log('getadvertis----',failc)
					uni.showToast({
					    title: that.$t('api.denglushibai'),
					    icon: 'none',
					    duration: 2500
					})
				})
			},
			registerAC(){
				uni.navigateTo({
					url:'/pages/UserCenter/RegisterView'
				})
			},
		}
	}
</script>

<style>
	page{
		background-color:white;
	}
.topimag{
	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: 32rpx;
	font-weight: bold;
	text-align: left;
}
.yzmctV{
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content:flex-start;
	margin-top: 30rpx;
	width: 100%;
}
.noinputV{
	width: 100%;
	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: -190rpx;
	border-radius: 2rpx;
	background-color:#60BA63;
}

.querenBt{
	margin-top: 30rpx;
	width: 100%;
	height: 60rpx;
	line-height: 60rpx;
	padding: 10rpx;
	border-radius: 20rpx;
	border: solid #40AE36;
	border-width: 0px 0px 6rpx 0px;
	text-align: center;
	justify-content: center;
	background-color: #40AE36;
	color: white;
	box-shadow: 0rpx 0rpx 10rpx 0rpx #40AE36;
}
.linktext{
	font-size: 24rpx;
	color:mediumblue;
	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: 100rpx;
	text-align: center;
}

.duoyuyanctv{
		margin-top: 20rpx;
		padding: 30rpx;
		border: solid lavender;
		border-width: 0px 0px 1rpx 0px;
}
.duoyuyIcon{
	width: 40rpx;
	height: 40rpx;
}

.zhuceBt{
	width: 40%;
	height: 60rpx;
	line-height: 60rpx;
	padding: 10rpx;
	border-radius: 20rpx;
	text-align: center;
	justify-content: center;
	background-color: darkgray;
	color: white;
	box-shadow: 0px 0rpx 10rpx 0rpx darkgray;
}

	
</style>
