Commit ab27a766 authored by 叶飞's avatar 叶飞

fix: notice

parent 6151b3f5
......@@ -2,13 +2,8 @@ module.exports = {
dev: {
'/CityInterface': {
// target: 'http://192.168.10.151:8055',
<<<<<<< HEAD
// target: 'https://panda-water.cn',
target: 'https://panda-water.com',
=======
target: 'https://panda-water.cn',
// target: 'https://panda-water.com',
>>>>>>> 933261f5fb1407b8a8e5c423964807f4542a36bb
// target: 'http://192.168.19.103:8112',
// target: 'http://192.168.12.8:8098',
// target: 'http://192.168.10.20:8888',
......@@ -22,13 +17,8 @@ module.exports = {
},
'/cityinterface': {
// target: 'http://192.168.10.151:8055',
<<<<<<< HEAD
// target: 'https://panda-water.cn',
target: 'https://panda-water.com',
=======
target: 'https://panda-water.cn',
// target: 'https://panda-water.com',
>>>>>>> 933261f5fb1407b8a8e5c423964807f4542a36bb
// target: 'http://192.168.12.8:8098',
// target: 'http://192.168.10.20:8888',
changeOrigin: true,
......@@ -43,13 +33,8 @@ module.exports = {
// target: 'http://192.168.12.8:8098',
// target: 'http://192.168.10.20:8888',
// target: 'http://192.168.10.151:8055',
<<<<<<< HEAD
// target: 'https://panda-water.cn',
target: 'https://panda-water.com',
=======
target: 'https://panda-water.cn',
// target: 'https://panda-water.com',
>>>>>>> 933261f5fb1407b8a8e5c423964807f4542a36bb
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
......
......@@ -29,17 +29,24 @@ class NoticeList extends React.Component {
this.state = {
isLoading: false,
};
this.mounted=false;
this.handleScrollCallback=this.throttle(this.handleScroll.bind(this), 30).bind(this);
}
componentDidMount() {
this.mounted=true;
if (this.container.current) {
this.container.current.addEventListener(
'scroll',
this.throttle(this.handleScroll.bind(this), 30),
this.handleScrollCallback,
);
}
}
componentWillUnmount(){
this.mounted=false;
}
throttle(fn, wait) {
var pre = Date.now();
return function() {
......@@ -55,6 +62,7 @@ class NoticeList extends React.Component {
handleScroll(e) {
e.stopPropagation();
if(!this.mounted) return;
if (!this.container.current) return;
let current = this.container.current;
if (
......@@ -75,11 +83,10 @@ class NoticeList extends React.Component {
() => {
if (!this.loadMore) return;
this.loadMore().then(data => {
if(!this.mounted) return;
this.setState({
isLoading: false,
});
this.forceUpdate();
console.log("开始更新了。。。。。",data);
});
},
);
......
......@@ -4,22 +4,41 @@ import commonStyles from '../common.less';
import classNames from 'classnames';
const Unknown = ({ message, confirmRead }) => {
let alarmContent = message.infoContent;
console.log('未知类型消息', message);
let content = '';
try {
let type = typeof message.infoContent;
switch (type) {
case 'object':
content = JSON.stringify(message.infoContent);
break;
case 'string':
content = message.infoContent;
break;
default:
break;
}
} catch (e) {
console.log;
}
return (
<div className={classNames(styles.unknown,commonStyles.messageContainer) } title="点击查看详情">
<div
className={classNames(styles.unknown, commonStyles.messageContainer)}
title="点击查看详情"
>
<div className={commonStyles.title}>
<span>消息</span>
<img
className={commonStyles.confirm}
title="点击标为已读"
onClick={() => {
confirmRead(false,[message.id]);
confirmRead(false, [message.id]);
}}
src="https://panda-water.cn/Web4/assets/images/message/%E5%8B%BE%E6%B5%85.png"
/>
</div>
<div className={commonStyles.content}>
<p>{message.infoContent}</p>
<p>{content}</p>
<p className={commonStyles.messageTime}>{message.time}</p>
</div>
</div>
......
......@@ -68,9 +68,9 @@ class Notifier {
// 对外接口
async start() {
window.cc=this.messageCache;
window.cc = this.messageCache;
this._getMqttSiteCode().then(() => {
this.loadHisMessages(this.currentPageIndex,this.currentPageSize);
this.loadHisMessages(this.currentPageIndex, this.currentPageSize);
this.connectMQTTServer();
});
}
......@@ -108,7 +108,7 @@ class Notifier {
try {
handler(payload);
} catch (e) {
console.log('订阅器委托错误');
console.log('订阅器委托错误' + e.message);
}
});
}
......@@ -135,7 +135,7 @@ class Notifier {
if (isAll) {
me.messageCache.totalCount = 0;
me.messageCache.messages = [];
me.currentPageIndex= 1;
me.currentPageIndex = 1;
} else {
hisIDs.forEach(id => {
let index = me.messageCache.messages.findIndex(
......@@ -160,7 +160,7 @@ class Notifier {
}
loadMore(callback) {
if (!this.hasMore()) return Promise.resolve([]);
this.currentPageIndex+=1;
this.currentPageIndex += 1;
return this.loadHisMessages(this.currentPageIndex, this.currentPageSize);
}
......@@ -292,7 +292,7 @@ class Notifier {
}
// 工具类
async loadHisMessages(pageIndex,pageSize) {
async loadHisMessages(pageIndex, pageSize) {
let me = this;
return Http.getInformationInfo({
userID: me.userInfo.OID,
......@@ -312,6 +312,10 @@ class Notifier {
});
index == -1 && me.messageCache.messages.push(message);
});
if(me.messageCache.totalCount > me.messageCache.messages.length && res.getMe.length==0){
// 服务端返回总数还有,但是查不到数据了,前端修正服务端返回的总数
me.messageCache.totalCount=me.messageCache.messages.length;
};
me.publish(NEW_MESSAGE, me.messageCache);
return Promise.resolve(result);
});
......@@ -379,6 +383,7 @@ class Notifier {
infoType = 'remindType';
break;
case 'SCADA报警':
case '':
infoType = 'scadaType';
default:
break;
......@@ -423,6 +428,7 @@ class Notifier {
}
_handleMessageStrToJSON(infoType, messString) {
let infoContent = messString;
try{
switch (infoType) {
case 'scadaType':
infoContent = this._analysisAlarm(messString);
......@@ -437,9 +443,15 @@ class Notifier {
break;
case 'EIMType':
break;
case 'unknown':
break;
default:
break;
}
}catch(e){
console.log("1.0消息通知解析消息内容出错:"+e.message,"消息对象:",messString);
}
return infoContent;
}
_analysisCase(messString) {
......@@ -482,7 +494,6 @@ class Notifier {
};
return noticeContent;
}
}
export default Notifier;
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