const app = getApp() import { calc } from 'a-calc' Page({ data: { injectionDate: '', injectionWeight: '', injectionDrugs: '', injectionNum: '', }, onLoad() { app.waitLogin().then(() => { this.getDetail() }) }, handleWeight(e) { const value = e.detail.value if (value) { const injectionDrugs = calc(`${value} * 1.25 | =0 ~+`) const injectionNum = calc(`${value} * 1.25 / 2 | =0 ~+`) this.setData({ injectionDrugs, injectionNum, }) } }, handleChangeDate(e) { const value = e.detail.value wx.ajax({ method: 'POST', url: '?r=wtx/treatment/save-injection-date', data: { injectionDate: value, }, }).then((res) => { console.log('res: ', res) }) }, getDetail() { wx.ajax({ method: 'GET', url: '?r=wtx/treatment/get-injection-info', data: {}, }).then((res) => { this.setData({ ...res, injectionDate: res.injectionDate || '', }) }) }, handleBack() { wx.navigateBack() }, handleSubmit() { const { injectionDate, injectionWeight } = this.data if (!injectionDate) { wx.showToast({ title: '请选择输注时间', icon: 'none', }) return } if (!injectionWeight) { wx.showToast({ title: '请输入体重', icon: 'none', }) return } wx.ajax({ method: 'POST', url: '?r=wtx/treatment/save-injection-info', data: { injectionWeight, }, }).then(() => { wx.navigateBack() }) }, }) export {}