const app = getApp() const licia = require('miniprogram-licia') Page({ data: { id: '', CateId: '', index: 0 as string | number, detail: {} as any, HistoryId: '', starShow: false, asideOut: false, asideType: '7', timeToast: false, timeToastType: '', timeToastParams: { rewardScore: 0, }, saveLock: false, starLock: false, shareLock: false, sendShare: false, // TODO:后期需补充逻辑,根据获取积分情况控制显隐 showTip: false, }, onLoad(options) { const { id } = options this.setData({ id, }) app.zdWaitLogin().then(() => { this.getDetail(true) }) }, onShow() { app.zdMpBehavior({ PageName: 'PG_PATIENTKNOWLEDGEDETAILS' }) if (this.data.sendShare) { this.setData({ sendShare: false, timeToastType: '9', }) this.handleTimeOut() } }, onHide() { if (this._time) { clearInterval(this._time) } }, onUnload() { if (this._time) { clearInterval(this._time) } }, getDetail(view = false) { wx.ajax({ method: 'GET', url: '?r=xd/pic-text/detail', data: { Id: this.data.id, }, }).then(async (res) => { res.Content = await this.formatVideo(res.Content) this.setData({ detail: res, }) if (view) { let asideOut = false if (res.CanGetScore) { asideOut = true } this.setData({ asideOut, }) this.saveView() } }) }, formatVideo(Content) { return new Promise((reslove) => { const query = wx.createSelectorQuery() query .select('#mp-html') .boundingClientRect((rect) => { const mpWidth = rect.width const reg = /]*)width="(.*?)".*?height="(.*?)".*?>/g Content = Content.replace(reg, (match, otherAttributes, width, height) => { if (!isNaN(Number(width)) && !isNaN(Number(height))) { return `