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: '---'}}]; }