<template>
	<view class="page">
		<uni-nav-bar @clickLeft="goto(1, 1)" left-icon="back"  :border="false" :shadow="false" :fixed="true"
		title="Languages" backgroundColor="#fff"></uni-nav-bar>
		<view class="cell_list" @click="changeLang('en')">
			<view class="cell_left txt">English</view>
			<view class="cell_right">
				<uni-icons size="20" v-if="lang=='en'" style=" margin-left: 20rpx; color: blue;" type="checkbox-filled"></uni-icons>
			</view>
		</view>
		<view class="cell_list" @click="changeLang('zh')">
			<view class="cell_left txt">简体中文</view>
			<view class="cell_right">
				<uni-icons size="20" v-if="lang=='zh'" style=" margin-left: 20rpx; color: blue;" type="checkbox-filled"></uni-icons>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		data() {
			return {
				lang: 'en'
			};
		},
		computed: {
			...mapState(['userInfo'])
		},
		//第一次加载
		onLoad(e) {
			if(this.$i18n.locale=="en"){
				this.lang = 'en';
			}else{
				this.lang = 'zh'
			}
		},
		//页面显示
		onShow() {},
		//方法
		methods: {
			onPageJump(url) {
				uni.navigateTo({
					url: url+""
				});
			},
			onTokenJump(url) {
				this.judgeLogin(() => {
					uni.navigateTo({
						url: url
					});
				});
			},
			goto(url, type) {
			    if (type == 2) {
			        return uni.switchTab({ url: url })
			    }
			    if (type == 1) {
			        return uni.navigateBack({ delta: url });
			    }
			    uni.navigateTo({
			        url: url
			    })
			},
			changeLang(l){
				this.$i18n.locale = l;
				setTimeout(() => {
					uni.navigateBack();
				}, 500);
			},
		},
		//页面隐藏
		onHide() {},
		//页面卸载
		onUnload() {},
		//页面下来刷新
		onPullDownRefresh() {},
		//页面上拉触底
		onReachBottom() {},
		//用户点击分享
		onShareAppMessage(e) {
			return this.wxShare();
		}
	};
</script>
<style lang="scss" scoped>
	@import '@/style/mixin.scss';
	body{background-color: #fff;}
	.rechargeTitle{
		font-weight: 400;font-size: 32rpx;color: #999999;line-height: 46rpx; text-align: center; margin-top: 60rpx;
	}
	.rechargeNet{
		font-weight: 600;font-size: 40rpx;color: #333;line-height: 46rpx; text-align: center; margin-top: 40rpx;
	}
</style>