<script>
	import {hasUpdate} from '@/utils/common.js'
	export default {
		onLaunch: function(options) {
			this.$store.dispatch('getUserInfo')
			this.$store.dispatch('getTabBar')
			const ENV=uni.getAccountInfoSync().miniProgram
    		console.log('当前版本',ENV);
			uni.getSystemInfo({
				success: function (res) {
					console.log('宽度：',res.windowWidth);
					console.log('设备：',res.platform);
					if (res.windowWidth > 600||['windows','mac'].includes(res.platform)) {
						const params=options.query//此处的query就是在pc分享钩子函数中拼接的参数
						let paramsStr=`xcxPath=${decodeURIComponent(options.path)}`
						for(const key in params){
							paramsStr=`${paramsStr}&${key}=${params[key]}`
						}
						console.log('进入pc');
						uni.reLaunch({
							url: `/pages/pc?${paramsStr}`,
						});
					}
				},
				fail:function(res){
				}
			})

			// 开启ios静音也行播放语音
			wx.setInnerAudioOption({
				obeyMuteSwitch:false
			})
			//设置在小程序内屏幕常亮（防止录音等操作自动息屏会停止录音）
			wx.setKeepScreenOn({
				keepScreenOn: true,
				fail(res){
					console.log('设置屏幕常亮失败：',res);
				}
			})
			if(ENV.envVersion!=='release'){
				// 打开调试
				wx.setEnableDebug({
					enableDebug: true
				})
			}
		},
		onShow: function(options) {
			console.log('App Show')
			hasUpdate()
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang='scss'>
	@import "/wxcomponents/vant/common/index.wxss";
	/* 页面公共样式 */
	@import "./style/common.scss";
	
</style>
