From 9faca9dec7d6c261d939456672abf59a8d41e5a3 Mon Sep 17 00:00:00 2001 From: luoye <397379429@qq.com> Date: Wed, 16 Aug 2017 15:31:06 +0800 Subject: [PATCH] =?UTF-8?q?pid=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- littleApp_child/pages/CheckReport/CheckReport.js | 60 ++++++++++++---- littleApp_child/pages/CheckReport/CheckReport.wxml | 2 +- littleApp_child/pages/checkTabList/checkTabList.js | 12 +--- littleApp_child/utils/network_util.js | 81 +--------------------- 4 files changed, 51 insertions(+), 104 deletions(-) diff --git a/littleApp_child/pages/CheckReport/CheckReport.js b/littleApp_child/pages/CheckReport/CheckReport.js index 38c8004..0693019 100644 --- a/littleApp_child/pages/CheckReport/CheckReport.js +++ b/littleApp_child/pages/CheckReport/CheckReport.js @@ -28,7 +28,11 @@ Page({ isShowLeft: true, isShowRight: false, // 没数据 - noData: 'no' + noData: 'no', + // 获取到的所以patent数据 + allPatient:[], + // 当前的pid + currentPID:'' }, onLoad: function (option) { this.setData({ @@ -130,14 +134,19 @@ Page({ // 通过日期列表下标改变日期文字 changeDateWithIndex(index){ var text = this.data.dateList[index] + var patientId = this.getPatientIdWithDateStr(text) + if (!patientId){ + return + } this.setData({ dateIndex: index, yearText: this.setDateYearText(text), - monthText: this.setDateMonthText(text) + monthText: this.setDateMonthText(text), + currentPID:patientId }) networkUtil.showLoading() - this.getCheckDetails() - this.getWzXinxi() + this.getCheckDetails(patientId) + this.getWzXinxi(patientId) }, // 获取检查日期列表 getCheckList() { @@ -146,17 +155,26 @@ Page({ networkUtil._get(api.checkList, { patientId: getApp().globalData.userId[0]}, function (res) { console.log('获取时间信息', res) var showLeft = true - if (res.data.data.length > 0 && res.data.data[0].checkTime.length > 0){ + + // 先遍历所有时间 存放 + var allCheckTimeArr = [] + res.data.data.map(function (item) { + var checkTimeArr = item.checkTime + allCheckTimeArr = allCheckTimeArr.concat(checkTimeArr) + }) + + if (allCheckTimeArr.length > 0){ // 只有一条数据两个圈圈都不显示 - if (res.data.data[0].checkTime.length == 1){ + if (allCheckTimeArr.length == 1) { showLeft = false - } + } self.setData({ - dateList: res.data.data[0].checkTime.reverse(), + dateList: allCheckTimeArr.reverse(), isShowLeft:showLeft, - noData: false + noData: false, + allPatient: res.data.data }) - self.changeDateWithIndex(res.data.data[0].checkTime.length - 1) + self.changeDateWithIndex(allCheckTimeArr.length - 1) } else { self.setData({ noData:true @@ -167,10 +185,10 @@ Page({ }) }, // 依据时间获取当天检查信息 - getCheckDetails() { + getCheckDetails(patientId) { var self = this var params = {} - params.patientId = getApp().globalData.userId[0] + params.patientId = patientId // params.patientId = 88635 params.checkTime = this.data.dateList[this.data.dateIndex] // 获取当天信息 @@ -194,10 +212,10 @@ Page({ }) }, // 获取问诊信息 - getWzXinxi() { + getWzXinxi(patientId) { var self = this var params = {} - params.patientId = getApp().globalData.userId[0] + params.patientId = patientId // params.patientId = 88635 params.checkTime = this.data.dateList[this.data.dateIndex] params.page = 0 @@ -222,8 +240,20 @@ Page({ // 设置月 日文字 setDateMonthText(text) { return text.substring(5, text.length) + }, + // 通过时间获取id + getPatientIdWithDateStr(dateStr){ + var pid = null + this.data.allPatient.map(function(item){ + console.log(item) + item.checkTime.map(function (str) { + if(dateStr == str){ + pid = item.patientId + } + }) + }) + return pid } - }) diff --git a/littleApp_child/pages/CheckReport/CheckReport.wxml b/littleApp_child/pages/CheckReport/CheckReport.wxml index 05991b8..4e0a766 100644 --- a/littleApp_child/pages/CheckReport/CheckReport.wxml +++ b/littleApp_child/pages/CheckReport/CheckReport.wxml @@ -42,7 +42,7 @@ - + diff --git a/littleApp_child/pages/checkTabList/checkTabList.js b/littleApp_child/pages/checkTabList/checkTabList.js index eee295e..b3272eb 100644 --- a/littleApp_child/pages/checkTabList/checkTabList.js +++ b/littleApp_child/pages/checkTabList/checkTabList.js @@ -88,7 +88,7 @@ Page({ other_textFZ:"" }, onLoad: function (e) { - patientId = app.globalData.userId[0] + patientId = e.patientId checkTime = e.checkTime // 数据初始化 var self = this @@ -113,13 +113,7 @@ Page({ showMoreContent: function (e) { var content = e.currentTarget.dataset.content // + "问诊检查问诊检查问诊检查问诊检查问诊检查问诊检查问诊检查问诊检查问诊检查问诊检查问诊检查问诊检查问诊检查问诊检查问诊检查问诊检查问诊检查问" var title = e.currentTarget.dataset.title - // wx.showModal({ - // title: title, - // content: content, - // showCancel: false, - // confirmText: '知道了', - // confirmColor: '#48C17B' - // }) + if(content.length>=4){ this.setData({ flag: true, @@ -160,7 +154,7 @@ Page({ networkUtil.showLoading() var param = { page: 10, limit: 100, patientId: patientId, checkTime: checkTime } - // console.log(param) + console.log('param', param) networkUtil._get(api.wzXinxi, param, function (res) { console.log(res) var result = res.data.list[0] diff --git a/littleApp_child/utils/network_util.js b/littleApp_child/utils/network_util.js index 7c96b39..b3fb37a 100644 --- a/littleApp_child/utils/network_util.js +++ b/littleApp_child/utils/network_util.js @@ -1,8 +1,8 @@ // 测试用户‘花雪莲’,手机号15928512992,验证码666666 -// 0测试环境 1正式环境 2演示环境 3衡水 -var Builing_Release_AppStore = 0 +// 0测试环境 1正式环境 2演示环境 3衡水 +var Builing_Release_AppStore = 1 // 获取服务器地址 function kServerBaseUrl() { switch (Builing_Release_AppStore) { @@ -18,81 +18,6 @@ function kServerBaseUrl() { } /* - 获取既往史类型 -* port: 接口名称 类型字符串 -* params: 参数 类型json -* success: 成功回调 类型function -* fail: 失败回调 类型function -*/ -function _get2(port, params, success, fail) { - - wx.request({ - url: 'https://dev-rp-api.healthbaby.com.cn/' + port, - data: params, - method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT - header: { - 'content-type': 'application/json', - 'Authorization': getApp().globalData.token ? getApp().globalData.token : '' - }, // 设置请求的 header - success: function (res) { - // success - successData(res, success, fail) - }, - fail: function (res) { - var error = {} - error.errorcode = 404 - error.errormsg = '数据获取失败,请稍后再试' - console.log(res) - // fail - fail(error) - }, - complete: function (res) { - // complete - wx.hideToast() - // 小程序提供的api,通知页面停止下拉刷新效果 - wx.stopPullDownRefresh(); - } - }) -} - -/* - 获取地址 -* port: 接口名称 类型字符串 -* params: 参数 类型json -* success: 成功回调 类型function -* fail: 失败回调 类型function -*/ -function _getAddress(params, success, fail) { - wx.request({ - url: 'https://rp-api.healthbaby.com.cn/queryRegions', - data: params, - method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT - header: { - 'content-type': 'application/json' - }, // 设置请求的 header - success: function (res) { - // success - successData(res, success, fail) - }, - fail: function (res) { - var error = {} - error.errorcode = 404 - error.errormsg = '数据获取失败,请稍后再试' - console.log(res) - // fail - fail(error) - }, - complete: function (res) { - // complete - wx.hideToast() - // 小程序提供的api,通知页面停止下拉刷新效果 - wx.stopPullDownRefresh(); - } - }) -} - - -/* * port: 接口名称 类型字符串 * params: 参数 类型json * success: 成功回调 类型function @@ -233,13 +158,11 @@ function showErrorToast(text) { module.exports = { _get: _get, - _get2: _get2, _post: _post, _put: _put, showLoading: showLoading, showErrorToast: showErrorToast, Builing_Release_AppStore: Builing_Release_AppStore, - _getAddress: _getAddress } // networkUtil._get(api,param,function(res){},function(res){}) \ No newline at end of file -- 1.8.3.1