const dayjs = require('dayjs') const licia = require('miniprogram-licia') const app = getApp() Page({ data: { id: '', detail: {} as any, LikeTimes: 0, starShow: false, }, onLoad(options) { this.setData({ id: options.id, }) app.waitLogin({type:2}).then(() => { this.handleView() }) }, handleView() { wx.ajax({ method: 'POST', url: '?r=wtx/doctor/knowledge/view', data: { Id: this.data.id, }, }).then(() => { this.getDetail() }) }, getDetail() { wx.ajax({ method: 'GET', url: '?r=wtx/doctor/knowledge/detail', data: { Id: this.data.id, }, }).then((res) => { res.UpdateTime = dayjs(res.UpdateTime).format('YYYY-MM-DD') this.setData({ detail: res, }) }) }, _timer: null as any, handleLike() { this.setData({ 'detail.LikeTimes': Number(this.data.detail.LikeTimes) + 1, 'detail.IsLike': true, LikeTimes: this.data.LikeTimes + 1, starShow: true, }) const header = this.selectComponent('#animate') header.start() if (this._timer) { clearInterval(this._timer) } this._timer = setTimeout(() => { this.setData({ starShow: false, }) }, 2000) this.likePost() }, likePost: licia.debounce(function (this: any) { const { id, LikeTimes } = this.data this.setData({ LikeTimes: 0, }) wx.ajax({ method: 'POST', url: '?r=wtx/doctor/knowledge/like', data: { Id: id, LikeTimes, }, }) }, 1000), onShareAppMessage() { this.setData({ 'detail.ShareTimes': Number(this.data.detail.ShareTimes) + 1, 'detail.IsShare': true, }) wx.ajax({ method: 'POST', url: '?r=wtx/doctor/knowledge/share', data: { Id: this.data.id }, }) }, }) export {}