wuliu_sy/App.vue

56 lines
1.1 KiB
Vue
Raw Normal View History

2023-11-18 11:02:11 +08:00
<script>
//#ifdef APP-PLUS
const jpushModule = uni.requireNativePlugin("JG-JPush");
// #endif
export default {
onLaunch: function() {
console.log('App Launch')
// #ifdef APP-PLUS
// 锁定屏幕方向 横屏正方向
plus.screen.lockOrientation('landscape-primary');
// #endif
var main = plus.android.runtimeMainActivity();
var pkName = main.getPackageName();
console.log(pkName)
},
onShow: function() {
console.log('App Show')
const audioContext = uni.createInnerAudioContext()
// 设置音频文件地址
audioContext.src = '/static/mp3/order.mp3'
// 播放音频
//#ifdef APP-PLUS
jpushModule.addNotificationListener(res => {
console.log(res,'111111')
if (res.notificationEventType == 'notificationOpened') return
audioContext.play()
uni.vibrateLong();
console.log("app的监听")
})
// #endif
},
onHide: function() {
console.log('App Hide')
}
}
</script>
<style lang="scss">
/*每个页面公共css */
* {
margin: 0;
padding: 0;
}
page {
background: #F3F4F8;
}
@import "static/css/base.css";
@import url('static/iconfont/iconfont.css')
</style>