From c701e1cbbc94ddad446b7dba695dfbfcf8a3ba75 Mon Sep 17 00:00:00 2001 From: LiaoYijun Date: Thu, 29 Sep 2022 10:39:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=AF=BB=E5=8F=96=E9=A1=BE?= =?UTF-8?q?=E9=97=AE=E5=92=8C=E5=AE=A2=E4=BA=BA=E7=9A=84=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/charts/Wechat_session.js | 28 ++++++++++++++++++++++++++-- src/stores/Wechat.js | 26 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/charts/Wechat_session.js b/src/charts/Wechat_session.js index 9ba1670..c3c9716 100644 --- a/src/charts/Wechat_session.js +++ b/src/charts/Wechat_session.js @@ -11,15 +11,24 @@ class Wechat_session extends Component { super(props); } + componentDidMount() { + const {wechatStore} = this.context; + wechatStore.fetchWechatUserList(); + } + handleUserClick(user) { - ///weixin/wxwork/get_externalcontact_list?userid=misscarol&searchstr= const {wechatStore} = this.context; wechatStore.fetchContactList(user); } + handleContactClick(contact) { + const {wechatStore} = this.context; + wechatStore.fetchChatMsgList(contact); + } render() { const {wechatStore} = this.context; const userList = wechatStore.userList; const contactList = wechatStore.contactList; + const chatMsgList = wechatStore.chatMsgList; return (
@@ -44,7 +53,7 @@ class Wechat_session extends Component { itemLayout="horizontal" dataSource={contactList} renderItem={(contact) => ( - {console.info(contact)}}> + {this.handleContactClick(contact)}}> } title={contact.username} @@ -54,6 +63,21 @@ class Wechat_session extends Component { )} /> + + ( + + } + title={chatMsg.from_name} + description={chatMsg.content.text} + /> + + )} + /> +
diff --git a/src/stores/Wechat.js b/src/stores/Wechat.js index 3e72868..296e6a6 100644 --- a/src/stores/Wechat.js +++ b/src/stores/Wechat.js @@ -16,6 +16,18 @@ class Wechat { 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(() => { @@ -26,6 +38,8 @@ class Wechat { }); } + // + fetchContactList(user) { req.fetchJSON(config.HT_HOST + '/weixin/wxwork/get_externalcontact_list?userid='+user.userid) @@ -37,8 +51,20 @@ class Wechat { }); }); } + + fetchChatMsgList(contact) { + + req.fetchJSON(config.HT_HOST + '/weixin/wxwork/GetChatmsg?external_userid='+contact.userid+'&Page_count=20&curr_page=0') + .then(json => { + runInAction(() => { + console.info(json.chatmsg); + this.chatMsgList = json.chatmsg; + }); + }); + } 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: '---'}}]; }