1 Star 0 Fork 5

小栈/腾云IM

forked from 汉潮/腾云IM 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
App.vue 4.19 KB
一键复制 编辑 原始数据 按行查看 历史
xiaogg 提交于 2023-01-07 18:26 . 腾云im
<script>
import {
version,
name
} from './package.json'
import {
versionName
} from '@/manifest.json'
// #ifdef APP-PLUS
import appUpgrade from '@/common/appUpgrade.js';
import NotifiUtil from '@/common/notification.js'
// #endif
export default {
globalData: {
//im 相关配置 开始
package_name:'chat', //组件名
appconfig:{}, //后台配置
pushversion:1,//unipush版本
pushcid:'',//推送标识
conversation_id:'',//当前聊天标识
//im 相关配置 结束
},
onLaunch: function() {
this.$fc.getConfig();
// #ifdef H5
uni.setStorageSync('device', 'H5');
uni.setStorageSync('version', versionName);
// #endif
if(this.globalData.pushversion==2){
uni.onPushMessage((msg) => {
this.$fc.dopushmsg(msg);
})
}else{
// #ifdef APP-PLUS
var msg={};
uni.onPushMessage((res) => {
if(res.type){
var content= JSON.parse(res.data.content);
msg.type = res.type;msg.data={};
msg.data.title = content.title;
msg.data.content = content.body;
msg.data.payload = res.data.payload?res.data.payload:content.payload;
}else{
msg.type = 'click';msg.data={};
msg.data.title = res.title;
msg.data.content = res.body;
msg.data.payload = res.payload;
}
this.$fc.dopushmsg(msg);
})
plus.push.addEventListener('click', res => {
if(res.type){
var content= JSON.parse(res.content);
msg.type = 'click';msg.data={};
msg.data.title = content.title;
msg.data.content = content.body;
msg.data.payload = res.payload?res.payload:content.payload;
}else{
msg.type = 'click';msg.data={};
msg.data.title = res.title;
msg.data.content = res.body;
msg.data.payload = res.payload;
}
this.$fc.dopushmsg(msg);
});
// #endif
}
let token = uni.getStorageSync('Authorization');
if (!token) {
// #ifdef APP-PLUS
plus.navigator.closeSplashscreen();
// #endif
} else {
uni.reLaunch({
url: '/'+this.globalData.package_name+"/index/index",
}).then(res=>{
// #ifdef APP-PLUS
plus.navigator.closeSplashscreen();
// #endif
})
}
// #ifdef APP-PLUS
//升级检测
uni.getSystemInfo({
success: (res)=> {
uni.setStorageSync('device', res.platform);
plus.runtime.getProperty(plus.runtime.appid, (widgetInfo)=> {
uni.setStorageSync('version', widgetInfo.version);
this.$http.request({
url: '/common/getVersion',
success: (res) => {
if(res.data.data.upgrade=='Y'){
appUpgrade.init({
titleText: '版本更新'+res.data.data.version,
packageUrl:res.data.data.url,
content: res.data.data.content,
forceUpgrade:res.data.data.forceUpgrade=='Y' ? true : false
});
appUpgrade.show();
}
}
});
});
}
});
uni.onNetworkStatusChange( (res)=> {
if(res.isConnected){
this.$store.dispatch('get_UserInfo')
}
});
var appname = uni.getSystemInfoSync().appName;
var NotificationUtil = NotifiUtil();//实例创建
NotificationUtil.clearNotification(1000);
NotificationUtil.setNotification(appname, appname+"应用正在运行中");
// #endif
},
onShow: function() {
// #ifdef APP-PLUS
var args = plus.runtime.arguments;
if(args){
var userInfo = this.$store.state.userInfo;
if(userInfo)return '';//console.log(args);
// 处理args参数,如直达到某新页面等
this.$store.dispatch('get_UserInfo').then(res=>{
userInfo = this.$store.state.userInfo;
}).catch((error)=>{
var token = this.$fc.url_query(args,'token');
this.$fc.loginwithtoken(token);
});
}
// #endif
},
methods: {
}
}
</script>
<style lang="scss">
/*每个页面公共css */
@import '@/uni_modules/uni-scss/index.scss';
@import "@/static/styles/animation.css";
/* #ifndef APP-NVUE */
@import '@/static/customicons.css';
// 设置整个项目的背景色
page {
box-sizing: border-box;
}
/* #endif */
</style>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/xiaozhan/tengyun-im.git
git@gitee.com:xiaozhan/tengyun-im.git
xiaozhan
tengyun-im
腾云IM
master

搜索帮助