105 lines
3.0 KiB
Vue
105 lines
3.0 KiB
Vue
<script>
|
||
//#ifdef APP-PLUS
|
||
const jpushModule = uni.requireNativePlugin("JG-JPush");
|
||
// #endif
|
||
import { loginShopAccount, userInfo } from "@/api/oaUser.js"
|
||
export default {
|
||
onLaunch: async function(info) {
|
||
// let noticeArr = []
|
||
// jpushModule.addNotificationListener(res => {
|
||
// if (!noticeArr.includes(res.messageID)) {
|
||
// const audioContext = uni.createInnerAudioContext()
|
||
// // 设置音频文件地址
|
||
// audioContext.src = `/static/audio/order.mp3`;
|
||
// // console.log(res.messageID)
|
||
// audioContext.play()
|
||
// noticeArr.push(res.messageID)
|
||
// console.log("app的监听")
|
||
// }
|
||
// })
|
||
|
||
// uni.showModal({
|
||
// content: info.referrerInfo.extraData
|
||
// })
|
||
|
||
if (info.referrerInfo?.extraData?.uniMP) {
|
||
//监听宿主App通讯数据
|
||
uni.onHostEventReceive((event, data) => {
|
||
if(event=='getLocation') uni.$emit('uniMP_getLocation', data);
|
||
});
|
||
uni.setStorageSync('uniMP', info.referrerInfo?.extraData?.uniMP);
|
||
uni.setStorageSync('APP_token', info.referrerInfo?.extraData?.token);
|
||
try {
|
||
let res = await loginShopAccount({
|
||
shop_token: info.referrerInfo?.extraData?.token
|
||
});
|
||
this.$store.commit('SET_USERINFO', {
|
||
user: data,
|
||
token: res.data.token
|
||
})
|
||
this.$store.dispatch('initConfig');
|
||
let {
|
||
data
|
||
} = await userInfo();
|
||
this.$store.commit('setUserInfo', data);
|
||
this.$isResolve()
|
||
// uni.$emit('home_initUserInfo', data);
|
||
return;
|
||
} catch (e) {
|
||
this.$isResolve()
|
||
console.log(e);
|
||
}
|
||
}
|
||
console.log('App Launch')
|
||
this.$store.dispatch('initConfig');
|
||
this.$isResolve()
|
||
try {
|
||
if (!this.$store.state.app.token) uni.reLaunch({
|
||
url: '/pages/oaLogin/oaLogin'
|
||
})
|
||
} catch (e) {
|
||
uni.reLaunch({
|
||
url: '/pages/oaLogin/oaLogin'
|
||
})
|
||
}
|
||
},
|
||
onShow: function() {
|
||
jpushModule.initJPushService()
|
||
// const audioContext = uni.createInnerAudioContext()
|
||
// // 设置音频文件地址
|
||
// audioContext.src = '/static/mp3/order.mp3'
|
||
// 播放音频
|
||
//#ifdef APP-PLUS
|
||
jpushModule.addNotificationListener(res => {
|
||
const audioContext = uni.createInnerAudioContext()
|
||
if(res.content.includes(':')){
|
||
audioContext.src = '/static/mp3/im.wav'
|
||
audioContext.play()
|
||
uni.vibrateLong();
|
||
console.log("im")
|
||
return
|
||
}
|
||
if (res.notificationEventType == 'notificationOpened') return
|
||
audioContext.src = '/static/mp3/order.mp3'
|
||
audioContext.play()
|
||
uni.vibrateLong();
|
||
console.log("app的监听")
|
||
})
|
||
// #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> |