<script setup>
	// 关于九亿
	// 设置
	import {
		ref,
		reactive,
		computed,
		getCurrentInstance
	} from 'vue'
	import {
		useStore
	} from 'vuex'
	import {
		onLoad,
	} from '@dcloudio/uni-app'
	// 工具库
	import util from '@/common/js/util.js'
	// 版本更新弹窗
	import appVerUpdateAlt from '@/components/index/appVerUpdate.vue';

	// app版本号
	const appVersion = reactive({})
	// 
	const {
		proxy
	} = getCurrentInstance()

	onLoad(() => {
		// #ifdef APP
		let system = uni.getSystemInfoSync()
		Object.assign(appVersion, system)
		// #endif
	})

	// 更新
	function handleUpdate() {
		util.getAppVersion((result) => {
			console.log('handleUpdate', result, appVersion)
			if (appVersion.appVersionCode < result.versionCode) {
				proxy.$refs.appVerUpdateRef.open()
			} else util.alert('当前已是最新版本')
		})
	}

	// 跳转
	function link(url) {
		uni.navigateTo({
			url,
		})
	}
</script>

<template>
	<view class="app">
		<!-- 顶部 -->
		<view class="header ver mt50">
			<view class="logo">
				<image class="logo wh200 br15" src="/static/logo.png" mode="aspectFit" />
			</view>
			<view class="version mt20 tac c999 f34">{{appVersion.appVersion}}</view>
		</view>

		<!-- 容器 -->
		<view class="container mt50 mlr50 plr20 bfff br10">
			<view class="line rows ptb30 plr10" @click="handleUpdate">
				<view class="key">检查更新</view>
				<view class="value">
					<uni-icons type="right" color="#999" />
				</view>
			</view>

			<view class="line rows ptb30 plr10" @click="link(util.setUrl('/pages/index/article', { id: 2, }))">
				<view class="key">关于我们</view>
				<view class="value">
					<uni-icons type="right" color="#999" />
				</view>
			</view>
		</view>

		<!-- app版本更新弹窗 -->
		<appVerUpdateAlt ref="appVerUpdateRef" />
	</view>
</template>

<style lang="scss">
	// 容器
	.container {
		.line+.line {
			border-top: 2rpx solid #eee;
		}
	}
</style>