123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- var curDays = 7;
- $('input[data-time=date]').val('7天内');
-
- $(function() {
- queryChat(getDateBefore(6), getNowDate());
- /* 选择日期 */
- var opt1 = {
- preset: 'date',
- theme: 'ios',
- lang: 'zh',
- minDate: new Date(1900, 01, 01),
- onSelect: function(valueText, inst) {
- var date_begin = $("#date_begin").val();
- var date_end = $("#date_end").val();
- if (date_begin == null || date_begin.length == 0) {
- return;
- }
- if (date_end == null || date_end.length == 0) {
- return;
- }
- queryChat(date_begin, date_end);
- }
- };
- $('input[data-time=date1]').mobiscroll(opt1);
- $('input[data-time=date2]').mobiscroll(opt1);
- var swiper = new Swiper('.swiper-container', {
- pagination: '.swiper-pagination',
- paginationClickable: false
- });
- //咨询药店
- $('input[data-time=date]').mobiscroll({
- theme: 'ios',
- lang: 'zh',
- formatValue: function(d) {
- return d.join('-');
- },
- customWheels: true,
- wheels: [
- [{
- keys: ['1', '2', '3'],
- values: ['7天内', '30天内', '自定义时间']
- }]
- ],
- onSelect: function(valueText, inst) {
- var dd = eval("[" + valueText + "]");
- $('input[data-time=date]').val(dd[0].values);
- if (dd[0].keys == "3") {
- $(".time-began").show();
- } else {
- $(".time-began").hide();
- }
- if (dd[0].keys == 1) {
- //7天内
- if (curDays == 7) {
- return;
- }
- curDays = 7;
- queryChat(getDateBefore(6), getNowDate());
- } else if (dd[0].keys == 2) {
- //30天内
- if (curDays == 30) {
- return;
- }
- curDays = 30;
- queryChat(getDateBefore(29), getNowDate());
- } else {
- curDays = 99;
- }
- }
- });
- });
- function queryChat(date_begin, date_end) {
- if (parseFloat(date_begin.replace(/-/g, "")) > parseFloat(date_end.replace(/-/g, ""))) {
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'开始时间不能晚于结束时间'}).show();
- return;
- }
- //发送请求
- queryChatByType(2, date_begin, date_end, queryChartSuccesss);
- }
- /**
- * 健康指标图表查询成功处理方法
- */
- function queryChartSuccesss(res) {
- if (res.status == 200) {
- d.close();
- showChart(res.list);
- } else {
- queryChartFailed(res);
- }
- }
- function buildData(value, max, min) {
- if ((value > 0 && value < min) || value > max) {
- return {
- value: value,
- itemStyle: {
- normal: {
- color: '#f00'
- }
- }
- }
- } else {
- return value;
- }
- }
- function showChart(list) {
- var legendArray = ['收缩压,舒张压'];
- var xAxisArray = new Array();
- var seriesArray = new Array();
- var allDatas = new Array();
- var data1 = new Array();
- var data2 = new Array();
- for (var i = 0; i < list.length; i++) {
- var data = list[i];
- if (!data) {
- continue;
- }
- xAxisArray.push(data.date.substr(5, 5));
- data1.push(buildData(data.value1, 139, 90));
- data2.push(buildData(data.value2, 89, 60));
- }
- allDatas.push(data1);
- allDatas.push(data2);
- var series1 = {
- name: legendArray[0].split(',')[0],
- type: 'line',
- symbol: 'emptyCircle',
- layerPadding: 0,
- nodePadding: 0,
- itemStyle: {
- normal: {
- borderWidth: 8,
- color: '#0ad800',
- lineStyle: { // 系列级个性化折线样式,横向渐变描边
- borderWidth: 2,
- color: '#5dd1d2',
- width: 4
- },
- nodeStyle: {
- borderWidth: 2,
- color: '#93DB70',
- borderColor: '#93DB70'
- }
- },
- emphasis: {
- label: {
- show: true
- }
- }
- },
- data: allDatas[0]
- };
-
- var series2 = {
- name: legendArray[0].split(',')[1],
- type: 'line',
- symbol: 'emptyCircle',
- layerPadding: 0,
- nodePadding: 0,
- itemStyle: {
- normal: {
- borderWidth: 8,
- color: '#0ad800',
- lineStyle: { // 系列级个性化折线样式,横向渐变描边
- borderWidth: 2,
- color: '#CC66FF',
- width: 4
- },
- nodeStyle: {
- borderWidth: 2,
- color: '#93DB70',
- borderColor: '#93DB70'
- }
- },
- emphasis: {
- label: {
- show: true
- }
- }
- },
- data: allDatas[1]
- };
-
- seriesArray.push(series1);
- seriesArray.push(series2);
- // 路径配置
- require.config({
- paths: {
- echarts: 'http://echarts.baidu.com/build/dist'
- }
- });
- // 使用
- require(['echarts',
- 'echarts/chart/line' // 使用柱状图就加载bar模块,按需加载
- ],
- DrawCharts);
-
- function DrawCharts() {
- var myChart = require('echarts').init(document.getElementById('chart1'));
- var option = {
- tooltip: {
- trigger: 'axis'
- },
- grid: {
- x: 30,
- y: 20,
- x2: 25,
- y2: 20
- },
- legend: {
- show: false,
- data: legendArray
- },
- toolbox: {
- show: false
- },
- calculable: false,
- xAxis: [{
- type: 'category',
- boundaryGap: false,
- data: xAxisArray,
- axisLabel: {
- margin: 6
- }
- }],
- yAxis: [{
- type: 'value'
- }],
- series: seriesArray
- };
- // 为echarts对象加载数据
- myChart.setOption(option);
- }
- }
- //添加数据添加监听
- window.addEventListener("refleshList", function(e) {
- //刷新列表
- if (curDays == 7) {
- //7天内
- queryChat(getDateBefore(6), getNowDate());
- } else if (curDays == 30) {
- //30天内
- queryChat(getDateBefore(29), getNowDate());
- } else {
- var date_begin = $("#date_begin").val();
- var date_end = $("#date_end").val();
- if (date_begin == null || date_begin.length == 0) {
- return;
- }
- if (date_end == null || date_end.length == 0) {
- return;
- }
- queryChat(date_begin, date_end);
- }
- });
|