import Magix from 'magix' import * as View from '../../../../view' Magix.applyStyle('@./crowds-loop.less') const LINE_HEIGHT = 28 export default View.extend({ tmpl: '@crowds-loop.html', init(options) { this.options = options }, async render() { // 其他人创建的人群 const scrollTop = 0 const otherCrowds = await this.getData() // otherCrowds[0].createTime = '2020-09-08 20:00' this.updater.digest({ LINE_HEIGHT, scrollTop, otherCrowds }) // 轮播显示创建人的群 this.loopShowCrowds() }, // 轮播显示创建人的群 loopShowCrowds() { const { otherCrowds } = this.updater.get() this._index = 0 this._itv = setInterval(e => { if (this._stop) { return } const scrollTop = this._index * LINE_HEIGHT this.updater.digest({ scrollTop: -scrollTop }) this._index++ if (this._index >= otherCrowds.length) { this._index = 0 } }, 2000) }, async getData() { try { const { params: _params } = this.options const params = { bizCode: this.options.bizCode, orderByRecent: true, pageSize: 20 } if (_params) { Object.assign(params, _params) } const models = [ { name: 'appone_api_dmp_crowd_findJxTemplateUsage_get', params } ] const [model] = await this.fetch(models) const data = model.get('data.list', []) return data } catch (error) { this.alert('错误提示', error.msg || error.message || error, null, { mask: true }) } }, 'stopLoop'(e) { this._stop = true }, 'startLoop'(e) { this._stop = false }, 'gotoCreateCrowd'(e) { Magix.Router.to('/crowds-new/create', { selectTagOptionSet: JSON.stringify(e.params.selectTagOptionSet) }) }, 'gotoTmpl'(e) { this.options.callback(e.params.crowd.templateId) } })