record.js
9.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
// pages/record/record.js
// 请注意常量的命名必须是Page
const Page = require('../../utils/ald-stat.js').Page;
var wxCharts = require('../../utils/wxcharts.js');
const app = getApp();
var lineCharthemoglobin=null;
var lineChartwhite=null;
var lineChartneutrophils=null;
var lineChartplatelet=null;
Page({
/**
* 页面的初始数据
*/
data: {
showrecord: null, //true显示趋势图,flase显示病情记录
shownomore:false,//是否显示不能加载更多
categories:[],//趋势图x轴数据
series:{},//趋势图数据
files_id: 1, // 档案ID
current_page: 1, //页码
per_page: 2, //每页病情记录的条数
last_page:null,//最后一页
line_rows: 10, //每页趋势图的个数
FilesLogList: []
},
//切换显示记录于趋势图
setshowrecord() {
let that=this;
this.setData({
showrecord: !this.data.showrecord
})
if (this.data.showrecord){
that.getFilesLogLine();
}
},
wxChartData() {
var windowWidth = 300,
windowHeight = 300; //定义宽高
try {
var res = wx.getSystemInfoSync(); //试图获取屏幕宽高数据
windowWidth = res.windowWidth / 750 * 690; //以设计图750为主进行比例算换
windowHeight = res.windowWidth / 750 * 550 //以设计图750为主进行比例算换
} catch (e) {
console.error('getSystemInfoSync failed!'); //如果获取失败
}
lineChart = new wxCharts({ //定义一个wxCharts图表实例
canvasId: 'lineCanvas', //输入wxml中canvas的id
type: 'line', //图标展示的类型有:'line','pie','column','area','ring','radar'
categories: [1], //模拟的x轴横坐标参数
animation: true, //是否开启动画
series: [{ //具体坐标数据
name: '高压', //名字
data: 136, //数据点
format: function(val, name) { //点击显示的数据注释
return val + 'mmHg';
}
}, {
name: '低压',
data: 90,
format: function(val, name) {
return val + 'mmHg';
}
}, {
name: '心率',
data: 67,
format: function(val, name) {
return val + '次/分钟';
}
}],
xAxis: { //是否隐藏x轴分割线
disableGrid: true,
},
yAxis: { //y轴数据
title: '数值', //标题
format: function(val) { //返回数值
return val;
},
min: 30, //最小值
max: 180, //最大值
gridColor: '#D8D8D8',
},
width: windowWidth, //图表展示内容宽度
height: windowHeight, //图表展示内容高度
dataLabel: false, //是否在图表上直接显示数据
dataPointShape: true, //是否在图标上显示数据点标志
extra: {
lineStyle: 'curve' //曲线
},
});
},
//血红蛋白
lineShowhemoglobin() {
let that=this;
let cate = this.data.categories;
lineCharthemoglobin=new wxCharts({
canvasId: 'lineCanvashemoglobin',
type: 'area',
categories: cate,
animation: true, //是否开启动画
series: [{
name: '血红蛋白',
data: that.data.series.hemoglobin,
format: function (val, name) { //点击显示的数据注释
return val + 'g/L';
}
}],
yAxis: {
format: function (val) {
return val + 'g/L';
}
},
width: 300,
height: 200,
dataLabel: false, // 是否在图表中显示数据内容值
});
},
//白细胞
lineShowwhite() {
let that = this;
let cate = this.data.categories;
lineChartwhite = new wxCharts({
canvasId: 'lineCanvaswhite',
type: 'area',
categories: cate,
animation: true, //是否开启动画
series: [{
name: '白细胞',
data: that.data.series.white_blood_cell,
format: function (val, name) { //点击显示的数据注释
return val + '*10^9/L';
}
}],
yAxis: {
format: function (val) {
return val + '*10^9/L';
}
},
width: 300,
height: 200,
dataLabel: false, // 是否在图表中显示数据内容值
});
},
//中粒细胞
lineShowneutrophils() {
let that = this;
let cate = this.data.categories;
console.log(cate)
lineChartneutrophils = new wxCharts({
canvasId: 'lineCanvasneutrophils',
type: 'area',
categories: cate,
animation: true, //是否开启动画
series: [{
name: '血红蛋白',
data: that.data.series.neutrophils,
format: function (val, name) { //点击显示的数据注释
return val + '*10^9/L';
}
}],
yAxis: {
format: function (val) {
return val + '*10^9/L';
}
},
width: 300,
height: 200,
dataLabel: false, // 是否在图表中显示数据内容值
});
},
//血小板
lineShowplatelet() {
let that = this;
let cate = this.data.categories;
console.log(cate)
lineChartplatelet = new wxCharts({
canvasId: 'lineCanvasplatelet',
type: 'area',
categories: cate,
animation: true, //是否开启动画
series: [{
name: '血小板',
data: that.data.series.hemoglobin,
format: function (val, name) { //点击显示的数据注释
return val + '*10^9/L';
}
}],
yAxis: {
format: function (val) {
return val + '*10^9/L';
}
},
width: 300,
height: 200,
dataLabel: false, // 是否在图表中显示数据内容值
});
},
//点击趋势图事件(血红蛋白)
touchHandlerhemoglobin: function (e) {
console.log(e);
lineCharthemoglobin.showToolTip(e, {
format: function (item, category) {
return category + ' ' + item.name + ':' + item.data
}
});
},
//点击趋势图事件(白细胞)
touchHandlerwhite: function (e) {
console.log(e);
lineChartwhite.showToolTip(e, {
format: function (item, category) {
return category + ' ' + item.name + ':' + item.data
}
});
},
gonormal(){
wx.navigateTo({
url: '/pages/normal/normal',
success: function (res) { },
fail: function (res) { },
complete: function (res) { },
})
},
//点击趋势图事件(中粒细胞)
touchHandlerneutrophils: function (e) {
console.log(e);
lineChartneutrophils.showToolTip(e, {
format: function (item, category) {
return category + ' ' + item.name + ':' + item.data
}
});
},
//点击趋势图事件(血小板)
touchHandlerplatelet(e){
console.log(e);
lineChartplatelet.showToolTip(e, {
format: function (item, category) {
return category + ' ' + item.name + ':' + item.data
}
});
},
//编辑病情记录
goeditfile(e){
console.log(e);
wx.navigateTo({
url: '/pages/editrecord/editrecord?id=' + e.currentTarget.dataset.id,
success: function(res) {},
fail: function(res) {},
complete: function(res) {},
})
},
onShareAppMessage: function(res) {
},
//获取病情记录
getFilesLogList() {
let that = this;
let url = 'user/getFilesLogList';
let header = {
'XX-Token':wx.getStorageSync('token'),
'XX-Device-Type': ''
}
let params = {
files_id: that.data.files_id,
page: that.data.current_page,
list_rows: that.data.per_page
}
app.post(url, params, header).then((res) => {
let List =res.data;
let FilesLogList = that.data.FilesLogList;
console.log(List);
for (let obj of List){
FilesLogList.push(obj);
if (obj.doctor_reply==null){
obj.showdoc_adv=false
}else{
obj.showdoc_adv = true
}
}
if (res.current_page == res.last_page) {
that.setData({
shownomore: true
})
} else {
that.setData({
shownomore: false
})
}
that.setData({
FilesLogList: FilesLogList,
current_page: res.current_page,
last_page: res.last_page,
per_page: res.per_page
})
}).catch((errMsg) => {
console.log(errMsg)
})
},
//获取病情曲线
getFilesLogLine() {
let that = this;
let header = {
'XX-Token': wx.getStorageSync('token'),
'XX-Device-Type': ''
}
let url = 'user/getFilesLogLine';
let params = {
files_id: that.data.files_id,
list_rows: that.data.line_rows
}
app.post(url, params, header).then((res) => {
that.setData({
series: res.series,
categories: res.categories
})
that.lineShowhemoglobin();
that.lineShowwhite();
that.lineShowneutrophils();
that.lineShowplatelet();
}).catch((errMsg) => {
console.log(errMsg)
})
},
//下拉加载
scrollbottom(){
let that = this;
if (!that.data.showrecord) {
console.log('页面上拉触底事件的处理函数');
let that = this;
that.setData({
current_page: parseInt(that.data.current_page) + 1
})
that.getFilesLogList();
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
let that = this;
app.setStatisticsVisitorLog('/pages/record/record');
if (options.showrecord == '1'){
that.setData({
showrecord: true,
files_id: options.files_id
})
} else {
that.setData({
showrecord: false,
files_id: options.files_id
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
let that=this;
that.setData({
FilesLogList:[],
current_page: 1, //页码
per_page: 2, //每页病情记录的条数
})
that.getFilesLogList();
that.getFilesLogLine();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})