import Magix from 'magix' import * as View from '../../../../view' Magix.applyStyle('@./create-item-crowd.less') Magix.applyStyle('@../create.less') const EMPTY_SYMBOL = '--' export default View.extend({ tmpl: '@crowd-set.html', init (options) { this.options = options }, render () { // const loc = Magix.Router.parse() this.updater.digest({ isIndustry: this.options.isIndustry, predictApi: this.options.predictApi, coverage: EMPTY_SYMBOL, EMPTY_SYMBOL, coverageLoading: false // 原始预估loading }) this.mountPredict() }, getParams () { return this.owner.parent().invoke('getParams') }, async getCoverage () { try { const marker = Magix.mark(this, 'getCoverage') const params = this.getParams() if (!params || this.options.unusable) { this.updater.digest({ coverage: EMPTY_SYMBOL }) } else { const api = this.options.api || 'api_scenario_cluster_coverage_post' const models = [{ name: api, params, isJson: true }] this.updater.digest({ coverageLoading: true }) const [model] = await this.fetch(models) const data = model.get('data', {}) if (marker()) { this.updater.digest({ coverage: data.count, coverageLoading: false }) } } } catch (error) { this.updater.digest({ coverage: EMPTY_SYMBOL, coverageLoading: false }) console.error(error) // this.alert('错误提示', error.msg || error.message || error, null, { mask: true }) } this.mountPredict() }, 'changeCrowd' (e) { this.mountPredict() }, // 刷新下流量分析view mountPredict () { const id = `${this.id}_predict` const { unableAnalyse, predictApi } = this.updater.get() const _cateId = this._cateId const _keywords = this._keywords this.owner.mountVframe(id, '@../crowd-predict', { predictApi, isItem: true, unableAnalyse, selectedCateId: _cateId, keywords: _keywords, // 保存类目选择 callback: (cateId) => { this._cateId = cateId }, // 保存关键词选择 callbackKeywords: (keywords) => { this._keywords = keywords } }) } })