<script>
	import config from 'common/config.js';
	import {
		mapMutations
	} from 'vuex'
	export default {

		methods: {
			...mapMutations(['onLuanchLogin', 'getBLEDeviceList', 'getFinalUseDevice', 'onAccAndGyroConvertDataGet',
				'getGuideUnlockState', 'setGuideUnlockState'
			]),

		},
		onLaunch: function() {
			console.log('App Launch');
			//这里先隐藏游戏和视频栏目
			uni.setTabBarItem({
				index:2,
				visible:false
			})
			uni.setTabBarItem({
				index:3,
				visible:false
			})
			// 先判断 系统版本
			const _systemInfo = uni.getSystemInfoSync();
			// uni.getSystemInfo({
			// 	success: (res) => {
			// 		console.log("系统信息:", res);
			// 		this.$store.state.clientName = res.model;
			// 		this.$store.state.system = res.system;
			// 		this.$store.state.platform = res.platform;
			// 		this.$store.state.systemInfo = res;
			// 	},
			// 	fail: (err) => {},
			// 	complete: () => {}
			// })
			console.log("系统信息:", _systemInfo);
			this.$store.state.clientName = _systemInfo.model;
			this.$store.state.system = _systemInfo.system;
			this.$store.state.platform = _systemInfo.platform;
			this.$store.state.systemInfo = _systemInfo;
			//获取记录的最后一次连接
			this.getFinalUseDevice();
			//获取记录的蓝牙列表数据
			this.getBLEDeviceList();

			// #ifdef APP-PLUS
			plus.runtime.getProperty(plus.runtime.appid, (info) => {
				console.log("version:", info);
				this.$store.state.version = info.version;
				this.$store.state.versionCode = info.versionCode;
				this.$store.state.appName = info.name;
			});

			// 锁住屏幕正方向
			plus.screen.lockOrientation('portrait-primary');
			// 屏幕常亮
			// 下面这个打包要开启手机设置权限
			plus.device.setWakelock(true);
			// #endif

			// #ifdef MP
			//开始登陆
			this.onLuanchLogin({});
			// #endif


			this.onAccAndGyroConvertDataGet();


			// this.setGuideUnlockState({
			// 	//是否首次安装
			// 	firstInstallation: true,
			// 	firstDisconnectBluetooth: true,
			// 	firstUnlockJumpUp: true,
			// 	firstUnlockLeftAndRightJump: true,
			// 	firstUnlockLeftAndRightRotationJump: true
			// });
			//获取guide任务的解锁状态
			this.getGuideUnlockState();
			
			
			if (plus.runtime.isApplicationExist({
					pname: 'com.tencent.mm',
					action: 'weixin://'
				})) {
				//安装了微信
				// console.log("安装了微信");
				this.$store.state.bInstallWechat = true;
			} else {
				//未安装微信
				// console.log("未安装微信");
				this.$store.state.bInstallWechat = false;
			}
			
		},
		onShow: function() {
			console.log('App Show');
			// #ifdef APP-PLUS
			// 锁住屏幕正方向
			// plus.screen.lockOrientation('portrait-primary');
			// 屏幕常亮
			// plus.device.setWakelock(true);
			// 下面这个打包要开启手机设置权限
			// uni.setScreenBrightness({
			//     value: 0.8,
			//     success: function () {
			//         console.log('setScreenBrightness success');
			//     }
			// });
			// uni.setKeepScreenOn({
			// 	keepScreenOn: true,
			// 	success: function () {
			// 	    console.log('setKeepScreenOn success');
			// 	}
			// });
			// let self = this;
			// uni.getScreenBrightness({
			//     success: function (res) {
			//         console.log('屏幕亮度值：' + res.value);
			// 		self.Test = '=='+plus.device.isWakelock()+ '=getScreenBrightness success';
			// 		self.screenValue = res.value;
			//     }
			// });
			// #endif
		},
		onHide: function() {
			console.log('App Hide')
		}

	}
</script>
<!-- <style src="@/util/util-css/main-nvue.css"></style> -->
<style>
	/*每个页面公共css */
	// #ifndef APP-PLUS-NVUE
	@import "util/util-css/main.css";
	@import "util/util-css/icon.css";
	// #endif
	/* nvue 页面公共css */
	// #ifdef APP-PLUS-NVUE 
	@import "util/util-css/main-nvue.css";
	// #endif 
</style>
