import Magix from 'magix' import * as View from '../../../../view' Magix.applyStyle('@./index.less') export default View.extend({ tmpl: '@index.html', init (options) { this.options = options this.observeLocation(['selectedTab']) }, async render () { const loc = Magix.Router.parse() const tabs = [{ text: '人群概览', value: '1' }, { text: '渠道投放分析', value: '2' }, { text: '消费者构成分析', value: '3' }] const selectedTab = loc.get('selectedTab') || tabs[0].value // 主营类目固定 const mainCates = [{ text: '女装/女士精品', value: '16' }] const mainCate = mainCates[0].value const viewMap = { 1: '@./overview', 2: '@./channel-analysis', 3: '@./customer-analysis' } this.updater.digest({ mainCates, mainCate, tabs, selectedTab }) const { beginDate, endDate, dateType, latelyDate } = await this.getDates() const { selectedIndicators, indicators } = await this.getIndicators() const { categoryName, categoryId } = await this.getMainCate() this.updater.digest({ latelyDate, dateType, indicators, categoryName, categoryId, viewMap, beginDate, endDate, selectedIndicators }) }, 'changeTab' (e) { const { selectedTab } = this.updater.get() Magix.Router.to({ selectedTab }) }, async 'changeDate' (e) { const { beginDate, endDate, dateType } = await this.getDates() this.updater.digest({ beginDate, endDate, dateType }) }, // 获取主营类目 async getMainCate () { try { const models = [{ name: 'api_report_maincat_get' }] 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 }) } }, // 获取日期 async getDates () { const vf = await this.waitVframeCreated(Magix.Vframe.get(`${this.id}_datePick`)) const dates = vf.invoke('getDates') return dates }, // 获取指标 async getIndicators () { const vf = await this.waitVframeCreated(Magix.Vframe.get(`${this.id}_indicatorPick`)) const inds = vf.invoke('getIndicators') return inds }, async 'changeInd' (e) { const { selectedIndicators } = await this.getIndicators() this.updater.digest({ selectedIndicators }) } })