From bb003a76072e7c25547de3681c2582036330e406 Mon Sep 17 00:00:00 2001 From: LiaoYijun Date: Tue, 27 Sep 2022 14:42:44 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=91=98=E5=B7=A5=E5=88=97=E8=A1=A8=E8=AF=BB?= =?UTF-8?q?=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/charts/Wechat_session.js | 56 +++++++++++------------------------- src/stores/Index.js | 2 ++ src/stores/Wechat.js | 32 +++++++++++++++++++++ 3 files changed, 51 insertions(+), 39 deletions(-) create mode 100644 src/stores/Wechat.js diff --git a/src/charts/Wechat_session.js b/src/charts/Wechat_session.js index aadccf5..7db438e 100644 --- a/src/charts/Wechat_session.js +++ b/src/charts/Wechat_session.js @@ -1,42 +1,19 @@ -import React, {useContext, useEffect} from 'react'; -import {Row, Col, List, Avatar, Table, Space, Radio, Tooltip} from 'antd'; -import { - ContainerOutlined, - SearchOutlined, -} from '@ant-design/icons'; +import React, {Component} from 'react'; +import {Row, Col, List, Avatar} from 'antd'; import {stores_Context} from '../config' -import {Line} from "@ant-design/charts"; import {observer} from 'mobx-react'; -import DatePickerCharts from '../charts/DatePickerCharts' -import {NavLink, useParams} from "react-router-dom"; -import * as comm from "../utils/commons"; -import * as config from "../config"; -import SiteSelect from "../charts/SiteSelect"; -import GroupSelect from "../charts/GroupSelect"; -import {utils, writeFileXLSX} from "xlsx"; +import { toJS } from "mobx"; -const Wechat_session = () => { +class Wechat_session extends Component { - const {orders_store, date_picker_store, customer_store} = useContext(stores_Context); - const inchina_data = customer_store.inchina_data; - - useEffect(() => { - - }, []) - const data = [ - { - title: 'Ant Design Title 1', - }, - { - title: 'Ant Design Title 2', - }, - { - title: 'Ant Design Title 3', - }, - { - title: 'Ant Design Title 4', - }, - ]; + static contextType = stores_Context; + constructor(props) { + super(props); + this.stores = this.props.stores; + } + render() { + const {wechatStore} = this.stores; + const userList = wechatStore.userList; return (
@@ -44,12 +21,12 @@ const Wechat_session = () => { ( + dataSource={userList} + renderItem={(user) => ( } - title={{item.title}} + avatar={} + title={user.username} description="" /> @@ -60,6 +37,7 @@ const Wechat_session = () => {
); + } } export default observer(Wechat_session); diff --git a/src/stores/Index.js b/src/stores/Index.js index be0d252..dd027bb 100644 --- a/src/stores/Index.js +++ b/src/stores/Index.js @@ -6,6 +6,7 @@ import CustomerStore from "./CustomerStore"; import AuthStore from "./AuthStore"; import ChatSessionStore from "./ChatSessionStore"; import FinancialStore from "./FinancialStore"; +import WechatStore from "./Wechat"; class Index { @@ -17,6 +18,7 @@ class Index { this.auth_store = new AuthStore(this); this.chat_session_store = new ChatSessionStore(this); this.financial_store = new FinancialStore(this); + this.wechatStore = new WechatStore(this); makeAutoObservable(this); } diff --git a/src/stores/Wechat.js b/src/stores/Wechat.js new file mode 100644 index 0000000..39308c1 --- /dev/null +++ b/src/stores/Wechat.js @@ -0,0 +1,32 @@ +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 => { + console.info(json); + runInAction(() => { + this.userList = json.Result; + }) + }); + } + userList = [{username: '---', avatar: 'https://joeschmoe.io/api/v1/random'},{username: '---', avatar: 'https://joeschmoe.io/api/v1/random'}]; + +} + + +export default Wechat; \ No newline at end of file From 38c75abd2ca8a04cb470e6552f0fcbff3a848d15 Mon Sep 17 00:00:00 2001 From: LiaoYijun Date: Wed, 28 Sep 2022 15:27:42 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E5=91=98=E5=B7=A5=E5=AF=B9=E5=BA=94=E7=9A=84=E8=81=94=E7=B3=BB?= =?UTF-8?q?=E4=BA=BA=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/charts/Wechat_session.js | 27 ++++++++++++++++++++++++--- src/stores/Wechat.js | 28 +++++++++++++++++++++------- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/src/charts/Wechat_session.js b/src/charts/Wechat_session.js index 7db438e..9ba1670 100644 --- a/src/charts/Wechat_session.js +++ b/src/charts/Wechat_session.js @@ -9,11 +9,17 @@ class Wechat_session extends Component { static contextType = stores_Context; constructor(props) { super(props); - this.stores = this.props.stores; + } + + handleUserClick(user) { + ///weixin/wxwork/get_externalcontact_list?userid=misscarol&searchstr= + const {wechatStore} = this.context; + wechatStore.fetchContactList(user); } render() { - const {wechatStore} = this.stores; + const {wechatStore} = this.context; const userList = wechatStore.userList; + const contactList = wechatStore.contactList; return (
@@ -23,7 +29,7 @@ class Wechat_session extends Component { itemLayout="horizontal" dataSource={userList} renderItem={(user) => ( - + {this.handleUserClick(user)}}> } title={user.username} @@ -33,6 +39,21 @@ class Wechat_session extends Component { )} /> + + ( + {console.info(contact)}}> + } + title={contact.username} + description="" + /> + + )} + /> +
diff --git a/src/stores/Wechat.js b/src/stores/Wechat.js index 39308c1..3e72868 100644 --- a/src/stores/Wechat.js +++ b/src/stores/Wechat.js @@ -17,14 +17,28 @@ class Wechat { makeAutoObservable(this); req.fetchJSON(config.HT_HOST + '/weixin/wxwork/get_permit_user_list') - .then(json => { - console.info(json); - runInAction(() => { - this.userList = json.Result; - }) - }); + .then(json => { + runInAction(() => { + this.userList = json.Result.filter(user => { + return user.SMPlatform === 'weixin'; + }); + }); + }); } - userList = [{username: '---', avatar: 'https://joeschmoe.io/api/v1/random'},{username: '---', avatar: 'https://joeschmoe.io/api/v1/random'}]; + + 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'; + }); + }); + }); + } + userList = [{username: '---', avatar: 'https://joeschmoe.io/api/v1/random'}]; + contactList = [{username: '---', avatar: 'https://joeschmoe.io/api/v1/random'}]; } From c701e1cbbc94ddad446b7dba695dfbfcf8a3ba75 Mon Sep 17 00:00:00 2001 From: LiaoYijun Date: Thu, 29 Sep 2022 10:39:05 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E9=A1=BE=E9=97=AE=E5=92=8C=E5=AE=A2=E4=BA=BA=E7=9A=84=E8=81=8A?= =?UTF-8?q?=E5=A4=A9=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: '---'}}]; }