<template>
	<view class="wx_download">
		<view class="content">
			<view>
				<view class="download-box" style="padding-top: 66upx;">
					<u-image width="80%" mode="widthFix" :src="download_src.img1"></u-image>
				</view>
				<view class="download-box" style="padding: 28upx 0;">
					<u-image width="48%" mode="widthFix" :src="download_src.img2"></u-image>
				</view>
				<view class="download-box" style="padding: 66upx 0 40upx;">
					<u-button type="primary" shape="circle" class="download-btn" @click="apkDownload">{{ $i18n.locale == 'zh' ? '下载能联全球APP' : 'Download' }}</u-button>
				</view>
				<view class="download-box">
					<easy-select ref="easySelect" size="medium" :value="languageSelect" :options="languageList" @selectOne="selectExportType"></easy-select>
				</view>
			</view>
		</view>

		<view v-if="is_wx" class="mask">
			<view class="warp">
				<u-image mode="widthFix" :src="is_wx_src.img1" style="width: 90%"></u-image>
			</view>
		</view>
	</view>
</template>

<script>
import easySelect from '@/components/easy-select/easy-select';

export default {
	components: {easySelect},
	data() {
		return {
			is_wx: false,
			platform: "",
			download_src: {
				img1: require("../../static/img/public/wxDownload/shan.png"),
				img2: require("../../static/img/public/wxDownload/icon.png")
			},
			is_wx_src: {
				img1: require("../../static/img/public/wxDownload/browser.png")
			},

			languageSelect:this.$i18n.locale=='zh'?'中文(简体)':'English',
			languageList:[
				{
					value: 'zh',
					label: '中文(简体)'
				}, {
					value: 'en',
					label: 'English'
				},
			]
		};
	},
	onLoad() {
		this.init()
	},
	methods: {
		init() {
			this.getPlatform()
			if (this.is_weixin()) {
				this.is_wx = true;
			} else {
				this.is_wx = false;
			}
		},
		is_weixin() {
			let ua = navigator.userAgent.toLowerCase();
			if (ua.match(/MicroMessenger/i) == "micromessenger") {
				return true;
			} else {
				return false;
			}
		},
		getPlatform() {
			this.platform = uni.getSystemInfoSync().platform;
		},
		apkDownload() {
			if(this.platform=='android'){
				window.location.href = 'https://www.geidcp.com/api/file/pub/app/apk/SN.apk'
			}
			if(this.platform=='ios'){
				window.location.href = 'https://apps.apple.com/us/app/id1543854564'
			}
		},
		selectExportType(data){
			this.languageSelect = data.label;
			this.$i18n.locale = data.value;
		},
	}
}
</script>

<style scoped lang="scss">
uni-page-body {
	padding-top: 0;
}
page {
	height: 100%;
}

.wx_download {
	position: relative;
	width: 100%;
	height: 100%;
}
.content{
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}
.mask{
	position: absolute;
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
	background: rgba(60,60,60,0.6);
	z-index: 9999;
}

.download-box {
	display: flex;
	justify-content: center;

	.download-btn {
		height: 60upx;
		display: inline-block;
		line-height: 60upx;
		padding: 0 30upx;
	}
	.u-btn--primary{
		background-color: linear-gradient(to right, #38BCEE, #333DDC);
	}

	/deep/ .easy-select{
		border: none;
		width: 200upx!important;
		.uni-input-input{
			font-size: 20upx;
		}
		.easy-select-options-item{
			font-size: 20upx;
		}
	}
}

.warp {
	display: flex;
	justify-content: center;
	width: 100%;
	height: 100%;
	//background: #3c3c3c;
}
</style>
