import Magix from 'magix' import * as View from '../../../../view' import * as GlobalHelper from '../../../mixins/helper' Magix.applyStyle('@./channels.less') export default View.extend({ tmpl: '@channels.html', init (options) { this.options = options }, async render () { // 渠道 const channels = await GlobalHelper.getChannels(this) const channelsMap = Magix.toMap(channels, 'value') const deliverType = this.updater.get('deliverType') || channels[0].value // 分析分类 const analysisTypes = [{ text: '投放漏斗分析', value: '1', tips: '系统提供所选广告投放渠道下,人群近30天被该广告触达投放分析,不限于达摩盘人群圈选投放。' }, { text: '特征效果分析', value: '2', tips: '系统提供近7天曝光人群在性别、年龄、消费力等级、城市等级效果分布。' }, { text: '优质特征挖掘', value: '3', tips: '系统基于展现和转化效果,为您提供曝光人群显著特征,您可以选择对应特征标签,组合新机会人群投放。' }] const analysisType = analysisTypes[0].value const viewMap = { 1: '@./funnel-analysis', 2: '@./effect-analysis', 3: '@./feat-dig' } // const channelAnalysis = await this.getData(deliverType) this.updater.digest({ channelsMap, viewMap, analysisTypes, analysisType, channelAnalysis, channels, deliverType, id: this.options.id }) }, // 获取渠道概览分析 async getData (deliverType) { try { const { beginDate, endDate, id, selectedIndicators } = this.options const params = { beginDate, endDate, crowdId: id, indicators: selectedIndicators.map(ind => ind.key), deliverType } const models = [{ name: 'api_report_overview_get', params }] 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 }) } }, changeTab (analysisType) { this.updater.digest({ analysisType }) }, 'showChannelEffect' (e) { const { deliverType, channelsMap } = this.updater.get() const { id, beginDate, endDate, indicators } = this.options const viewPath = '@./crowd-trend' const viewOptions = { deliverType, id, beginDate, endDate, indicators, isModal: true } const dialogOptions = { width: 1060, header: { title: `${channelsMap[deliverType].text}渠道效果趋势` }, footer: { cancel: false, enterText: '关闭' } } this.mxModal(viewPath, viewOptions, dialogOptions) }, showPlanAnalysis () { const { deliverType, channelsMap } = this.updater.get() const { id, beginDate, endDate, indicators, selectedIndicators } = this.options const viewPath = '@./plan-analysis' const viewOptions = { deliverType, id, beginDate, endDate, indicators, selectedIndicators, channelName: channelsMap[deliverType].text } const dialogOptions = { width: 1220, header: { title: `${channelsMap[deliverType].text}投放计划分析` }, footer: { cancel: false, enterText: '关闭' } } this.mxModal(viewPath, viewOptions, dialogOptions) }, 'showPlanAnalysis' (e) { this.showPlanAnalysis() }, 'changeChannel' (e) { this.render() } })