const app = getApp() Component({ properties: { show: { type: Boolean, value: false, }, type: String, params: { type: Object, value() { return {} }, }, }, observers: { show(val) { if (val) { app.getTheme().then((res) => { this.setData({ theme: res, }) }) if (this.data.params.timeOut) { let time = this.data.params.timeOut const timerFunc = () => { if (time <= 0) { this.setData({ timeOut: '', }) clearInterval(this.timer) return } this.setData({ timeOut: `${time}s`, }) --time } timerFunc() this.timer = setInterval(timerFunc, 1000) } if (['storyLead', 'storyStar', 'storyShare'].includes(this.data.type)) { this.getSettingInfo() } } this.setData({ userInfo: app.globalData.userInfo, }) }, type(val) { if (val === 'healthCare') { this.getOpenPatientList() } }, }, data: { imageUrl: '', protocol: true, timeOut: '', settingsInfo: {}, userInfo: {}, openPatientList: {}, }, lifetimes: { attached() { this.setData({ imageUrl: app.globalData.imageUrl, Timestamp: app.globalData.Timestamp, }) }, }, methods: { timer: null as any, handleOk() { if (this.data.timeOut) { return } this.triggerEvent('ok', { protocol: this.data.protocol }) }, handleCancel(e = { currentTarget: { dataset: { key: '' } } }) { const { key } = e.currentTarget.dataset if (this.timer) { clearInterval(this.timer) this.setData({ timeOut: '', }) } this.triggerEvent('cancel', { key }) }, handleTaskCancel() { this.triggerEvent('taskCancel') }, handleJump() { this.triggerEvent('jump') }, handleDel() { this.triggerEvent('del') }, routerTo(e) { const { path } = e.currentTarget.dataset wx.navigateTo({ url: path, }) this.handleCancel() }, getSettingInfo() { wx.ajax({ method: 'GET', url: '?r=xd/drugs/setting-info', data: {}, }).then((res) => { this.setData({ settingsInfo: res, }) }) }, getOpenPatientList() { wx.ajax({ method: 'GET', url: '?r=xd/nrdl/open-patient-list', data: {}, }).then((res) => { this.setData({ openPatientList: res, }) }) }, handleProtocolChange() { this.setData({ protocol: !this.data.protocol, }) }, handleAdlQuestion() { wx.navigateTo({ url: '/pages/repositoryDetail/index?id=9', }) }, }, })