import Magix from 'magix' import View from '../../../../../view' import Helper from '../../helper' Magix.applyStyle('@./top-crowds.less') Magix.applyStyle('@../index.less') const textMap = { 1: { title: '消耗', key: 'charge' }, 2: { title: '点击率', key: 'ctr' }, 3: { title: '收藏加购率', key: 'collectCartRate' }, 4: { title: '投资回报率', key: 'roi' } } export default View.extend({ tmpl: '@top-crowds.html', mixins: [Helper], init (options) { this.options = options }, async render () { // const loc = Magix.Router.parse() const { crowdTopType, currentWeekly } = this.options const topCrowds = await this.getTopCrowds() const allIndicators = await this._getAllIndicators() const allIndicatorsMap = Magix.toMap(allIndicators, 'key') this.updater.digest({ allIndicatorsMap, currentWeekly, crowdTopType, topCrowds, textMap }) }, async getTopCrowds () { try { const { crowdTopType, currentWeekly } = this.options const params = { crowdTopType, weeklyReportId: currentWeekly.id } const models = [{ name: 'api_weekly_report_old_crowd_top_get', params }] const [model] = await this.fetch(models) const data = model.get('data', []) return data } catch (error) { this.alert('错误提示', error.msg || error.message || error) } } // 'showReports' (e) { // const { id, crowdName } = e.params // const viewPath = '@../../crowds/detail' // const viewOptions = { // id, // crowdName, // noChannels: true // } // const dialogOptions = { // width: 1300, // header: { // title: `人群报表:${crowdName}` // }, // footer: { // cancel: false, // enterText: '关闭' // } // } // this.mxModal(viewPath, viewOptions, dialogOptions) // } })