OfficeApp/App.vue

105 lines
3.1 KiB
Vue
Raw Normal View History

2023-07-15 17:27:06 +08:00
<script>
2023-09-04 19:50:47 +08:00
//#ifdef APP-PLUS
const jpushModule = uni.requireNativePlugin("JG-JPush");
// #endif
2023-09-07 17:33:57 +08:00
import { loginShopAccount, userInfo } from "@/api/oaUser.js"
2023-09-04 19:50:47 +08:00
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的监听")
// }
// })
2023-09-04 18:54:55 +08:00
// uni.showModal({
// content: info.referrerInfo.extraData
// })
2023-09-04 19:50:47 +08:00
if (info.referrerInfo?.extraData?.uniMP) {
//监听宿主App通讯数据
uni.onHostEventReceive((event, data) => {
if(event=='getLocation') uni.$emit('uniMP_getLocation', data);
});
2023-09-04 19:50:47 +08:00
uni.setStorageSync('uniMP', info.referrerInfo?.extraData?.uniMP);
uni.setStorageSync('APP_token', info.referrerInfo?.extraData?.token);
try {
2023-09-04 19:50:47 +08:00
let res = await loginShopAccount({
shop_token: info.referrerInfo?.extraData?.token
});
this.$store.commit('SET_USERINFO', {
user: data,
token: res.data.token
})
2023-09-07 17:33:57 +08:00
this.$store.dispatch('initConfig');
2023-09-04 19:50:47 +08:00
let {
data
} = await userInfo();
this.$store.commit('setUserInfo', data);
2023-09-09 09:03:38 +08:00
this.$isResolve()
2023-09-07 17:33:57 +08:00
// uni.$emit('home_initUserInfo', data);
return;
} catch (e) {
2023-09-09 09:12:54 +08:00
this.$isResolve()
2023-09-04 19:50:47 +08:00
console.log(e);
}
}
2023-09-09 20:13:04 +08:00
console.log('App Launch')
2023-09-04 19:50:47 +08:00
this.$store.dispatch('initConfig');
2023-09-09 09:12:54 +08:00
this.$isResolve()
2023-09-04 19:50:47 +08:00
try {
if (!this.$store.state.app.token) uni.reLaunch({
2023-10-07 10:28:04 +08:00
url: '/pages/oaLogin/oaLogin',
success() {
2023-10-11 14:39:21 +08:00
// #ifdef APP-PLUS
2023-10-07 10:28:04 +08:00
plus.navigator.closeSplashscreen(); // 关闭渲染启动图
2023-10-11 14:39:21 +08:00
// #endif
2023-10-07 10:28:04 +08:00
}
2023-09-04 19:50:47 +08:00
})
2023-10-11 14:39:21 +08:00
else {
// #ifdef APP-PLUS
plus.navigator.closeSplashscreen(); // 关闭渲染启动图
// #endif
}
2023-09-04 19:50:47 +08:00
} catch (e) {
2023-10-11 14:39:21 +08:00
// #ifdef APP-PLUS
plus.navigator.closeSplashscreen(); // 关闭渲染启动图
// #endif
2023-09-04 19:50:47 +08:00
}
},
onShow: function() {
const audioContext = uni.createInnerAudioContext()
// 设置音频文件地址
audioContext.src = '/static/mp3/order.mp3'
// 播放音频
//#ifdef APP-PLUS
jpushModule.addNotificationListener(res => {
if (res.notificationEventType == 'notificationOpened') return
audioContext.play()
uni.vibrateLong();
console.log("app的监听")
})
// #endif
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
}
}
2023-07-15 17:27:06 +08:00
</script>
<style>
2023-09-04 19:50:47 +08:00
/*每个页面公共css */
@import "static/css/base.css";
@import "static/css/style.scss";
2023-07-15 17:51:20 +08:00
2023-09-04 19:50:47 +08:00
view {
box-sizing: border-box;
}
2023-08-16 16:51:41 +08:00
</style>