123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- // pages/reportDetail/reportDetail.js
- import { getReport, getReportUserInfo } from '../../api/my'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- reportid: '',
- name: '评估说明', // 默认展示: 评估说明 小结 ReportTotal, 系统:用具体的中文名称
- systemNameList: [
- {
- index: 0,
- viewName: '评估说明',
- reqName: '评估说明'
- },
- {
- index: 1,
- viewName: '检测小结',
- reqName: 'ReportTotal'
- },
- {
- index: 2,
- viewName: '循环系统',
- reqName: '循环系统'
- },
- {
- index: 3,
- viewName: '呼吸系统',
- reqName: '呼吸系统'
- },
- {
- index: 4,
- viewName: '消化系统',
- reqName: '消化系统'
- },
- {
- index: 5,
- viewName: '泌尿系统',
- reqName: '泌尿与生殖系统'
- },
- {
- index: 6,
- viewName: '血液系统',
- reqName: '血液系统'
- },
- {
- index: 7,
- viewName: '内分泌系统',
- reqName: '内分泌系统'
- },
- {
- index: 8,
- viewName: '营养代谢',
- reqName: '营养与代谢'
- },
- {
- index: 9,
- viewName: '神经系统',
- reqName: '神经系统'
- },
- {
- index: 10,
- viewName: '免疫系统',
- reqName: '免疫系统'
- },
- {
- index: 11,
- viewName: '运动系统',
- reqName: '运动系统'
- },
- {
- index: 12,
- viewName: '感官系统',
- reqName: '感官系统'
- },
- {
- index: 13,
- viewName: '理化因素',
- reqName: '理化因素'
- },
- {
- index: 14,
- viewName: '情绪压力',
- reqName: '精神及心理'
- }
- ],
- leftNavActive: 0, // 0 小结 1 系统
- summaryList: [],
- systemList: [],
- realName: '',
- addTime: ''
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.setData({
- reportId: options.reportid,
- leftNavActive: 0,
- name: '评估说明'
- })
- this.getReportUserInfoFn(options.reportid)
- },
- // 获取当前报告人的信息
- getReportUserInfoFn (reportid) {
- var that = this
- getReportUserInfo({
- reportId: reportid
- }).then(res => {
- that.setData({
- addTime: res.data.addTime,
- realName: res.data.realName
- })
- })
- },
- // 获取具体的报告信息
- getReportFn () {
- var that = this
- var data = {
- reportId: this.data.reportId,
- name: this.data.name
- }
- wx.showLoading({
- title: '加载中...',
- mask: true
- })
- getReport(data).then(res => {
- wx.hideLoading()
- if (that.data.name == 'ReportTotal' || that.data.name == '精神及心理') {
- that.setData({
- summaryList: res.data || []
- })
- } else {
- that.handleRespose(res.data)
- }
- }).catch(e => {
- wx.hideLoading()
- wx.showModal({
- content: e,
- confirmColor: '#333',
- showCancel: false
- })
- })
- },
- // 处理系统返回的数据
- handleRespose (response) {
- 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
- }
- )
- }
- this.handleSortFn(result)
- },
- // 排序函数
- 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 reqName = e.currentTarget.dataset.reqname
- this.setData({
- name: reqName,
- leftNavActive: navIndex
- })
- this.getReportFn()
- }
- })
|