import Magix from 'magix' import View from '../../../view' // import rankMixin from '../home/tag-recommend/tag-rank-mixin' import * as Helper from 'dmp-new/views/mixins/helper' import folderMixin from '../reports/crowds/tags-folder-mixin' Magix.applyStyle('@./recommend.less') // const ltKey = '_dmp_tag_recommend_rank_types' module.exports = View.extend({ tmpl: '@recommend.html', // mixins: [rankMixin], init (options) { this.options = options this.observeLocation(['filterUsed']) this.on('destroy', () => { $(window).off('scroll.tagRecommend') }) }, async render () { // const { all } = this.updater.get() const loc = Magix.Router.parse() const cates = await Helper.getCates(this) const _cateId = await Helper.getMainCate(this, cates) const cateId = _cateId const channels = await Helper.getChannels(this) channels.unshift({ text: '全部', value: '99' }) const channelId = channels[0].value // const rankPeriods = [{ // text: '周排行', // value: '1' // }, { // text: '半月排行', // value: '2' // }, { // text: '月排行', // value: '3' // }] // const featureTypes = [{ // text: '店铺潜客', // value: '1' // }, { // text: '店铺新客', // value: '2' // }, { // text: '店铺老客', // value: '3' // }] // let rankTypes = all.defaultRankTypes // //还原本地存储的榜单配置 // if (localStorage.getItem(all.rankTypeConfigKey)) { // rankTypes = localStorage.getItem(all.rankTypeConfigKey).split(',') // } const page = 1 const pageSize = 3 this.updater.set({ // rankTypesTotal: all.rankTypesTotal, page, pageSize }) // const rankTypes = this.getRankTypes() const rankTypes = [{ text: '拉新场景榜', value: '0', icon: 'https://img.alicdn.com/tfs/TB1fYwKjfzO3e4jSZFxXXaP_FXa-68-68.png', desc: '多场景人群拓新推荐', tips: '基于所选类目和渠道,提供不同场景下拉新标签及组合方案推荐,助力店铺全域扩新,拉新引流有妙招!', bg: 'https://img.alicdn.com/imgextra/i4/O1CN01KgWTfM1mlIcLJDqGl_!!6000000004994-2-tps-140-72.png', spmc: 'ld_acquisition' }, { text: '店铺用户运营榜', value: '1', icon: 'https://img.alicdn.com/tfs/TB16WObTKL2gK0jSZFmXXc7iXXa-68-68.png', desc: '店铺私域人群牢牢锁定', tips: '基于所选类目和渠道,提供店铺潜客、新客、老客组合投放人群,助力店铺全面提升人群转化!', bg: 'https://img.alicdn.com/imgextra/i2/O1CN0192pI5v1DAeN0AzL6S_!!6000000000176-2-tps-140-72.png', spmc: 'ld_retention' }, { text: '大促营销榜', value: '2', icon: 'https://img.alicdn.com/tfs/TB1Zzailj39YK4jSZPcXXXrUFXa-68-68.png', desc: '大促场景高效引流收割人群', tips: '基于不同大促时间场景,提供大促引流、大促收割人群,帮助店铺锁定活动优质高效人群。', bg: 'https://img.alicdn.com/imgextra/i2/O1CN01bHk4Le1H4TUls5Nnc_!!6000000000704-2-tps-140-72.png', spmc: 'ld_promotion' }] // const rankPeriod = rankPeriods[0].value const _filterUsed = loc.get('filterUsed') == '1' const filterUsed = loc.get('filterUsed') || '0' this.updater.digest({ selectedOptions: [], selectedCombinationKeys: [], rankTypes, // featureTypes, // featureType: featureTypes[0].value, filterUsed, _filterUsed, // rankPeriods, // rankPeriod, cateId, cates, channels, channelId }) if (cates && cates.length) { // 延迟300,侧菜单动画结束后 setTimeout(() => { // 计算好要吸顶的topbar的宽度 this.setTopBarWidth() // 吸顶处理 this.setBarTop() }, 300) } }, 'showQuestions' (e) { // 弹出反馈 // FeedBackLoader({ id: 4792, frequency: 'all' }) FeedBackLoader({ id: 4940, frequency: 'all', needMask: true }) }, // 计算好要吸顶的topbar的宽度 setTopBarWidth () { const { barWidth, barHeight } = this.updater.get() const width = barWidth || $(`#${this.id}_topbar`).width() const height = barHeight || $(`#${this.id}_topbar_wrap`).height() $(`#${this.id}_topbar`).width(width) $(`#${this.id}_topbar_wrap`).height(height) this.updater.set({ barWidth: width, barHeight: height }) }, setBarTop () { $(window).on('scroll.tagRecommend', () => setFixed.bind(this)()) setFixed.bind(this)() function setFixed () { const offset = $(`#${this.id}_topbar_wrap`).offset() if (offset) { if ($(window).scrollTop() > offset.top) { $(`#${this.id}_topbar`).addClass('@./recommend.less:top-bar-fixed') } else { $(`#${this.id}_topbar`).removeClass('@./recommend.less:top-bar-fixed') } } } }, // 选择数据指标 'selectIndex' (e) { const { all } = this.updater.get() this.mxDialog('@./tag-recommend/select-index', { rankTypes: this.updater.get('rankTypes'), callback: (rankTypes) => { window.localStorage.setItem(all.rankTypeConfigKey, rankTypes.join(',')) this.updater.digest({ rankTypes }) } }, { top: 100 }) }, 'hideUsedTags' (e) { const { _filterUsed } = this.updater.get() Magix.Router.to({ filterUsed: _filterUsed ? '1' : '0' }) }, 'changeChannel' (e) { const { channelId } = this.updater.get() Magix.Router.to({ channelId }) }, 'changeCate' (e) { const { cateId } = this.updater.get() Magix.Router.to({ cateId }) }, 'showTagsFolder' (e) { const { selectedOptions } = this.updater.get() const viewPath = '@../reports/crowds/tags-folder' const viewOptions = { selectedOptions, callback: (_selectedOptions) => { const selectedCombinationKeys = [] // 已选中的标签的combinationKeyId // for (const set of _selectedOptions) { for (const select of set.selects) { if (!selectedCombinationKeys.includes(select.combinationKeyId)) { selectedCombinationKeys.push(select.combinationKeyId) } } } this.updater.digest({ selectedOptions: _selectedOptions, selectedCombinationKeys }) // 计算好要吸顶的topbar的宽度 this.setTopBarWidth() // 吸顶处理 this.setBarTop() // 处理子view的已添加状态,手动invoke子view的方法来更新状态,以避免页面重刷 this.setSelected() } } const dialogOptions = { top: 100, width: 500 } this.mxDialog(viewPath, viewOptions, dialogOptions) }, // 添加标签到标签夹 addTag (selected, feat) { const { selectedOptions, selectedCombinationKeys } = this.updater.get() const maxCount = 5 // 已选择的特征 selectedCombinationKeys.push(feat.combinationKeyId) if (selectedOptions.length >= maxCount && folderMixin.checkExcludeTags(selected, selectedOptions)) { this.gmessage({ msg: `最多添加 ${maxCount} 个标签条件`, timeout: 2000, type: 'error' }) return } for (const option of selected) { folderMixin.getCommonSelected(selectedOptions, option, feat.combinationKeyId) } this.gmessage({ msg: `标签 ${feat.tag.tagName} 添加成功,请到标签夹中查看`, timeout: 2000 }) this.updater.digest({ selectedOptions, selectedCombinationKeys }) // 计算好要吸顶的topbar的宽度 this.setTopBarWidth() // 吸顶处理 this.setBarTop() // 处理子view的已添加状态,手动invoke子view的方法来更新状态,以避免页面重刷 this.setSelected() }, // 处理子view的已添加状态,手动invoke子view的方法来更新状态,以避免页面重刷 setSelected () { const { selectedCombinationKeys, rankTypes } = this.updater.get() // 精选推荐 const choicenessView = Magix.Vframe.get('choicenessView') choicenessView.invoke('setSelected', [selectedCombinationKeys]) // 排行榜 rankTypes.forEach((rank, i) => { const rankView = Magix.Vframe.get(`rankView${i}`) rankView.invoke('setSelected', [selectedCombinationKeys]) }) }, 'changeSystemRecommend' (e) { this.updater.digest() // 计算好要吸顶的topbar的宽度 this.setTopBarWidth() // 吸顶处理 this.setBarTop() } })