<template>
	<view class="containers">
		<div class="bg" style="background: url('/static/download/appeq_bg.png') no-repeat center bottom / cover;"></div>

		<view class="content">
			<image class="logo" src="/static/download/appLogo.png"></image>
			<view style="font-size: 40rpx;margin-top: 22rpx;color: #FFFFFF;font-weight: bold;">{{data.confirmBtn}}</view>
			<view style="font-size: 28rpx;margin-top: 16rpx;color: #FFFFFF;font-weight: bold;">海量电子榨菜  免费又过瘾</view>
			<button class="confirm-btn" @click="download">点击下载{{data.confirmBtn}}</button>
			
		</view>
		
		<!-- #ifdef H5 -->
		<div v-if="data.isWeixin" style="width: 100%;height: 100%;position: absolute;top: 0;background: url('/static/download/open_guide.png') no-repeat center bottom / cover;"></div>
		<!-- #endif -->
	</view>
</template>

<script setup>
	import { reactive } from 'vue';
	import { onLoad} from '@dcloudio/uni-app'
	import { commonType } from '@/api/init.js';
	
	let data = reactive({
		openShare: false,
		openShares: false,
		confirmBtn: '斯耀短剧APP',
		isWeixin: false,
	})
	
	onLoad(() => {
		// #ifdef H5
		let u = window.navigator.userAgent;
		if ( uni.getSystemInfoSync().platform == 'ios') {
			data.confirmBtn = "顺享短剧APP"
		}
		if ( u.toLowerCase().indexOf('micromessenger') !== -1) {
			data.isWeixin = true
		}
		// #endif
	})
	
	
	function download() { 
		console.log(uni.getSystemInfoSync().platform == 'android')
		if (uni.getSystemInfoSync().platform == 'android') {
			commonType(49).then(res => {
				if (res && res.value) {
					// #ifndef H5
					plus.runtime.openURL(res.value, function(res) {});
					// #endif
					// #ifdef H5
					window.location.href = res.value;
					// #endif
				}
			});
		} else {
			// #ifndef H5
				plus.runtime.openURL('https://apps.apple.com/cn/app/%E9%A1%BA%E4%BA%AB%E7%9F%AD%E5%89%A7/id6740074541', function(res) {});
			// #endif
			// #ifdef H5
				window.location.href = 'https://apps.apple.com/cn/app/%E9%A1%BA%E4%BA%AB%E7%9F%AD%E5%89%A7/id6740074541';
			// #endif
		}
	}
</script>

<style lang="scss" scoped>
	uni-page-body{
		width: 100%;
		height: 100%;
	}
	.containers {
		width: 100%;
		height: 100%;
		.bg{
			width: 100%;
			height: 85%;
			position: absolute;
		}
		.content{
			position: relative;
			height: 100%;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			.logo{
				width: 124rpx;
				height: 124rpx;
				margin-top: -920rpx;
				border-radius: 20rpx;
			}
		}
	}

	.confirm-btn {
		width: 416rpx;
		height: 90rpx;
		line-height: 90rpx;
		background: #FD5775;
		color: #fff;
		font-size: 32rpx;
		font-weight: bold;
		font-size: 32rpx;
		color: #FFFFFF;
		position: absolute;
		left: 0;
		right: 0;
		bottom: 70rpx;
		margin: auto;
	}
</style>