映射
id是自己本地模拟的数据字段,tdid是后台给的数据字段
getMarketAccountOrderList(market, state, pageNumber, pageSize, filterKey, filterSort) {
const mapping = {
id: "tdid",
market: "fCoincode",
price: "price",
quantity: "num",
doneQuantity: "deal",
turnover: "gnum",
type: "type",
typename: "typename",
time: "tradetime",
state: "status",
statusname: "statusname",
}
if(filterKey){
filterKey = mapping[filterKey]
}
class Processor {
constructor(result) {
if (result.getState() == 200) {
const data = result.getBody()
data.total = data.total
data.dataList = data.t
if (data.dataList && data.dataList instanceof Array && data.dataList.length > 0) {
data.dataList.map((item) => {
item.id = item.tdid//编号
item.market = item.fCoincode//市场
item.price = item.price//当前价格
item.quantity = item.num//买卖数量
item.doneQuantity = item.deal//成交数量
item.turnover = item.gnum//总价值
item.type = item.type//交易类型
item.typename = item.typename//交易类型名称
item.time = item.tradetime//委托时间
item.state = item.status//状态(1:完成交易 -1:取消委托)
item.statusname = item.statusname//状态(1:完成交易 -1:取消委托 0 委托中)
})
}
}
return result
}
};
return new Promise((resolve, reject) => {
const prm = this.request("/index", {
market, state,
pageNum: pageNumber,
pageSize: pageSize,
filterKey,
filterSort
})
prm.then((result) => {
resolve(new Processor(result))
})
})
}