<template>
	<view class="lPage">
		<!-- <scroll-view class="pageContent"> -->
		<levitatedsphere :x="100" :y="80"></levitatedsphere>
		<headers :showBack="true">
			<view class="headerName">
				系统设置
			</view>
		</headers>

		<view class="operateBar" @click="toLegalTerms">
			<view class="left">
				法律条款
			</view>
			<uni-icons2 class="arrowright" type="arrowright" size="20"></uni-icons2>
		</view>
		<view class="operateBar">
			<view class="left">
				当前版本
			</view>
			<view class="arrowright">
				{{versionName}}
			</view>
		</view>
		<!-- </scroll-view> -->
	</view>
</template>

<script>
	import headers from '@/components/headers/headers.vue';
	import checkVersion from '@/pages/lq-upgrade/checkVersion.js'
	export default {
		components: {
			headers
		},
		data() {
			return {
				versionNo:"",
				versionName:"--",
			};
		},
		onLoad() {
			// #ifdef APP-PLUS
			this.viewVersionInfo()
			// #endif
		},
		methods: {
			toLegalTerms() {
				uni.navigateTo({
					url: './legalTerms/legalTerms'
				})
			},
			viewVersionInfo() {
				console.log('进入页面调用');
				//fix 避开检查更新  罗劲章
				// return false
				var that = this
				//获取当前应用版本
				plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
					console.log('版本号的数据信息', widgetInfo);//其实是应用版本名称
					console.log('应用版本名称', widgetInfo.version);
					that.versionName = widgetInfo.version
					console.log('应用版本号', widgetInfo.versionCode);
					that.versionNo = widgetInfo.versionCode
				})
				console.log('viewVersionInfo', that.url_config)
				// uni.navigateTo({
				// 	url:'versionInfo'
				// })
				const systemInfo = uni.getStorageSync('systemInfo')
				if (
					systemInfo.platform.indexOf('android') != -1 &&
					typeof plus !== 'undefined'
				) {
					//获取最新版本
					that.sendRequest({
						url: 'xmgl/appVersion/getAppVersion',
						data: {},
						method: 'POST',
						success(res2) {
							console.log('获取当前app应用版本名称', that.versionName);
							console.log('获取平台版本名称', res2.result.versionName);
							let jxjAppVersionName = res2.result.versionName
							console.log('获取当前app应用版本号', that.versionNo);
							console.log('获取平台版本号', res2.result.versionNo);
							let jxjAppVersionNo = res2.result.versionNo

							if (res2.result && jxjAppVersionNo !== that.versionNo) {

								let name = res2.result.versionName; //新版本名称
								let code = res2.result.versionNo; //新版本号（数字）
								let content = res2.result.versionDescribe; //更新内容
								let url = JSON.parse(res2.result.downloadUrl)[0].url; //app下载链接，（演示请换成真正在下载链接）
								let forceUpdate = false; //是否强制更新
								checkVersion({
									name, //最新版本名称
									code, //最新版本号
									content, //更新内容
									url, //下载链接
									forceUpdate //是否强制升级			  
								})
							} else {
								// uni.showToast({
								// 	title: '您已经是最新版本啦！',
								// 	icon: 'none'
								// })
							}
						}
					})
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.lPage {
		background-color: #f3f5fd;
		height: 100%;
	}

	.operateBar {
		background-color: #FFFFFF;
		font-size: 28rpx;
		height: 80rpx;
		display: flex;
		align-items: center;
		// margin-bottom: 20rpx;
		padding: 0 30rpx;
		justify-content: space-between;

		&.first {
			margin-top: 30rpx;
			border-bottom: 2rpx solid #f3f5fd;
		}

		.left {
			display: flex;
			align-items: center;
		}

		.operateIcon {
			width: 40rpx;
			height: 40rpx;
			margin-right: 20rpx;
		}

		.arrowright {
			opacity: 0.5;
		}
	}
</style>