import Magix from 'magix' import View from '../../../../../view' Magix.applyStyle('@../index.less') Magix.applyStyle('@./overview.less') export default View.extend({ tmpl: '@overview.html', init (options) { this.options = options }, async render () { const { currentWeekly } = this.options const indicators = await this.getOverviewData() const trendData = await this.getTrendData() this.updater.digest({ showPeer: true, trendData, currentWeekly, indicators // chartData }) }, async getTrendData () { try { const { currentWeekly } = this.options const { beginDate, endDate } = currentWeekly const models = [{ name: 'api_report_indicator_trend_get', params: { dateType: 1, beginDate, endDate, indicators: ['charge', 'shopSgUv'] } }] const [model] = await this.fetch(models) const trends = model.get('data', []) for (const data of trends) { data['店铺首购人数'] = data.shopSgUv data['消耗(元)'] = data.charge } return trends } catch (error) { this.alert('错误提示', error.msg || error.message || error, null, { mask: true }) } }, async getOverviewData () { try { const { currentWeekly } = this.options const { beginDate, endDate } = currentWeekly const indicators = ['showUv', 'ctr', 'roi', 'collectCartRate', 'clickCost', 'dealGmv'] const models = [{ name: 'api_report_overview_get', params: { beginDate, endDate, indicators, growthRatioType: 1 } }] const [model] = await this.fetch(models) const data = model.get('data', []) return data } catch (error) { this.alert('错误提示', error.msg || error.message || error, null, { mask: true }) } } })