// 网络请求工具类
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:'1月11日',
yearText:'2017',
todayInfo:'',
// 是否建档
subscribe:false,
flag: false,
// 问诊信息
wzInfo:'',
// 预约详细信息
subscribeDetails:''
},
onLoad: function (option) {
var date1 = new Date('2017-1-8')
console.log('date1', date1)
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 --
if (index < 0) {
index = this.data.dateList.length - 1
}
this.changeDateWithIndex(index)
},
toAfter() {
var index = this.data.dateIndex
index++
if (index >= this.data.dateList.length){
index = 0
}
this.changeDateWithIndex(index)
},
clickDate(e){
this.changeDateWithIndex(e.detail.value)
},
// 查看预约建档
lookSubscribe(){
this.setData({ flag: true })
},
// 关闭预约建档
closeMask(){
this.setData({ flag: false })
},
// 通过日期列表下标改变日期文字
changeDateWithIndex(index){
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.data.data)
if (res.data.data[0].checkTime.length > 0){
self.setData({
dateList: res.data.data[0].checkTime
})
self.changeDateWithIndex(0)
}
}, 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)
}
})