const app = getApp() // pages/story/a.ts Component({ /** * 组件的属性列表 */ properties: { detailId: { type: String, value: '0', }, asideOut: { type: Boolean, value: false, }, asideType: { type: String, value: '', }, timeToast: { type: Boolean, value: false, }, timeToastType: { type: String, value: '', }, timeToastParams: { type: Object, value() { return {} }, }, }, observers: { asideOut(asideOut) { if (asideOut) { setTimeout(() => { this.countDown() }, 1000) } }, }, lifetimes: { attached() { const systemInfo = wx.getSystemInfoSync() this.setData({ sliderTop: systemInfo.screenHeight - 250, }) }, detached() { if (this.timer) clearInterval(this.timer) }, }, data: { imageUrl: app.globalData.imageUrl, Timestamp: app.globalData.Timestamp, rewardScore: 0, circleVal: 100, centerVal: 9, sliderTop: 450, }, methods: { timer: null as any, countDown() { const that = this if (that.timer) return let circle = 100 that.timer = setInterval(() => { circle-- that.setData({ circleVal: circle, centerVal: Math.floor(circle / 10), }) if (circle <= 0) { clearInterval(that.timer) this.handleAsideOut() } }, 100) }, handleAsideOut() { wx.ajax({ method: 'POST', url: '?r=xd/score/send-score', data: { Type: this.data.asideType, Id: this.data.detailId, }, }).then((res) => { if (!Array.isArray(res)) { this.setData({ rewardScore: res.rewardScore, }) } }) }, }, })