<script>
	//#ifdef APP-PLUS
	const jpushModule = uni.requireNativePlugin("JG-JPush");
	// #endif
	export default {
		onLaunch: async function() {
			console.log('App Launch')
			try {
				if (!this.$store.state.app.token) uni.redirectTo({
					url: '/pages/oaLogin/oaLogin'
				})
			} catch (e) {
				uni.redirectTo({
					url: '/pages/oaLogin/oaLogin'
				})
			}

			// jpushModule.initJPushService()
			// const audioContext = uni.createInnerAudioContext()
			// audioContext.src = './static/mp3/order.mp3'
			// let ida = [0]
			// jpushModule.addNotificationListener(function (result) {
			//   if (!ida.includes(result.messageID)) {
			//     audioContext.play()
			//   }
			//   ida.push(result.messageID)
			// })
		},
		onShow: function() {
			const audioContext = uni.createInnerAudioContext()
			// 设置音频文件地址
			audioContext.src = './static/mp3/order.mp3'
			let noticeArr = []
			// 播放音频
			//#ifdef APP-PLUS
			jpushModule.addNotificationListener(res => {
				if (!noticeArr.includes(res.messageID)) {
					console.log(res.messageID)
					audioContext.play()
					noticeArr.push(res.messageID)
					console.log("app的")
					uni.vibrateLong({
						success: function() {
							console.log('success');
						}
					});
				}


			})
			// #endif
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
	@import "static/css/base.css";
	@import "static/css/style.scss";

	view {
		box-sizing: border-box;
	}
</style>