Commit ac93bdff authored by zhengke's avatar zhengke

修改

parent d96c12bc
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
socektObj:{ socektObj:{
type:Array, type:Array,
default: null default: null
} },
}, },
components: { components: {
noneData noneData
...@@ -271,8 +271,7 @@ ...@@ -271,8 +271,7 @@
created() { created() {
this.init(); this.init();
this.getNotify(); this.getNotify();
this.getLogList(); this.socektArr = this.socektObj;
this.getMsg();
}, },
methods: { methods: {
init() { init() {
...@@ -301,15 +300,6 @@ ...@@ -301,15 +300,6 @@
// }).onOk(() => { // }).onOk(() => {
// }); // });
}, },
//获取日志列表
getLogList(){
GetMsgLogList().then(res => {
if (res.Code == 1) {
console.log(res,'日志数据');
this.socektArr = res.Data;
}
})
},
//请求公告数据 //请求公告数据
getNotify() { getNotify() {
GetMyNoticePageList(this.noticeMsg).then(res => { GetMyNoticePageList(this.noticeMsg).then(res => {
...@@ -334,81 +324,17 @@ ...@@ -334,81 +324,17 @@
   window.open(routeUrl.href, '_blank');    window.open(routeUrl.href, '_blank');
}, },
getMsg() {
let userinfo = this.getLocalStorage();
var SendData = {
AppId: "JiaHeJiaoYu",
ClientId: userinfo.Id,
};
sendSock(SendData, this.getDataFunc)
},
getDataFunc(e) {
console.log("socketData",e);
if (e.data) {
var newData = JSON.parse(e.data)
console.log(newData,'newData');
this.socektArr = this.socektArr.concat(newData)
this.showNotification(newData[0].Title, newData[0].Content, newData.CoverImg)
}
},
/**
* 通过Html调用显示系统通知
* @param title
* @param msg
* @param imgUrl
*/
showNotification(title, msg, imgUrl) {
var Notification = window.Notification || window.mozNotification || window.webkitNotification;
// 判断浏览器是否支持桌面通知
if (Notification) {
Notification.requestPermission(function (result) {
//result 默认值'default'等同于拒绝 'denied' -用户选择了拒绝 'granted' -用户同意启用通知
if ("granted" != result) {
console.log('请授权浏览器能够进行通知!');
return false;
} else {
var tag = "sds" + Math.random();
var notify = new Notification(
title, {
dir: 'auto',
lang: 'zh-CN',
tag: tag, //实例化的notification的id
icon: imgUrl, //通知的缩略图,icon 支持ico、png、jpg、jpeg格式
title: title, //通知的标题
body: msg //通知的具体内容
}
);
// 定义通知窗口点击函数
notify.onclick = function () {
//如果通知消息被点击,通知窗口将被激活
window.focus();
};
// 定义通知错误事件
notify.onerror = function () {
// console.log("");
};
// 定义通知显示事件 可以设置多少秒之后关闭 也可以不设置关闭
notify.onshow = function () {
// 窗口显示3S后关闭
setTimeout(function () {
notify.close();
}, 3000);
};
// 定义通知关闭事件
notify.onclose = function () {
};
}
});
} else {
// 提示不支持系统通知
console.log('您的浏览器不支持系统通知,建议使用Chrome浏览');
}
},
//跳转链接 新页面打开 //跳转链接 新页面打开
goMsgDetail(url){ goMsgDetail(url){
if(url){ let url2='/course/prepareclassDetails?ClassId=5&ClassPlanId=2898'
window.open(url); if(url!=null&&url.length>0){
if(url.indexOf('http://')==-1 || url.indexOf('https://')==-1){
url='http://'+url;
}else{
url=document.domain+url2;
console.log(url,'url');
}
window.open(url, "_blank");
} }
}, },
//看过后删除 //看过后删除
......
...@@ -16,7 +16,9 @@ ...@@ -16,7 +16,9 @@
</q-tabs> </q-tabs>
<div class="q-pl-lg flex items-center"> <div class="q-pl-lg flex items-center">
<div class="wave_wrapper" @click="showNotify"> <div class="wave_wrapper" @click="showNotify">
<span class="dona wave_scale"> <!-- <span class="dona wave_scale">
</span> -->
<span :class="{'dona':socektArr.length>0,'wave_scale':socektArr.length>0}">
</span> </span>
<inline-svg class="svg-icon svg-icon-primary" src="icons/svg/Code/Compiling.svg"></inline-svg> <inline-svg class="svg-icon svg-icon-primary" src="icons/svg/Code/Compiling.svg"></inline-svg>
</div> </div>
...@@ -73,7 +75,7 @@ ...@@ -73,7 +75,7 @@
</div> </div>
</q-page-container> </q-page-container>
<user-info-box v-if="persistent" :show-obj="userInfo" @close="closeSaveForm"></user-info-box> <user-info-box v-if="persistent" :show-obj="userInfo" @close="closeSaveForm"></user-info-box>
<notify v-if="persistentNotify" :show-obj="userInfo" @close="closeSaveForm"></notify> <notify v-if="persistentNotify" :show-obj="userInfo" :socekt-obj="socektArr" @close="closeSaveForm"></notify>
</q-layout> </q-layout>
</template> </template>
...@@ -83,6 +85,11 @@ ...@@ -83,6 +85,11 @@
} from 'vuex' } from 'vuex'
import userInfoBox from '../components/global/user-right-box' import userInfoBox from '../components/global/user-right-box'
import notify from '../components/global/notify' import notify from '../components/global/notify'
import {
GetMsgLogList
} from '../api/course/index'
import { import {
sendSock sendSock
} from '../api/common/socket' } from '../api/common/socket'
...@@ -112,6 +119,7 @@ ...@@ -112,6 +119,7 @@
isExpend: false, isExpend: false,
IsShowLeft: true, IsShowLeft: true,
userCenterMenuList: [], //用户中心菜单 userCenterMenuList: [], //用户中心菜单
socektArr:[], //消息数组
} }
}, },
components: { components: {
...@@ -170,6 +178,9 @@ ...@@ -170,6 +178,9 @@
if (this.userInfo && this.userInfo.MenuList) { if (this.userInfo && this.userInfo.MenuList) {
this.secondNavs = this.userInfo.MenuList.length > 0 ? this.userInfo.MenuList[i].SubList : [] this.secondNavs = this.userInfo.MenuList.length > 0 ? this.userInfo.MenuList[i].SubList : []
} }
this.getLogList();
this.getMsg();
}, },
methods: { methods: {
changeLeft() { changeLeft() {
...@@ -197,7 +208,90 @@ ...@@ -197,7 +208,90 @@
this.$router.push({ this.$router.push({
path: this.userInfo.MenuList[val].MenuUrl path: this.userInfo.MenuList[val].MenuUrl
}) })
} },
//获取日志列表
getLogList(){
GetMsgLogList().then(res => {
if (res.Code == 1) {
console.log(res,'mainLayout日志数据');
this.socektArr = res.Data;
}
})
},
getMsg() {
let userinfo = this.getLocalStorage();
var SendData = {
AppId: "JiaHeJiaoYu",
ClientId: userinfo.Id,
};
sendSock(SendData, this.getDataFunc)
},
getDataFunc(e) {
console.log("socketData",e);
if (e.data) {
var newData = JSON.parse(e.data)
console.log(newData,'newData');
this.socektArr = this.socektArr.concat(newData)
console.log(this.socektArr,'this.socektArr');
this.showNotification(newData[0].Title, newData[0].Content, newData.CoverImg)
}
},
/**
* 通过Html调用显示系统通知
* @param title
* @param msg
* @param imgUrl
*/
showNotification(title, msg, imgUrl) {
var Notification = window.Notification || window.mozNotification || window.webkitNotification;
// 判断浏览器是否支持桌面通知
if (Notification) {
Notification.requestPermission(function (result) {
//result 默认值'default'等同于拒绝 'denied' -用户选择了拒绝 'granted' -用户同意启用通知
if ("granted" != result) {
console.log('请授权浏览器能够进行通知!');
return false;
} else {
var tag = "sds" + Math.random();
var notify = new Notification(
title, {
dir: 'auto',
lang: 'zh-CN',
tag: tag, //实例化的notification的id
icon: imgUrl, //通知的缩略图,icon 支持ico、png、jpg、jpeg格式
title: title, //通知的标题
body: msg //通知的具体内容
}
);
// 定义通知窗口点击函数
notify.onclick = function () {
//如果通知消息被点击,通知窗口将被激活
window.focus();
};
// 定义通知错误事件
notify.onerror = function () {
// console.log("");
};
// 定义通知显示事件 可以设置多少秒之后关闭 也可以不设置关闭
notify.onshow = function () {
// 窗口显示3S后关闭
setTimeout(function () {
notify.close();
}, 3000);
};
// 定义通知关闭事件
notify.onclose = function () {
};
}
});
} else {
// 提示不支持系统通知
console.log('您的浏览器不支持系统通知,建议使用Chrome浏览');
}
},
}, },
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment