import Magix from 'magix' import * as View from '../../../../view' import * as GlobalHelper from '../../../mixins/helper' Magix.applyStyle('@./channels-new.less') export default View.extend({ tmpl: '@channels-new.html', init(options) { this.options = options }, async render() { // 渠道 const channels = await this.getChannels() const channelsMap = Magix.toMap(channels, 'value') let { deliverType = channels[0].value } = this.updater.get() const { inputKey, inputType, crowd, period } = this.options // 沉淀人群渠道是指定传进来的 if (inputType) { deliverType = crowd.deliverType } // 分析分类 const analysisTypes = [ { text: '曝光人群画像洞察', value: '3', tips: '系统提供近7天曝光人群在性别、年龄、消费力等级、城市等级等维度的画像洞察,帮助您立体刻画曝光人群特征分布' } ] // 渠道沉淀人群进来的报表有额外的tab: 跨渠道触达机会分析 if (inputType) { analysisTypes.unshift({ text: '跨渠道触达机会分析', value: '4', tips: '该沉淀人群在其他营销渠道下近7天的预估曝光人数及对比(跨渠道预估曝光人数/该渠道曝光人数)' }) } else { analysisTypes.unshift({ text: '人群场景推荐', value: '2', tips: '结合此人群的投放表现,系统为您智能推荐场景洞察和人群策略,帮助你挖掘新机会人群方向。' }) analysisTypes.unshift({ text: '优质人群特征', value: '1', tips: '系统基于人群点击投放数据,为您提供点击效果较优的显著特征,您可以选择对应特征标签,组合成新机会人群投放。' }) } const analysisType = analysisTypes[0].value const viewMap = { 1: '@./feat-dig-new', 2: '@./crowd-scene', 3: '@./effect-analysis', 4: '@./chance-analysis' } this.updater.digest({ period, crowd, inputKey, inputType, channelsMap, viewMap, analysisTypes, analysisType, channels, deliverType, id: this.options.id }) this.mountSub() }, mountSub() { const { id } = this.options const { deliverType, viewMap, analysisType, crowd, inputType, inputKey } = this.updater.get() this.owner.mountVframe(`${this.id}_analysis`, viewMap[analysisType], { deliverType, crowdId: id, inputType, inputKey, crowd, close: () => { this.options.close() } }) }, async getChannels() { try { const params = {} const models = [ { name: 'api_report_channel_funnel_config_get', params } ] const [model] = await this.fetch(models) const data = model.get('data', []) return data.map(item => { return { text: item.deliverName, value: item.deliverType } }) } catch (error) { console.error(error) } }, 'changeTab'(e) { this.mountSub() }, changeTab(analysisType) { $(`#${this.id}_tab`)[0].scrollIntoView({ behavior: 'smooth' }) this.updater.digest({ analysisType }) this.mountSub() }, // '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() } })