<script>
	var jpushModule = uni.requireNativePlugin("JG-JPush")
	export default {
		onLaunch: function() {
			console.log('App Launch')
			if(uni.getSystemInfoSync().platform == "ios"){
				// 请求定位权限
				let locationServicesEnabled = jpushModule.locationServicesEnabled()
				let locationAuthorizationStatus = jpushModule.getLocationAuthorizationStatus()
				console.log('locationAuthorizationStatus',locationAuthorizationStatus)	
				if (locationServicesEnabled == true && locationAuthorizationStatus < 3) {
					jpushModule.requestLocationAuthorization((result)=>{
						console.log('定位权限',result.status)
					})
				}
				
				
				jpushModule.requestNotificationAuthorization((result)=>{
					let status = result.status
					if (status < 2) {
						uni.showToast({
							icon: 'none',
							title: '您还没有打开通知权限',
							duration: 3000
						})
					}
				})
				jpushModule.addGeofenceListener(result=>{
					let code = result.code
					let type = result.type
					let geofenceId = result.geofenceId
					let userInfo = result.userInfo
					uni.showToast({
						icon: 'none',
						title: '触发地理围栏',
						duration: 3000
					})
				})
			
			}
			
			jpushModule.initJPushService();
			jpushModule.setLoggerEnable(true);
			jpushModule.addConnectEventListener(result=>{
				let connectEnable = result.connectEnable
				uni.$emit('connectStatusChange',connectEnable)
			});
			
			jpushModule.addNotificationListener(result=>{
				let notificationEventType = result.notificationEventType
				let messageID = result.messageID
				let title = result.title
				let content = result.content
				let extras = result.extras
				
				uni.showToast({
					icon: 'none',
					title: JSON.stringify(result),
					duration: 3000
				})
			});
			
			jpushModule.addCustomMessageListener(result=>{
				let type = result.type
				let messageType = result.messageType
				let content = result.content
				uni.showToast({
					icon: 'none',
					title: JSON.stringify(result),
					duration: 3000
				})
			})
			
			jpushModule.addLocalNotificationListener(result=>{
				let messageID = result.messageID
				let title = result.title
				let content = result.content
				let extras = result.extras
				uni.showToast({
					icon: 'none',
					title: JSON.stringify(result),
					duration: 3000
				})
			})
			
			jpushModule.addGeofenceListener(result=>{
				let code = result.code
				let type = result.type
				let geofenceId = result.geofenceId
				let userInfo = result.userInfo
				uni.showToast({
					icon: 'none',
					title: '触发地理围栏',
					duration: 3000
				})
			})
			
			jpushModule.setIsAllowedInMessagePop(true)
			jpushModule.pullInMessage(result=>{
				let code = result.code
				console.log(code)
			})
			
			jpushModule.addInMessageListener(result=>{
				let eventType = result.eventType
				let messageType = result.messageType
				let content = result.content
				console.log('inMessageListener',eventType,messageType,content)
				
				uni.showToast({
					icon: 'none',
					title: JSON.stringify(result),
					duration: 3000
				})
			})
			
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	@import "uview-ui/index.scss";
	/*每个页面公共css */
	.empty {
		padding: 40rpx 0;
	}
	.content {
		width: 100vw;
		min-height: 100vh;
		background: #F5F5F5;
		box-sizing: border-box;
		position: relative;
	}
	.hflex {
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
	}
	.vflex {
		display: flex;
		flex-direction: column;
		flex-wrap: nowrap;
	}
	.jbetween {
		justify-content: space-between;
	}
	.jaround {
		justify-content: space-around;
	}
	.jend {
		justify-content: flex-end;
	}
	.jcenter {
		justify-content: center;
	}
	.acenter {
		align-items: center;
	}
	.abetween {
		align-content: space-between;
	}
	.astart {
		align-items: flex-start;
	}
	.aend {
		align-items: flex-end;
	}
	.fwrap {
		flex-wrap: wrap;
	}
	.text_hide {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}
	.text_hide2 {
		text-overflow: -o-ellipsis-lastline;
		overflow: hidden;				//溢出内容隐藏
		text-overflow: ellipsis;		//文本溢出部分用省略号表示
		display: -webkit-box;			//特别显示模式
		-webkit-line-clamp: 2;			//行数
		line-clamp: 2;					
		-webkit-box-orient: vertical;	//盒子中内容竖直排列
	}
	.text_hide3 {
		text-overflow: -o-ellipsis-lastline;
		overflow: hidden;				//溢出内容隐藏
		text-overflow: ellipsis;		//文本溢出部分用省略号表示
		display: -webkit-box;			//特别显示模式
		-webkit-line-clamp: 3;			//行数
		line-clamp: 3;					
		-webkit-box-orient: vertical;	//盒子中内容竖直排列
	}
</style>