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-10-10 18:44:37 +08:00
|
|
|
|
// console.log('App Launch:',info);
|
2023-09-04 19:50:47 +08:00
|
|
|
|
if (info.referrerInfo?.extraData?.uniMP) {
|
2023-09-20 20:09:43 +08:00
|
|
|
|
//监听宿主App通讯数据
|
|
|
|
|
uni.onHostEventReceive((event, data) => {
|
|
|
|
|
if(event=='getLocation') uni.$emit('uniMP_getLocation', data);
|
2023-10-10 18:44:37 +08:00
|
|
|
|
else if(event=='im'){
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url:'/subpkg/chatMang/index'
|
|
|
|
|
})
|
|
|
|
|
}
|
2023-09-20 20:09:43 +08:00
|
|
|
|
});
|
2023-09-04 19:50:47 +08:00
|
|
|
|
uni.setStorageSync('uniMP', info.referrerInfo?.extraData?.uniMP);
|
|
|
|
|
uni.setStorageSync('APP_token', info.referrerInfo?.extraData?.token);
|
2023-09-20 20:09:43 +08:00
|
|
|
|
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);
|
2023-09-20 20:09:43 +08:00
|
|
|
|
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({
|
|
|
|
|
url: '/pages/oaLogin/oaLogin'
|
|
|
|
|
})
|
|
|
|
|
} catch (e) {
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: '/pages/oaLogin/oaLogin'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onShow: function() {
|
2023-10-10 18:44:37 +08:00
|
|
|
|
// uni.onHostEventReceive((event, data) => {
|
|
|
|
|
// // if(event=='getLocation') uni.$emit('uniMP_getLocation', data);
|
|
|
|
|
// });
|
2023-10-09 20:22:16 +08:00
|
|
|
|
// const audioContext = uni.createInnerAudioContext()
|
|
|
|
|
// // 设置音频文件地址
|
|
|
|
|
// audioContext.src = '/static/mp3/order.mp3'
|
2023-09-04 19:50:47 +08:00
|
|
|
|
// 播放音频
|
2023-10-10 18:44:37 +08:00
|
|
|
|
uni.onHostEventReceive((event,data)=>{
|
|
|
|
|
if(event=='im'){
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url:'/subpkg/chatMang/index'
|
|
|
|
|
})
|
|
|
|
|
}else if(event=='re_id'){
|
|
|
|
|
uni.setStorageSync("re_id",data)
|
|
|
|
|
}
|
|
|
|
|
// console.log('Receive event('+event+') from HOST: '+JSON.stringify(data));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
2023-09-04 19:50:47 +08:00
|
|
|
|
//#ifdef APP-PLUS
|
2023-10-09 23:32:04 +08:00
|
|
|
|
jpushModule.initJPushService()
|
2023-09-04 19:50:47 +08:00
|
|
|
|
jpushModule.addNotificationListener(res => {
|
2023-10-09 20:22:16 +08:00
|
|
|
|
const audioContext = uni.createInnerAudioContext()
|
|
|
|
|
if(res.content.includes(':')){
|
|
|
|
|
audioContext.src = '/static/mp3/im.wav'
|
|
|
|
|
audioContext.play()
|
|
|
|
|
uni.vibrateLong();
|
|
|
|
|
console.log("im")
|
|
|
|
|
return
|
|
|
|
|
}
|
2023-09-04 19:50:47 +08:00
|
|
|
|
if (res.notificationEventType == 'notificationOpened') return
|
2023-10-09 20:22:16 +08:00
|
|
|
|
audioContext.src = '/static/mp3/order.mp3'
|
2023-09-04 19:50:47 +08:00
|
|
|
|
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>
|