OfficeApp/App.vue

118 lines
3.0 KiB
Vue
Raw Normal View History

2023-07-15 17:27:06 +08:00
<script>
2023-10-18 16:26:54 +08:00
//#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的监听")
// }
// })
2023-09-04 19:50:47 +08:00
2023-10-18 16:26:54 +08:00
// uni.showModal({
// content: info.referrerInfo.extraData
// })
2023-10-18 16:26:54 +08:00
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', {
2023-11-07 16:17:13 +08:00
user: {},
2023-10-18 16:26:54 +08:00
token: res.data.token
})
this.$store.dispatch('initConfig');
let {
data
} = await userInfo();
this.$store.commit('setUserInfo', data);
2023-11-08 18:02:28 +08:00
// this.$isResolve()
2023-10-18 16:26:54 +08:00
// uni.$emit('home_initUserInfo', data);
2023-11-08 18:02:28 +08:00
// return;
2023-10-18 16:26:54 +08:00
} catch (e) {
2023-11-08 18:02:28 +08:00
// this.$isResolve()
2023-10-18 16:26:54 +08:00
console.log(e);
}
}
console.log('App Launch')
try {
if (!this.$store.state.app.token) uni.reLaunch({
2023-10-19 14:06:20 +08:00
url: '/pages/oaLogin/oaLogin',
success() {
// #ifdef APP-PLUS
plus.navigator.closeSplashscreen(); // 关闭渲染启动图
// #endif
this.$isResolve()
2023-10-19 14:06:20 +08:00
}
2023-10-18 16:26:54 +08:00
})
2023-10-19 14:06:20 +08:00
else {
this.$store.dispatch('initConfig');
this.$isResolve()
2023-10-19 14:06:20 +08:00
// #ifdef APP-PLUS
plus.navigator.closeSplashscreen(); // 关闭渲染启动图
// #endif
}
2023-10-18 16:26:54 +08:00
} catch (e) {
this.$isResolve()
2023-10-19 14:06:20 +08:00
// #ifdef APP-PLUS
uni.reLaunch({
url: '/pages/oaLogin/oaLogin',
success() {
// #ifdef APP-PLUS
plus.navigator.closeSplashscreen(); // 关闭渲染启动图
// #endif
this.$isResolve()
}
})
2023-10-19 14:06:20 +08:00
// #endif
2023-10-18 16:26:54 +08:00
}
},
onShow: function() {
2023-10-19 14:06:20 +08:00
const audioContext = uni.createInnerAudioContext()
// 设置音频文件地址
audioContext.src = '/static/mp3/order.mp3'
2023-10-18 16:26:54 +08:00
// 播放音频
//#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-10-09 20:22:16 +08:00
}
2023-10-18 16:26:54 +08:00
}
2023-07-15 17:27:06 +08:00
</script>
<style>
2023-10-18 16:26:54 +08:00
/*每个页面公共css */
@import "static/css/base.css";
@import "static/css/style.scss";
2023-07-15 17:51:20 +08:00
2023-10-18 16:26:54 +08:00
view {
box-sizing: border-box;
}
2023-08-16 16:51:41 +08:00
</style>