import Magix from 'magix' import View from '../../../../../view' import Helper from '../../helper' Magix.applyStyle('@../index.less') Magix.applyStyle('@./item-top3-effect.less') export default View.extend({ tmpl: '@item-top3-effect.html', mixins: [Helper], init (options) { this.options = options }, async render () { const { currentWeekly, top3Items } = this.options const allIndicators = await this._getAllIndicators() const allIndicatorsMap = Magix.toMap(allIndicators, 'key') const fields = [{ name: '达摩盘消耗', key: 'charge', valueType: '1', valueKey: 'chargeDmp', valueRateKey: 'chargeDmpWeeklyRate', tips: '选定时间周期内的达摩盘人群在本单品所在单元下推广总花费,统计推广渠道包含直通车、超级推荐、超级钻展。' }, { name: '点击率', key: 'ctr', valueType: '2', valueKey: 'ctr', valueRateKey: 'ctrWeeklyRate', tips: '选定时间周期内的达摩盘人群在本单品所在单元下推广带来的点击量' }] top3Items.forEach((item, i) => { item.text = `
${item.itemName}
` item.value = item.itemId }) this.updater.digest({ allIndicatorsMap, currentWeekly, top3Items, loading: true, fields, selectedItem: top3Items[0].value }) this.getTop3Crowds() }, async getTop3Crowds () { this.updater.digest({ loading: true }) try { const { currentWeekly } = this.options const { selectedItem } = this.updater.get() const params = { weeklyReportId: currentWeekly.id, itemId: selectedItem } const models = [{ name: 'api_weekly_report_old_item_top_crowd_get', params }] const [model] = await this.fetch(models) const top3Crowds = model.get('data', []) this.updater.digest({ top3Crowds, loading: false }) } catch (error) { this.alert('错误提示', error.msg || error.message || error) this.updater.digest({ loading: false }) } }, 'changeTab' (e) { this.getTop3Crowds() } })