123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409 |
- // pages/reportDetail/reportDetail.js
- import { getReport, getReportUserInfo } from '../../api/my'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- reportid: '',
- name: '评估说明', // 默认展示: 评估说明 小结 ReportTotal, 系统:用具体的中文名称
- systemNameList: [
- {
- index: 0,
- viewName: '评估说明',
- reqName: '评估说明',
- toview: 'shuoming',
- response: []
- },
- {
- index: 1,
- viewName: '检测小结',
- reqName: 'ReportTotal',
- toview: 'xiaojie',
- response: []
- },
- {
- index: 2,
- viewName: '循环系统',
- reqName: '循环系统',
- toview: 'xunhuan',
- response: []
- },
- {
- index: 3,
- viewName: '呼吸系统',
- reqName: '呼吸系统',
- toview: 'huxi',
- response: []
- },
- {
- index: 4,
- viewName: '消化系统',
- reqName: '消化系统',
- toview: 'xiaohua',
- response: []
- },
- {
- index: 5,
- viewName: '泌尿系统',
- reqName: '泌尿与生殖系统',
- toview: 'miniao',
- response: []
- },
- {
- index: 6,
- viewName: '血液系统',
- reqName: '血液系统',
- toview: 'xuexie',
- response: []
- },
- {
- index: 7,
- viewName: '内分泌系统',
- reqName: '内分泌系统',
- toview: 'neifenmi',
- response: []
- },
- {
- index: 8,
- viewName: '营养代谢',
- reqName: '营养与代谢',
- toview: 'yinyangdaixie',
- response: []
- },
- {
- index: 9,
- viewName: '神经系统',
- reqName: '神经系统',
- toview: 'shenjin',
- response: []
- },
- {
- index: 10,
- viewName: '免疫系统',
- reqName: '免疫系统',
- toview: 'mianyi',
- response: []
- },
- {
- index: 11,
- viewName: '运动系统',
- reqName: '运动系统',
- toview: 'yundong',
- response: []
- },
- {
- index: 12,
- viewName: '感官系统',
- reqName: '感官系统',
- toview: 'ganguan',
- response: []
- },
- {
- index: 13,
- viewName: '理化因素',
- reqName: '理化因素',
- toview: 'lihuayinshu',
- response: []
- },
- {
- index: 14,
- viewName: '情绪压力',
- reqName: '精神及心理',
- toview: 'qinxuyali',
- response: []
- }
- ],
- systemNameList1Res:[],
- systemNameList2Res:[],
- systemNameList3Res:[],
- systemNameList4Res:[],
- systemNameList5Res:[],
- systemNameList6Res:[],
- systemNameList7Res:[],
- systemNameList8Res:[],
- systemNameList9Res:[],
- systemNameList10Res:[],
- systemNameList11Res:[],
- systemNameList12Res:[],
- systemNameList13Res:[],
- systemNameList14Res:[],
- leftNavActive: 0, // 0 小结 1 系统
- summaryList: [],
- systemList: [],
- realName: '',
- addTime: '',
- toView: 'shuoming',
- scrollIntoViewIndex: 0
- },
- onUnload() {
- this.setData({
- scrollIntoViewIndex: 0
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.setData({
- reportId: options.reportid,
- leftNavActive: 0,
- name: '评估说明'
- })
- this.getAllReportInfo(options.reportid)
- //this.getReportUserInfoFn(options.reportid)
- },
- bindscroll () {
- this.returnTop()
- },
- returnTop () {
- const query = wx.createSelectorQuery()
- const that = this
- query.select("#shuoming").boundingClientRect()
- query.select("#xiaojie").boundingClientRect()
- query.select("#xunhuan").boundingClientRect()
- query.select("#huxi").boundingClientRect()
- query.select("#xiaohua").boundingClientRect()
- query.select("#miniao").boundingClientRect()
- query.select("#xuexie").boundingClientRect()
- query.select("#neifenmi").boundingClientRect()
- query.select("#yinyangdaixie").boundingClientRect()
- query.select("#shenjin").boundingClientRect()
- query.select("#mianyi").boundingClientRect()
- query.select("#yundong").boundingClientRect()
- query.select("#ganguan").boundingClientRect()
- query.select("#lihuayinshu").boundingClientRect()
- query.select("#qinxuyali").boundingClientRect()
- query.exec(function(res){
- that.setLeftNavActive(res)
- })
- },
- setLeftNavActive (TopArr) {
- let res = []
- TopArr.map((item, index) => {
- res.push({
- index: index,
- id: item.id,
- top: Math.abs(item.top)
- })
- })
- const fItem = res.find(item => {
- return item.top < 200
- })
- if (fItem && this.data.scrollIntoViewIndex != fItem.index) {
- this.setData({
- scrollIntoViewIndex: fItem.index,
- leftNavActive: fItem.index
- })
- }
- },
- // 获取所有节点的返回信息
- async getAllReportInfo (reportid) {
- const that = this
- wx.showLoading({
- title: '加载中...',
- mask: true
- })
- await this.getReportUserInfoFn(reportid)
- await this.getReportFn(this.data.systemNameList[1].reqName).then(response => {
- that.setData({
- systemNameList1Res: response || []
- })
- })
- await this.getReportFn(this.data.systemNameList[2].reqName).then(response => {
- const handleRespose = that.handleRespose(response)
- that.setData({
- systemNameList2Res: handleRespose
- })
- })
- await this.getReportFn(this.data.systemNameList[3].reqName).then(response => {
- const handleRespose = that.handleRespose(response)
- that.setData({
- systemNameList3Res: handleRespose
- })
- })
- await this.getReportFn(this.data.systemNameList[4].reqName).then(response => {
- const handleRespose = that.handleRespose(response)
- that.setData({
- systemNameList4Res: handleRespose
- })
- })
- await this.getReportFn(this.data.systemNameList[5].reqName).then(response => {
- const handleRespose = that.handleRespose(response)
- that.setData({
- systemNameList5Res: handleRespose
- })
- })
- await this.getReportFn(this.data.systemNameList[6].reqName).then(response => {
- const handleRespose = that.handleRespose(response)
- that.setData({
- systemNameList6Res: handleRespose
- })
- })
- await this.getReportFn(this.data.systemNameList[7].reqName).then(response => {
- const handleRespose = that.handleRespose(response)
- that.setData({
- systemNameList7Res: handleRespose
- })
- })
- await this.getReportFn(this.data.systemNameList[8].reqName).then(response => {
- const handleRespose = that.handleRespose(response)
- that.setData({
- systemNameList8Res: handleRespose
- })
- })
- await this.getReportFn(this.data.systemNameList[9].reqName).then(response => {
- const handleRespose = that.handleRespose(response)
- that.setData({
- systemNameList9Res: handleRespose
- })
- })
- await this.getReportFn(this.data.systemNameList[10].reqName).then(response => {
- const handleRespose = that.handleRespose(response)
- that.setData({
- systemNameList10Res: handleRespose
- })
- })
- await this.getReportFn(this.data.systemNameList[11].reqName).then(response => {
- const handleRespose = that.handleRespose(response)
- that.setData({
- systemNameList11Res: handleRespose
- })
- })
- await this.getReportFn(this.data.systemNameList[12].reqName).then(response => {
- const handleRespose = that.handleRespose(response)
- that.setData({
- systemNameList12Res: handleRespose
- })
- })
- await this.getReportFn(this.data.systemNameList[13].reqName).then(response => {
- const handleRespose = that.handleRespose(response)
- that.setData({
- systemNameList13Res: handleRespose
- })
- })
- await this.getReportFn(this.data.systemNameList[14].reqName).then(response => {
- that.setData({
- systemNameList14Res: response
- })
- })
- wx.hideLoading()
- },
- // 获取当前报告人的信息
- getReportUserInfoFn (reportid) {
- var that = this
- return new Promise((reslove,reject) => {
- getReportUserInfo({
- reportId: reportid
- }).then(res => {
- that.setData({
- addTime: res.data.addTime,
- realName: res.data.realName
- })
- reslove(res)
- })
- })
- },
- // 获取具体的报告信息
- getReportFn (name, index = 0) {
- var that = this
- var data = {
- reportId: this.data.reportId,
- name: name
- }
- return new Promise((resolve, reject) => {
- getReport(data).then(res => {
- /* if (name == 'ReportTotal' || name == '精神及心理') {
- that.setData({
- summaryList: res.data || []
- })
- } else {
- that.handleRespose(res.data, index)
- } */
- resolve(res.data)
- }).catch(e => {
- reject(e)
- wx.showModal({
- content: e,
- confirmColor: '#333',
- showCancel: false
- })
- })
- })
- },
- // 处理系统返回的数据
- handleRespose (response, index) {
- var outKey = Object.keys(response)
- var result = []
- for (var index = 0; index < outKey.length; index++) {
- const element = outKey[index];
- const innetList = Object.keys(response[element])
- var tempArr = []
- for (var i = 0; i < innetList.length; i++) {
- const innerElement = innetList[i];
- tempArr.push({
- fatherName: element,
- name: innerElement,
- value: response[element][innerElement]
- })
- }
- result.push(
- {
- name: element,
- childNode: tempArr
- }
- )
- }
- var handleResult = [...result]
- for (var index = 0; index < handleResult.length; index++) {
- const element = handleResult[index];
- hanldSort(element.childNode)
- }
- function hanldSort (childNode) {
- childNode.sort(function(a,b){
- return b.value - a.value
- })
- }
- return handleResult
- },
- // 排序函数
- handleSortFn (result) {
- var handleResult = [...result]
- for (var index = 0; index < handleResult.length; index++) {
- const element = handleResult[index];
- hanldSort(element.childNode)
- }
- function hanldSort (childNode) {
- childNode.sort(function(a,b){
- return b.value - a.value
- })
- }
- this.setData({
- systemList: handleResult
- })
- },
- /**
- * 用户点击左侧系统分类
- */
- handleSwitchNav(e) {
- var navIndex = e.currentTarget.dataset.index
- var toview = e.currentTarget.dataset.toview
- this.setData({
- leftNavActive: navIndex,
- toView: toview
- })
- }
- })
|