import Magix from 'magix' import View from '../../../../view' Magix.applyStyle('@./compete-coverage.less') const BLOCK_HEIGHT = 100 // 每一块的高度 const BLOCK_GAP = 10 export default View.extend({ tmpl: '@compete-coverage.html', init (options) { this.options = options }, async render () { // const loc = Magix.Router.parse() const data = this.options.competeData this.updater.digest({ BLOCK_HEIGHT, BLOCK_GAP, data, svgHeight: data?.finalCrowdList?.length * BLOCK_HEIGHT + (data?.finalCrowdList?.length - 1) * BLOCK_GAP }) this.renderFlowSvg() }, renderFlowSvg () { const { data, svgHeight } = this.updater.get() const svgWidth = $(`#${this.id}_svg`).outerWidth() const curveLeft = svgWidth / 7 // 曲线转折点的横坐标 const lineLeft = svgWidth / 1 // 曲线后跟直线的起始横坐标 const blockWholeHeight = BLOCK_HEIGHT + BLOCK_GAP const hafBlockHeight = BLOCK_HEIGHT / 2 data.finalCrowdList.forEach((item, i) => { const endPos = hafBlockHeight + i * blockWholeHeight // Y轴结束位置 const svgConfig = { // svg画图path配置 d: `M 0 ${svgHeight / 2} Q ${curveLeft} ${endPos} ${lineLeft} ${endPos} L ${svgWidth} ${endPos}`, lineWidth: 5 // 默认粗细 } item.svgConfig = svgConfig }) this.updater.digest({ data }) }, // 直接投放 async 'createCrowd' (e) { const { data } = this.updater.get() const { virtualId, crowd } = e.params // parent view: ./status-no-deepen crowd.loading = true this.updater.digest({ data }) const { selectTagOptionSet, extra } = await this.owner.parent().invoke('dumpCrowd', [virtualId, 2]) crowd.loading = false this.updater.digest({ data }) const viewPath = 'dmp-new/views/pages/crowds-new/crowd-set' const viewOptions = { // crowdName: crowd.name, 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 'mixCrowd' (e) { const { data } = this.updater.get() const { virtualId, crowd } = e.params // parent view: ./status-no-deepen crowd.loadingMore = true this.updater.digest({ data }) const { selectTagOptionSet, extra } = await this.owner.parent().invoke('dumpCrowd', [virtualId, 3]) crowd.loadingMore = false this.updater.digest({ data }) const jumpParams = { selectTagOptionSet: JSON.stringify(selectTagOptionSet) // crowdName: crowd.name } // 创建人群的额外埋点信息,由后端返回,拼格式为 $xxxx=xxx if (extra) { for (const key in extra) { jumpParams[`$${key}`] = extra[key] } } Magix.Router.to('/crowds-new/create', jumpParams) } })