You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
255 lines
7.3 KiB
255 lines
7.3 KiB
import Vue from 'vue'
|
|
import App from './App.vue'
|
|
import VueBus from 'vue-bus';
|
|
import '../../utils/global-import';
|
|
import 'vue2-toast/lib/toast.css';
|
|
import Toast from 'vue2-toast';
|
|
import { Modal, Icon } from 'ant-design-vue'
|
|
import '../../self-font/style.css';
|
|
import "../../commonStyle/commonStyle.scss";
|
|
import './themeParams.scss';
|
|
import vuescroll from "vuescroll";//引入vuescroll
|
|
import "vuescroll/dist/vuescroll.css";//引入vuescroll样式
|
|
import router from '../../router/router';
|
|
import axiosConfig from '../../global-llibs/axios-config';
|
|
import BaseConfig from '../../global-llibs/base-config';
|
|
import InterfaceConfig from '../../commonInterface/interfaceConfig';
|
|
import Cookie from '../../global-llibs/cookie';
|
|
import iconFont from './font/iconfont';
|
|
import axios from "axios";
|
|
|
|
const MyIcon = Icon.createFromIconfontCN({
|
|
scriptUrl: iconFont, // 在 iconfont.cn 上生成
|
|
});
|
|
|
|
var RongIMClient;
|
|
function mineReadfile() {
|
|
return new Promise((resolve, reject) => {
|
|
axios.all([axios.get("/rongcloud/getRongYunInfo"), axios.get("/rongcloud/getOnlyTokenRongCloud")]).then(
|
|
axios.spread(function (acct, perms) {
|
|
// 两个请求现在都执行完成
|
|
// console.log(acct, perms, "rongyun");
|
|
const data = {}
|
|
data.key = acct.data.rong_key
|
|
data.token = perms.data.token
|
|
resolve(data)
|
|
// console.log(data)
|
|
})
|
|
// )
|
|
).catch((error) => {
|
|
reject(error)
|
|
});
|
|
})
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取未读总数数量
|
|
function getTotalUnreadCount() {
|
|
RongIMClient.Conversation.getTotalUnreadCount(false, [
|
|
RongIMLib.CONVERSATION_TYPE.PRIVATE,
|
|
RongIMLib.CONVERSATION_TYPE.GROUP,
|
|
RongIMLib.ConversationType.SYSTEM,
|
|
]).then(function (totalUnreadCount) {
|
|
// Vue.prototype.RongIMClientNum = totalUnreadCount
|
|
vueCom.$bus.emit('totalNoticeChange', totalUnreadCount);
|
|
|
|
console.log("获取未读总数成功", totalUnreadCount);
|
|
// this.notice_count = total_notice(totalUnreadCount);
|
|
});
|
|
|
|
}
|
|
|
|
|
|
mineReadfile().then(value => {
|
|
|
|
RongIMClient = RongIMLib.init({
|
|
appkey: value.key,
|
|
});
|
|
RongIMClient.connect({ token: value.token })
|
|
.then((user) => {
|
|
console.log("连接成功, 用户 id 为:", user.id);
|
|
localStorage.setItem("user_info", JSON.stringify({ id: user.id }));
|
|
// 获取消息数量
|
|
getTotalUnreadCount()
|
|
|
|
// 添加事件监听
|
|
RongIMClient.watch({
|
|
// 监听消息通知
|
|
message(event) {
|
|
// 新接收到的消息内容
|
|
const message = event.message;
|
|
console.log("event", event);
|
|
|
|
getTotalUnreadCount()
|
|
if (event.message.type === 1) {
|
|
vueCom.$bus.emit("handelSendMessage", 1, event.message);
|
|
}
|
|
},
|
|
// 监听 IM 连接状态变化
|
|
status(event) {
|
|
// 链接监听失败回调
|
|
console.log('connection status:', event.status);
|
|
}
|
|
});
|
|
// 发送全局融云以便其他地方调取融云方法
|
|
Vue.prototype.RongIMClient = RongIMClient
|
|
|
|
})
|
|
.catch((error) => {
|
|
|
|
console.log("连接失败: ", error.code, error.msg);
|
|
});
|
|
|
|
}, reason => {
|
|
console.log(reason, 222)
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
Vue.use(Toast);
|
|
Vue.use(VueBus);
|
|
Vue.use(Modal);
|
|
Vue.use(MyIcon)
|
|
Vue.component('my-icon', MyIcon)
|
|
Vue.component('vueScroll', vuescroll)
|
|
Vue.config.productionTip = false
|
|
Vue.prototype.RSALogin = false;
|
|
Vue.prototype.isTestLogin = false;
|
|
Vue.prototype.PUBLIC_KEY = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCi0thPP5lZbBp1zWGhHLnEkAcXeBVkz4SW/7grZWdsCa4QVjT/YzbLE8Lj8v2XbrOIcrkCz4AZPrM9n9Vt7nizwTULVypBkhL4cOHbAWahtbEkgVGLkb3Jk/pvO+R24pllfkOeteo82FnR1fCrx+/+Va6il/0VggzhpDKEcBbmawIDAQAB'
|
|
import { loadMineMapJs } from './loadResources';
|
|
let loadedMineMapJs = false;//是否加载完js
|
|
let sso = "";
|
|
function testSSO(to, from, next) {
|
|
if (sso === "2") {//接入统一认证
|
|
if (!loadedMineMapJs) {//未加载js
|
|
loadMineMapJs().then(() => {
|
|
loadedMineMapJs = true;
|
|
});
|
|
let interval = setInterval(() => {
|
|
if (loadedMineMapJs) {
|
|
clearInterval(interval);
|
|
testLogin(to, from, next)
|
|
}
|
|
}, 100);
|
|
|
|
} else {
|
|
if (Vue.prototype.isTestLogin === false) {
|
|
testLogin(to, from, next)
|
|
} else {
|
|
testPersonInfo(to, from, next)
|
|
}
|
|
}
|
|
} else {//未接入统一认证
|
|
testPersonInfo(to, from, next)
|
|
}
|
|
}
|
|
|
|
function testPersonInfo(to, from, next) {
|
|
let person_id = Cookie.get('person_id');
|
|
if (!person_id || person_id === '') {//没有用户信息 进入登录
|
|
if (to.name === 'login') {
|
|
next();
|
|
} else {
|
|
next({ replace: true, name: 'login' });
|
|
}
|
|
} else {
|
|
|
|
|
|
|
|
|
|
gotoPage(to, from, next);
|
|
}
|
|
}
|
|
|
|
function testLogin(to, from, next) {
|
|
let s = new SSO();
|
|
s.exeFun(function (data) {
|
|
Vue.prototype.isTestLogin = true;
|
|
if (data.success === true) {//已登录过
|
|
console.log("登录过")
|
|
gotoPage(to, from, next);
|
|
} else {//未登录过 进入登录页面
|
|
console.log("未登录过")
|
|
if (to.name === 'login') {
|
|
next();
|
|
} else {
|
|
next({ replace: true, name: 'login' });
|
|
}
|
|
}
|
|
})
|
|
}
|
|
function gotoPage(to, from, next) {
|
|
if (!window.person_info_my) {//没有人员具体信息
|
|
BaseConfig.userInfo.identity_id_cookie = Cookie.get('identity_id');
|
|
BaseConfig.userInfo.person_id_cookie = Cookie.get('person_id');
|
|
BaseConfig.userInfo.identity_id = Cookie.get('identity_id');
|
|
BaseConfig.userInfo.person_id = Cookie.get('person_id');
|
|
axiosConfig.callInterface([{
|
|
url: InterfaceConfig.getValueByKey.url,
|
|
params: { key: 'common.server.location' },
|
|
method: InterfaceConfig.getValueByKey.method,
|
|
isTestLogin: InterfaceConfig.getValueByKey.isTestLogin
|
|
}], (res) => {
|
|
if (res[0].status === 200) {
|
|
let env = res[0].data;
|
|
BaseConfig.pt_type = env["common.server.location"];
|
|
window.pt_type = env["common.server.location"];
|
|
BaseConfig.ConfigFn.setParamsValue();
|
|
// BaseConfig.ConfigFn.getPersonInfo_I();
|
|
let interval = setInterval(() => {
|
|
if (window.person_info_my) {
|
|
clearInterval(interval);
|
|
if (to.name === 'login') {
|
|
next({ replace: true, name: 'mainPlatform' })
|
|
} else {
|
|
next()
|
|
}
|
|
}
|
|
}, 500)
|
|
}
|
|
})
|
|
} else {
|
|
if (to.name === 'login') {
|
|
next({ replace: true, name: 'mainPlatform' });
|
|
} else {
|
|
next();
|
|
}
|
|
}
|
|
}
|
|
router.beforeEach((to, from, next) => {
|
|
if (sso === "") {
|
|
axiosConfig.callInterface([{
|
|
url: InterfaceConfig.getValueByKey.url,
|
|
params: { key: 'common.sso' },
|
|
method: InterfaceConfig.getValueByKey.method,
|
|
isTestLogin: InterfaceConfig.getValueByKey.isTestLogin
|
|
}], (res) => {
|
|
if (res[0].status === 200) {
|
|
let env = res[0].data;
|
|
sso = env["common.sso"];//0 未接入统一认证
|
|
Vue.prototype.sso_flag = sso;
|
|
testSSO(to, from, next);
|
|
}
|
|
})
|
|
} else {
|
|
testSSO(to, from, next)
|
|
}
|
|
});
|
|
let vueCom = new Vue({
|
|
router,
|
|
render: h => h(App),
|
|
// beforeMount(){
|
|
// let sn = document.getElementsByTagName('head')[0]
|
|
// let jsAry = ["jquery.js","jsencrypt.min.js","jquery.cookie.js","base-config.js","sso.js"];
|
|
// jsAry.forEach((item)=>{
|
|
// let s = document.createElement('script');
|
|
// s.src = 'http://10.10.14.199/dsideal_yy/js/' + item;
|
|
// sn.appendChild(s);
|
|
// })
|
|
// }
|
|
}).$mount('#app')
|