<script>
	import {
		defaultRequest,
		defaultRequest4
	} from 'api/index.js'
	var jpushModule = uni.requireNativePlugin("JG-JPush");
	export default {
		data() {
			return {
				globalData:{
					
				},
				backButtonPress: 0,
			}
		},
		onLaunch: function() {
			// 判断是否有网络(尝试解决IOS白屏)
			// uni.getNetworkType({
			//     success: function (res) {
			//         console.log(res.networkType);//网络类型 wifi、2g、3g、4g、ethernet、unknown、none
			//         if(res.networkType === "none"){
			//             console.log("当前无网络");
			// 			this.globalData.typee = 1;
			// 			console.log('=====', this.globalData.typee)
			//         }else{
			// 			this.globalData.typee = 0
			// 			console.log('==',this.globalData.typee)
			//         }
			//     }
			// });
			// alert(this.globalData.type)
			// 判断是不是ios，是否发生白屏
			// uni.getSystemInfo({
			// 	success: (res) => {
			// 		if (res.platform == 'ios') {
			// 			const query = uni.createSelectorQuery().in(this);
			// 			var isRecovery = true;
			// 			query
			// 				.select('#containerId')
			// 				.boundingClientRect(data => {
			// 					isRecovery = false;
			// 				})
			// 				.exec();
			// 			var timer = setTimeout(() => {
			// 				if (isRecovery) {
			// 					uni.reLaunch({
			// 						url: '/pages/tabbar/user/user'
			// 					})
			// 					clearTimeout(timer);
			// 					timer = null;
			// 				}
			// 			}, 500)
			// 		}
			// 	},
			// })
			// ios 结束
			// console.log('App Launch')
			uni.hideTabBar()
			// uni.onTabBarMidButtonTap(()=>{
			// 		console.log("点击了")
			//         // 这里可以根据 个人需求 做点击处理，
			//         // 本人需进行页面跳转。
			// 		uni.navigateTo({
			// 			url:"../index/index2",
			// 			animationType:'slide-in-bottom'
			// 		})
			// 	})
			// plus.screen.lockOrientation("portrait-primary");
			setTimeout(() => {
				// plus.navigator.closeSplashscreen();
			}, 2400);

			//#ifdef APP-PLUS
			jpushModule.setLoggerEnable(true);
			jpushModule.initJPushService()
			jpushModule.addConnectEventListener(result => {
				let connectEnable = result.connectEnable
				console.log("jpush连接", connectEnable)
			})

			// 设置别名
			jpushModule.setAlias({
				'alias': uni.getStorageSync('userId'),
				'sequence': 1
			})
			//
			jpushModule.addTagAliasListener(result => {
				let code = result.code
				let sequence = result.sequence
				let tags = result.tags
				let tag = result.tag
				let tagEnable = result.tagEnable
				let alias = result.alias
				console.log(alias, '别名')
			})
			// 通知事件回调
			jpushModule.addNotificationListener(result => {
				let notificationEventType = result.notificationEventType
				let messageID = result.messageID
				let title = result.title
				let content = result.content
				let extras = result.extras
				console.log("通知", result)
				// 点击事件
				if (notificationEventType == 'notificationOpened') {
					uni.navigateTo({
						url: ''
					})
				}
			})
			jpushModule.getRegistrationID(result => {
				console.log("注册ID", result.registerID)
				if (result.registerID) {
					uni.setStorageSync("register_id", result.registerID)
				}
			})
			jpushModule.addCustomMessageListener(result => {
				let messageID = result.messageID
				let content = result.content
				let extras = result.extras
				console.log("自定义消息", result)
			})
			//#endif
		},


		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			// console.log('App Hide')
		},

	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import "@/common/common.scss";

	page {
		overflow-x: hidden;
	}
</style>
