完成 WhatsApp 会话功能
parent
9b7d599ad7
commit
e447bd26e3
@ -0,0 +1,63 @@
|
|||||||
|
import {makeAutoObservable, runInAction} from "mobx"
|
||||||
|
import * as config from "../config";
|
||||||
|
import * as req from '../utils/request';
|
||||||
|
|
||||||
|
class WhatsApp {
|
||||||
|
|
||||||
|
constructor(rootStore) {
|
||||||
|
this.rootStore = rootStore;
|
||||||
|
makeAutoObservable(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchWechatUserList() {
|
||||||
|
|
||||||
|
req.fetchJSON(config.HT_HOST + '/weixin/wxwork/get_permit_user_list')
|
||||||
|
.then(json => {
|
||||||
|
if (json.errcode === 0) {
|
||||||
|
runInAction(() => {
|
||||||
|
this.userList = json.Result.filter(user => {
|
||||||
|
return user.SMPlatform === 'whatsapp';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchContactList(user) {
|
||||||
|
|
||||||
|
req.fetchJSON(config.HT_HOST + '/weixin/wxwork/get_externalcontact_list?userid='+user.userid)
|
||||||
|
.then(json => {
|
||||||
|
if (json.errcode === 0) {
|
||||||
|
runInAction(() => {
|
||||||
|
this.contactList = json.Result.filter(user => {
|
||||||
|
return user.SMPlatform === 'whatsapp';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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 => {
|
||||||
|
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 WhatsApp;
|
Loading…
Reference in New Issue