|
@@ -283,159 +283,47 @@ export default {
|
|
// 给服务器发送一个字符串:
|
|
// 给服务器发送一个字符串:
|
|
socket.send('111');
|
|
socket.send('111');
|
|
},
|
|
},
|
|
-
|
|
|
|
- methods: {
|
|
|
|
- CollapseBtn() {
|
|
|
|
- this.collapse = !this.collapse;
|
|
|
|
- this.CompanyList = [
|
|
|
|
- {
|
|
|
|
- companyAddress: '测试地址0',
|
|
|
|
- companyId: 1,
|
|
|
|
- companyName: '测试公司0',
|
|
|
|
- },
|
|
|
|
- ];
|
|
|
|
- bus.$emit('funCol', this.collapse);
|
|
|
|
- },
|
|
|
|
- confirmDelete() {
|
|
|
|
- this.$store.commit('SET_TOKEN', '');
|
|
|
|
- this.$store.commit('SET_companyList', '');
|
|
|
|
- this.$store.commit('SET_USER', '');
|
|
|
|
- this.$router.push('/login');
|
|
|
|
- },
|
|
|
|
- // showNewList(){
|
|
|
|
- // var url = "push/message/list";
|
|
|
|
- // var param = {
|
|
|
|
- // userId: sessionStorage.getItem('user'),
|
|
|
|
- // type: 1
|
|
|
|
- // };
|
|
|
|
- // this.axios.post(url, param).then(res => {
|
|
|
|
- // if (res.statusCode === "1") {
|
|
|
|
- // var data = res
|
|
|
|
- // this.NewList = data.data.records?data.data.records:[]
|
|
|
|
- // }
|
|
|
|
- // });
|
|
|
|
- // },
|
|
|
|
- createWebSocket() {
|
|
|
|
- try {
|
|
|
|
- // 创建Web Socket 连接
|
|
|
|
- socket = new WebSocket(this.wsCfg.url + '?currentUserId=' + JSON.parse(sessionStorage.getItem('user')));
|
|
|
|
- // 初始化事件
|
|
|
|
- this.initEventHandle(socket);
|
|
|
|
- this.test();
|
|
|
|
- } catch (e) {
|
|
|
|
- // 出错时重新连接
|
|
|
|
- this.reconnect(this.wsCfg.url + '?currentUserId=' + JSON.parse(sessionStorage.getItem('user')));
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- initEventHandle(socket) {
|
|
|
|
- // 连接关闭时触发
|
|
|
|
- socket.onclose = () => {
|
|
|
|
- console.log('连接关闭');
|
|
|
|
- };
|
|
|
|
- // 通信发生错误时触发
|
|
|
|
- socket.onerror = () => {
|
|
|
|
- // 重新创建长连接
|
|
|
|
- this.reconnect();
|
|
|
|
- console.log('通信错误');
|
|
|
|
- };
|
|
|
|
- // 连接建立时触发
|
|
|
|
- socket.onopen = () => {
|
|
|
|
- console.log('连接成功');
|
|
|
|
- };
|
|
|
|
- // 客户端接收服务端数据时触发
|
|
|
|
- socket.onmessage = msg => {
|
|
|
|
- // 业务逻辑处理
|
|
|
|
- console.log(JSON.parse(msg.data));
|
|
|
|
- if (JSON.parse(msg.data).msgList) {
|
|
|
|
- this.NewList = JSON.parse(msg.data).msgList;
|
|
|
|
- } else {
|
|
|
|
- this.NewList = [
|
|
|
|
- {
|
|
|
|
- id: 0,
|
|
|
|
- content: '暂无消息',
|
|
|
|
- },
|
|
|
|
- ];
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- },
|
|
|
|
- showNewsOne(item) {
|
|
|
|
- this.NewsContent = item.content;
|
|
|
|
- this.dialogshowNews = true;
|
|
|
|
- this.isnews = !this.isnews;
|
|
|
|
- if (item.viewFlag == 0) {
|
|
|
|
- var url = 'push/message/read';
|
|
|
|
- var param = {
|
|
|
|
- ids: [item.id],
|
|
|
|
- };
|
|
|
|
- this.axios.post(url, param).then(result => {
|
|
|
|
- var data = result;
|
|
|
|
- if (data.statusCode === '1') {
|
|
|
|
- } else {
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- reconnect() {
|
|
|
|
- if (this.lockReconnect) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this.lockReconnect = true;
|
|
|
|
-
|
|
|
|
- //没连接上会一直重连,设置延迟避免请求过多
|
|
|
|
- setTimeout(() => {
|
|
|
|
- this.lockReconnect = false;
|
|
|
|
- this.createWebSocket(this.wsCfg.url + '?currentUserId=' + JSON.parse(sessionStorage.getItem('user')));
|
|
|
|
- }, 60000);
|
|
|
|
- },
|
|
|
|
- test() {
|
|
|
|
- // 给服务器发送一个字符串:
|
|
|
|
- socket.send('111');
|
|
|
|
- },
|
|
|
|
- retreat() {
|
|
|
|
- var that = this;
|
|
|
|
- this.$confirm('您确定要退出登录吗?', '退出登录', {
|
|
|
|
- confirmButtonText: '确定',
|
|
|
|
- cancelButtonText: '取消',
|
|
|
|
- type: 'warning',
|
|
|
|
- })
|
|
|
|
- .then(async () => {
|
|
|
|
- that.confirmDelete();
|
|
|
|
- this.$refs.message.reset();
|
|
|
|
- })
|
|
|
|
- .catch(() => {
|
|
|
|
- this.$message({
|
|
|
|
- type: 'info',
|
|
|
|
- message: '已取消退出',
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- //团队点击
|
|
|
|
- handleCommand(command) {
|
|
|
|
- this.$store.commit('SET_mtCompanyId', command.id);
|
|
|
|
- sessionStorage.setItem('companyID', JSON.stringify(command));
|
|
|
|
- this.CompanyClick = command.name;
|
|
|
|
- var url = 'system/login/changeTeam';
|
|
|
|
- var param = {
|
|
|
|
- companyId: JSON.parse(sessionStorage.getItem('mtCompanyId')),
|
|
|
|
- userId: JSON.parse(sessionStorage.getItem('user')),
|
|
|
|
- };
|
|
|
|
- console.warn('param-------------',param);
|
|
|
|
- this.axios.post(url, param).then(result => {
|
|
|
|
- var data = result;
|
|
|
|
- console.warn('data-------------',data);
|
|
|
|
- if (data.statusCode === '1') {
|
|
|
|
- this.$store.commit('SET_TOKEN', result.data.token);
|
|
|
|
- this.$store.commit('SET_menus', result.data.menus);
|
|
|
|
- this.$store.commit('SET_USERROLE', result.data.role ? result.data.role.name : '');
|
|
|
|
- // window.location.reload();
|
|
|
|
- } else {
|
|
|
|
- this.$message.error(result.message);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- toUserAccount() {
|
|
|
|
- this.$router.push('/UserAccount');
|
|
|
|
- },
|
|
|
|
|
|
+ retreat() {
|
|
|
|
+ var that = this;
|
|
|
|
+ this.$confirm("您确定要退出登录吗?", "退出登录", {
|
|
|
|
+ confirmButtonText: "确定",
|
|
|
|
+ cancelButtonText: "取消",
|
|
|
|
+ type: "warning"
|
|
|
|
+ })
|
|
|
|
+ .then(async () => {
|
|
|
|
+ that.confirmDelete();
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {
|
|
|
|
+ this.$message({
|
|
|
|
+ type: "info",
|
|
|
|
+ message: "已取消退出"
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ //团队点击
|
|
|
|
+ handleCommand(command){
|
|
|
|
+ this.$store.commit("SET_mtCompanyId",command.id);
|
|
|
|
+ sessionStorage.setItem('companyID',JSON.stringify(command))
|
|
|
|
+ this.CompanyClick = command.name;
|
|
|
|
+ var url = "system/login/changeTeam";
|
|
|
|
+ var param = {
|
|
|
|
+ companyId:JSON.parse(sessionStorage.getItem('mtCompanyId')),
|
|
|
|
+ userId:JSON.parse(sessionStorage.getItem("user"))
|
|
|
|
+ };
|
|
|
|
+ this.axios.post(url, param).then(result => {
|
|
|
|
+ var data = result;
|
|
|
|
+ if(data.statusCode==="1"){
|
|
|
|
+ this.$store.commit("SET_TOKEN",result.data.token);
|
|
|
|
+ this.$store.commit("SET_menus",result.data.menus);
|
|
|
|
+ this.$store.commit("SET_USERROLE",result.data.role?result.data.role.name:'');
|
|
|
|
+ window.location.reload();
|
|
|
|
+ }else{
|
|
|
|
+ this.$message.error(result.message);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ toUserAccount(){
|
|
|
|
+ this.$router.push("/UserAccount");
|
|
},
|
|
},
|
|
}
|
|
}
|
|
};
|
|
};
|