import { makeAutoObservable, runInAction } from 'mobx'; import * as req from '../utils/request'; import { isEmpty } from '../utils/commons'; /** * 计算变化值 */ const calcRate = (r1, r2) => { // 的 }; class Trade { constructor(rootStore) { this.rootStore = rootStore; makeAutoObservable(this); } fetchSummaryData() { this.summaryData.loading = true; req.fetchJSON('/service-web/QueryData/GetTradeSummary').then((json) => { if (json.errcode === 0) { runInAction(() => { this.summaryData = { loading: false, ...json }; }); } }); } fetchTradeDataByMonth() { this.sideData.loading = true; req.fetchJSON('/service-web/QueryData/GetTradeByMonth').then((json) => { if (json.errcode === 0) { runInAction(() => { const _sideData = json.data.reduce((r, v) => { (r[v.biz_side] || (r[v.biz_side] = [])).push(v); return r; }, {}); console.log(_sideData); this.sideData = { loading: false, ...json }; }); } }); } summaryData = { loading: false }; sideData = { loading: false }; } export default Trade;