import Magix from 'magix' import * as View from '../../../../view' Magix.applyStyle('@../../../spmtips.less') Magix.applyStyle('@./tips.less') const LOCALSTORAGE_KEY = '_dmp_tips_no_show' // localstorage的key // const EXPIRED_DAYS = 7 // 7天内不再提示 export default View.extend({ tmpl: '@tips.html', init (options) { this.options = options }, render () { // const { Moment, user } = this.updater.get() // const today = Moment() const spmTip = { show: localStorage[`${LOCALSTORAGE_KEY}_${this.options.content}`] != '1', width: this.options.width, type: this.options.type, tips: this.options.content } this.updater.digest({ tip: spmTip }) }, 'noShow' (e) { const { tip } = this.updater.get() tip.show = false // 7天内不再提示 // 状态存在localStorage里 // let expiredDays = Moment().add(EXPIRED_DAYS, 'days').format('YYYY-MM-DD') localStorage[`${LOCALSTORAGE_KEY}_${this.options.content}`] = '1' this.updater.digest({ tip }) }, 'close' (e) { const { tip } = this.updater.get() tip.show = false this.updater.digest({ tip }) } })