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

fix: notice

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