|
|
|
import dayjs from 'dayjs'
|
|
|
|
|
|
|
|
const licia = require('miniprogram-licia')
|
|
|
|
const app = getApp<IAppOption>()
|
|
|
|
|
|
|
|
Page({
|
|
|
|
data: {
|
|
|
|
calendarConfig: {
|
|
|
|
multi: false,
|
|
|
|
hideSelectYear: true,
|
|
|
|
markToday: '今', // 当天日期展示不使用默认数字,用特殊文字标记
|
|
|
|
firstDayOfWeek: 'Mon',
|
|
|
|
theme: 'geneb',
|
|
|
|
takeoverTap: true,
|
|
|
|
highlightToday: true,
|
|
|
|
onlyShowCurrentMonth: true,
|
|
|
|
disableMode: {
|
|
|
|
type: 'after', // [‘before’, 'after']
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
endGif: false,
|
|
|
|
gifPath: `${app.globalData.imageUrl}gif2.gif?t=${app.globalData.Timestamp}`,
|
|
|
|
|
|
|
|
injectionDate: '',
|
|
|
|
injectionDateName: '',
|
|
|
|
},
|
|
|
|
onLoad() {
|
|
|
|
this.loadGifImage()
|
|
|
|
app.waitLogin({ type: 1 }).then(() => {
|
|
|
|
this.getDetail()
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getDetail() {
|
|
|
|
wx.ajax({
|
|
|
|
method: 'GET',
|
|
|
|
url: '?r=wtx/treatment/get-injection-date',
|
|
|
|
data: {},
|
|
|
|
}).then((res) => {
|
|
|
|
if (res.injectionDate) {
|
|
|
|
const [year, month, date] = dayjs(res.injectionDate).format('YYYY-MM-DD').split('-')
|
|
|
|
const calendar = this.selectComponent('#calendar').calendar
|
|
|
|
calendar.setSelectedDates([
|
|
|
|
{
|
|
|
|
year,
|
|
|
|
month,
|
|
|
|
date,
|
|
|
|
},
|
|
|
|
])
|
|
|
|
this.setData({
|
|
|
|
injectionDate: res.injectionDate,
|
|
|
|
injectionDateName: dayjs(res.injectionDate).format('YYYY年MM月DD日 ddd'),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
takeoverTap(e) {
|
|
|
|
const { year, month, date } = e.detail
|
|
|
|
const injectionDate = dayjs(`${year}-${month}-${date}`).format('YYYY-MM-DD')
|
|
|
|
const injectionDateName = dayjs(`${year}-${month}-${date}`).format('YYYY年MM月DD日 ddd')
|
|
|
|
const calendar = this.selectComponent('#calendar').calendar
|
|
|
|
calendar.cancelSelectedDates()
|
|
|
|
calendar.setSelectedDates([
|
|
|
|
{
|
|
|
|
year,
|
|
|
|
month,
|
|
|
|
date,
|
|
|
|
},
|
|
|
|
])
|
|
|
|
this.setData({
|
|
|
|
injectionDate,
|
|
|
|
injectionDateName,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
loadGifImage() {
|
|
|
|
wx.preloadAssets({
|
|
|
|
data: [
|
|
|
|
{
|
|
|
|
type: 'image',
|
|
|
|
src: `${app.globalData.imageUrl}gif2.gif?t=${app.globalData.Timestamp}`,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
success: () => {
|
|
|
|
wx.getImageInfo({
|
|
|
|
src: `${app.globalData.imageUrl}gif2.gif?t=${app.globalData.Timestamp}`,
|
|
|
|
success: (res) => {
|
|
|
|
this.setData({
|
|
|
|
gifPath: res.path,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
})
|
|
|
|
},
|
|
|
|
})
|
|
|
|
},
|
|
|
|
handleBack() {
|
|
|
|
wx.navigateBack()
|
|
|
|
},
|
|
|
|
handleSubmit() {
|
|
|
|
const { injectionDate } = this.data
|
|
|
|
|
|
|
|
if (!injectionDate) {
|
|
|
|
wx.showToast({
|
|
|
|
title: '请选择注射日期',
|
|
|
|
icon: 'none',
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
wx.ajax({
|
|
|
|
method: 'POST',
|
|
|
|
url: '?r=wtx/treatment/save-injection-date',
|
|
|
|
data: {
|
|
|
|
injectionDate,
|
|
|
|
},
|
|
|
|
}).then(() => {
|
|
|
|
this.setData({
|
|
|
|
endGif: true,
|
|
|
|
})
|
|
|
|
setTimeout(() => {
|
|
|
|
wx.navigateBack()
|
|
|
|
}, 3000)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
export {}
|