// 网络请求工具类
var networkUtil = require('../../utils/network_util.js')
var api = require('../../utils/apiFile.js')
var util = require('../../utils/util.js')
var event = require('../../utils/event.js')
Page({
data: {
dateList: {},
isShowOne: false,
isShowTwo: false,
isShowThree: false,
// 用户信息
userData:{},
// 时间下标
dateIndex:0,
monthText:'-',
yearText:'-',
todayInfo:'',
// 是否建档
subscribe:false,
flag: false,
// 问诊信息
wzInfo:'',
// 预约详细信息
subscribeDetails:'',
isShowLeft: true,
isShowRight: false,
// 没数据
noData: 'no'
},
onLoad: function (option) {
this.setData({
userData: getApp().globalData.userInfo
})
networkUtil.showLoading()
this.getCheckList()
},
isShowMore: function (e) {
var self = this
var index = e.currentTarget.dataset.index
if (index == 1) {
self.setData({
isShowOne: !self.data.isShowOne,
isShowTwo: false,
isShowThree: false,
})
} if (index == 2) {
if (!self.data.wzInfo.handlSuggest){
return
}
self.setData({
isShowOne: false,
isShowTwo: !self.data.isShowTwo,
isShowThree: false,
})
} if (index == 3) {
if (!self.data.wzInfo.guideSuggest) {
return
}
self.setData({
isShowOne: false,
isShowTwo: false,
isShowThree: !self.data.isShowThree,
})
}
},
toBefore(){
var index = this.data.dateIndex
index --
console.log('index',index)
var left = true
var right = true
if (index == 0) {
left = false
}
this.setData({
isShowLeft: left,
isShowRight : right
})
this.changeDateWithIndex(index)
},
toAfter() {
var index = this.data.dateIndex
index++
console.log('index', index)
var left = true
var right = true
if (index == this.data.dateList.length - 1){
right = false
}
this.setData({
isShowLeft: left,
isShowRight: right
})
this.changeDateWithIndex(index)
},
clickDate(e){
var left = true
var right = true
if (e.detail.value == this.data.dateList.length - 1) {
right = false
}
if (e.detail.value == 0) {
left = false
}
this.setData({
isShowLeft: left,
isShowRight: right
})
this.changeDateWithIndex(e.detail.value)
},
// 查看预约建档
lookSubscribe(){
this.setData({ flag: true })
},
// 关闭预约建档
closeMask(){
this.setData({ flag: false })
},
// 通过日期列表下标改变日期文字
changeDateWithIndex(index){
if (this.data.dateList.length == 0){
return
}
var text = this.data.dateList[index]
this.setData({
dateIndex: index,
yearText: this.setDateYearText(text),
monthText: this.setDateMonthText(text)
})
networkUtil.showLoading()
this.getCheckDetails()
this.getWzXinxi()
},
getCheckList() {
var self = this
// 列表
networkUtil._get(api.checkList,{}, function (res) {
console.log('获取时间信息', res)
var showLeft = true
if (res.data.data.length > 0 && res.data.data[0].checkTime.length > 0){
// 只有一条数据两个圈圈都不显示
if (res.data.data[0].checkTime.length == 1){
showLeft = false
}
self.setData({
dateList: res.data.data[0].checkTime.reverse(),
isShowLeft:showLeft,
noData: false
})
self.changeDateWithIndex(res.data.data[0].checkTime.length - 1)
} else {
self.setData({
noData:true
})
}
}, function (res) {
})
},
getCheckDetails() {
var self = this
var params = {}
params.patientId = getApp().globalData.userId[0]
// params.patientId = 88635
params.checkTime = this.data.dateList[this.data.dateIndex]
// 获取当天信息
networkUtil._get(api.checkDetails, params, function (res) {
console.log('获取当天信息', res)
var subscribe = false
var subscribeDetail = {}
// 下次产检信息
if (res.data.data && res.data.data.nextcheck && res.data.data.nextcheck.length > 0){
subscribe = true
subscribeDetail.checkhospital = res.data.data.checkhospital
subscribeDetail.nextcheck = res.data.data.nextcheck
}
self.setData({
todayInfo: res.data.data,
subscribe: subscribe,
subscribeDetails: subscribeDetail
})
}, function (res) {
})
},
getWzXinxi() {
var self = this
var params = {}
params.patientId = getApp().globalData.userId[0]
// params.patientId = 88635
params.checkTime = this.data.dateList[this.data.dateIndex]
params.page = 0
params.limit = 30
// 具体检查信息
networkUtil._get(api.wzXinxi, params, function (res) {
console.log('获取详细信息', res)
if (res.data.diagnose && res.data.diagnose.length > 0) {
res.data.diagnose = res.data.diagnose.split(",")
}
self.setData({
wzInfo: res.data
})
}, function (res) {
})
},
setDateYearText(text){
return text.substr(0, 5)
},
setDateMonthText(text) {
return text.substring(5, text.length)
}
})