import Magix from 'magix' import * as View from '../../../view' Magix.applyStyle('@./crowds-loop.less') export default View.extend({ tmpl: '@crowds-loop.html', init (options) { this.options = options }, async render () { clearInterval(this._itv) // const loc = Magix.Router.parse() // const { Moment } = this.updater.get() // 其他人创建的人群 const scrollTop = 0 const otherCrowds = await this.getData() // otherCrowds[0].createTime = '2020-09-08 20:00' this.updater.digest({ 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 * 18 this.updater.digest({ scrollTop: -scrollTop }) this._index++ if (this._index >= Math.ceil(otherCrowds.length / 3)) { this._index = 0 } }, 3000) }, async getData () { try { const models = [{ name: 'api_crowd_promotion_roll_get' }] const [model] = await this.fetch(models) const data = model.get('data.list', []) return data } catch (error) { console.error('错误提示', error.msg || error.message || error) return [] } }, 'stopLoop' (e) { this._stop = true }, 'startLoop' (e) { this._stop = false } // 'gotoCreateCrowd' (e) { // // Magix.config({ // // selectTagOptionSet: e.params.selectTagOptionSet // // }) // Magix.Router.to('/crowds-new/create', { // selectTagOptionSet: JSON.stringify(e.params.selectTagOptionSet), // $DOUBLE11_PROMOTION_ROLL_CROWD: '1' // 打标 // }) // } })