import Magix from 'magix' import View from '../../../../view' Magix.applyStyle('@./overview.less') const PERMEATE_ID = 'deeplinkSubdividePermeateAnalysis' export default View.extend({ tmpl: '@overview.html', init(options) { this.options = options this.observeLocation(['benchmarkSubdivide']) }, async render() { const loc = Magix.Router.parse() const benchmarkSubdivide = loc.get('benchmarkSubdivide') === 'true' this.updater.set({ benchmarkSubdivide, params: this.options }) const data = await this.getData() this.updater.digest({ data }) if (benchmarkSubdivide) { await this.renderBenchmark() } }, // 加载本店数据 async getData() { const data = await this.getOriginData('0') const { benchmarkSubdivide } = this.updater.get() if (benchmarkSubdivide) { data.benchmarkLoading = true } return data }, // 加载同行标杆数据 async renderBenchmark() { const { benchmarkId } = this.options const dataBenchmark = await this.getOriginData('1', benchmarkId) const { data } = this.updater.get() const benchmarkKeys = ['assetSeepRate', 'assetDeepenRate'] for (const key of benchmarkKeys) { data[`${key}Benchmark`] = dataBenchmark[key] } data.benchmarkLoading = false this.updater.digest({ data }) }, // 获取数据,benchmark=0:本店,benchmark=1:同行 async getOriginData(benchmark, benchmarkId) { try { const { brandId, analyseCrowd = {} } = this.options const params = { brandId, crowdId: analyseCrowd.crowdId, benchmark, benchmarkId } const models = [ { name: 'api_asset_deeplink_market_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) } }, 'toggle'(e) { const { benchmarkSubdivide } = this.updater.get() Magix.Router.to({ benchmarkSubdivide }) }, // 查看已渗透资产加深情况 'checkSeep'(e) { Magix.Router.to({ permeateAnalysisType: '1' }) document.getElementById(PERMEATE_ID).scrollIntoView({ behavior: 'smooth' }) }, // 查看未渗透市场机会 'checkNoSeep'(e) { Magix.Router.to({ permeateAnalysisType: '2' }) document.getElementById(PERMEATE_ID).scrollIntoView({ behavior: 'smooth' }) }, async 'createCrowd'(e) { this.updater.digest({ loading: true }) // parent view: ./status-no-deepen const { selectTagOptionSet, extra } = await this.dumpCrowd() this.updater.digest({ loading: false }) const viewPath = 'dmp-new/views/pages/crowds-new/crowd-set' const viewOptions = { hasAdjust: true, // 是否有规模调节模块 scaleType: 0, selectTagOptionSet, callback: () => { this._alert('提示', '恭喜,人群创建成功') } } // 创建人群的额外埋点信息,由后端返回,拼格式为 $xxxx=xxx if (extra) { for (const key in extra) { viewOptions[`$${key}`] = extra[key] } } const dialogOptions = { top: 100, width: 500 } this.mxDialog(viewPath, viewOptions, dialogOptions) }, async dumpCrowd() { const { analyseCrowd = {}, brandId } = this.options const { crowdId } = analyseCrowd const selectTagOptionSetKey = `__selectTagOptionSet_${crowdId}_${brandId}` try { if (this[selectTagOptionSetKey]) { return this[selectTagOptionSetKey] } const params = this.getParams() const models = [ { name: 'api_asset_deeplink_crowd_dump_post', isJson: true, params } ] const [model] = await this.fetch(models) const data = model.get('data', {}) this[selectTagOptionSetKey] = data return data } catch (error) { this._alert('错误提示', error.msg || error.message || error) } }, getParams() { const { brandId, bizDate, startDate, dateType, analyseCrowd = {} } = this.options const { crowdId, crowdType } = analyseCrowd const params = { brandId, bizDate, dateType, dataType: 'market', crowdId, crowdType, // 场景ID 1-市场未渗透人群、2-竞品覆盖直接投放、3-竞品覆盖叠加更多特征、4-圈选流转人群叠加更多特征、5-一键投放时导出 sceneId: 1 } if (dateType == '4') { params.startDate = startDate } return params } })