import * as React from 'react'; import { taker, getApiUrl2 } from '&/helper'; interface info{ title:string, type:number, descriptLeft:string, discriptRight:string, emptyText:string } interface Props{ data:info } interface resData{ rank:number, value:string, trend:number, overPercentage:string } export default class DigitalCard extends React.Component{ async componentWillMount(){ const { type } = this.props.data; // GET /api/v2/{tenant_id}/{user_id}/reward/rank/detail // 查询某个排名的信息(本周打赏、累积打赏、本周获赏、累积获赏) // type: 1:本周打赏 2:累积打赏 3:本周获赏 4:累积获赏 const url = getApiUrl2(`reward/rank/detail?type=${type}`) const response = await taker(url); this.setState({info: response.Data}); } state={ info:{ rank:0, value:"0.00", trend:0, overPercentage:'' } } getStatus = (info:resData)=>{ if(!info) { return 'up' } else{ switch(info.trend){ case -1: return 'down'; default: return 'up'; } } } render(){ const {data} = this.props; const {info} = this.state; const { type } = data; return
{data.title}
{ info.value != '0.00' ?
{info && info.value} {data.discriptRight && } {data.descriptLeft} {`${info ? data.discriptRight? info.overPercentage : info.rank : 0}`} {!data.discriptRight && } {data.discriptRight}
:
{data.emptyText}
}
} }