import Magix from 'magix' import View from '../../../../../view' import Helper from '../../helper' Magix.applyStyle('@../index.less') Magix.applyStyle('@./item-top3.less') export default View.extend({ tmpl: '@item-top3.html', mixins: [Helper], init (options) { this.options = options }, async render () { // const loc = Magix.Router.parse() const { currentWeekly } = this.options const allIndicators = await this._getAllIndicators() const allIndicatorsMap = Magix.toMap(allIndicators, 'key') // valueType 0:数量指标(整型)、1:金额指标(浮点型)、2:比率指标(浮点型且需要转成百分比) const fields = [{ name: '达摩盘消耗', key: 'charge', valueType: '1', valueKey: 'chargeDmp', valueRateKey: 'chargeDmpWeeklyRate', tips: '选定时间周期内的达摩盘人群在本单品所在单元下推广总花费,统计推广渠道包含直通车、超级推荐、超级钻展。' }, { name: '展现人数', key: 'showUv', valueType: '0', valueKey: 'uv', valueRateKey: 'uvWeeklyRate', tips: '选定时间周期内的达摩盘人群在本单品所在单元下推广带来的展现人数(已去重)。' }, { name: '点击率', key: 'ctr', valueType: '2', valueKey: 'ctr', valueRateKey: 'ctrWeeklyRate', tips: '选定时间周期内的达摩盘人群在本单品所在单元下推广带来的点击量/曝光量*100%' }, { name: '投资回报率', key: 'roi', valueType: '1', valueKey: 'roi', valueRateKey: 'roiWeeklyRate', tips: '选定时间周期内的达摩盘人群在本单品所在单元下推广带来的成交订单金额/消耗' }, { name: '收藏加购率', key: 'collectCartRate', valueType: '2', valueKey: 'col', valueRateKey: 'colWeeklyRate', tips: '选定时间周期内的达摩盘人群在本单品所在单元下推广带来的收藏加购量/点击量*100%' }] const [top3Items, topItem] = await Promise.all([this.getTop3(), this.getTop()]) this.updater.digest({ fields, currentWeekly, allIndicatorsMap, top3Items, topItem: topItem.topItems && topItem.topItems[0], numItems: topItem.numItems }) }, // 单品TOP async getTop () { try { const { currentWeekly } = this.options const params = { weeklyReportId: currentWeekly.id } const models = [{ name: 'api_weekly_report_old_item_summary_get', params }] const [model] = await this.fetch(models) const data = model.get('data', {}) return data } catch (error) { this.alert('错误提示', error.msg || error.message || error) } }, // 投放消耗TOP3单品 async getTop3 () { try { const { currentWeekly } = this.options const params = { weeklyReportId: currentWeekly.id } const models = [{ name: 'api_weekly_report_old_item_top_get', params }] const [model] = await this.fetch(models) const data = model.get('data', []) // 补齐数据 for (const item of data) { item.item_id = item.itemId item.pic_url = item.itemPicUrl item.item_title = item.itemName item.item_price = item.itemPrice // cateName, tags, cateId } return data } catch (error) { this.alert('错误提示', error.msg || error.message || error) } } })