import Magix from 'magix' import View from '../../../view' Magix.applyStyle('@./distribute.less') export default View.extend({ tmpl: '@distribute.html', init(options) { this.options = options this.observeLocation([ 'brandId', 'statusId', 'dateType', 'startDate', 'bizDate', 'benchmark', 'benchmarkId' ]) }, async render() { const loc = Magix.Router.parse() // const benchmark = loc.get('benchmark') === 'true' const benchmarkChannel = loc.get('benchmarkChannel') === 'true' this.updater.digest({ loading: true, benchmark, benchmarkChannel, topBarCallback: async dataObj => { this.updater.set({ ...dataObj }) // dataObj: 接口相关入参参数都在dataObj里 if (!dataObj.brandId) { return this.updater.digest({ loading: false }) } // 概览数据 const data = await this.getData() this.updater.digest({ data, loading: false }) } }) }, async getData() { return await this.getOverviewData('0') }, async getOverviewData(benchmark) { try { const { bizDate, dateType, brandId, startDate } = this.updater.get() const params = { brandId, dateType, bizDate, benchmark } // 累计有起始日期 if (dateType == '4') { params.startDate = startDate } const models = [ { name: 'api_asset_deeplink_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) } }, 'createCrowd'(e) { const viewPath = 'dmp-new/views/pages/deeplink/create-crowd' const { brandsMap, brandId, dateType, startDate, bizDate, statusId } = this.updater.get() const viewOptions = { brand: brandsMap[brandId], dateType, startDate, bizDate, statusId, createType: 1 // 创建入口,1:圈人浮层,2:渠道投放,3:流转圈人浮层,4:流转贡献圈人 } const dialogOptions = { header: { title: '圈选品牌 DEEPLINK 资产人群' }, footer: { enter: false, cancel: false }, width: 736 } this.mxModal(viewPath, viewOptions, dialogOptions) }, 'toggle'(e) { const { benchmark } = this.updater.get() Magix.Router.to({ benchmark }) }, 'toggleChannel'(e) { const { benchmarkChannel } = this.updater.get() Magix.Router.to({ benchmarkChannel }) }, getParams() { const { brandId, bizDate, startDate, dateType, statusId } = this.updater.get() const transferData = statusId.toString() // 资产分布圈人 const params = { brandId, bizDate, dateType, dataType: 'uv', transferData } if (dateType == '4') { params.startDate = startDate } return params }, // 跳向洞察页面 async 'gotoInsight'(e) { try { const params = this.getParams() this.updater.digest({ customLoading: true }) const models = [ { name: 'api_asset_deeplink_crowd_dump_post', isJson: true, params } ] const [model] = await this.fetch(models) const id = model.get('data.id').toString() // const { all, statusIdsMap } = this.updater.get() const crowdName = statusIdsMap[params.transferData].text const selectTagOptionSet = $.extend(true, {}, all.selectTagOptionSet_412) // deeplink 人群拼特定标签结构,前往洞察页面 const deeplinkSelects = [ { tagId: all.DEEPLINK_TAG_ID, optionGroupId: all.DEEPLINK_OPTIONGROUP_ID, values: id, names: crowdName } ] selectTagOptionSet.selectTagOptionSet[0].selectTagOptionSet[0].selectTagOptionSet = [ { selects: deeplinkSelects } ] Magix.Router.to( `/insight-new/perspective?selectTagOptionSet=${JSON.stringify( selectTagOptionSet )}&crowdName=${crowdName}` ) } catch (error) { this._alert('错误提示', error.msg || error.message || error) } this.updater.digest({ customLoading: false }) } })