完成读取顾问和客人的聊天记录

feature/2.0-sales-trade
LiaoYijun 3 years ago
parent 38c75abd2c
commit c701e1cbbc

@ -11,15 +11,24 @@ class Wechat_session extends Component {
super(props); super(props);
} }
componentDidMount() {
const {wechatStore} = this.context;
wechatStore.fetchWechatUserList();
}
handleUserClick(user) { handleUserClick(user) {
///weixin/wxwork/get_externalcontact_list?userid=misscarol&searchstr=
const {wechatStore} = this.context; const {wechatStore} = this.context;
wechatStore.fetchContactList(user); wechatStore.fetchContactList(user);
} }
handleContactClick(contact) {
const {wechatStore} = this.context;
wechatStore.fetchChatMsgList(contact);
}
render() { render() {
const {wechatStore} = this.context; const {wechatStore} = this.context;
const userList = wechatStore.userList; const userList = wechatStore.userList;
const contactList = wechatStore.contactList; const contactList = wechatStore.contactList;
const chatMsgList = wechatStore.chatMsgList;
return ( return (
<div> <div>
@ -44,7 +53,7 @@ class Wechat_session extends Component {
itemLayout="horizontal" itemLayout="horizontal"
dataSource={contactList} dataSource={contactList}
renderItem={(contact) => ( renderItem={(contact) => (
<List.Item onClick={() => {console.info(contact)}}> <List.Item onClick={() => {this.handleContactClick(contact)}}>
<List.Item.Meta <List.Item.Meta
avatar={<Avatar src={contact.avatar} />} avatar={<Avatar src={contact.avatar} />}
title={contact.username} title={contact.username}
@ -54,6 +63,21 @@ class Wechat_session extends Component {
)} )}
/> />
</Col> </Col>
<Col span={8}>
<List
itemLayout="horizontal"
dataSource={chatMsgList}
renderItem={(chatMsg) => (
<List.Item>
<List.Item.Meta
avatar={<Avatar src={chatMsg.from_avatar} />}
title={chatMsg.from_name}
description={chatMsg.content.text}
/>
</List.Item>
)}
/>
</Col>
</Row> </Row>
</div> </div>

@ -16,6 +16,18 @@ class Wechat {
this.rootStore = rootStore; this.rootStore = rootStore;
makeAutoObservable(this); 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') req.fetchJSON(config.HT_HOST + '/weixin/wxwork/get_permit_user_list')
.then(json => { .then(json => {
runInAction(() => { runInAction(() => {
@ -26,6 +38,8 @@ class Wechat {
}); });
} }
//
fetchContactList(user) { fetchContactList(user) {
req.fetchJSON(config.HT_HOST + '/weixin/wxwork/get_externalcontact_list?userid='+user.userid) 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'}]; userList = [{username: '---', avatar: 'https://joeschmoe.io/api/v1/random'}];
contactList = [{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: '---'}}];
} }

Loading…
Cancel
Save