diff --git a/src/charts/Wechat_session.js b/src/charts/Wechat_session.js
index c3c9716..ccc4e26 100644
--- a/src/charts/Wechat_session.js
+++ b/src/charts/Wechat_session.js
@@ -1,8 +1,11 @@
import React, {Component} from 'react';
-import {Row, Col, List, Avatar} from 'antd';
+import {Row, Col, List, Avatar, DatePicker, Pagination} from 'antd';
import {stores_Context} from '../config'
+import * as config from "../config";
import {observer} from 'mobx-react';
-import { toJS } from "mobx";
+import moment from "moment";
+import 'moment/locale/zh-cn';
+import locale from 'antd/es/date-picker/locale/zh_CN';
class Wechat_session extends Component {
@@ -12,6 +15,7 @@ class Wechat_session extends Component {
}
componentDidMount() {
+ console.info('Wechat_session.componentDidMount');
const {wechatStore} = this.context;
wechatStore.fetchWechatUserList();
}
@@ -22,18 +26,23 @@ class Wechat_session extends Component {
}
handleContactClick(contact) {
const {wechatStore} = this.context;
- wechatStore.fetchChatMsgList(contact);
+ wechatStore.fetchChatMsgList(contact, 0, 20);
+ }
+ handlePageChanged(page, pageSize) {
+ const {wechatStore} = this.context;
+ wechatStore.fetchChatMsgList(wechatStore.selectedContact, page, pageSize);
}
render() {
const {wechatStore} = this.context;
const userList = wechatStore.userList;
const contactList = wechatStore.contactList;
const chatMsgList = wechatStore.chatMsgList;
+ const chatMsgPage = wechatStore.chatMsgPage;
return (
-
+ <>
-
+
}
title={user.username}
- description=""
/>
)}
/>
-
+
}
title={contact.username}
- description=""
/>
)}
/>
-
+
}
title={chatMsg.from_name}
- description={chatMsg.content.text}
+ description={chatMsg.msgtime}
/>
+ {chatMsg.content.text}
)}
/>
+ { this.handlePageChanged(page, pageSize)}} />
-
+ >
);
}
}
-export default observer(Wechat_session);
+export default observer(Wechat_session);
\ No newline at end of file
diff --git a/src/stores/Wechat.js b/src/stores/Wechat.js
index 296e6a6..95e5204 100644
--- a/src/stores/Wechat.js
+++ b/src/stores/Wechat.js
@@ -1,72 +1,63 @@
import {makeAutoObservable, runInAction} from "mobx"
-import {
- CaretUpOutlined,
- CaretDownOutlined
-} from '@ant-design/icons';
-import {Tag} from 'antd';
import * as config from "../config";
-import moment from "moment";
-import {NavLink} from "react-router-dom";
import * as req from '../utils/request';
-
class Wechat {
constructor(rootStore) {
this.rootStore = rootStore;
makeAutoObservable(this);
-
- // req.fetchJSON(config.HT_HOST + '/weixin/wxwork/get_permit_user_list')
- // .then(json => {
- // runInAction(() => {
- // this.userList = json.Result.filter(user => {
- // return user.SMPlatform === 'weixin';
- // });
- // });
- // });
}
fetchWechatUserList() {
req.fetchJSON(config.HT_HOST + '/weixin/wxwork/get_permit_user_list')
.then(json => {
- runInAction(() => {
- this.userList = json.Result.filter(user => {
- return user.SMPlatform === 'weixin';
+ if (json.errcode === 0) {
+ runInAction(() => {
+ this.userList = json.Result.filter(user => {
+ return user.SMPlatform === 'weixin';
+ });
});
- });
+ }
});
}
- //
-
fetchContactList(user) {
req.fetchJSON(config.HT_HOST + '/weixin/wxwork/get_externalcontact_list?userid='+user.userid)
.then(json => {
- runInAction(() => {
- this.contactList = json.Result.filter(user => {
- return user.SMPlatform === 'weixin';
+ if (json.errcode === 0) {
+ runInAction(() => {
+ this.contactList = json.Result.filter(user => {
+ return user.SMPlatform === 'weixin';
+ });
});
- });
+ }
});
}
- fetchChatMsgList(contact) {
-
- req.fetchJSON(config.HT_HOST + '/weixin/wxwork/GetChatmsg?external_userid='+contact.userid+'&Page_count=20&curr_page=0')
+ fetchChatMsgList(contact, page, pageSize) {
+ runInAction(() => {
+ this.selectedContact = contact;
+ });
+ req.fetchJSON(config.HT_HOST + '/weixin/wxwork/GetChatmsg?external_userid='+this.selectedContact.userid+'&Page_count='+pageSize+'&curr_page='+page)
.then(json => {
- runInAction(() => {
- console.info(json.chatmsg);
- this.chatMsgList = json.chatmsg;
- });
+ if (json.errcode === 0) {
+ runInAction(() => {
+ this.chatMsgList = json.chatmsg;
+ this.chatMsgPage = json.chatpage;
+ });
+ }
});
}
+
userList = [{username: '---', avatar: 'https://joeschmoe.io/api/v1/random'}];
contactList = [{username: '---', avatar: 'https://joeschmoe.io/api/v1/random'}];
chatMsgList = [{from_name: '---', from_avatar: 'https://joeschmoe.io/api/v1/random', content: {text: '---'}}];
+ chatMsgPage = {currpage: 1, totalpage: 1};
+ selectedContact = this.contactList[0];
}
-
export default Wechat;
\ No newline at end of file