import Magix from 'magix' import View from '../../../../view' Magix.applyStyle('@../detail.less') Magix.applyStyle('@./crowd-classify.less') export default View.extend({ tmpl: '@crowd-classify.html', init (options) { this.options = options this.observeLocation(['statusId', 'mbrType']) }, async render () { const loc = Magix.Router.parse() const { date, period, brandId, sceneType, brandsMap } = this.options const data = await this.getOverviewData() data.groupedList = this.grouped(data.list) const statusId = loc.get('statusId') || data.list[3]?.statusId // 默认选中第四个行动人群 const mbrType = loc.get('mbrType') || data.list[3]?.mbrType const matchStatus = data.list.find(item => { return item.statusId == statusId && item.mbrType == mbrType }) const statusName = matchStatus?.statusName // 推荐人群的 sceneType const recommendSceneTypeMap = { 1: '25', // 会员招募拉新 2: '26', // 会员首购引导 3: '27' // 会员复购引导 } const recommendSceneType = recommendSceneTypeMap[sceneType] this.updater.digest({ recommendSceneType, sceneType, statusName, mbrType, statusId, data, date, period, brandId, brandsMap }) }, async getOverviewData () { if (this.__data) { return this.__data } try { const { date, period, brandId, sceneType } = this.options const params = { date, period, brandId, sceneType } const models = [{ name: 'api_asset_deeplink_member_overview_get', params }] const [model] = await this.fetch(models) const data = model.get('data', {}) this.__data = data return data } catch (error) { this.alert('错误提示', error.msg || error.message || error) } }, grouped (list) { const _map = {} const result = [] for (const item of list) { if (_map[item.aiplKey]) { _map[item.aiplKey].push(item) } else { _map[item.aiplKey] = [item] result.push(_map[item.aiplKey]) } } return result }, 'selectStatusId' (e) { const { item } = e.params const { statusId, disable, mbrType } = item if (disable) { return } Magix.Router.to({ statusId, mbrType }) // this.updater.digest({ // statusName, // statusId, // mbrType // }) } })