TODO: continue

This commit is contained in:
eson 2020-09-01 19:15:56 +08:00
parent 23171e6cbf
commit 4eb8a353a6
3 changed files with 20 additions and 16 deletions

View File

@ -30,9 +30,8 @@ class App extends React.Component {
}; };
changePlatform = (p) => { changePlatform = (p) => {
this.setState({platform: p}, () => { this.setState({platform: p})
this.refs.ctabs.changePlatform(this.state.platform); this.refs.ctabs.changePlatform(p)
})
} }

View File

@ -100,17 +100,20 @@ class ChartsCount extends React.Component {
updateData = (params = {}) => { updateData = (params = {}) => {
const {platform, countkey, title} = params // const {platform, countkey, title} = params
const platform = params.platform?params.platform:this.state.platform
const countkey = params.countkey?params.countkey:this.state.countkey
const title = params.title?params.title:this.state.title
fetch(`${apihost}/tag/count?platform=${platform?platform:this.state.platform}&countkey=${countkey?countkey:this.state.countkey}`, { fetch(`${apihost}/tag/count?platform=${platform}&countkey=${countkey}`, {
"mode": "cors" "mode": "cors"
}).then( }).then(
response => { response => {
response.json().then(value => { response.json().then(value => {
this.setState({ this.setState({
title: title?title:this.state.title, title: title ,
platform: platform?platform:this.state.platform, platform: platform ,
countkey: countkey?countkey:this.state.countkey, countkey: countkey ,
data: parseData(value) data: parseData(value)
}, () => { }, () => {
var ins = this.echarts_react.getEchartsInstance(); var ins = this.echarts_react.getEchartsInstance();

View File

@ -13,7 +13,6 @@ class ContentTabs extends React.Component {
this.state = { this.state = {
platform: this.props.platform, platform: this.props.platform,
tab: this.props.tab, tab: this.props.tab,
count: 1,
} }
} }
@ -24,30 +23,33 @@ class ContentTabs extends React.Component {
} }
changeTab = (tab) => { changeTab = (tab) => {
this.setState({tab: tab}, ()=>{ this.updateDate() }) this.updateDate({tab: tab})
} }
updateDate() { updateDate(params = {}) {
switch(this.state.tab) { const platform = params.platform?params.platform:this.state.platform
const tab = params.tab?params.tab:this.state.tab
this.setState({platform: platform, tab:tab});
switch(tab) {
case "tabledata": case "tabledata":
if (this.refs.tabledata) { if (this.refs.tabledata) {
this.refs.tabledata.changePlatform(this.state.platform); this.refs.tabledata.changePlatform(platform);
} }
break; break;
case "chartscount": case "chartscount":
if (this.refs.chartscount) { if (this.refs.chartscount) {
this.refs.chartscount.changePlatform(this.state.platform); this.refs.chartscount.changePlatform(platform);
} }
break; break;
default: default:
} }
} }
changePlatform = (platform) => { changePlatform = (platform) => {
this.setState({platform: platform}, ()=>{ this.updateDate()}) this.updateDate({platform: platform})
} }
render() { render() {