Commit 933261f5 authored by 叶飞's avatar 叶飞

fix: notice

parent dfe20ef7
...@@ -2,11 +2,11 @@ module.exports = { ...@@ -2,11 +2,11 @@ module.exports = {
dev: { dev: {
'/CityInterface': { '/CityInterface': {
// target: 'http://192.168.10.151:8055', // target: 'http://192.168.10.151:8055',
// target: 'https://panda-water.cn', target: 'https://panda-water.cn',
// target: 'https://panda-water.com', // target: 'https://panda-water.com',
// target: 'http://192.168.19.103:8112', // target: 'http://192.168.19.103:8112',
// target: 'http://192.168.12.8:8098', // target: 'http://192.168.12.8:8098',
target: 'http://192.168.10.20:8888', // target: 'http://192.168.10.20:8888',
changeOrigin: true, changeOrigin: true,
headers: { headers: {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
...@@ -17,10 +17,10 @@ module.exports = { ...@@ -17,10 +17,10 @@ module.exports = {
}, },
'/cityinterface': { '/cityinterface': {
// target: 'http://192.168.10.151:8055', // target: 'http://192.168.10.151:8055',
// target: 'https://panda-water.cn', target: 'https://panda-water.cn',
// target: 'https://panda-water.com', // target: 'https://panda-water.com',
// target: 'http://192.168.12.8:8098', // target: 'http://192.168.12.8:8098',
target: 'http://192.168.10.20:8888', // target: 'http://192.168.10.20:8888',
changeOrigin: true, changeOrigin: true,
headers: { headers: {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
...@@ -31,9 +31,9 @@ module.exports = { ...@@ -31,9 +31,9 @@ module.exports = {
}, },
'/Publish': { '/Publish': {
// target: 'http://192.168.12.8:8098', // target: 'http://192.168.12.8:8098',
target: 'http://192.168.10.20:8888', // target: 'http://192.168.10.20:8888',
// target: 'http://192.168.10.151:8055', // target: 'http://192.168.10.151:8055',
// target: 'https://panda-water.cn', target: 'https://panda-water.cn',
// target: 'https://panda-water.com', // target: 'https://panda-water.com',
changeOrigin: true, changeOrigin: true,
headers: { headers: {
......
...@@ -16,7 +16,7 @@ const Authorized = ({ ...@@ -16,7 +16,7 @@ const Authorized = ({
/> />
), ),
}) => { }) => {
debugger
const childrenRender = typeof children === 'undefined' ? null : children; const childrenRender = typeof children === 'undefined' ? null : children;
const dom = check(authority, flatMenu, childrenRender, noMatch); const dom = check(authority, flatMenu, childrenRender, noMatch);
return <>{dom}</>; return <>{dom}</>;
......
...@@ -9,7 +9,7 @@ const checkPermissions = ( ...@@ -9,7 +9,7 @@ const checkPermissions = (
target, target,
Exception, Exception,
) => { ) => {
debugger; ;
const filterPath = [ const filterPath = [
{ name: '/', path: '/' }, { name: '/', path: '/' },
{ name: 'civbase', path:`/civbase/?client=${window.globalConfig.client}` }, { name: 'civbase', path:`/civbase/?client=${window.globalConfig.client}` },
...@@ -38,7 +38,7 @@ const checkPermissions = ( ...@@ -38,7 +38,7 @@ const checkPermissions = (
}; };
function check(authority, flatMenu, target, Exception) { function check(authority, flatMenu, target, Exception) {
debugger; ;
return checkPermissions( return checkPermissions(
authority, authority,
flatMenu, flatMenu,
......
...@@ -56,7 +56,7 @@ export default class PromiseRender extends React.Component { ...@@ -56,7 +56,7 @@ export default class PromiseRender extends React.Component {
} }
render() { render() {
debugger
const { } = this.state; const { } = this.state;
const { ok, error, promise, ...rest } = this.props; const { ok, error, promise, ...rest } = this.props;
return component ? ( return component ? (
......
...@@ -40,7 +40,6 @@ var checkPermissions = function checkPermissions(authority, flatMenu, currentAut ...@@ -40,7 +40,6 @@ var checkPermissions = function checkPermissions(authority, flatMenu, currentAut
}; };
function check(authority, flatMenu, target, Exception) { function check(authority, flatMenu, target, Exception) {
debugger;
return checkPermissions(authority, flatMenu, _renderAuthorize.CURRENT, target, Exception); return checkPermissions(authority, flatMenu, _renderAuthorize.CURRENT, target, Exception);
} }
......
...@@ -180,7 +180,6 @@ class CitySelector extends React.Component { ...@@ -180,7 +180,6 @@ class CitySelector extends React.Component {
) )
} }
} else { } else {
debugger
let flg1 = false let flg1 = false
for (var k = 0; k < siteOption.length; k++) { for (var k = 0; k < siteOption.length; k++) {
if (siteOption[k].city.indexOf(item.address) > -1) { if (siteOption[k].city.indexOf(item.address) > -1) {
...@@ -234,15 +233,13 @@ class CitySelector extends React.Component { ...@@ -234,15 +233,13 @@ class CitySelector extends React.Component {
this.handleChangeTab(this.nextTab()) this.handleChangeTab(this.nextTab())
} }
handleChangeTab = (activeKey) => { handleChangeTab = (activeKey) => {
debugger
this.setState({ this.setState({
activeIndex: activeKey activeIndex: activeKey
}) })
} }
selectCityHandle = (event, item, status) => { selectCityHandle = (event, item, status) => {
debugger
event.persist(); event.persist();
this.setState({ this.setState({
...@@ -252,7 +249,6 @@ class CitySelector extends React.Component { ...@@ -252,7 +249,6 @@ class CitySelector extends React.Component {
} }
districtHandle = (event, item, status) => { districtHandle = (event, item, status) => {
debugger
event.persist(); event.persist();
this.setState({ this.setState({
districtCurrentItem: item districtCurrentItem: item
......
...@@ -12,7 +12,6 @@ class NoticeIconView extends Component { ...@@ -12,7 +12,6 @@ class NoticeIconView extends Component {
noticeData: [], noticeData: [],
}; };
this.notifier = new Notifier(this.props.global.userInfo); this.notifier = new Notifier(this.props.global.userInfo);
} }
async componentDidMount() { async componentDidMount() {
...@@ -44,6 +43,7 @@ class NoticeIconView extends Component { ...@@ -44,6 +43,7 @@ class NoticeIconView extends Component {
emptyText="你已查看所有通知" emptyText="你已查看所有通知"
confirmRead={this.notifier.confirmRead} confirmRead={this.notifier.confirmRead}
loadMore={this.notifier.loadMore} loadMore={this.notifier.loadMore}
hasMore = {this.notifier.hasMore}
/> />
</NoticeIcon> </NoticeIcon>
); );
......
...@@ -51,7 +51,6 @@ const SearchPanel = props => { ...@@ -51,7 +51,6 @@ const SearchPanel = props => {
} }
const handlerMore = (event) => { const handlerMore = (event) => {
debugger
event.persist && event.persist() event.persist && event.persist()
event && event.nativeEvent.stopImmediatePropagation() event && event.nativeEvent.stopImmediatePropagation()
setVisible(true) setVisible(true)
......
...@@ -21,10 +21,10 @@ const Empty = ({ emptyText }) => ( ...@@ -21,10 +21,10 @@ const Empty = ({ emptyText }) => (
class NoticeList extends React.Component { class NoticeList extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.data = props.data;
this.emptyText = props.emptyText; this.emptyText = props.emptyText;
this.confirmRead = props.confirmRead; this.confirmRead = props.confirmRead;
this.loadMore = props.loadMore; this.loadMore = props.loadMore;
this.hasMore = props.hasMore;
this.container = React.createRef(); this.container = React.createRef();
this.state = { this.state = {
isLoading: false, isLoading: false,
...@@ -67,6 +67,7 @@ class NoticeList extends React.Component { ...@@ -67,6 +67,7 @@ class NoticeList extends React.Component {
handleLoadMore() { handleLoadMore() {
if (this.state.isLoading) return; if (this.state.isLoading) return;
if(!this.hasMore()) return;
this.setState( this.setState(
{ {
isLoading: true, isLoading: true,
...@@ -77,20 +78,22 @@ class NoticeList extends React.Component { ...@@ -77,20 +78,22 @@ class NoticeList extends React.Component {
this.setState({ this.setState({
isLoading: false, isLoading: false,
}); });
this.forceUpdate();
console.log("开始更新了。。。。。",data);
}); });
}, },
); );
} }
render() { render() {
if (!this.data || this.data.length === 0) { if (!this.props.data || this.props.data.length === 0) {
return <Empty emptyText={this.emptyText} />; return <Empty emptyText={this.emptyText} />;
} }
return ( return (
<div className={styles.container} ref={this.container}> <div className={styles.container} ref={this.container}>
<List <List
className={styles.list} className={styles.list}
dataSource={this.data} dataSource={this.props.data}
renderItem={(item, i) => { renderItem={(item, i) => {
const itemCls = classNames(styles.item, { const itemCls = classNames(styles.item, {
[styles.read]: item.read, [styles.read]: item.read,
...@@ -131,7 +134,7 @@ class NoticeList extends React.Component { ...@@ -131,7 +134,7 @@ class NoticeList extends React.Component {
<Spin /> 加载中... <Spin /> 加载中...
</> </>
) : ( ) : (
<span>下拉加载更多</span> this.hasMore() ? <span>下拉加载更多</span> : <span>已经没有更多消息了</span>
)} )}
</div> </div>
</div> </div>
......
...@@ -243,7 +243,6 @@ function () { ...@@ -243,7 +243,6 @@ function () {
password: password, password: password,
onSuccess: this.onMQTTConnect.bind(this), onSuccess: this.onMQTTConnect.bind(this),
onFailure: function onFailure(e) { onFailure: function onFailure(e) {
debugger;
console.log(e); console.log(e);
} }
}; };
......
...@@ -1309,7 +1309,6 @@ function onMessageArrived(message) { ...@@ -1309,7 +1309,6 @@ function onMessageArrived(message) {
ClientImpl.prototype._on_socket_message = function (event) { ClientImpl.prototype._on_socket_message = function (event) {
debugger;
this._trace("Client._on_socket_message", event.data); this._trace("Client._on_socket_message", event.data);
......
...@@ -53,22 +53,24 @@ class Notifier { ...@@ -53,22 +53,24 @@ class Notifier {
this.MQTTClient = null; this.MQTTClient = null;
this.MQTTOptions = {}; this.MQTTOptions = {};
this.IsNeedReconnect = true; this.IsNeedReconnect = true;
this.pageIndex=1; this.currentPageIndex = 1;
this.pageSize=10; this.currentPageSize = 10;
// 对外接口处理this指向问题 // 对外接口处理this指向问题
this.start=this.start.bind(this); this.start = this.start.bind(this);
this.stop=this.stop.bind(this); this.stop = this.stop.bind(this);
this.subscribe=this.subscribe.bind(this); this.subscribe = this.subscribe.bind(this);
this.unsubscribe=this.unsubscribe.bind(this); this.unsubscribe = this.unsubscribe.bind(this);
this.confirmRead=this.confirmRead.bind(this); this.confirmRead = this.confirmRead.bind(this);
this.loadMore=this.loadHisMessages.bind(this); this.loadMore = this.loadMore.bind(this);
this.hasMore = this.hasMore.bind(this);
} }
// 对外接口 // 对外接口
async start() { async start() {
window.cc=this.messageCache;
this._getMqttSiteCode().then(() => { this._getMqttSiteCode().then(() => {
this.loadHisMessages({ userID: this.userInfo.OID }); this.loadHisMessages(this.currentPageIndex,this.currentPageSize);
this.connectMQTTServer(); this.connectMQTTServer();
}); });
} }
...@@ -133,6 +135,7 @@ class Notifier { ...@@ -133,6 +135,7 @@ class Notifier {
if (isAll) { if (isAll) {
me.messageCache.totalCount = 0; me.messageCache.totalCount = 0;
me.messageCache.messages = []; me.messageCache.messages = [];
me.currentPageIndex= 1;
} else { } else {
hisIDs.forEach(id => { hisIDs.forEach(id => {
let index = me.messageCache.messages.findIndex( let index = me.messageCache.messages.findIndex(
...@@ -150,6 +153,16 @@ class Notifier { ...@@ -150,6 +153,16 @@ class Notifier {
console.log('postInformationStatus调用失败' + err); console.log('postInformationStatus调用失败' + err);
}); });
} }
hasMore() {
if (!this.messageCache) return false;
if (!this.messageCache.totalCount) return false;
return this.messageCache.totalCount > this.messageCache.messages.length;
}
loadMore(callback) {
if (!this.hasMore()) return Promise.resolve([]);
this.currentPageIndex+=1;
return this.loadHisMessages(this.currentPageIndex, this.currentPageSize);
}
// mqtt // mqtt
async connectMQTTServer() { async connectMQTTServer() {
...@@ -161,7 +174,7 @@ class Notifier { ...@@ -161,7 +174,7 @@ class Notifier {
cleanSession = true, cleanSession = true,
ssl = this._siteConfig.IsSSL, ssl = this._siteConfig.IsSSL,
userName = 'mao2080', userName = 'mao2080',
password = "123", password = '123',
path = this._siteConfig.mqtt_path; path = this._siteConfig.mqtt_path;
this.MQTTCount = 0; this.MQTTCount = 0;
this.MQTTClient = new MqttClient.Client(hostname, port, path, clientId); this.MQTTClient = new MqttClient.Client(hostname, port, path, clientId);
...@@ -180,7 +193,6 @@ class Notifier { ...@@ -180,7 +193,6 @@ class Notifier {
password: password, password: password,
onSuccess: this.onMQTTConnect.bind(this), onSuccess: this.onMQTTConnect.bind(this),
onFailure: function(e) { onFailure: function(e) {
debugger;
console.log(e); console.log(e);
}, },
}; };
...@@ -233,7 +245,7 @@ class Notifier { ...@@ -233,7 +245,7 @@ class Notifier {
onMessageArrived(buffer) { onMessageArrived(buffer) {
let me = this; let me = this;
try { try {
console.log('收到消息:' + buffer.payloadString); // console.log('收到消息:' + buffer.payloadString);
let temp = JSON.parse(buffer.payloadString); let temp = JSON.parse(buffer.payloadString);
let infoType = this._typeInfo(temp.infoType); let infoType = this._typeInfo(temp.infoType);
if ( if (
...@@ -280,11 +292,10 @@ class Notifier { ...@@ -280,11 +292,10 @@ class Notifier {
} }
// 工具类 // 工具类
async loadHisMessages({ userID, pageIndex = this.pageIndex, pageSize = this.pageSize }) { async loadHisMessages(pageIndex,pageSize) {
debugger;
let me = this; let me = this;
return Http.getInformationInfo({ return Http.getInformationInfo({
userID, userID: me.userInfo.OID,
pageIndex, pageIndex,
pageSize, pageSize,
'request.preventCache': Date.now(), 'request.preventCache': Date.now(),
...@@ -293,9 +304,15 @@ class Notifier { ...@@ -293,9 +304,15 @@ class Notifier {
totalCount: res.totalRcdNum, totalCount: res.totalRcdNum,
messages: res.getMe.map(this._handleHisToMessage.bind(this)), messages: res.getMe.map(this._handleHisToMessage.bind(this)),
}; };
this.messageCache.totalCount += result.totalCount; me.messageCache.totalCount = result.totalCount;
this.messageCache.messages.push(...result.messages); result.messages.forEach(message => {
me.publish(NEW_MESSAGE, this.messageCache); // 防止加载更多时候塞入重复数据
let index = me.messageCache.messages.findIndex(item => {
return item.id == message.id;
});
index == -1 && me.messageCache.messages.push(message);
});
me.publish(NEW_MESSAGE, me.messageCache);
return Promise.resolve(result); return Promise.resolve(result);
}); });
} }
...@@ -368,7 +385,6 @@ class Notifier { ...@@ -368,7 +385,6 @@ class Notifier {
} }
return infoType; return infoType;
} }
_handleHisToMessage(hisMessage) { _handleHisToMessage(hisMessage) {
var timeH = (new Date() - new Date(hisMessage.HisCreateTime)) / 1000 / 60; var timeH = (new Date() - new Date(hisMessage.HisCreateTime)) / 1000 / 60;
var timeMss = var timeMss =
...@@ -466,6 +482,7 @@ class Notifier { ...@@ -466,6 +482,7 @@ class Notifier {
}; };
return noticeContent; return noticeContent;
} }
} }
export default Notifier; export default Notifier;
...@@ -1219,7 +1219,6 @@ function onMessageArrived(message) { ...@@ -1219,7 +1219,6 @@ function onMessageArrived(message) {
* @ignore * @ignore
*/ */
ClientImpl.prototype._on_socket_message = function (event) { ClientImpl.prototype._on_socket_message = function (event) {
debugger
this._trace("Client._on_socket_message", event.data); this._trace("Client._on_socket_message", event.data);
var messages = this._deframeMessages(event.data); var messages = this._deframeMessages(event.data);
for (var i = 0; i < messages.length; i+=1) { for (var i = 0; i < messages.length; i+=1) {
......
...@@ -66,7 +66,7 @@ const menuExtraRender = currentRoutes => { ...@@ -66,7 +66,7 @@ const menuExtraRender = currentRoutes => {
<a style={{ display: 'flex', alignItems: 'center' }}> <a style={{ display: 'flex', alignItems: 'center' }}>
<img <img
src={`http://panda-water.cn/web4/${currentRoutes && src={`http://panda-water.cn/web4/${currentRoutes &&
currentRoutes.extData.icon}`} currentRoutes.extData && currentRoutes.extData.icon}`}
style={{ width: '20px', height: '20px' }} style={{ width: '20px', height: '20px' }}
/> />
<span <span
......
...@@ -56,7 +56,6 @@ class Site { ...@@ -56,7 +56,6 @@ class Site {
}, { }, {
ignoreSite: true ignoreSite: true
}).then(res => { }).then(res => {
debugger
if(res && res.say.errMsg === '' && res.say.statusCode === ERR_OK) { if(res && res.say.errMsg === '' && res.say.statusCode === ERR_OK) {
const result = res.getMe; const result = res.getMe;
let city = self.weatherCity; let city = self.weatherCity;
...@@ -427,7 +426,6 @@ class Site { ...@@ -427,7 +426,6 @@ class Site {
} }
handEnd = (event, item) => { handEnd = (event, item) => {
debugger
event.persist(); event.persist();
const self = this; const self = this;
if(item) { if(item) {
......
...@@ -416,7 +416,6 @@ class Login { ...@@ -416,7 +416,6 @@ class Login {
}); });
} }
getUserInfoAndConfig(failCallback, flag, industry) { getUserInfoAndConfig(failCallback, flag, industry) {
debugger
const token = this.globalConfig.token; const token = this.globalConfig.token;
const site = Cookies.get('site'); const site = Cookies.get('site');
const self = this; const self = this;
...@@ -471,9 +470,9 @@ class Login { ...@@ -471,9 +470,9 @@ class Login {
{}, {},
response, response,
self.globalConfig.userInfo, self.globalConfig.userInfo,
{ // {
site: response.site === "" ? "": self.globalConfig.userInfo.site // site: response.site === "" ? "": self.globalConfig.userInfo.site
} // }
); );
// Cookies.set('site', this.globalConfig.userInfo.site); // Cookies.set('site', this.globalConfig.userInfo.site);
console.log("self.globalConfig.userInfo", self.globalConfig.userInfo) console.log("self.globalConfig.userInfo", self.globalConfig.userInfo)
......
...@@ -7,7 +7,6 @@ let Authorized = RenderAuthorize(getAuthority()); ...@@ -7,7 +7,6 @@ let Authorized = RenderAuthorize(getAuthority());
// Reload the rights component // Reload the rights component
const reloadAuthorized = () => { const reloadAuthorized = () => {
debugger
Authorized = RenderAuthorize(getAuthority()); Authorized = RenderAuthorize(getAuthority());
}; };
......
...@@ -17,7 +17,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d ...@@ -17,7 +17,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
var Authorized = (0, _Authorized["default"])((0, _authority.getAuthority)()); // Reload the rights component var Authorized = (0, _Authorized["default"])((0, _authority.getAuthority)()); // Reload the rights component
var reloadAuthorized = function reloadAuthorized() { var reloadAuthorized = function reloadAuthorized() {
debugger;
Authorized = (0, _Authorized["default"])((0, _authority.getAuthority)()); Authorized = (0, _Authorized["default"])((0, _authority.getAuthority)());
}; };
......
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