<script>
	import {defaultRequest,defaultRequest4} from 'api/index.js'
	var jpushModule = uni.requireNativePlugin("JG-JPush");
	export default {
		data(){
			return {
				backButtonPress:0,
			}
		},
		onLaunch: function() {
			let channel=plus.runtime.channel || '';
			let channelName='';
			let isInstall=0;
			let firstTime=uni.getStorageSync('firstTime') || '';
			if(!firstTime){
				isInstall=1;
				uni.setStorageSync('firstTime','1');
			}
			addAppCount({channel:channel,is_install:isInstall});

			// 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>
