data.js 131 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949
  1. import * as echarts from '../../ec-canvas/echarts';
  2. let chart000;
  3. let chart00;
  4. let chart0;
  5. let chart;
  6. let chart1;
  7. let chart2;
  8. let chart3;
  9. let chart4;
  10. let chart5;
  11. let chart6;
  12. let chart7;
  13. let chart8;
  14. let chart81;
  15. let chart9;
  16. let chart10;
  17. let chart11;
  18. // pages/data/data.js
  19. function addZero(str) {
  20. if (String(str).length == 1) {
  21. return "0" + String(str);
  22. } else {
  23. return String(str);
  24. }
  25. }
  26. function flushChart000() {
  27. var option = {
  28. series: [
  29. {
  30. type: 'pie',
  31. radius: ['60%', '70%'], // 外环半径和内环半径,控制圆环宽度
  32. data: [
  33. { value: 0, name: '暂无', itemStyle: {color: '#eaeaea'} }, // 进度数据
  34. { value: 100, name: '暂无', itemStyle: {color: '#eaeaea'} } // 剩余数据,用于形成完整的圆环
  35. ],
  36. label: {
  37. show: true,
  38. position: 'center',
  39. // formatter: function (params) {
  40. // // 这里假设进度数据在第一个数据项中
  41. // if (params.dataIndex === 0) {
  42. // // return `第一行文字\n${params.percent.toFixed(2)}% 第二行文字`;
  43. // return '<text class="text-line text-line-1">'+rscore_desc+'</text>'+'\n '+
  44. // '<text class="text-line text-line-2">'+rscore_value+'</text>';
  45. // }
  46. // return ''; // 其他数据项不显示标签
  47. // },
  48. rich: {
  49. // ... 如果需要设置富文本样式,可以在这里定义
  50. },
  51. textStyle: { // 设置标签文本样式
  52. fontSize: 16, // 根据需要调整字体大小
  53. color: '#333', // 根据需要调整字体颜色
  54. // ... 其他样式设置
  55. },
  56. alignTo: 'labelLine', // 文本水平居中到标签线
  57. align: 'center' // 文本垂直居中对齐到标签线
  58. },
  59. label: {
  60. show: true,
  61. position: 'center',
  62. // formatter: function (params) {
  63. // // 假设 params.percent 是进度百分比
  64. // return `{normal|`+rscore_desc+`}\n\n{bold|`+rscore_value+`}`;
  65. // },
  66. rich: {
  67. bold: {
  68. fontWeight: 'bold', // 加粗
  69. fontSize: 18, // 字体大小,根据需要调整
  70. color: '#333' // 字体颜色,根据需要调整
  71. // 其他样式配置...
  72. },
  73. normal: {
  74. fontWeight: 'normal', // 普通字体
  75. fontSize: 14, // 字体大小,根据需要调整
  76. color: '#666' // 字体颜色,根据需要调整
  77. // 其他样式配置...
  78. }
  79. // 可以继续定义其他样式...
  80. },
  81. // 其他 label 配置...
  82. }
  83. // ... 其他配置项
  84. }
  85. ]
  86. };
  87. chart000.setOption(option, true);
  88. }
  89. function flushChart00(rscore_desc,rscore_value,that) {
  90. var option = {
  91. backgroundColor: 'white',
  92. series: [
  93. {
  94. type: 'pie',
  95. radius: ['60%', '70%'], // 外环半径和内环半径,控制圆环宽度
  96. data: [
  97. // { value: rscore_value?rscore_value:0, name: '进度', itemStyle: {color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{offset: 0, color: '#874bff'}, {offset: 0.6, color: '#a87cff'},{offset: 0.9, color: '#f19cff'},{offset: 1, color: '#ff55ff'}])} }, // 进度数据
  98. { value: rscore_value?rscore_value:0, name: '进度', itemStyle: {color: '#874bff'} },
  99. { value: 100-(rscore_value?rscore_value:0), name: '剩余', itemStyle: {color: '#eaeaea'} } // 剩余数据,用于形成完整的圆环
  100. ],
  101. label: {
  102. show: true,
  103. position: 'center',
  104. formatter: function (params) {
  105. // 这里假设进度数据在第一个数据项中
  106. if (params.dataIndex === 0) {
  107. // return `第一行文字\n${params.percent.toFixed(2)}% 第二行文字`;
  108. return '<text class="text-line text-line-1">'+rscore_desc+'</text>'+'\n '+
  109. '<text class="text-line text-line-2">'+rscore_value+'</text>';
  110. }
  111. return ''; // 其他数据项不显示标签
  112. },
  113. rich: {
  114. // ... 如果需要设置富文本样式,可以在这里定义
  115. },
  116. textStyle: { // 设置标签文本样式
  117. fontSize: 16, // 根据需要调整字体大小
  118. color: '#333', // 根据需要调整字体颜色
  119. // ... 其他样式设置
  120. },
  121. alignTo: 'labelLine', // 文本水平居中到标签线
  122. align: 'center' // 文本垂直居中对齐到标签线
  123. },
  124. label: {
  125. show: true,
  126. position: 'center',
  127. formatter: function (params) {
  128. // 假设 params.percent 是进度百分比
  129. return `{normal|`+rscore_desc+`}\n\n{bold|`+rscore_value+`}`;
  130. },
  131. rich: {
  132. bold: {
  133. fontWeight: 'bold', // 加粗
  134. fontSize: 18, // 字体大小,根据需要调整
  135. color: '#333' // 字体颜色,根据需要调整
  136. // 其他样式配置...
  137. },
  138. normal: {
  139. fontWeight: 'normal', // 普通字体
  140. fontSize: 14, // 字体大小,根据需要调整
  141. color: '#666' // 字体颜色,根据需要调整
  142. // 其他样式配置...
  143. }
  144. // 可以继续定义其他样式...
  145. },
  146. // 其他 label 配置...
  147. }
  148. // ... 其他配置项
  149. }
  150. ]
  151. };
  152. that.setData({
  153. flushChart00Flag:true
  154. });
  155. console.log('that.data.flushChart00Flag='+that.data.flushChart00Flag);
  156. chart00.setOption(option, true);
  157. }
  158. function flushChart0(data) {
  159. var option = {
  160. series: [
  161. {
  162. name: '进度',
  163. type: 'pie',
  164. radius: ['50%', '70%'],
  165. avoidLabelOverlap: false,
  166. label: {
  167. show: true,
  168. position: 'center'
  169. },
  170. emphasis: {
  171. label: {
  172. show: true,
  173. fontSize: '30',
  174. fontWeight: 'bold'
  175. }
  176. },
  177. labelLine: {
  178. show: false
  179. },
  180. data: data
  181. }
  182. ]
  183. };
  184. chart0.setOption(option, true);
  185. }
  186. function flushChart(data) {
  187. var option = {
  188. backgroundColor: '#0c1041',
  189. // title: {
  190. // text: '当天睡眠时间曲线图',
  191. // left: 'center',
  192. // color: '#ffffff',
  193. // backgroundColor: '#ff0000'
  194. // },
  195. color: ["#62c4d9"],
  196. legend: {
  197. data: ['睡眠时间'],
  198. top: 20,
  199. left: 'right',
  200. backgroundColor: '#0c1041',
  201. textStyle:{
  202. color:'#fff',
  203. }
  204. },
  205. grid: {
  206. containLabel: true
  207. },
  208. tooltip: {
  209. show: true,
  210. trigger: 'axis'
  211. },
  212. xAxis: {
  213. type: 'category',
  214. boundaryGap: false,
  215. axisLine:{
  216. lineStyle:{
  217. color: '#fff',
  218. width:1,//这里是为了突出显示加上的
  219. }
  220. }
  221. },
  222. yAxis: {
  223. name: "时长" ,
  224. x: 'center',
  225. type: 'value',
  226. axisLine:{
  227. lineStyle:{
  228. color: '#fff',
  229. width:1,//这里是为了突出显示加上的
  230. }
  231. // splitLine: {
  232. // lineStyle: {
  233. // type: 'dashed'
  234. // }
  235. }
  236. // show: false
  237. },
  238. series: [{
  239. name: '睡眠时间',
  240. type: 'line',
  241. smooth: true,
  242. data: data,
  243. color: '#62c4d9'
  244. }]
  245. };
  246. chart.setOption(option, true);
  247. }
  248. function flushChart1(data1,data2) {
  249. var option = {
  250. // title: {
  251. // text: '睡眠心率监测',
  252. // left: 'center',
  253. // textStyle: {
  254. // color: '#ffffff', // 字体颜色
  255. // fontStyle: 'normal', // 字体风格
  256. // // fontWeight: 'bold', // 字体粗细
  257. // fontFamily: 'sans-serif', // 字体族
  258. // fontSize: 18 // 字体大小
  259. // },
  260. // backgroundColor: '#57f7ff'
  261. // },
  262. tooltip: {},
  263. xAxis: {
  264. axisLabel: {
  265. color: '#000' // 设置 x 轴标签颜色为白色
  266. },
  267. splitLine: {
  268. show: false, // 是否显示刻度线
  269. },
  270. axisTick: {
  271. // 不显示Y轴刻度线
  272. show: false
  273. },
  274. axisLine: {
  275. // 不显示X轴轴线
  276. show: false
  277. },
  278. data: data1?data1:[]
  279. },
  280. yAxis: {
  281. // Y 轴配置
  282. type: 'value',
  283. // 设置 Y 轴名称
  284. name: '单位:次',
  285. // 设置 Y 轴名称的位置
  286. nameLocation: 'end', // 可以是 'start'、'middle' 或 'end'
  287. axisLine: {
  288. // 不显示Y轴轴线
  289. show: false,
  290. },
  291. axisTick: {
  292. // 不显示Y轴刻度线
  293. show: false
  294. },
  295. axisLabel: {
  296. color: '#000',
  297. },
  298. splitLine: {
  299. show: false ,// 不显示纵坐标轴的刻度线
  300. lineStyle: {
  301. color: 'rgba(255, 0, 255, 0.8)', // 灰色并调整透明度
  302. width: 1, // 刻度线宽度
  303. type: 'solid' // 刻度线类型,默认为实线
  304. }
  305. },
  306. },
  307. series: [{
  308. type: 'line',
  309. data: data2?data2:[],
  310. // lineStyle: {
  311. // color: 'rgba(255, 85, 127, 0.1)' // 奶白色,80% 透明度
  312. // },
  313. showSymbol: false, // 是否显示标记图形
  314. smooth: true, // 使折线平滑
  315. markPoint: {
  316. symbol: 'circle', // 标记的符号为圆圈
  317. symbolSize: 10, // 标记的大小
  318. itemStyle: {
  319. color: 'rgba(255, 0, 255, 0.8)',
  320. // borderColor: 'blue',
  321. borderWidth: 1, // 设置边框宽度
  322. fill: 'none' // 设置填充颜色为无,即空心
  323. },
  324. data: [
  325. // 假设 data[0] 和 data[data.length - 1] 分别是开始和结束的数据点
  326. {coord: [data1?data1[0]:'', data2?data2[0]:''], name: '开始'},
  327. {coord: [data1?data1[data1.length-1]:'', data2?data2[data2.length-1]:''], name: '结束'}
  328. // 如果要添加拐角处的标记,需要手动计算并添加
  329. ]
  330. },
  331. areaStyle: { // 折线下方的区域样式
  332. color: new echarts.graphic.LinearGradient(
  333. 0, 0, 0, 1, // 渐变方向
  334. [ // 渐变颜色
  335. {offset: 0, color: 'rgba(255, 0, 255, 0.8)'}, // 使用之前定义的渐变
  336. {offset: 0.9, color: 'rgba(255, 255, 255, 1)'} // 可选,结束颜色
  337. ]
  338. ),
  339. opacity: 0.3 // 区域的不透明度,可以根据需要调整
  340. },
  341. }]
  342. };
  343. chart1.setOption(option, true);
  344. }
  345. function flushChart2(data) {
  346. var option = {
  347. // title: {
  348. // text: '睡眠状态监测',
  349. // left: 'center',
  350. // textStyle: {
  351. // color: '#ffffff', // 字体颜色
  352. // fontStyle: 'normal', // 字体风格
  353. // // fontWeight: 'bold', // 字体粗细
  354. // fontFamily: 'sans-serif', // 字体族
  355. // fontSize: 18 // 字体大小
  356. // },
  357. // backgroundColor: '#57f7ff'
  358. // },
  359. tooltip: {
  360. trigger: 'item'
  361. },
  362. legend: {
  363. orient: 'vertical',
  364. left: 'left',
  365. },
  366. series: [{
  367. type: 'pie',
  368. radius: '55%',
  369. data: data?data:[]
  370. }],
  371. graphic: [{
  372. type: 'text',
  373. left: '2%', // 文本水平位置,这里设置为居中,你可以根据需要调整
  374. top: '84%', // 文本垂直位置,这里设置为距离顶部 10% 的位置,作为左下方的文本
  375. style: {
  376. text: '时长(分钟)分析', // 文本内容
  377. textFill: '#333', // 文本颜色
  378. textFontSize: 14, // 文本字体大小
  379. textAlign: 'left', // 文本水平对齐方式
  380. verticalAlign: 'middle' // 文本垂直对齐方式
  381. }
  382. }],
  383. };
  384. chart2.setOption(option, true);
  385. }
  386. function flushChart3(data1,data2) {
  387. var option = {
  388. // title: {
  389. // text: '睡眠呼吸监测',
  390. // left: 'center',
  391. // textStyle: {
  392. // color: '#ffffff', // 字体颜色
  393. // fontStyle: 'normal', // 字体风格
  394. // // fontWeight: 'bold', // 字体粗细
  395. // fontFamily: 'sans-serif', // 字体族
  396. // fontSize: 18 // 字体大小
  397. // },
  398. // backgroundColor: '#57f7ff'
  399. // },
  400. tooltip: {},
  401. xAxis: {
  402. data: data1?data1:[]
  403. },
  404. yAxis: {
  405. // Y 轴配置
  406. type: 'value',
  407. // 设置 Y 轴名称
  408. name: '单位:次',
  409. // 设置 Y 轴名称的位置
  410. nameLocation: 'end', // 可以是 'start'、'middle' 或 'end'
  411. },
  412. series: [{
  413. type: 'line',
  414. data: data2?data2:[]
  415. }]
  416. };
  417. chart3.setOption(option, true);
  418. }
  419. function flushChart4(data) {
  420. var option = {
  421. // title: {
  422. // text: '睡眠与清醒时间',
  423. // left: 'center',
  424. // textStyle: {
  425. // color: '#ffffff', // 字体颜色
  426. // fontStyle: 'normal', // 字体风格
  427. // // fontWeight: 'bold', // 字体粗细
  428. // fontFamily: 'sans-serif', // 字体族
  429. // fontSize: 18 // 字体大小
  430. // },
  431. // backgroundColor: '#57f7ff'
  432. // },
  433. tooltip: {},
  434. series: [{
  435. type: 'gauge',
  436. // 设置刻度盘的最大值
  437. max: 24,
  438. // 设置刻度盘的最小值
  439. min: 0,
  440. pointer: {
  441. width: 5,
  442. // 可以调整第二个指针的样式以区分
  443. itemStyle: {
  444. color: '#FF0000'
  445. }
  446. },
  447. // 刻度盘轴
  448. axisLine: {
  449. textStyle: {
  450. fontSize: 14
  451. },
  452. lineStyle: {
  453. width: 30,
  454. color: [[0.2, '#80FF80'], [0.8, '#FF8080'], [1, '#8080FF']] // 刻度盘颜色分区
  455. },
  456. rich: {
  457. // 为第一个刻度盘设置刻度颜色
  458. '0%': {
  459. color: '#FF0000'
  460. },
  461. '50%': {
  462. color: '#00FF00'
  463. },
  464. '100%': {
  465. color: '#0000FF'
  466. }
  467. }
  468. },
  469. detail: {formatter: '{value} 小时'},
  470. data: data?data:{}
  471. }
  472. // ,{
  473. // type: 'gauge',
  474. // // 设置刻度盘的最大值
  475. // max: 24,
  476. // // 设置刻度盘的最小值
  477. // min: 0,
  478. // // 刻度盘轴
  479. // axisLine: {
  480. // textStyle: {
  481. // fontSize: 14
  482. // },
  483. // lineStyle: {
  484. // width: 30,
  485. // color: [[0.2, '#80FF80'], [0.8, '#FF8080'], [1, '#8080FF']] // 刻度盘颜色分区
  486. // },
  487. // rich: {
  488. // // 为第二个刻度盘设置刻度颜色
  489. // '0%': {
  490. // color: '#FFFF00'
  491. // },
  492. // '50%': {
  493. // color: '#00FFFF'
  494. // },
  495. // '100%': {
  496. // color: '#FF00FF'
  497. // }
  498. // }
  499. // },
  500. // detail: {formatter: '{value} 小时'},
  501. // data: data2?data2:{}
  502. // },
  503. ]
  504. };
  505. chart4.setOption(option, true);
  506. }
  507. function flushChart5(data1,data2,that) {
  508. var option = {
  509. // title: {
  510. // text: '睡眠状态监测',
  511. // left: 'center',
  512. // textStyle: {
  513. // color: '#ffffff', // 字体颜色
  514. // fontStyle: 'normal', // 字体风格
  515. // // fontWeight: 'bold', // 字体粗细
  516. // fontFamily: 'sans-serif', // 字体族
  517. // fontSize: 18 // 字体大小
  518. // },
  519. // backgroundColor: '#57f7ff'
  520. // },
  521. tooltip: {},
  522. xAxis: {
  523. data: data1?data1:[]
  524. },
  525. yAxis: {
  526. // Y 轴配置
  527. type: 'value',
  528. // 设置 Y 轴名称
  529. name: '单位:次',
  530. // 设置 Y 轴名称的位置
  531. nameLocation: 'end', // 可以是 'start'、'middle' 或 'end'
  532. axisLabel: {
  533. formatter: function (value) {
  534. return that.sleepStateChange(value);
  535. }
  536. },
  537. },
  538. series: [{
  539. type: 'line',
  540. data: data2?data2:[]
  541. }]
  542. };
  543. chart5.setOption(option, true);
  544. }
  545. function flushChart6(data1,data2,startSleepTime,endSleepTime,that) {
  546. var option = {
  547. backgroundColor: '#000000', // 设置背景色
  548. tooltip: {},
  549. xAxis: {
  550. data: data1?data1:[]
  551. },
  552. yAxis: {
  553. // Y 轴配置
  554. type: 'value',
  555. // 设置 Y 轴名称
  556. name: '睡眠状态',
  557. // 设置 Y 轴名称的位置
  558. nameLocation: 'end', // 可以是 'start'、'middle' 或 'end'
  559. axisLabel: {
  560. formatter: function (value) {
  561. return that.sleepStateChange(value);
  562. }
  563. }
  564. },
  565. series: [{
  566. type: 'line',
  567. data: data2?data2:[],
  568. lineStyle: { // 系列级个性化折线样式
  569. width: 10,
  570. type: 'solid',
  571. color: new echarts.graphic.LinearGradient(0, 0.4, 0.7, 1, [{
  572. offset: 0,
  573. color: '#ffb71b'
  574. } , {
  575. offset: 0.4,
  576. color: '#b75cee'
  577. }, {
  578. offset: 0.7,
  579. color: '#66acfc'
  580. }, {
  581. offset: 1,
  582. color: '#3843fa'
  583. }]),//线条渐变色
  584. },
  585. }
  586. // {
  587. // name: '分类2',
  588. // type: 'line',
  589. // data: data2,
  590. // lineStyle: { // 系列级个性化折线样式
  591. // width: 4,
  592. // type: 'solid',
  593. // color: new echarts.graphic.LinearGradient(0, 0.4, 0.7, 1, [{
  594. // offset: 0,
  595. // color: '#ffb71b'
  596. // } , {
  597. // offset: 0.4,
  598. // color: '#b75cee'
  599. // }, {
  600. // offset: 0.7,
  601. // color: '#66acfc'
  602. // }, {
  603. // offset: 1,
  604. // color: '#3843fa'
  605. // }]),//线条渐变色
  606. // },
  607. // },
  608. ],
  609. graphic: [{
  610. type: 'text',
  611. left: '5%', // 文本水平位置,这里设置为居中,你可以根据需要调整
  612. top: '90%', // 文本垂直位置,这里设置为距离顶部 10% 的位置,作为左下方的文本
  613. style: {
  614. text: '入睡时间:'+startSleepTime?startSleepTime:'', // 文本内容
  615. textFill: '#333', // 文本颜色
  616. textFontSize: 14, // 文本字体大小
  617. textAlign: 'left', // 文本水平对齐方式
  618. verticalAlign: 'middle' // 文本垂直对齐方式
  619. }
  620. }, {
  621. type: 'text',
  622. right: '5%', // 文本水平位置,这里设置为距离右侧 10% 的位置,作为右下方的文本
  623. top: '90%', // 文本垂直位置,这里设置为距离底部 10% 的位置
  624. style: {
  625. text: '醒来时间:'+endSleepTime?endSleepTime:'', // 文本内容
  626. textFill: '#333', // 文本颜色
  627. textFontSize: 14, // 文本字体大小
  628. textAlign: 'right', // 文本水平对齐方式
  629. verticalAlign: 'middle' // 文本垂直对齐方式
  630. }
  631. }],
  632. };
  633. // var list0 = [];
  634. // var list10 = [];
  635. // var list20 = [];
  636. // var list30 = [];
  637. // if(data2){
  638. // for (let i = 0; i < data2.length; i++) {
  639. // if (data2[i] == '0') {
  640. // list0.push(data2[i]);
  641. // }else if (data2[i] == '10') {
  642. // list10.push(data2[i]);
  643. // }else if (data2[i] == '20') {
  644. // list20.push(data2[i]);
  645. // }else if (data2[i] == '30') {
  646. // list30.push(data2[i]);
  647. // }else{
  648. // }
  649. // }
  650. // }
  651. // var option = {
  652. // xAxis: {
  653. // type: 'category',
  654. // data: data1
  655. // },
  656. // yAxis: {
  657. // type: 'value',
  658. // axisLabel: {
  659. // show: true,
  660. // position: 'buttom' // 分类标签显示在顶部,相当于曲线下方位置
  661. // }
  662. // },
  663. // series: [
  664. // {
  665. // name: '清醒',
  666. // type: 'line',
  667. // data: list0,
  668. // itemStyle: {
  669. // areaColor: new echarts.graphic.LinearGradient(
  670. // 0, 0, 0, 1,
  671. // [{ offset: 0, color: 'rgba(255, 0, 0, 0.3)' }, { offset: 1, color: 'rgba(255, 0, 0, 0)' }]
  672. // )
  673. // },
  674. // smooth: true,
  675. // lineStyle: {
  676. // color: 'red' // 线条颜色
  677. // }
  678. // },
  679. // {
  680. // name: '浅睡',
  681. // type: 'line',
  682. // data: list10,
  683. // itemStyle: {
  684. // areaColor: new echarts.graphic.LinearGradient(
  685. // 0, 0, 0, 1,
  686. // [{ offset: 0, color: 'rgba(0, 255, 0, 0.3)' }, { offset: 1, color: 'rgba(0, 255, 0, 0)' }]
  687. // )
  688. // },
  689. // smooth: true,
  690. // lineStyle: {
  691. // color: 'green' // 线条颜色
  692. // }
  693. // },
  694. // {
  695. // name: '中睡',
  696. // type: 'line',
  697. // data: list20,
  698. // itemStyle: {
  699. // areaColor: new echarts.graphic.LinearGradient(
  700. // 0, 0, 0, 1,
  701. // [{ offset: 0, color: 'rgba(0, 255, 0, 0.3)' }, { offset: 1, color: 'rgba(0, 255, 0, 0)' }]
  702. // )
  703. // },
  704. // smooth: true,
  705. // lineStyle: {
  706. // color: 'green' // 线条颜色
  707. // }
  708. // } ,
  709. // {
  710. // name: '深睡',
  711. // type: 'line',
  712. // data: list30,
  713. // itemStyle: {
  714. // areaColor: new echarts.graphic.LinearGradient(
  715. // 0, 0, 0, 1,
  716. // [{ offset: 0, color: 'rgba(0, 255, 0, 0.3)' }, { offset: 1, color: 'rgba(0, 255, 0, 0)' }]
  717. // )
  718. // },
  719. // smooth: true,
  720. // lineStyle: {
  721. // color: 'green' // 线条颜色
  722. // }
  723. // }
  724. // // 如果有更多分类,继续添加...
  725. // ],
  726. // tooltip: {
  727. // trigger: 'axis',
  728. // axisPointer: {
  729. // type: 'cross',
  730. // label: {
  731. // backgroundColor: '#6a7985'
  732. // }
  733. // }
  734. // },
  735. // graphic: [{
  736. // type: 'text',
  737. // left: '5%', // 文本水平位置,这里设置为居中,你可以根据需要调整
  738. // top: '90%', // 文本垂直位置,这里设置为距离顶部 10% 的位置,作为左下方的文本
  739. // style: {
  740. // text: '入睡时间:'+startSleepTime, // 文本内容
  741. // textFill: '#333', // 文本颜色
  742. // textFontSize: 14, // 文本字体大小
  743. // textAlign: 'left', // 文本水平对齐方式
  744. // verticalAlign: 'middle' // 文本垂直对齐方式
  745. // }
  746. // }, {
  747. // type: 'text',
  748. // right: '5%', // 文本水平位置,这里设置为距离右侧 10% 的位置,作为右下方的文本
  749. // top: '90%', // 文本垂直位置,这里设置为距离底部 10% 的位置
  750. // style: {
  751. // text: '醒来时间:'+endSleepTime, // 文本内容
  752. // textFill: '#333', // 文本颜色
  753. // textFontSize: 14, // 文本字体大小
  754. // textAlign: 'right', // 文本水平对齐方式
  755. // verticalAlign: 'middle' // 文本垂直对齐方式
  756. // }
  757. // }],
  758. // };
  759. chart6.setOption(option, true);
  760. }
  761. function flushChart7(data1,data2,startSleepTime,endSleepTime,that) {
  762. data1 = (!data1 || data1.length === 0)?['']:data1;
  763. data2 = (!data2 || data2.length === 0)?['']:data2;
  764. var option = {
  765. // backgroundColor: rgba(168, 115, 182, 0.5), // 设置背景色
  766. tooltip: {},
  767. xAxis: {
  768. axisLabel: {
  769. color: '#a5a5a5' ,// 设置 x 轴标签颜色为白色
  770. fontSize: 12,
  771. // interval: 0, // 设置为0表示全部显示,设置为非零值表示间隔显示
  772. // rotate: 45, // 旋转45度
  773. },
  774. splitLine: {
  775. show: false, // 是否显示刻度线
  776. },
  777. axisTick: {
  778. // 不显示Y轴刻度线
  779. show: false
  780. },
  781. data: data1,
  782. axisLine: {
  783. // 不显示X轴轴线
  784. show: false
  785. }
  786. },
  787. yAxis: {
  788. // Y 轴配置
  789. type: 'value',
  790. // inverse: true,// 设置 Y 轴逆序
  791. // 设置 Y 轴名称
  792. name: '离床次数',
  793. // 设置 Y 轴名称的位置
  794. nameLocation: 'end', // 可以是 'start'、'middle' 或 'end'
  795. axisLine: {
  796. // 不显示Y轴轴线
  797. show: false,
  798. },
  799. axisLabel: {
  800. color: '#000',
  801. show: true,
  802. fontSize: 12,
  803. formatter: function (value) {
  804. if(value == 0){
  805. return '离床';
  806. }else if(value == 1){
  807. return '在床';
  808. }else{
  809. return '';
  810. }
  811. }
  812. },
  813. axisTick: {
  814. // 不显示Y轴刻度线
  815. show: false
  816. },
  817. splitLine: {
  818. show: false ,// 不显示纵坐标轴的刻度线
  819. lineStyle: {
  820. color: 'rgba(222, 222, 222, 0.1)', // 灰色并调整透明度
  821. width: 1, // 刻度线宽度
  822. type: 'solid' // 刻度线类型,默认为实线
  823. }
  824. },
  825. },
  826. series: [{
  827. type: 'line',
  828. data: data2,
  829. smooth: true, // 使折线平滑
  830. markPoint: {
  831. symbol: 'circle', // 标记的符号为圆圈
  832. symbolSize: 10, // 标记的大小
  833. itemStyle: {
  834. color: 'rgba(85, 255, 127, 0.8)',
  835. // borderColor: 'blue',
  836. borderWidth: 1, // 设置边框宽度
  837. fill: 'none' // 设置填充颜色为无,即空心
  838. },
  839. data: [
  840. // 假设 data[0] 和 data[data.length - 1] 分别是开始和结束的数据点
  841. {coord: [data1?data1[0]:'', data2?data2[0]:''], name: '开始'},
  842. {coord: [data1?data1[data1.length-1]:'', data2?data2[data2.length-1]:''], name: '结束'}
  843. // 如果要添加拐角处的标记,需要手动计算并添加
  844. ]
  845. },
  846. areaStyle: { // 折线下方的区域样式
  847. color: new echarts.graphic.LinearGradient(
  848. 0, 0, 0, 1, // 渐变方向
  849. [ // 渐变颜色
  850. {offset: 0, color: 'rgba(85, 255, 127, 0.8)'}, // 使用之前定义的渐变
  851. {offset: 0.9, color: 'rgba(255, 255, 255, 1)'} // 可选,结束颜色
  852. ]
  853. ),
  854. opacity: 0.3 // 区域的不透明度,可以根据需要调整
  855. },
  856. lineStyle: {
  857. color: 'rgba(85, 255, 127, 0.8)' // 奶白色,80% 透明度
  858. },
  859. showSymbol: false // 是否显示标记图形
  860. }
  861. ],
  862. // graphic: {
  863. // type: 'rect',
  864. // left: 'center', // 相对于容器左侧的距离
  865. // top: 'bottom', // 相对于容器上侧的距离
  866. // width: 'auto', // 宽度自适应
  867. // height: '10', // 设置你想要的渐变高度
  868. // shape: {
  869. // // 可以通过 shape 来调整矩形的形状以适应你的需求
  870. // },
  871. // style: {
  872. // fill: {
  873. // type: 'linear',
  874. // x: 0,
  875. // y: 0,
  876. // x2: 0,
  877. // y2: 1,
  878. // colorStops: [{
  879. // offset: 0, color: 'rgba(0,0,0,0)' // 开始颜色,透明
  880. // }, {
  881. // offset: 1, color: 'rgba(255,0,0,0.3)' // 结束颜色,半透明红色
  882. // }],
  883. // global: false // 缺省为 false
  884. // },
  885. // // 其他样式配置
  886. // },
  887. // z: -1 // 设置层级,确保在折线图下方
  888. // }
  889. // graphic: [{
  890. // type: 'text',
  891. // left: '5%', // 文本水平位置,这里设置为居中,你可以根据需要调整
  892. // top: '90%', // 文本垂直位置,这里设置为距离顶部 10% 的位置,作为左下方的文本
  893. // style: {
  894. // text: '入睡时间:'+startSleepTime?startSleepTime:'', // 文本内容
  895. // textFill: '#333', // 文本颜色
  896. // textFontSize: 14, // 文本字体大小
  897. // textAlign: 'left', // 文本水平对齐方式
  898. // verticalAlign: 'middle' // 文本垂直对齐方式
  899. // }
  900. // }, {
  901. // type: 'text',
  902. // right: '5%', // 文本水平位置,这里设置为距离右侧 10% 的位置,作为右下方的文本
  903. // top: '90%', // 文本垂直位置,这里设置为距离底部 10% 的位置
  904. // style: {
  905. // text: '醒来时间:'+endSleepTime?endSleepTime:'', // 文本内容
  906. // textFill: '#333', // 文本颜色
  907. // textFontSize: 14, // 文本字体大小
  908. // textAlign: 'right', // 文本水平对齐方式
  909. // verticalAlign: 'middle' // 文本垂直对齐方式
  910. // }
  911. // }],
  912. };
  913. chart7.setOption(option, true);
  914. }
  915. function flushChart8(data1,data2,startSleepTime,endSleepTime,that) {
  916. var option = {
  917. // backgroundColor: rgba(168, 115, 182, 0.5), // 设置背景色
  918. tooltip: {},
  919. xAxis: {
  920. axisLabel: {
  921. color: '#000' // 设置 x 轴标签颜色为白色
  922. },
  923. splitLine: {
  924. show: false, // 是否显示刻度线
  925. },
  926. axisTick: {
  927. // 不显示Y轴刻度线
  928. show: false
  929. },
  930. axisLine: {
  931. // 不显示X轴轴线
  932. show: false
  933. },
  934. data: data1?data1:[]
  935. },
  936. yAxis: {
  937. // Y 轴配置
  938. type: 'value',
  939. // 设置 Y 轴名称
  940. name: '睡眠状态',
  941. // 设置 Y 轴名称的位置
  942. nameLocation: 'end', // 可以是 'start'、'middle' 或 'end'
  943. axisLine: {
  944. // 不显示Y轴轴线
  945. show: false,
  946. },
  947. axisTick: {
  948. // 不显示Y轴刻度线
  949. show: false
  950. },
  951. axisLabel: {
  952. color: '#000',
  953. formatter: function (value) {
  954. return that.sleepRmove_arrChange(value);
  955. }
  956. },
  957. splitLine: {
  958. show: false ,// 不显示纵坐标轴的刻度线
  959. lineStyle: {
  960. color: 'rgba(222, 222, 222, 0.1)', // 灰色并调整透明度
  961. width: 1, // 刻度线宽度
  962. type: 'solid' // 刻度线类型,默认为实线
  963. }
  964. },
  965. },
  966. series: [{
  967. type: 'line',
  968. data: data2?data2:[],
  969. lineStyle: {
  970. color: 'rgba(255, 255, 255, 0.8)' // 奶白色,80% 透明度
  971. },
  972. showSymbol: false, // 是否显示标记图形
  973. smooth: true, // 使折线平滑
  974. markPoint: {
  975. symbol: 'circle', // 标记的符号为圆圈
  976. symbolSize: 10, // 标记的大小
  977. itemStyle: {
  978. color: 'rgba(0, 170, 255, 0.8)',
  979. // borderColor: 'blue',
  980. borderWidth: 1, // 设置边框宽度
  981. fill: 'none' // 设置填充颜色为无,即空心
  982. },
  983. data: [
  984. // 假设 data[0] 和 data[data.length - 1] 分别是开始和结束的数据点
  985. {coord: [data1?data1[0]:'', data2?data2[0]:''], name: '开始'},
  986. {coord: [data1?data1[data1.length-1]:'', data2?data2[data2.length-1]:''], name: '结束'}
  987. // 如果要添加拐角处的标记,需要手动计算并添加
  988. ]
  989. },
  990. areaStyle: { // 折线下方的区域样式
  991. color: new echarts.graphic.LinearGradient(
  992. 0, 0, 0, 1, // 渐变方向
  993. [ // 渐变颜色
  994. {offset: 0, color: 'rgba(0, 170, 255, 0.8)'}, // 使用之前定义的渐变
  995. {offset: 0.9, color: 'rgba(255, 255, 255, 1)'} // 可选,结束颜色
  996. ]
  997. ),
  998. opacity: 0.3 // 区域的不透明度,可以根据需要调整
  999. },
  1000. },
  1001. ],
  1002. // graphic: [{
  1003. // type: 'text',
  1004. // left: '5%', // 文本水平位置,这里设置为居中,你可以根据需要调整
  1005. // top: '90%', // 文本垂直位置,这里设置为距离顶部 10% 的位置,作为左下方的文本
  1006. // style: {
  1007. // text: '入睡时间:'+startSleepTime?startSleepTime:'', // 文本内容
  1008. // textFill: '#333', // 文本颜色
  1009. // textFontSize: 14, // 文本字体大小
  1010. // textAlign: 'left', // 文本水平对齐方式
  1011. // verticalAlign: 'middle' // 文本垂直对齐方式
  1012. // }
  1013. // }, {
  1014. // type: 'text',
  1015. // right: '5%', // 文本水平位置,这里设置为距离右侧 10% 的位置,作为右下方的文本
  1016. // top: '90%', // 文本垂直位置,这里设置为距离底部 10% 的位置
  1017. // style: {
  1018. // text: '醒来时间:'+endSleepTime?endSleepTime:'', // 文本内容
  1019. // textFill: '#333', // 文本颜色
  1020. // textFontSize: 14, // 文本字体大小
  1021. // textAlign: 'right', // 文本水平对齐方式
  1022. // verticalAlign: 'middle' // 文本垂直对齐方式
  1023. // }
  1024. // }],
  1025. };
  1026. chart8.setOption(option, true);
  1027. }
  1028. function flushChart81(data1,data2,startSleepTime,endSleepTime,that) {
  1029. var option = {
  1030. // backgroundColor: rgba(168, 115, 182, 0.5), // 设置背景色
  1031. tooltip: {},
  1032. xAxis: {
  1033. axisLabel: {
  1034. color: '#000' // 设置 x 轴标签颜色为白色
  1035. },
  1036. splitLine: {
  1037. show: false, // 是否显示刻度线
  1038. },
  1039. axisTick: {
  1040. // 不显示Y轴刻度线
  1041. show: false
  1042. },
  1043. axisLine: {
  1044. // 不显示X轴轴线
  1045. show: false
  1046. },
  1047. data: data1?data1:[]
  1048. },
  1049. yAxis: {
  1050. // Y 轴配置
  1051. type: 'value',
  1052. // 设置 Y 轴名称
  1053. name: '呼吸平均值',
  1054. // 设置 Y 轴名称的位置
  1055. nameLocation: 'end', // 可以是 'start'、'middle' 或 'end'
  1056. axisLine: {
  1057. // 不显示Y轴轴线
  1058. show: false,
  1059. },
  1060. axisTick: {
  1061. // 不显示Y轴刻度线
  1062. show: false
  1063. },
  1064. axisLabel: {
  1065. color: '#000',
  1066. // formatter: function (value) {
  1067. // return that.sleepRmove_arrChange(value);
  1068. // }
  1069. },
  1070. splitLine: {
  1071. show: false ,// 不显示纵坐标轴的刻度线
  1072. lineStyle: {
  1073. color: 'rgba(222, 222, 222, 0.1)', // 灰色并调整透明度
  1074. width: 1, // 刻度线宽度
  1075. type: 'solid' // 刻度线类型,默认为实线
  1076. }
  1077. },
  1078. },
  1079. series: [{
  1080. type: 'line',
  1081. data: data2?data2:[],
  1082. lineStyle: {
  1083. color: 'rgba(0, 182, 182, 0.8)' // 奶白色,80% 透明度
  1084. },
  1085. showSymbol: false ,// 是否显示标记图形
  1086. smooth: true, // 使折线平滑
  1087. markPoint: {
  1088. symbol: 'circle', // 标记的符号为圆圈
  1089. symbolSize: 10, // 标记的大小
  1090. itemStyle: {
  1091. color: 'rgba(0, 182, 182, 0.8)',
  1092. // borderColor: 'blue',
  1093. borderWidth: 1, // 设置边框宽度
  1094. fill: 'none' // 设置填充颜色为无,即空心
  1095. },
  1096. data: [
  1097. // 假设 data[0] 和 data[data.length - 1] 分别是开始和结束的数据点
  1098. {coord: [data1?data1[0]:'', data2?data2[0]:''], name: '开始'},
  1099. {coord: [data1?data1[data1.length-1]:'', data2?data2[data2.length-1]:''], name: '结束'}
  1100. // 如果要添加拐角处的标记,需要手动计算并添加
  1101. ]
  1102. },
  1103. areaStyle: { // 折线下方的区域样式
  1104. color: new echarts.graphic.LinearGradient(
  1105. 0, 0, 0, 1, // 渐变方向
  1106. [ // 渐变颜色
  1107. {offset: 0, color: 'rgba(0, 182, 182, 0.8)'}, // 使用之前定义的渐变
  1108. {offset: 0.9, color: 'rgba(255, 255, 255, 1)'} // 可选,结束颜色
  1109. ]
  1110. ),
  1111. opacity: 0.3 // 区域的不透明度,可以根据需要调整
  1112. },
  1113. }
  1114. ],
  1115. // graphic: [{
  1116. // type: 'text',
  1117. // left: '5%', // 文本水平位置,这里设置为居中,你可以根据需要调整
  1118. // top: '90%', // 文本垂直位置,这里设置为距离顶部 10% 的位置,作为左下方的文本
  1119. // style: {
  1120. // text: '入睡时间:'+startSleepTime?startSleepTime:'', // 文本内容
  1121. // textFill: '#333', // 文本颜色
  1122. // textFontSize: 14, // 文本字体大小
  1123. // textAlign: 'left', // 文本水平对齐方式
  1124. // verticalAlign: 'middle' // 文本垂直对齐方式
  1125. // }
  1126. // }, {
  1127. // type: 'text',
  1128. // right: '5%', // 文本水平位置,这里设置为距离右侧 10% 的位置,作为右下方的文本
  1129. // top: '90%', // 文本垂直位置,这里设置为距离底部 10% 的位置
  1130. // style: {
  1131. // text: '醒来时间:'+endSleepTime?endSleepTime:'', // 文本内容
  1132. // textFill: '#333', // 文本颜色
  1133. // textFontSize: 14, // 文本字体大小
  1134. // textAlign: 'right', // 文本水平对齐方式
  1135. // verticalAlign: 'middle' // 文本垂直对齐方式
  1136. // }
  1137. // }],
  1138. };
  1139. chart81.setOption(option, true);
  1140. }
  1141. function flushChart9(data1,data2,startSleepTime,endSleepTime,that) {
  1142. var option = {
  1143. // backgroundColor: rgba(168, 115, 182, 0.5), // 设置背景色
  1144. tooltip: {},
  1145. xAxis: {
  1146. axisLabel: {
  1147. color: '#000' // 设置 x 轴标签颜色为白色
  1148. },
  1149. splitLine: {
  1150. show: false, // 是否显示刻度线
  1151. },
  1152. axisTick: {
  1153. // 不显示Y轴刻度线
  1154. show: false
  1155. },
  1156. axisLine: {
  1157. // 不显示X轴轴线
  1158. show: false
  1159. },
  1160. data: data1?data1:[]
  1161. },
  1162. yAxis: {
  1163. // Y 轴配置
  1164. type: 'value',
  1165. // 设置 Y 轴名称
  1166. name: '睡眠状态',
  1167. // 设置 Y 轴名称的位置
  1168. nameLocation: 'end', // 可以是 'start'、'middle' 或 'end'
  1169. axisLine: {
  1170. // 不显示Y轴轴线
  1171. show: false,
  1172. },
  1173. axisTick: {
  1174. // 不显示Y轴刻度线
  1175. show: false
  1176. },
  1177. axisLabel: {
  1178. color: '#000',
  1179. formatter: function (value) {
  1180. return that.sleepRsnoring_arrChange(value);
  1181. }
  1182. },
  1183. splitLine: {
  1184. show: false ,// 不显示纵坐标轴的刻度线
  1185. lineStyle: {
  1186. color: 'rgba(222, 222, 222, 0.1)', // 灰色并调整透明度
  1187. width: 1, // 刻度线宽度
  1188. type: 'solid' // 刻度线类型,默认为实线
  1189. }
  1190. },
  1191. },
  1192. series: [{
  1193. type: 'line',
  1194. data: data2?data2:[],
  1195. lineStyle: {
  1196. color: 'rgba(255, 170, 127, 0.8)' // 奶白色,80% 透明度
  1197. },
  1198. showSymbol: false ,// 是否显示标记图形
  1199. smooth: true, // 使折线平滑
  1200. markPoint: {
  1201. symbol: 'circle', // 标记的符号为圆圈
  1202. symbolSize: 10, // 标记的大小
  1203. itemStyle: {
  1204. color: 'rgba(255, 170, 127, 0.8)',
  1205. // borderColor: 'blue',
  1206. borderWidth: 1, // 设置边框宽度
  1207. fill: 'none' // 设置填充颜色为无,即空心
  1208. },
  1209. data: [
  1210. // 假设 data[0] 和 data[data.length - 1] 分别是开始和结束的数据点
  1211. {coord: [data1?data1[0]:'', data2?data2[0]:''], name: '开始'},
  1212. {coord: [data1?data1[data1.length-1]:'', data2?data2[data2.length-1]:''], name: '结束'}
  1213. // 如果要添加拐角处的标记,需要手动计算并添加
  1214. ]
  1215. },
  1216. areaStyle: { // 折线下方的区域样式
  1217. color: new echarts.graphic.LinearGradient(
  1218. 0, 0, 0, 1, // 渐变方向
  1219. [ // 渐变颜色
  1220. {offset: 0, color: 'rgba(255, 170, 127, 0.8)'}, // 使用之前定义的渐变
  1221. {offset: 0.9, color: 'rgba(255, 255, 255, 1)'} // 可选,结束颜色
  1222. ]
  1223. ),
  1224. opacity: 0.3 // 区域的不透明度,可以根据需要调整
  1225. },
  1226. }
  1227. ],
  1228. // graphic: [{
  1229. // type: 'text',
  1230. // left: '5%', // 文本水平位置,这里设置为居中,你可以根据需要调整
  1231. // top: '90%', // 文本垂直位置,这里设置为距离顶部 10% 的位置,作为左下方的文本
  1232. // style: {
  1233. // text: '入睡时间:'+startSleepTime?startSleepTime:'', // 文本内容
  1234. // textFill: '#333', // 文本颜色
  1235. // textFontSize: 14, // 文本字体大小
  1236. // textAlign: 'left', // 文本水平对齐方式
  1237. // verticalAlign: 'middle' // 文本垂直对齐方式
  1238. // }
  1239. // }, {
  1240. // type: 'text',
  1241. // right: '5%', // 文本水平位置,这里设置为距离右侧 10% 的位置,作为右下方的文本
  1242. // top: '90%', // 文本垂直位置,这里设置为距离底部 10% 的位置
  1243. // style: {
  1244. // text: '醒来时间:'+endSleepTime?endSleepTime:'', // 文本内容
  1245. // textFill: '#333', // 文本颜色
  1246. // textFontSize: 14, // 文本字体大小
  1247. // textAlign: 'right', // 文本水平对齐方式
  1248. // verticalAlign: 'middle' // 文本垂直对齐方式
  1249. // }
  1250. // }],
  1251. };
  1252. chart9.setOption(option, true);
  1253. }
  1254. function flushChart10(data1,data2,startSleepTime,endSleepTime,that) {
  1255. var option = {
  1256. // backgroundColor: rgba(168, 115, 182, 0.5), // 设置背景色
  1257. tooltip: {},
  1258. xAxis: {
  1259. axisLabel: {
  1260. color: '#000' // 设置 x 轴标签颜色为白色
  1261. },
  1262. splitLine: {
  1263. show: false, // 是否显示刻度线
  1264. },
  1265. axisTick: {
  1266. // 不显示Y轴刻度线
  1267. show: false
  1268. },
  1269. axisLine: {
  1270. // 不显示X轴轴线
  1271. show: false
  1272. },
  1273. data: data1?data1:[]
  1274. },
  1275. yAxis: {
  1276. // Y 轴配置
  1277. type: 'value',
  1278. // 设置 Y 轴名称
  1279. name: '睡眠状态',
  1280. // 设置 Y 轴名称的位置
  1281. nameLocation: 'end', // 可以是 'start'、'middle' 或 'end'
  1282. axisLine: {
  1283. // 不显示Y轴轴线
  1284. show: false,
  1285. },
  1286. axisTick: {
  1287. // 不显示Y轴刻度线
  1288. show: false
  1289. },
  1290. axisLabel: {
  1291. color: '#000',
  1292. formatter: function (value) {
  1293. return that.sleepRhxstop_arrChange(value);
  1294. }
  1295. },
  1296. splitLine: {
  1297. show: false ,// 不显示纵坐标轴的刻度线
  1298. lineStyle: {
  1299. color: 'rgba(222, 222, 222, 0.1)', // 灰色并调整透明度
  1300. width: 1, // 刻度线宽度
  1301. type: 'solid' // 刻度线类型,默认为实线
  1302. }
  1303. },
  1304. },
  1305. series: [{
  1306. type: 'line',
  1307. data: data2?data2:[],
  1308. lineStyle: {
  1309. color: 'rgba(0, 85, 255, 0.8)' // 奶白色,80% 透明度
  1310. },
  1311. showSymbol: false ,// 是否显示标记图形
  1312. smooth: true, // 使折线平滑
  1313. markPoint: {
  1314. symbol: 'circle', // 标记的符号为圆圈
  1315. symbolSize: 10, // 标记的大小
  1316. itemStyle: {
  1317. color: 'rgba(0, 85, 255, 0.8)',
  1318. // borderColor: 'blue',
  1319. borderWidth: 1, // 设置边框宽度
  1320. fill: 'none' // 设置填充颜色为无,即空心
  1321. },
  1322. data: [
  1323. // 假设 data[0] 和 data[data.length - 1] 分别是开始和结束的数据点
  1324. {coord: [data1?data1[0]:'', data2?data2[0]:''], name: '开始'},
  1325. {coord: [data1?data1[data1.length-1]:'', data2?data2[data2.length-1]:''], name: '结束'}
  1326. // 如果要添加拐角处的标记,需要手动计算并添加
  1327. ]
  1328. },
  1329. areaStyle: { // 折线下方的区域样式
  1330. color: new echarts.graphic.LinearGradient(
  1331. 0, 0, 0, 1, // 渐变方向
  1332. [ // 渐变颜色
  1333. {offset: 0, color: 'rgba(0, 85, 255, 0.8)'}, // 使用之前定义的渐变
  1334. {offset: 0.9, color: 'rgba(255, 255, 255, 1)'} // 可选,结束颜色
  1335. ]
  1336. ),
  1337. opacity: 0.3 // 区域的不透明度,可以根据需要调整
  1338. },
  1339. }
  1340. ],
  1341. // graphic: [{
  1342. // type: 'text',
  1343. // left: '5%', // 文本水平位置,这里设置为居中,你可以根据需要调整
  1344. // top: '90%', // 文本垂直位置,这里设置为距离顶部 10% 的位置,作为左下方的文本
  1345. // style: {
  1346. // text: '入睡时间:'+startSleepTime?startSleepTime:'', // 文本内容
  1347. // textFill: '#333', // 文本颜色
  1348. // textFontSize: 14, // 文本字体大小
  1349. // textAlign: 'left', // 文本水平对齐方式
  1350. // verticalAlign: 'middle' // 文本垂直对齐方式
  1351. // }
  1352. // }, {
  1353. // type: 'text',
  1354. // right: '5%', // 文本水平位置,这里设置为距离右侧 10% 的位置,作为右下方的文本
  1355. // top: '90%', // 文本垂直位置,这里设置为距离底部 10% 的位置
  1356. // style: {
  1357. // text: '醒来时间:'+endSleepTime?endSleepTime:'', // 文本内容
  1358. // textFill: '#333', // 文本颜色
  1359. // textFontSize: 14, // 文本字体大小
  1360. // textAlign: 'right', // 文本水平对齐方式
  1361. // verticalAlign: 'middle' // 文本垂直对齐方式
  1362. // }
  1363. // }],
  1364. };
  1365. chart10.setOption(option, true);
  1366. }
  1367. function flushChart11(data1,data2,that) {
  1368. // data2 = data2?data2.map(value => {
  1369. // return value+10;
  1370. // }):[];
  1371. let adjustedData = data2?data2.map(value => {
  1372. return 10;
  1373. }):[];
  1374. // var option = {
  1375. // // title: {
  1376. // // text: '睡眠呼吸监测',
  1377. // // left: 'center',
  1378. // // textStyle: {
  1379. // // color: '#ffffff', // 字体颜色
  1380. // // fontStyle: 'normal', // 字体风格
  1381. // // // fontWeight: 'bold', // 字体粗细
  1382. // // fontFamily: 'sans-serif', // 字体族
  1383. // // fontSize: 18 // 字体大小
  1384. // // },
  1385. // // backgroundColor: '#57f7ff'
  1386. // // },
  1387. // // grid: {
  1388. // // top: '10%',
  1389. // // height: '30%',
  1390. // // },
  1391. // tooltip: {},
  1392. // xAxis: {
  1393. // type: 'category',
  1394. // axisLabel: {
  1395. // color: 'rgba(0, 0, 0, 0.8)' // 设置 x 轴标签颜色为白色
  1396. // },
  1397. // axisTick: {
  1398. // // 不显示Y轴刻度线
  1399. // show: false
  1400. // },
  1401. // axisLine: {
  1402. // // 不显示X轴轴线
  1403. // show: false
  1404. // },
  1405. // splitLine: {
  1406. // show: false, // 是否显示刻度线
  1407. // },
  1408. // data: data1?data1:[]
  1409. // },
  1410. // yAxis: {
  1411. // // Y 轴配置
  1412. // type: 'value',
  1413. // // 设置 Y 轴名称
  1414. // name: '睡眠状态',
  1415. // // 设置 Y 轴名称的位置
  1416. // nameLocation: 'end', // 可以是 'start'、'middle' 或 'end'
  1417. // axisLine: {
  1418. // // 不显示Y轴轴线
  1419. // show: false,
  1420. // },
  1421. // axisTick: {
  1422. // // 不显示Y轴刻度线
  1423. // show: false
  1424. // },
  1425. // axisLabel: {
  1426. // color: '#000',
  1427. // formatter: function (value) {
  1428. // return that.sleepStateChange(value);
  1429. // }
  1430. // },
  1431. // splitLine: {
  1432. // show: false ,// 不显示纵坐标轴的刻度线
  1433. // lineStyle: {
  1434. // color: 'rgba(0, 170, 255, 0.9)', // 灰色并调整透明度
  1435. // width: 1, // 刻度线宽度
  1436. // type: 'solid' // 刻度线类型,默认为实线
  1437. // }
  1438. // },
  1439. // },
  1440. // series: [{
  1441. // type: 'bar',
  1442. // data: data2?data2:[],
  1443. // // barCategoryGap: '50%', // 类别间柱形距离
  1444. // // label: {
  1445. // // show: true,
  1446. // // position: 'top',
  1447. // // formatter: '{b}: {c}'
  1448. // // },
  1449. // stack: 'stackGroup',
  1450. // itemStyle: {
  1451. // color: 'rgba(0,0,0,0)' // 透明颜色
  1452. // },
  1453. // // itemStyle: {
  1454. // // color: function(params) {
  1455. // // // 根据数据或其他条件返回颜色值
  1456. // // // 这里只是简单地返回了一个颜色数组中的颜色
  1457. // // // var colorList = ['#c23531','#2f4554','#61a0a8','#d48265','#91c7ae','#749f83','#ca8622','#bda29a','#6e7074','#546570','#c4ccd3'];
  1458. // // if(params.value == '0'){
  1459. // // return '#e2e2e2'
  1460. // // }else if(params.value == '10'){
  1461. // // return '#8cc4ff'
  1462. // // }else if(params.value == '20'){
  1463. // // return '#a6b2ff'
  1464. // // }else if(params.value == '30'){
  1465. // // return '#9b79ff'
  1466. // // }else{
  1467. // // return '';
  1468. // // }
  1469. // // // return colorList[params.dataIndex % colorList.length];
  1470. // // }
  1471. // // }
  1472. // }]
  1473. // };
  1474. var option = {
  1475. xAxis: {
  1476. type: 'category',
  1477. data: data1?data1:[]
  1478. },
  1479. yAxis: {
  1480. type: 'value',
  1481. min: 0, // 确保 Y 轴从 0 开始
  1482. // max 可以根据需要设置,但通常不需要为了固定柱子高度而设置
  1483. axisLabel: {
  1484. color: '#000',
  1485. formatter: function (value) {
  1486. return that.sleepStateChange(value);
  1487. }
  1488. },
  1489. },
  1490. series: [
  1491. // 透明柱子,占满整个柱子空间
  1492. {
  1493. data: data2?data2:[],
  1494. type: 'bar',
  1495. stack: 'stackGroup',
  1496. itemStyle: {
  1497. color: 'rgba(0,0,0,0)' // 透明颜色
  1498. },
  1499. barGap: '-100%', // 设置柱子间距为负值,让柱子紧挨在一起
  1500. barMaxWidth: '30px' // 根据需要调整柱子宽度
  1501. },
  1502. // 有色柱子,只显示上半部分(固定高度)
  1503. {
  1504. data: adjustedData, // 固定高度数据
  1505. type: 'bar',
  1506. stack: 'stackGroup', // 与透明系列使用相同的叠加组名
  1507. itemStyle: {
  1508. color: function(params) {
  1509. console.log('params='+JSON.stringify(params))
  1510. if(data2 && data2[params.dataIndex] == 0){
  1511. return '#e2e2e2'
  1512. }else if(data2 && data2[params.dataIndex] == 10){
  1513. return '#d8c6ff'
  1514. }else if(data2 && data2[params.dataIndex] == 20){
  1515. return '#c6b3ff'
  1516. }else if(data2 && data2[params.dataIndex] == 30){
  1517. return '#b090ff'
  1518. }else{
  1519. return '';
  1520. }
  1521. }
  1522. },
  1523. barGap: '-100%', // 保持与透明系列相同的柱子间距
  1524. barMaxWidth: '30px' // 保持与透明系列相同的宽度
  1525. }
  1526. ]
  1527. };
  1528. chart11.setOption(option, true);
  1529. }
  1530. var homeApi = "https://haold.aidsleep.cn";
  1531. var homeApi_http = "http://haold.aidsleep.cn";
  1532. var homeApi_http_port = "8123";
  1533. var homeApi_https = "https://haold.aidsleep.cn";
  1534. const aipushApi = "https://aipush.aidsleep.cn";
  1535. const token_15 = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiN2JlOGE0MDExZjY0NjA2OGUxYjJiZTE4M2Y2NzU0NSIsImlhdCI6MTcxMTYxNDY2NCwiZXhwIjoyMDI2OTc0NjY0fQ.XJ73cXAoEsouTgvgpNVobq9oKdwlJr88TiAFLYlaahE";
  1536. var token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJlZGVjOWI3YWQ0MTQ0ZTIxYWQ1NTE1Nzc5NTkzNjBjNiIsImlhdCI6MTcxMjEzNTM2MywiZXhwIjoyMDI3NDk1MzYzfQ.IfrvdiaVuhCKsdy69JvUYhJ64bnhMT8MI1hN8R38whc";
  1537. const token_push = "b74fd5754c5ef24cf600c39194abdaeb";
  1538. Page({
  1539. /**
  1540. * 页面的初始数据
  1541. */
  1542. data: {
  1543. header: false,
  1544. nowDate: [{ //日历的初始化数据
  1545. month: 'current',
  1546. day: new Date().getDate(),
  1547. color: '#ffd700',
  1548. background: 'white'
  1549. }],
  1550. total1: 0,
  1551. total2: 0,
  1552. total3: 0,
  1553. temArr: [],
  1554. humArr: [],
  1555. clickDate: "",
  1556. status: "",
  1557. isShow: false,
  1558. year: addZero(new Date().getFullYear()),
  1559. month: addZero(new Date().getMonth()),
  1560. date: addZero(new Date().getDate()),
  1561. hours: addZero(new Date().getHours()),
  1562. moke_data: {
  1563. "20240414": [
  1564. {
  1565. sleepAllTime: 902,
  1566. sleepFeedback: "很好"
  1567. },
  1568. {
  1569. sleepAllTime: 222,
  1570. sleepFeedback: "疲惫"
  1571. }
  1572. ],
  1573. "20240415": [
  1574. {
  1575. sleepAllTime: 902,
  1576. sleepFeedback: "很好"
  1577. },
  1578. {
  1579. sleepAllTime: 222,
  1580. sleepFeedback: "疲惫"
  1581. },
  1582. {
  1583. sleepAllTime: 902,
  1584. sleepFeedback: "很好"
  1585. },
  1586. {
  1587. sleepAllTime: 222,
  1588. sleepFeedback: "疲惫"
  1589. },
  1590. {
  1591. sleepAllTime: 902,
  1592. sleepFeedback: "很好"
  1593. }
  1594. ]
  1595. },
  1596. rdt_arr: [],
  1597. rrh_arr: [],
  1598. rhx_arr: [],
  1599. rsnoring_arr: [],
  1600. routbed_arr: [],
  1601. rmove_arr: [],
  1602. rhxstop_arr: [],
  1603. rsleep_arr: [],
  1604. rdt_arrNew:[],//睡眠时间轴数据集合
  1605. rrh_arrNew:[],//睡眠心率数据集合
  1606. rhx_arrNew:[],//睡眠呼吸数据集合
  1607. rmove_arrNew:[],//体动状态数据集合,0-否,1-体动状态
  1608. rsleep_arrNew:[],//睡眠状态数据集合,0-清醒,10-浅睡,20-中睡,30-深睡
  1609. rsleep_arr_all_New:[],//睡眠状态数据集合,0-清醒,10-浅睡,20-中睡,30-深睡
  1610. durationData:[], //睡眠时长
  1611. sleep_duration:[], //睡眠和清醒对比
  1612. rdeep_duration: 0,
  1613. rlight_duration: 0,
  1614. rin_duration: 0,
  1615. rawake_duration: 0,
  1616. rrs_duration: 0,//入睡时长
  1617. routbed_count_value: 0,//离床次数
  1618. rsleep_eff_value: '',//睡眠效率
  1619. rdeep_durationFormat: '',
  1620. rlight_durationFormat: '',
  1621. rin_durationFormat: '',
  1622. rawake_durationFormat: '',
  1623. ravg_hx_value: 0,
  1624. ravg_hx_desc: '',
  1625. ravg_rh_value: 0,
  1626. ravg_rh_desc: '',
  1627. rscore_value: 0,
  1628. rscore_desc: '',
  1629. sleep_efficiency: '',//睡眠效率
  1630. zdTime: ["00:00","01:00","02:00","03:00","04:00","05:00",
  1631. ,"06:00","07:00","08:00","09:00","10:00","11:00"
  1632. ,"12:00","13:00","14:00","15:00","16:00","17:00"
  1633. ,"18:00","19:00","20:00","21:00","22:00","23:00"],
  1634. zdPoint: [],
  1635. percentage: 75, // 初始百分比值
  1636. canvasWidth: 0,
  1637. canvasHeight: 0,
  1638. rsn: '',
  1639. rdate: '',
  1640. rtotal_duration: 0,
  1641. rinbed_duration: 0,
  1642. rgobed_time: 0,
  1643. routbed_time: 0,
  1644. rgobed_routbed: 0,
  1645. sleepHourSub: 0,
  1646. routbed_count_value: 0,
  1647. isButtonClicked: false, // 用来控制按钮是否被点击的标记
  1648. home_room: [
  1649. 'company_laboratory',
  1650. '2802',
  1651. ],
  1652. isButtonPressed: false, // 用来标记按钮是否被按下
  1653. reportDate: '',
  1654. currentDate: '',
  1655. currentTime: '',
  1656. rmove_arrFrequency: 0,//体动次数
  1657. routbed_arrFrequency: 0,//离床次数
  1658. rsnoring_arrFrequency: 0,//打鼾次数
  1659. rhxstop_arrFrequency: 0,//呼吸暂停次数
  1660. sleep_durationCountA: 0,//睡眠时间
  1661. sns: [],
  1662. selectedValue: '', // 用于存储选中的值
  1663. selectedIndex: 0, // 默认选中第一个选项
  1664. hotelcode: '',//酒店编码
  1665. roomcode: '',//房间编码
  1666. rdeep_duration_efficiency: '',//深睡比例
  1667. rlight_duration_efficiency: '',//浅睡比例
  1668. rin_duration_efficiency: '',//中睡比例
  1669. isLoading: false,
  1670. ec7: '',
  1671. width7: '',
  1672. height7: '',
  1673. ec8: '',
  1674. width8: '',
  1675. height8: '',
  1676. ec1: '',
  1677. width1: '',
  1678. height1: '',
  1679. ec81: '',
  1680. width81: '',
  1681. height81: '',
  1682. ec9: '',
  1683. width9: '',
  1684. height9: '',
  1685. ec10: '',
  1686. width10: '',
  1687. height10: '',
  1688. ec11: '',
  1689. width11: '',
  1690. height11: '',
  1691. flushChart00Flag:false,
  1692. arrayFourth: [ [], []],//多级选择数组
  1693. valueFourth: [0, 0],//多级选择结果index
  1694. sourceFourth: [
  1695. {
  1696. id: 1,
  1697. text: '2024-05-24',
  1698. children: [{
  1699. id: 1,
  1700. text: '01:01~01:20',
  1701. reportId: '11111',
  1702. }, {
  1703. id: 2,
  1704. text: '03:05~04:20',
  1705. reportId: '22222',
  1706. }, {
  1707. id: 3,
  1708. text: '05:21~07:20',
  1709. reportId: '33333',
  1710. }]
  1711. },
  1712. {
  1713. id: 2,
  1714. text: '2024-05-23',
  1715. children: [{
  1716. id: 3,
  1717. text: '00:01~03:20',
  1718. reportId: '454545',
  1719. }, {
  1720. id: 4,
  1721. text: '00:03~06:20',
  1722. reportId: '66666',
  1723. }]
  1724. },
  1725. ],//后台读取的所及数据源
  1726. reportId: '',
  1727. hotelname: '',
  1728. roomname: '',
  1729. pushReportId: '',//推送用:reportId
  1730. },
  1731. //点击确定选择结果时,保存结果
  1732. bindMultiPickerChange: function (e) {
  1733. var result = e.detail.value;
  1734. var data = this.data.sourceFourth;
  1735. console.info('result='+result);
  1736. console.info('result[0]='+result[0]);
  1737. console.info('data[result[0]].text='+data[Number(result[0])].text);
  1738. console.info('data[result[0]].children[result[1]].text='+data[Number(result[0])].children[Number(result[1])].text);
  1739. this.setData({
  1740. reportDate: data[Number(result[0])].text,
  1741. rgobed_routbed: data[Number(result[0])].children[Number(result[1])].text,
  1742. reportId: data[Number(result[0])].children[Number(result[1])].reportId,
  1743. });
  1744. this.onPickerDateTimeChange(this.data.reportId);
  1745. },
  1746. //选择列变更时,处理下级数组变更
  1747. bindMultiPickerColumnChange: function (e) {
  1748. var column = e.detail.column;
  1749. var index = e.detail.value;
  1750. var array = this.data.arrayFourth;
  1751. if (column == 0) {
  1752. array[1] = array[column][index].children;
  1753. this.setData({
  1754. arrayFourth: array
  1755. });
  1756. } else if (column == 1) {
  1757. //最后一列不处理
  1758. }
  1759. },
  1760. drawCircle: function() {
  1761. // 创建 canvas 上下文
  1762. const ctx = wx.createCanvasContext('myCanvas');
  1763. // 设置圆环的颜色和样式
  1764. ctx.setStrokeStyle('green'); // 圆环的颜色
  1765. ctx.setLineWidth(20); // 圆环的宽度
  1766. // 绘制外圆
  1767. ctx.beginPath();
  1768. ctx.arc(80, 80, 50, 0, 2 * Math.PI); // 圆心 (100, 100),半径 100
  1769. ctx.stroke(); // 绘制外圆
  1770. // 绘制内圆(与外圆同圆心,但半径小20rpx,即80rpx)
  1771. ctx.beginPath();
  1772. ctx.arc(80, 80, 50, 0, 2 * Math.PI);
  1773. ctx.setFillStyle('white'); // 设置内圆的填充颜色为白色(或者透明,取决于你希望的效果)
  1774. ctx.fill(); // 填充内圆,这样圆环内部就是白色或透明的了
  1775. // 结束绘制并更新 canvas
  1776. ctx.draw();
  1777. },
  1778. startInterval: function () {
  1779. // 使用 setInterval 创建定时任务,每8秒执行一次 this.myMethod 方法
  1780. var that = this;
  1781. this.intervalId = setInterval(() => {
  1782. console.log(Date.now());
  1783. }, 6000);
  1784. },
  1785. clearInterval: function () {
  1786. // 清除定时任务
  1787. if (this.intervalId) {
  1788. clearInterval(this.intervalId);
  1789. this.intervalId = null;
  1790. }
  1791. },
  1792. onPickerChange: function(e) {
  1793. var that = this;
  1794. var selectedOption = this.data.sns[e.detail.value];
  1795. this.setData({
  1796. selectedIndex: e.detail.value,
  1797. selectedValue: selectedOption.pos,
  1798. rsn: selectedOption.sn,
  1799. });
  1800. console.log("e.detail.value="+e.detail.value);
  1801. console.log("selectedOption="+JSON.stringify(selectedOption));
  1802. this.getData(selectedOption.sn,this.data.hotelcode,this.data.roomcode,null);
  1803. //-----
  1804. //-----
  1805. this.selectComponent('#mychart-dom-bar00').init((canvas, width, height) => {
  1806. that.initChart00(canvas, width, height,null)
  1807. });
  1808. this.selectComponent('#mychart-dom-bar7').init((canvas, width, height) => {
  1809. that.initChart7(canvas, width, height,null)
  1810. });
  1811. this.selectComponent('#mychart-dom-bar8').init((canvas, width, height) => {
  1812. that.initChart8(canvas, width, height,null)
  1813. });
  1814. this.selectComponent('#mychart-dom-bar1').init((canvas, width, height) => {
  1815. that.initChart1(canvas, width, height,null)
  1816. });
  1817. this.selectComponent('#mychart-dom-bar81').init((canvas, width, height) => {
  1818. that.initChart81(canvas, width, height,null)
  1819. });
  1820. this.selectComponent('#mychart-dom-bar9').init((canvas, width, height) => {
  1821. that.initChart9(canvas, width, height,null)
  1822. });
  1823. this.selectComponent('#mychart-dom-bar10').init((canvas, width, height) => {
  1824. that.initChart10(canvas, width, height,null)
  1825. });
  1826. this.selectComponent('#mychart-dom-bar11').init((canvas, width, height) => {
  1827. that.initChart11(canvas, width, height,null)
  1828. });
  1829. },
  1830. onPickerDateTimeChange: function(reportId) {
  1831. var that = this;
  1832. // var selectedOption = this.data.sns[e.detail.value];
  1833. // this.setData({
  1834. // selectedIndex: e.detail.value,
  1835. // selectedValue: selectedOption.pos,
  1836. // rsn: selectedOption.sn,
  1837. // });
  1838. // console.log("e.detail.value="+e.detail.value);
  1839. // console.log("selectedOption="+JSON.stringify(selectedOption));
  1840. this.getData(that.data.sn,this.data.hotelcode,this.data.roomcode,reportId);
  1841. this.selectComponent('#mychart-dom-bar00').init((canvas, width, height) => {
  1842. that.initChart00(canvas, width, height,reportId)
  1843. });
  1844. this.selectComponent('#mychart-dom-bar7').init((canvas, width, height) => {
  1845. that.initChart7(canvas, width, height,reportId)
  1846. });
  1847. this.selectComponent('#mychart-dom-bar8').init((canvas, width, height) => {
  1848. that.initChart8(canvas, width, height,reportId)
  1849. });
  1850. this.selectComponent('#mychart-dom-bar1').init((canvas, width, height) => {
  1851. that.initChart1(canvas, width, height,reportId)
  1852. });
  1853. this.selectComponent('#mychart-dom-bar81').init((canvas, width, height) => {
  1854. that.initChart81(canvas, width, height,reportId)
  1855. });
  1856. this.selectComponent('#mychart-dom-bar9').init((canvas, width, height) => {
  1857. that.initChart9(canvas, width, height,reportId)
  1858. });
  1859. this.selectComponent('#mychart-dom-bar10').init((canvas, width, height) => {
  1860. that.initChart10(canvas, width, height,reportId)
  1861. });
  1862. this.selectComponent('#mychart-dom-bar11').init((canvas, width, height) => {
  1863. that.initChart11(canvas, width, height,reportId)
  1864. });
  1865. },
  1866. onButtonTap: function() {
  1867. // 切换按钮的样式类
  1868. this.setData({
  1869. isButtonPressed: !this.data.isButtonPressed
  1870. });
  1871. },
  1872. dayClick(event) { //日历点击选择日期
  1873. var that = this;
  1874. var clickDate = String(event.detail.year) + addZero(event.detail.month) + addZero(event.detail.day)
  1875. // that.getTargetData(clickDate)
  1876. console.log("change date", that.data.target_sleep_list)
  1877. flushChart(that.data.target_sleep_list)
  1878. that.setData({
  1879. nowDate: [{
  1880. month: 'current',
  1881. day: event.detail.day,
  1882. color: 'white',
  1883. background: '#82d5f8'
  1884. }, {
  1885. month: 'current',
  1886. day: new Date().getDate(),
  1887. color: '#ffd700',
  1888. background: 'white'
  1889. }],
  1890. clickDate: clickDate,
  1891. ec: {
  1892. onInit: that.construct_sleep_plot
  1893. }
  1894. })
  1895. },
  1896. getTargetData(date) {
  1897. var that = this;
  1898. var sleep_data = wx.getStorageSync("sleep_data")
  1899. console.log("find date is", date)
  1900. if (sleep_data || that.data.moke_data){
  1901. if (date == "20240414" || date == "20240415"){
  1902. var parse_sleep_data = that.data.moke_data[date]
  1903. }else{
  1904. var parse_sleep_data = JSON.parse(sleep_data)[date]
  1905. }
  1906. var sleep_cnt = 0
  1907. if (parse_sleep_data){
  1908. sleep_cnt = parse_sleep_data.length;
  1909. }
  1910. var sleep_time = 0.0;
  1911. var sleep_desc = "";
  1912. var sleep_tj_map = {
  1913. '早醒': 0,
  1914. '疲惫': 0,
  1915. '多梦': 0,
  1916. '很好': 0
  1917. };
  1918. var slepp_sugg = "";
  1919. var target_sleep_list = [];
  1920. for (var i in parse_sleep_data){
  1921. var fix_sleep_tm = (parse_sleep_data[i].sleepAllTime / 60).toFixed(1);
  1922. sleep_time += parseFloat(fix_sleep_tm);
  1923. sleep_tj_map[parse_sleep_data[i].sleepFeedback] += 1
  1924. target_sleep_list.push(parseFloat(fix_sleep_tm))
  1925. }
  1926. for(var j in sleep_tj_map){
  1927. if (sleep_tj_map[j] > 0){
  1928. sleep_desc += j + String(sleep_tj_map[j]) + " 次."
  1929. }
  1930. }
  1931. switch (sleep_cnt) {
  1932. case 5:
  1933. slepp_sugg = "继续保持睡前良好状态";
  1934. break;
  1935. case 1:
  1936. slepp_sugg = "学会释放工作压力";
  1937. break;
  1938. case 2:
  1939. slepp_sugg = "睡前一小时不要进行有氧运动";
  1940. break;
  1941. case 3:
  1942. slepp_sugg = "睡前尽量不要摄入高热量餐饮";
  1943. break;
  1944. case 0:
  1945. slepp_sugg = "还未产生睡眠报告";
  1946. break;
  1947. case 4:
  1948. slepp_sugg = "做一些助眠工作";
  1949. break;
  1950. }
  1951. that.setData({
  1952. data_dispaly: true,
  1953. sleep_cnt: sleep_cnt,
  1954. sleep_time: sleep_time.toFixed(1),
  1955. sleep_desc: sleep_desc,
  1956. slepp_sugg: slepp_sugg,
  1957. target_sleep_list: target_sleep_list,
  1958. ec0: {onInit: target_sleep_list},
  1959. ec: {onInit: target_sleep_list},
  1960. ec1: {onInit: target_sleep_list},
  1961. ec2: {onInit: target_sleep_list},
  1962. ec3: {onInit: target_sleep_list},
  1963. ec4: {onInit: target_sleep_list},
  1964. })
  1965. }
  1966. },
  1967. initChart000(canvas, width, height){
  1968. var that = this;
  1969. chart000 = echarts.init(canvas, null, {
  1970. width: width,
  1971. height: height
  1972. });
  1973. console.log("plot in ......")
  1974. canvas.setChart(chart000);
  1975. flushChart000();
  1976. },
  1977. initChart00(canvas, width, height,reportId){
  1978. var that = this;
  1979. wx.request({
  1980. url: `${aipushApi}`+'/getsn',
  1981. data: {
  1982. // "hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  1983. // "roomcode":that.data.hotelcode?that.data.roomcode:"nuange",
  1984. "hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  1985. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  1986. "token":token_push},
  1987. method: 'POST',
  1988. success(res) {
  1989. try {
  1990. if(res && res.data && res.data[0]){
  1991. that.setData({
  1992. roomname: res.data[0].rn
  1993. });
  1994. console.log("res.data=sn="+JSON.stringify(res.data));
  1995. wx.request({
  1996. url: `${aipushApi}`+'/getsingle',
  1997. data: {
  1998. "sn":that.data.rsn?that.data.rsn:res.data[0].sn,
  1999. "rpids":reportId,
  2000. "token":token_push},
  2001. method: 'POST',
  2002. success(ress) {
  2003. if(ress && ress.data){
  2004. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2005. try {
  2006. let rscore_descTemp = [];
  2007. if(ress.data.results.rscore_desc){
  2008. rscore_descTemp = ress.data.results.rscore_desc;
  2009. }
  2010. let rscore_valueTemp = [];
  2011. if(ress.data.results.rscore_value){
  2012. rscore_valueTemp = ress.data.results.rscore_value;
  2013. }
  2014. that.setData({
  2015. rscore_desc:rscore_descTemp,
  2016. rscore_value:rscore_valueTemp,
  2017. });
  2018. chart00 = echarts.init(canvas, null, {
  2019. width: width,
  2020. height: height
  2021. });
  2022. console.log("plot in ......")
  2023. canvas.setChart(chart00);
  2024. flushChart00(rscore_descTemp,rscore_valueTemp,that);
  2025. } catch (error) {
  2026. console.error(error);
  2027. }
  2028. // console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
  2029. // console.log("");
  2030. }
  2031. }
  2032. });
  2033. }
  2034. } catch (error) {
  2035. console.error(error);
  2036. }
  2037. },
  2038. })
  2039. },
  2040. initChart0(canvas, width, height){
  2041. var that = this;
  2042. chart0 = echarts.init(canvas, null, {
  2043. width: width,
  2044. height: height
  2045. });
  2046. console.log("plot in ......")
  2047. canvas.setChart(chart0);
  2048. var percentage = parseFloat(that.data.percentage)
  2049. var unPercentage = 100-percentage;
  2050. var percentages = []
  2051. var obj = {};
  2052. obj.name = '已完成';
  2053. obj.value = percentage;
  2054. percentages.push(obj);
  2055. obj = {};
  2056. obj.name = '未完成';
  2057. obj.value = unPercentage;
  2058. percentages.push(obj);
  2059. console.log("that.data.rdt_arrNew,that.data.rrh_arrNew="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
  2060. flushChart0(percentages);
  2061. },
  2062. initChart(canvas, width, height){
  2063. var that = this;
  2064. chart = echarts.init(canvas, null, {
  2065. width: width,
  2066. height: height
  2067. });
  2068. console.log("plot in ......")
  2069. canvas.setChart(chart);
  2070. flushChart(that.data.target_sleep_list)
  2071. },
  2072. initChart1(canvas, width, height,reportId){
  2073. var that = this;
  2074. wx.request({
  2075. url: `${aipushApi}`+'/getsn',
  2076. data: {
  2077. // "hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2078. // "roomcode":that.data.hotelcode?that.data.roomcode:"nuange",
  2079. "hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2080. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2081. "token":token_push},
  2082. method: 'POST',
  2083. success(res) {
  2084. try {
  2085. if(res && res.data && res.data[0]){
  2086. that.setData({
  2087. roomname: res.data[0].rn
  2088. });
  2089. console.log("res.data=sn="+JSON.stringify(res.data));
  2090. wx.request({
  2091. url: `${aipushApi}`+'/getsingle',
  2092. data: {
  2093. "sn":that.data.rsn?that.data.rsn:res.data[0].sn,
  2094. "token":token_push,
  2095. "rpids":reportId},
  2096. method: 'POST',
  2097. success(ress) {
  2098. if(ress && ress.data){
  2099. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2100. try {
  2101. let rdt_arrTemp = [];
  2102. if(ress.data.results.rrh_arr){
  2103. rdt_arrTemp = that.splitN(ress.data.results.rdt_arr.split(","),100);
  2104. }
  2105. if(ress.data.results.rdate){
  2106. that.setData({
  2107. reportDate: ress.data.results.rdate
  2108. });
  2109. }
  2110. let rrh_arrTemp = [];
  2111. if(ress.data.results.rrh_arr){
  2112. rrh_arrTemp = that.splitN(ress.data.results.rrh_arr.split(","),100);
  2113. }
  2114. that.setData({
  2115. rdt_arrNew:rdt_arrTemp,
  2116. rrh_arrNew:rrh_arrTemp,
  2117. });
  2118. chart1 = echarts.init(canvas, null, {
  2119. width: width,
  2120. height: height
  2121. });
  2122. // console.log("plot in ......")
  2123. canvas.setChart(chart1);
  2124. console.log("that.data.rdt_arrNew,that.data.rrh_arrNew="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
  2125. flushChart1(that.data.rdt_arrNew,that.data.rrh_arrNew);
  2126. } catch (error) {
  2127. console.error(error);
  2128. }
  2129. // console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
  2130. // console.log("");
  2131. }
  2132. }
  2133. });
  2134. }
  2135. } catch (error) {
  2136. console.error(error);
  2137. }
  2138. },
  2139. })
  2140. },
  2141. initChart2(canvas, width, height){
  2142. var that = this;
  2143. wx.request({
  2144. url: `${aipushApi}`+'/getsn',
  2145. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2146. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2147. "token":token_push},
  2148. method: 'POST',
  2149. success(res) {
  2150. try {
  2151. if(res && res.data && res.data[0]){
  2152. that.setData({
  2153. roomname: res.data[0].rn
  2154. });
  2155. wx.request({
  2156. url: `${aipushApi}`+'/getsingle',
  2157. data: {"sn":res.data[0].sn,
  2158. "token":token_push},
  2159. method: 'POST',
  2160. success(ress) {
  2161. if(ress&&ress.data){
  2162. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2163. try {
  2164. let durationDataTemp = [];
  2165. let obj = {};
  2166. obj.name = '深睡';
  2167. obj.value = ress.data.results.rdeep_duration;
  2168. durationDataTemp.push(obj);
  2169. obj = {};
  2170. obj.name = '中睡';
  2171. obj.value = ress.data.results.rin_duration;
  2172. durationDataTemp.push(obj);
  2173. obj = {};
  2174. obj.name = '浅睡';
  2175. obj.value = ress.data.results.rlight_duration;
  2176. durationDataTemp.push(obj);
  2177. obj = {};
  2178. obj.name = '清醒';
  2179. obj.value = ress.data.results.rawake_duration;
  2180. durationDataTemp.push(obj);
  2181. console.log("durationDataTemp="+JSON.stringify(durationDataTemp));
  2182. that.setData({
  2183. durationData:durationDataTemp,
  2184. });
  2185. chart2 = echarts.init(canvas, null, {
  2186. width: width,
  2187. height: height
  2188. });
  2189. // console.log("plot in ......")
  2190. canvas.setChart(chart2);
  2191. flushChart2(that.data.durationData)
  2192. } catch (error) {
  2193. console.error(error);
  2194. }
  2195. // console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
  2196. // console.log("");
  2197. }
  2198. },
  2199. });
  2200. }
  2201. } catch (error) {
  2202. console.error(error);
  2203. }
  2204. },
  2205. })
  2206. },
  2207. initChart3(canvas, width, height){
  2208. var that = this;
  2209. wx.request({
  2210. url: `${aipushApi}`+'/getsn',
  2211. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2212. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2213. "token":token_push},
  2214. method: 'POST',
  2215. success(res) {
  2216. try {
  2217. if(res && res.data && res.data[0]){
  2218. that.setData({
  2219. roomname: res.data[0].rn
  2220. });
  2221. wx.request({
  2222. url: `${aipushApi}`+'/getsingle',
  2223. data: {"sn":res.data[0].sn,
  2224. "token":token_push},
  2225. method: 'POST',
  2226. success(ress) {
  2227. if(ress && ress.data){
  2228. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2229. try {
  2230. let rdt_arrTemp = [];
  2231. if(ress.data.results.rrh_arr){
  2232. rdt_arrTemp = that.splitN(ress.data.results.rdt_arr.split(","),100);
  2233. }
  2234. let rhx_arrTemp = [];
  2235. if(ress.data.results.rhx_arr){
  2236. rhx_arrTemp = that.splitN(ress.data.results.rhx_arr.split(","),100);
  2237. }
  2238. that.setData({
  2239. rdt_arrNew:rdt_arrTemp,
  2240. rhx_arrNew:rhx_arrTemp,
  2241. });
  2242. chart3 = echarts.init(canvas, null, {
  2243. width: width,
  2244. height: height
  2245. });
  2246. console.log("plot in ......")
  2247. canvas.setChart(chart3);
  2248. flushChart3(that.data.rdt_arrNew,that.data.rhx_arrNew)
  2249. } catch (error) {
  2250. console.error(error);
  2251. }
  2252. // console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
  2253. // console.log("");
  2254. }
  2255. },
  2256. });
  2257. }
  2258. } catch (error) {
  2259. console.error(error);
  2260. }
  2261. },
  2262. })
  2263. },
  2264. initChart11(canvas, width, height,reportId){
  2265. var that = this;
  2266. wx.request({
  2267. url: `${aipushApi}`+'/getsn',
  2268. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2269. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2270. "token":token_push},
  2271. method: 'POST',
  2272. success(res) {
  2273. try {
  2274. if(res && res.data && res.data[0]){
  2275. that.setData({
  2276. roomname: res.data[0].rn
  2277. });
  2278. wx.request({
  2279. url: `${aipushApi}`+'/getsingle',
  2280. data: {"sn":that.data.rsn?that.data.rsn:res.data[0].sn,
  2281. "token":token_push,
  2282. "rpids":reportId},
  2283. method: 'POST',
  2284. success(ress) {
  2285. if(ress && ress.data){
  2286. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2287. try {
  2288. let rdt_arrTemp = [];
  2289. if(ress.data.results.rrh_arr){
  2290. rdt_arrTemp = that.splitN(ress.data.results.rdt_arr.split(","),100);
  2291. }
  2292. let rsleep_arr_Temp = [];
  2293. if(ress.data.results.rsleep_arr){
  2294. rsleep_arr_Temp = that.splitN(ress.data.results.rsleep_arr.split(","),100);
  2295. }
  2296. that.setData({
  2297. rdt_arrNew:rdt_arrTemp,
  2298. rsleep_arr:rsleep_arr_Temp,
  2299. rdeep_durationFormat: that.convertTimeToHoursAndMinutes(ress.data.results.rdeep_duration,1),
  2300. rlight_durationFormat: that.convertTimeToHoursAndMinutes(ress.data.results.rlight_duration,1),
  2301. rin_durationFormat: that.convertTimeToHoursAndMinutes(ress.data.results.rin_duration,1),
  2302. rawake_durationFormat: that.convertTimeToHoursAndMinutes(ress.data.results.rawake_duration,1),
  2303. });
  2304. console.log('ress.data.results.rdeep_duration='+ress.data.results.rdeep_duration);
  2305. console.log('ress.data.results.rlight_duration='+ress.data.results.rlight_duration);
  2306. console.log('ress.data.results.rin_duration='+ress.data.results.rin_duration);
  2307. console.log('ress.data.results.rawake_duration='+ress.data.results.rawake_duration);
  2308. chart11 = echarts.init(canvas, null, {
  2309. width: width,
  2310. height: height
  2311. });
  2312. console.log("plot in ......")
  2313. canvas.setChart(chart11);
  2314. flushChart11(that.data.rdt_arrNew,that.data.rsleep_arr,that)
  2315. } catch (error) {
  2316. console.error(error);
  2317. }
  2318. console.log("that.data.rsleep_arr="+that.data.rsleep_arr);
  2319. console.log("");
  2320. }
  2321. },
  2322. });
  2323. }
  2324. } catch (error) {
  2325. console.error(error);
  2326. }
  2327. },
  2328. })
  2329. },
  2330. initChart4(canvas, width, height){
  2331. var that = this;
  2332. wx.request({
  2333. url: `${aipushApi}`+'/getsn',
  2334. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2335. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2336. "token":token_push},
  2337. method: 'POST',
  2338. success(res) {
  2339. try {
  2340. if(res && res.data && res.data[0]){
  2341. that.setData({
  2342. roomname: res.data[0].rn
  2343. });
  2344. wx.request({
  2345. url: `${aipushApi}`+'/getsingle',
  2346. data: {"sn":res.data[0].sn,
  2347. "token":token_push},
  2348. method: 'POST',
  2349. success(ress) {
  2350. if(ress && ress.data){
  2351. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2352. try {
  2353. let sleep_durationCount = 0;
  2354. if(ress.data.results.rdeep_duration){
  2355. sleep_durationCount += parseFloat(ress.data.results.rdeep_duration)
  2356. }
  2357. if(ress.data.results.rlight_duration){
  2358. sleep_durationCount += parseFloat(ress.data.results.rlight_duration)
  2359. }
  2360. if(ress.data.results.rin_duration){
  2361. sleep_durationCount += parseFloat(ress.data.results.rin_duration)
  2362. }
  2363. let sleep_durationTemp = [];
  2364. // let data1 = [];
  2365. let obj1 = {};
  2366. obj1.name = '睡眠时间';
  2367. obj1.value = Math.ceil(sleep_durationCount / 60);
  2368. sleep_durationTemp.push(obj1);
  2369. // data1.push(obj1);
  2370. // let data2 = [];
  2371. obj1 = {};
  2372. obj1.name = '清醒时间';
  2373. obj1.value = Math.ceil(parseFloat(ress.data.results.rawake_duration) / 60);
  2374. sleep_durationTemp.push(obj1);
  2375. // data2.push(obj1);
  2376. that.setData({
  2377. sleep_duration:sleep_durationTemp,
  2378. });
  2379. chart4 = echarts.init(canvas, null, {
  2380. width: width,
  2381. height: height
  2382. });
  2383. console.log("plot in ......")
  2384. canvas.setChart(chart4);
  2385. // console.log("that.data.sleep_duration="+JSON.stringify(that.data.sleep_duration))
  2386. flushChart4(that.data.sleep_duration)
  2387. } catch (error) {
  2388. console.error(error);
  2389. }
  2390. console.log("");
  2391. }
  2392. },
  2393. });
  2394. }
  2395. } catch (error) {
  2396. console.error(error);
  2397. }
  2398. },
  2399. })
  2400. },
  2401. initChart5(canvas, width, height){
  2402. var that = this;
  2403. wx.request({
  2404. url: `${aipushApi}`+'/getsn',
  2405. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2406. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2407. "token":token_push},
  2408. method: 'POST',
  2409. success(res) {
  2410. if(res && res.data && res.data[0]){
  2411. that.setData({
  2412. roomname: res.data[0].rn
  2413. });
  2414. try {
  2415. wx.request({
  2416. url: `${aipushApi}`+'/getsingle',
  2417. data: {"sn":res.data[0].sn,
  2418. "token":token_push},
  2419. method: 'POST',
  2420. success(ress) {
  2421. if(ress && ress.data){
  2422. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2423. try {
  2424. let rdt_arrTemp = [];
  2425. if(ress.data.results.rrh_arr){
  2426. rdt_arrTemp = that.splitN(ress.data.results.rdt_arr.split(","),100);
  2427. }
  2428. let rsleep_arrTemp = [];
  2429. if(ress.data.results.rsleep_arr){
  2430. rsleep_arrTemp = that.splitN(ress.data.results.rsleep_arr.split(","),100);
  2431. }
  2432. that.setData({
  2433. rdt_arrNew:rdt_arrTemp,
  2434. rsleep_arrNew:rsleep_arrTemp,
  2435. });
  2436. chart5 = echarts.init(canvas, null, {
  2437. width: width,
  2438. height: height
  2439. });
  2440. console.log("plot in ......")
  2441. canvas.setChart(chart5);
  2442. flushChart5(that.data.rdt_arrNew,that.data.rsleep_arrNew,that)
  2443. } catch (error) {
  2444. console.error(error);
  2445. }
  2446. console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
  2447. console.log("");
  2448. }
  2449. },
  2450. });
  2451. } catch (error) {
  2452. console.error(error);
  2453. }
  2454. }
  2455. },
  2456. })
  2457. },
  2458. initChart6(canvas, width, height){
  2459. var that = this;
  2460. wx.request({
  2461. url: `${aipushApi}`+'/getsn',
  2462. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2463. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2464. "token":token_push},
  2465. method: 'POST',
  2466. success(res) {
  2467. try {
  2468. if(res && res.data && res.data[0]){
  2469. that.setData({
  2470. roomname: res.data[0].rn
  2471. });
  2472. wx.request({
  2473. url: `${aipushApi}`+'/getsingle',
  2474. data: {"sn":res.data[0].sn,
  2475. "token":token_push},
  2476. method: 'POST',
  2477. success(ress) {
  2478. if(ress && ress.data){
  2479. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2480. try {
  2481. var rsleep_arr_all_Temp = [];
  2482. if(ress.data.results.rsleep_arr){
  2483. rsleep_arr_all_Temp = ress.data.results.rsleep_arr.split(",");
  2484. }
  2485. that.setData({
  2486. rdt_arr: that.splitN(ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],100),
  2487. rsleep_arr_all: that.splitN(rsleep_arr_all_Temp,100),
  2488. rgobed_time: ress.data.results.rgobed_time,
  2489. routbed_time: ress.data.results.routbed_time,
  2490. rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
  2491. });
  2492. chart6 = echarts.init(canvas, null, {
  2493. width: width,
  2494. height: height
  2495. });
  2496. console.log("plot in ......")
  2497. canvas.setChart(chart6);
  2498. // var list = that.getRsleep_arr(ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(","):[])
  2499. flushChart6(that.data.rdt_arr,that.data.rsleep_arr_all,that.data.rgobed_time,that.data.routbed_time,that)
  2500. } catch (error) {
  2501. console.error(error);
  2502. }
  2503. console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
  2504. console.log("");
  2505. }
  2506. },
  2507. });
  2508. }
  2509. } catch (error) {
  2510. console.error(error);
  2511. }
  2512. },
  2513. })
  2514. },
  2515. initChart7(canvas, width, height,reportId){//离床次数
  2516. var that = this;
  2517. wx.request({
  2518. url: `${aipushApi}`+'/getsn',
  2519. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2520. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2521. "token":token_push},
  2522. method: 'POST',
  2523. success(res) {
  2524. try {
  2525. if(res && res.data && res.data[0]){
  2526. that.setData({
  2527. roomname: res.data[0].rn
  2528. });
  2529. wx.request({
  2530. url: `${aipushApi}`+'/getsingle',
  2531. data: {"sn":that.data.rsn?that.data.rsn:res.data[0].sn,
  2532. "token":token_push,
  2533. "rpids":reportId},
  2534. method: 'POST',
  2535. success(ress) {
  2536. if(ress && ress.data){
  2537. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2538. try {
  2539. var routbed_arr_Temp = [];
  2540. if(ress.data.results.routbed_arr){
  2541. routbed_arr_Temp = ress.data.results.routbed_arr.split(",");
  2542. }
  2543. that.setData({
  2544. // rdt_arr: that.splitN(ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],100),
  2545. // routbed_arr: that.splitN(routbed_arr_Temp,100),
  2546. rdt_arr: ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],
  2547. routbed_arr: routbed_arr_Temp,
  2548. rgobed_time: ress.data.results.rgobed_time,
  2549. routbed_time: ress.data.results.routbed_time,
  2550. rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
  2551. });
  2552. chart7 = echarts.init(canvas, null, {
  2553. width: width,
  2554. height: height
  2555. });
  2556. console.log("plot in ......")
  2557. canvas.setChart(chart7);
  2558. // var list = that.getRsleep_arr(ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(","):[])
  2559. // flushChart7(that.takePortionDateData(that.data.rdt_arr,that.data.routbed_arr,0),that.takePortionData(that.data.routbed_arr,0),that.data.routbed_time,that)
  2560. flushChart7(that.data.rdt_arr,that.data.routbed_arr,that.data.routbed_time,that)
  2561. } catch (error) {
  2562. console.error(error);
  2563. }
  2564. console.log("that.data.routbed_arr="+that.data.routbed_arr);
  2565. console.log("");
  2566. }
  2567. },
  2568. });
  2569. }
  2570. } catch (error) {
  2571. console.error(error);
  2572. }
  2573. },
  2574. })
  2575. },
  2576. initChart8(canvas, width, height,reportId){//体动次数
  2577. var that = this;
  2578. wx.request({
  2579. url: `${aipushApi}`+'/getsn',
  2580. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2581. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2582. "token":token_push},
  2583. method: 'POST',
  2584. success(res) {
  2585. try {
  2586. if(res && res.data && res.data[0]){
  2587. that.setData({
  2588. roomname: res.data[0].rn
  2589. });
  2590. wx.request({
  2591. url: `${aipushApi}`+'/getsingle',
  2592. data: {"sn":that.data.rsn?that.data.rsn:res.data[0].sn,
  2593. "token":token_push,
  2594. "rpids":reportId},
  2595. method: 'POST',
  2596. success(ress) {
  2597. if(ress && ress.data){
  2598. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2599. try {
  2600. var rmove_arr_Temp = [];
  2601. if(ress.data.results.rmove_arr){
  2602. rmove_arr_Temp = ress.data.results.rmove_arr.split(",");
  2603. }
  2604. that.setData({
  2605. rdt_arr: that.splitN(ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],100),
  2606. rmove_arr: that.splitN(rmove_arr_Temp,100),
  2607. rgobed_time: ress.data.results.rgobed_time,
  2608. routbed_time: ress.data.results.routbed_time,
  2609. rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
  2610. });
  2611. chart8 = echarts.init(canvas, null, {
  2612. width: width,
  2613. height: height
  2614. });
  2615. console.log("plot in ......")
  2616. canvas.setChart(chart8);
  2617. // var list = that.getRsleep_arr(ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(","):[])
  2618. flushChart8(that.data.rdt_arr,that.data.rmove_arr,that.data.rgobed_time,that.data.routbed_time,that)
  2619. } catch (error) {
  2620. console.error(error);
  2621. }
  2622. console.log("c8_that.data.rmove_arr="+that.data.rmove_arr);
  2623. console.log("");
  2624. }
  2625. },
  2626. });
  2627. }
  2628. } catch (error) {
  2629. console.error(error);
  2630. }
  2631. },
  2632. })
  2633. },
  2634. initChart81(canvas, width, height,reportId){//平均呼吸率
  2635. var that = this;
  2636. wx.request({
  2637. url: `${aipushApi}`+'/getsn',
  2638. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2639. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2640. "token":token_push},
  2641. method: 'POST',
  2642. success(res) {
  2643. try {
  2644. if(res && res.data && res.data[0]){
  2645. that.setData({
  2646. roomname: res.data[0].rn
  2647. });
  2648. wx.request({
  2649. url: `${aipushApi}`+'/getsingle',
  2650. data: {"sn":that.data.rsn?that.data.rsn:res.data[0].sn,
  2651. "token":token_push,
  2652. "rpids":reportId},
  2653. method: 'POST',
  2654. success(ress) {
  2655. if(ress && ress.data){
  2656. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2657. try {
  2658. var rhx_arr_Temp = [];
  2659. if(ress.data.results.rhx_arr){
  2660. rhx_arr_Temp = ress.data.results.rhx_arr.split(",");
  2661. }
  2662. that.setData({
  2663. rdt_arr: that.splitN(ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],100),
  2664. rhx_arr: that.splitN(rhx_arr_Temp,100),
  2665. rgobed_time: ress.data.results.rgobed_time,
  2666. routbed_time: ress.data.results.routbed_time,
  2667. rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
  2668. });
  2669. chart81 = echarts.init(canvas, null, {
  2670. width: width,
  2671. height: height
  2672. });
  2673. console.log("plot in ......")
  2674. canvas.setChart(chart81);
  2675. // var list = that.getRsleep_arr(ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(","):[])
  2676. flushChart81(that.data.rdt_arr,that.data.rhx_arr,that.data.rgobed_time,that.data.routbed_time,that)
  2677. } catch (error) {
  2678. console.error(error);
  2679. }
  2680. console.log("c81_that.data.ravg_hx_value="+that.data.ravg_hx_value);
  2681. console.log("");
  2682. }
  2683. },
  2684. });
  2685. }
  2686. } catch (error) {
  2687. console.error(error);
  2688. }
  2689. },
  2690. })
  2691. },
  2692. initChart9(canvas, width, height,reportId){//体动次数
  2693. var that = this;
  2694. wx.request({
  2695. url: `${aipushApi}`+'/getsn',
  2696. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2697. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2698. "token":token_push},
  2699. method: 'POST',
  2700. success(res) {
  2701. try {
  2702. if(res && res.data && res.data[0]){
  2703. that.setData({
  2704. roomname: res.data[0].rn
  2705. });
  2706. wx.request({
  2707. url: `${aipushApi}`+'/getsingle',
  2708. data: {"sn":that.data.rsn?that.data.rsn:res.data[0].sn,
  2709. "token":token_push,
  2710. "rpids":reportId},
  2711. method: 'POST',
  2712. success(ress) {
  2713. if(ress && ress.data){
  2714. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2715. try {
  2716. var rsnoring_arr_Temp = [];
  2717. if(ress.data.results.rsnoring_arr){
  2718. rsnoring_arr_Temp = ress.data.results.rsnoring_arr.split(",");
  2719. }
  2720. that.setData({
  2721. rdt_arr: that.splitN(ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],100),
  2722. rsnoring_arr: that.splitN(rsnoring_arr_Temp,100),
  2723. rgobed_time: ress.data.results.rgobed_time,
  2724. routbed_time: ress.data.results.routbed_time,
  2725. rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
  2726. });
  2727. chart9 = echarts.init(canvas, null, {
  2728. width: width,
  2729. height: height
  2730. });
  2731. console.log("plot in ......")
  2732. canvas.setChart(chart9);
  2733. // var list = that.getRsleep_arr(ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(","):[])
  2734. flushChart9(that.data.rdt_arr,that.data.rsnoring_arr,that.data.rgobed_time,that.data.routbed_time,that)
  2735. } catch (error) {
  2736. console.error(error);
  2737. }
  2738. console.log("c8_that.data.rmove_arr="+that.data.rmove_arr);
  2739. console.log("");
  2740. }
  2741. },
  2742. });
  2743. }
  2744. } catch (error) {
  2745. console.error(error);
  2746. }
  2747. },
  2748. })
  2749. },
  2750. initChart10(canvas, width, height,reportId){//体动次数
  2751. var that = this;
  2752. wx.request({
  2753. url: `${aipushApi}`+'/getsn',
  2754. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2755. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2756. "token":token_push},
  2757. method: 'POST',
  2758. success(res) {
  2759. try {
  2760. if(res && res.data && res.data[0]){
  2761. that.setData({
  2762. roomname: res.data[0].rn
  2763. });
  2764. wx.request({
  2765. url: `${aipushApi}`+'/getsingle',
  2766. data: {"sn":that.data.rsn?that.data.rsn:res.data[0].sn,
  2767. "token":token_push,
  2768. "rpids":reportId},
  2769. method: 'POST',
  2770. success(ress) {
  2771. if(ress && ress.data){
  2772. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2773. try {
  2774. var rhxstop_arr_Temp = [];
  2775. if(ress.data.results.rhxstop_arr){
  2776. rhxstop_arr_Temp = ress.data.results.rhxstop_arr.split(",");
  2777. }
  2778. that.setData({
  2779. rdt_arr: that.splitN(ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],100),
  2780. rhxstop_arr: that.splitN(rhxstop_arr_Temp,100),
  2781. rgobed_time: ress.data.results.rgobed_time,
  2782. routbed_time: ress.data.results.routbed_time,
  2783. rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
  2784. });
  2785. chart10 = echarts.init(canvas, null, {
  2786. width: width,
  2787. height: height
  2788. });
  2789. console.log("plot in ......")
  2790. canvas.setChart(chart10);
  2791. // var list = that.getRsleep_arr(ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(","):[])
  2792. flushChart10(that.data.rdt_arr,that.data.rhxstop_arr,that.data.rgobed_time,that.data.routbed_time,that)
  2793. } catch (error) {
  2794. console.error(error);
  2795. }
  2796. console.log("c8_that.data.rhxstop_arr="+that.data.rhxstop_arr);
  2797. console.log("");
  2798. }
  2799. },
  2800. });
  2801. }
  2802. } catch (error) {
  2803. console.error(error);
  2804. }
  2805. },
  2806. })
  2807. },
  2808. getRsleep_arr(list){
  2809. if(list){
  2810. console.log("getRsleep_arr_list1=="+JSON.stringify(list));
  2811. for (let i = 0; i < list.length; i++) {
  2812. if (list[i] == '0') {
  2813. list[i] = '清醒';
  2814. }else if (list[i] == '10') {
  2815. list[i] = '浅睡';
  2816. }else if (list[i] == '20') {
  2817. list[i] = '中睡';
  2818. }else if (list[i] == '30') {
  2819. list[i] = '深睡';
  2820. }else{
  2821. list[i] = '其他';
  2822. }
  2823. }
  2824. }
  2825. console.log("getRsleep_arr_list2=="+JSON.stringify(list));
  2826. },
  2827. getFrequency(list){//获取
  2828. if(list){
  2829. console.log("getRsleep_arr_list1=="+JSON.stringify(list));
  2830. for (let i = 0; i < list.length; i++) {
  2831. if (list[i] == '0') {
  2832. list[i] = '清醒';
  2833. }else if (list[i] == '10') {
  2834. list[i] = '浅睡';
  2835. }else if (list[i] == '20') {
  2836. list[i] = '中睡';
  2837. }else if (list[i] == '30') {
  2838. list[i] = '深睡';
  2839. }else{
  2840. list[i] = '其他';
  2841. }
  2842. }
  2843. }
  2844. console.log("getRsleep_arr_list2=="+JSON.stringify(list));
  2845. },
  2846. initChart12(canvas, width, height){//体动次数
  2847. var that = this;
  2848. wx.request({
  2849. url: `${aipushApi}`+'/getsn',
  2850. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2851. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2852. "token":token_push},
  2853. method: 'POST',
  2854. success(res) {
  2855. try {
  2856. if(res && res.data && res.data[0]){
  2857. that.setData({
  2858. roomname: res.data[0].rn
  2859. });
  2860. wx.request({
  2861. url: `${aipushApi}`+'/getsingle',
  2862. data: {"sn":res.data[0].sn,
  2863. "token":token_push},
  2864. method: 'POST',
  2865. success(ress) {
  2866. if(ress && ress.data){
  2867. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2868. try {
  2869. var rsnoring_arr_Temp = [];
  2870. if(ress.data.results.rsnoring_arr){
  2871. rsnoring_arr_Temp = ress.data.results.rsnoring_arr.split(",");
  2872. }
  2873. that.setData({
  2874. rdt_arr: that.splitN(ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],100),
  2875. rsnoring_arr: that.splitN(rsnoring_arr_Temp,100),
  2876. rgobed_time: ress.data.results.rgobed_time,
  2877. routbed_time: ress.data.results.routbed_time,
  2878. rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
  2879. });
  2880. chart9 = echarts.init(canvas, null, {
  2881. width: width,
  2882. height: height
  2883. });
  2884. console.log("plot in ......")
  2885. canvas.setChart(chart9);
  2886. // var list = that.getRsleep_arr(ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(","):[])
  2887. flushChart9(that.data.rdt_arr,that.data.rsnoring_arr,that.data.rgobed_time,that.data.routbed_time,that)
  2888. } catch (error) {
  2889. console.error(error);
  2890. }
  2891. console.log("c8_that.data.rmove_arr="+that.data.rmove_arr);
  2892. console.log("");
  2893. }
  2894. },
  2895. });
  2896. }
  2897. } catch (error) {
  2898. console.error(error);
  2899. }
  2900. },
  2901. })
  2902. },
  2903. sleepStateChange(data){
  2904. console.log("change-data=="+data)
  2905. switch(data) {
  2906. case 0:
  2907. return '清醒';
  2908. case 10:
  2909. return '浅睡';
  2910. case 20:
  2911. return '中睡';
  2912. case 30:
  2913. return '深睡';
  2914. default:
  2915. return '';
  2916. }
  2917. },
  2918. sleepRoutbed_arrChange(data){
  2919. console.log("change-data=="+data)
  2920. switch(data) {
  2921. case 0:
  2922. return '离床';
  2923. case 1:
  2924. return '在床';
  2925. default:
  2926. return '';
  2927. }
  2928. },
  2929. sleepRmove_arrChange(data){
  2930. console.log("change-data=="+data)
  2931. switch(data) {
  2932. case 0:
  2933. return '否';
  2934. case 1:
  2935. return '体动';
  2936. default:
  2937. return '';
  2938. }
  2939. },
  2940. sleepRsnoring_arrChange(data){
  2941. console.log("change-data=="+data)
  2942. switch(data) {
  2943. case 0:
  2944. return '否';
  2945. case 1:
  2946. return '打鼾';
  2947. default:
  2948. return '';
  2949. }
  2950. },
  2951. sleepRhxstop_arrChange(data){
  2952. console.log("change-data=="+data)
  2953. switch(data) {
  2954. case 0:
  2955. return '否';
  2956. case 1:
  2957. return '停止';
  2958. default:
  2959. return '';
  2960. }
  2961. },
  2962. splitN(originalArray,n){
  2963. if(!originalArray) return [];
  2964. // 计算每份的大小
  2965. let chunkSize = Math.ceil(originalArray.length / n);
  2966. // 分割数组并获取每份的最后一个元素
  2967. let lastElements = [];
  2968. for (let i = 0; i < originalArray.length; i += chunkSize) {
  2969. let chunk = originalArray.slice(i, i + chunkSize);
  2970. lastElements.push(chunk[chunk.length - 1]);
  2971. }
  2972. // 输出每份的最后一个元素
  2973. console.log('lastElements='+lastElements);
  2974. return lastElements;
  2975. },
  2976. takePortionDateData(rdt_arrArray,originalArray,n){
  2977. if(!rdt_arrArray || !originalArray) return [];
  2978. var portionDateData = [];
  2979. var portionData = [];
  2980. for (let i = 0; i < originalArray.length; i ++) {
  2981. if(originalArray[i] == n){
  2982. portionDateData.push(rdt_arrArray[i]);
  2983. portionData.push(originalArray[i]);
  2984. } else{
  2985. }
  2986. }
  2987. console.log('portionDateData='+JSON.stringify(portionDateData));
  2988. return portionDateData;
  2989. },
  2990. takePortionData(originalArray,n){
  2991. if(!originalArray) return [];
  2992. var portionData = [];
  2993. for (let i = 0; i < originalArray.length; i ++) {
  2994. if(originalArray[i] == n){
  2995. portionData.push(originalArray[i])
  2996. } else{
  2997. }
  2998. }
  2999. console.log('portionData='+JSON.stringify(portionData));
  3000. return portionData;
  3001. },
  3002. getFrequency(list,o){//获取次数
  3003. if(!list) return 0;
  3004. let frequency = 0;
  3005. for (let i = 0; i < list.length; i++) {
  3006. if(list[i] == o) frequency++;
  3007. }
  3008. console.log('frequency='+frequency);
  3009. return frequency;
  3010. },
  3011. getTimeDiffInHours: function(startTimeStr, endTimeStr) {
  3012. // 假设两个时间都是同一天的,这里我们使用当前日期作为基准
  3013. if(!startTimeStr || !endTimeStr) return null;
  3014. const now = new Date();
  3015. const startDate = new Date(now.getFullYear(), now.getMonth(), now.getDate(), ...startTimeStr.split(':').map(Number));
  3016. const endDate = new Date(now.getFullYear(), now.getMonth(), now.getDate(), ...endTimeStr.split(':').map(Number));
  3017. // 处理跨天的情况
  3018. if (endDate < startDate) {
  3019. endDate.setDate(endDate.getDate() + 1); // 将结束时间设置为第二天的同一时间
  3020. }
  3021. // 计算时间差(毫秒)
  3022. const diffInMs = endDate - startDate;
  3023. // 转换为小时
  3024. const diffInHours = diffInMs / (1000 * 60 * 60);
  3025. return diffInHours;
  3026. },
  3027. drawProgressCircle: function() {
  3028. const ctx = wx.createCanvasContext('progressCircleCanvas');
  3029. // 假设屏幕的宽度为 windowWidth px
  3030. const windowWidth = wx.getSystemInfoSync().windowWidth;
  3031. // 假设你有一个以 rpx 为单位的值
  3032. const valueInRpx = 300;
  3033. // 计算对应的 px 值
  3034. const valueInPx = (valueInRpx / 750) * windowWidth;
  3035. const radius = 60; // 圆的半径
  3036. const centerX = valueInPx; // 圆心的x坐标
  3037. const centerY = valueInPx/2; // 圆心的y坐标
  3038. const strokeWidth = 10; // 进度条的宽度
  3039. const percentage = this.data.percentage; // 进度百分比
  3040. // 绘制外圆
  3041. ctx.beginPath();
  3042. ctx.arc(centerX, centerY, radius, 0, 2 * Math.PI);
  3043. ctx.setStrokeStyle('#46ff81'); // 外圆颜色
  3044. ctx.setLineWidth(strokeWidth * 2); // 外圆线宽
  3045. ctx.stroke();
  3046. // 绘制内圆(进度条背景)
  3047. ctx.beginPath();
  3048. ctx.arc(centerX, centerY, radius - strokeWidth, 0, 2 * Math.PI);
  3049. ctx.setStrokeStyle('#e0e0e0'); // 内圆颜色
  3050. ctx.setLineWidth(strokeWidth); // 内圆线宽
  3051. ctx.stroke();
  3052. // 绘制进度条
  3053. ctx.beginPath();
  3054. ctx.arc(centerX, centerY, radius - strokeWidth, -0.5 * Math.PI, -0.5 * Math.PI + 2 * Math.PI * (percentage / 100));
  3055. ctx.setStrokeStyle('#007aff'); // 进度条颜色
  3056. ctx.setLineWidth(strokeWidth);
  3057. ctx.setLineCap('round'); // 设置线条端点的样式为圆形
  3058. ctx.stroke();
  3059. // 绘制中心圆点
  3060. ctx.beginPath();
  3061. ctx.arc(centerX, centerY, 5, 0, 2 * Math.PI);
  3062. ctx.setFillStyle('#ffffff');
  3063. ctx.fill();
  3064. // 绘制完成,将内容渲染到canvas中
  3065. ctx.draw();
  3066. },
  3067. // 假设你有一个方法来更新进度条的值
  3068. updateProgress: function(newPercentage) {
  3069. this.setData({
  3070. percentage: newPercentage
  3071. });
  3072. this.drawProgressCircle(); // 重新绘制进度条
  3073. },
  3074. buttonClicked: function() {
  3075. var that = this;
  3076. // 切换按钮的点击状态
  3077. this.setData({
  3078. isButtonClicked: !that.data.isButtonClicked,
  3079. });
  3080. // 在这里可以添加其他点击后的逻辑,比如调用接口等
  3081. },
  3082. telScreeProjection: function() {
  3083. var that = this;
  3084. that.setData({
  3085. isLoading: true,
  3086. });
  3087. wx.request({
  3088. url: `${aipushApi}`+'/getbigreport',
  3089. method: 'POST',
  3090. header: {
  3091. 'content-type': 'application/json', // 默认值
  3092. 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
  3093. },
  3094. data:{
  3095.     "sn":that.data.rsn,"tokens":token_push
  3096. },
  3097. success(ress) {
  3098. console.log('wx.getStorageSync(tvEntityId)='+wx.getStorageSync('tvEntityId'));
  3099. if(ress && ress.data && wx.getStorageSync('tvEntityId')){
  3100. console.log("ress.data=="+JSON.stringify(ress.data.url));
  3101. console.log("wx.getStorageSync(tvEntityId)=="+wx.getStorageSync('tvEntityId'));
  3102. wx.request({
  3103. // url: `${homeApi_http}`+':'+`${homeApi_http_port}`+'/api/services/media_player/play_media', //http
  3104. // url: `${homeApi_https}`+'/api/services/media_player/play_media', //https
  3105. url: `${homeApi_https}`+'/api/services/media_player/select_source', //https
  3106. method: 'POST',
  3107. header: {
  3108. 'content-type': 'application/json', // 默认值
  3109. 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
  3110. },
  3111. data:{
  3112.     "entity_id": wx.getStorageSync('tvEntityId'),
  3113. //     "media_content_id": ress.data.url,
  3114. // "media_content_id": 'https://alifei01.cfp.cn/creative/vcg/800/new/VCG41175510742.jpg',
  3115. // "media_content_id": 'https://alifei01.cfp.cn/creative/vcg/veer/1600water/veer-368621010.jpg',
  3116. //     "media_content_type": "image/jpeg/png",
  3117. "source": "X浏览器"
  3118. },
  3119. success(res) {
  3120. that.setData({
  3121. isLoading: false,
  3122. });
  3123. if(res && res.data){
  3124. var resData = res.data
  3125. console.log('res-推送='+JSON.stringify(res));
  3126. console.log('res.data-推送='+JSON.stringify(resData));
  3127. wx.showToast({
  3128. title: "推送成功",
  3129. icon: "success",
  3130. mask: true,
  3131. });
  3132. }else{
  3133. wx.showToast({
  3134. title: '推送失败',
  3135. icon: 'none'
  3136. });
  3137. }
  3138. },
  3139. fail: function (error) {
  3140. // 请求失败后的回调函数
  3141. console.error('推送失败', error);
  3142. // 在这里处理请求失败的情况,比如显示错误信息给用户
  3143. that.setData({
  3144. isLoading: false,
  3145. });
  3146. wx.showToast({
  3147. title: '推送失败',
  3148. icon: 'none'
  3149. });
  3150. }
  3151. });
  3152. }else{
  3153. that.setData({
  3154. isLoading: false,
  3155. });
  3156. wx.showToast({
  3157. title: '电视找不到,推送失败',
  3158. icon: 'none'
  3159. });
  3160. }
  3161. },
  3162. });
  3163. },
  3164. getData(sn,hotelcode,roomcode,reportId){
  3165. var that = this;
  3166. wx.request({
  3167. url: `${aipushApi}`+'/getsn',
  3168. data: {"hotelcode":hotelcode?hotelcode:"club",
  3169. "roomcode":roomcode?roomcode:"nuange",
  3170. "token":token_push},
  3171. method: 'POST',
  3172. success(res) {
  3173. try {
  3174. // that.setData({
  3175. // airText: now.category, //空气质量
  3176. // airValue: now.aqi //空气指数
  3177. // })
  3178. if(res && res.data && res.data[0]){
  3179. that.setData({
  3180. roomname: res.data[0].rn
  3181. });
  3182. console.log("res.data-sn="+JSON.stringify(res.data));
  3183. wx.request({
  3184. url: `${aipushApi}`+'/getsingle',
  3185. data: {"sn":sn?sn:res.data[0].sn,
  3186. "token":token_push,
  3187. "rpids":reportId},
  3188. method: 'POST',
  3189. success(ress) {
  3190. try {
  3191. if(ress && ress.data){
  3192. console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  3193. // that.setData({
  3194. // airText: now.category, //空气质量
  3195. // airValue: now.aqi //空气指数
  3196. // })
  3197. // rdt_arr = ress.data.results.rdt_arr //睡眠时间轴数据集合
  3198. // rrh_arr = ress.data.results.rdt_arr//睡眠心率数据集合
  3199. // rhx_arr = ress.data.results.rhx_arr//睡眠呼吸数据集合
  3200. // rsnoring_arr = ress.data.results.rsnoring_arr//睡眠打鼾数据集合,0-否,1-打鼾状态
  3201. // routbed_arr = ress.data.results.routbed_arr//离床状态数据集合,0-离床,1-在床
  3202. // rmove_arr = ress.data.results.rmove_arr//体动状态数据集合,0-否,1-体动状态
  3203. // rhxstop_arr = ress.data.results.rhxstop_arr//呼吸停止状态数据集合
  3204. // rsleep_arr = ress.data.results.rsleep_arr//睡眠状态数据集合,0-清醒,10-浅睡,20-中睡,30-深睡
  3205. // rdeep_duration = ress.data.results.rdeep_duration//深睡时长,单位分钟
  3206. // rlight_duration = ress.data.results.rlight_duration//浅睡时长,单位分钟
  3207. // rin_duration = ress.data.results.rin_duration//中睡时长,单位分钟
  3208. // rawake_duration = ress.data.results.rawake_duration//清醒时长,单位分钟
  3209. // ravg_hx_value = ress.data.results.ravg_hx_value//呼吸平均值
  3210. // ravg_hx_desc = ress.data.results.ravg_hx_desc//呼吸平均值评分描述
  3211. // ravg_rh_value = ress.data.results.ravg_rh_value//心率平均值
  3212. // ravg_rh_desc = ress.data.results.ravg_rh_desc//心率平均值评分描述
  3213. // rscore_value = ress.data.results.rscore_value//睡眠报告得分值
  3214. // rscore_desc = ress.data.results.rscore_desc//睡眠报告得分评比描述
  3215. // that.setData({
  3216. // rdt_arr: ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],
  3217. // rrh_arr: ress.data.results.rrh_arr?ress.data.results.rrh_arr.split(','):[],
  3218. // rhx_arr: ress.data.results.rhx_arr?ress.data.results.rhx_arr.split(','):[],
  3219. // rsnoring_arr: ress.data.results.rsnoring_arr?ress.data.results.rsnoring_arr.split(','):[],
  3220. // routbed_arr: ress.data.results.routbed_arr?ress.data.results.routbed_arr.split(','):[],
  3221. // rmove_arr: ress.data.results.rmove_arr?ress.data.results.rmove_arr.split(','):[],
  3222. // rhxstop_arr: ress.data.results.rhxstop_arr?ress.data.results.rhxstop_arr.split(','):[],
  3223. // rsleep_arr: ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(','):[],
  3224. // rdeep_duration: ress.data.results.rdeep_duration,
  3225. // rlight_duration: ress.data.results.rlight_duration,
  3226. // rin_duration: ress.data.results.rin_duration,
  3227. // rawake_duration: ress.data.results.rawake_duration,
  3228. // ravg_hx_value: ress.data.results.ravg_hx_value,
  3229. // ravg_hx_desc: ress.data.results.ravg_hx_desc,
  3230. // ravg_rh_value: ress.data.results.ravg_rh_value,
  3231. // ravg_rh_desc: ress.data.results.ravg_rh_desc,
  3232. // rscore_value: ress.data.results.rscore_value,
  3233. // rscore_desc: ress.data.results.rscore_desc,
  3234. // rsn: ress.data.results.rsn,
  3235. // rdate: ress.data.results.rdate,
  3236. // rtotal_duration: ress.data.results.rtotal_duration,//睡眠总时长,单位分钟
  3237. // rinbed_duration: ress.data.results.rinbed_duration,//在床时长,单位分钟
  3238. // rgobed_time: ress.data.results.rgobed_time,//上床时间
  3239. // routbed_time: ress.data.results.routbed_time,//离床时间
  3240. // routbed_count_value: ress.data.results.routbed_count_value,//离床次数
  3241. // rsn: ress.data.results.rsn,
  3242. // });
  3243. let durationDataTemp = [];
  3244. let obj = {};
  3245. obj.name = '深睡';
  3246. obj.value = ress.data.results.rdeep_duration;
  3247. durationDataTemp.push(obj);
  3248. obj = {};
  3249. obj.name = '浅睡';
  3250. obj.value = ress.data.results.rlight_duration;
  3251. durationDataTemp.push(obj);
  3252. obj = {};
  3253. obj.name = '中睡';
  3254. obj.value = ress.data.results.rin_duration;
  3255. durationDataTemp.push(obj);
  3256. obj = {};
  3257. obj.name = '清醒';
  3258. obj.value = ress.data.results.rawake_duration;
  3259. durationDataTemp.push(obj);
  3260. console.log("durationDataTemp="+JSON.stringify(durationDataTemp));
  3261. let sleep_durationCount = 0;
  3262. if(ress.data.results.rdeep_duration){
  3263. sleep_durationCount += parseFloat(ress.data.results.rdeep_duration)
  3264. }
  3265. if(ress.data.results.rlight_duration){
  3266. sleep_durationCount += parseFloat(ress.data.results.rlight_duration)
  3267. }
  3268. if(ress.data.results.rin_duration){
  3269. sleep_durationCount += parseFloat(ress.data.results.rin_duration)
  3270. }
  3271. let sleep_efficiency_temp = ress.data.results.rtotal_duration?(Math.ceil((sleep_durationCount / ress.data.results.rtotal_duration)*100)+'%'):'%'
  3272. let rdeep_duration_efficiency_temp = ress.data.results.rtotal_duration?(Math.ceil(((ress.data.results.rdeep_duration?parseFloat(ress.data.results.rdeep_duration):0) / ress.data.results.rtotal_duration)*100)+'%'):'%'
  3273. let rlight_duration_efficiency_temp = ress.data.results.rtotal_duration?(Math.ceil(((ress.data.results.rlight_duration?parseFloat(ress.data.results.rlight_duration):0) / ress.data.results.rtotal_duration)*100)+'%'):'%'
  3274. let rin_duration_efficiency_temp = ress.data.results.rtotal_duration?(Math.ceil(((ress.data.results.rin_duration?parseFloat(ress.data.results.rin_duration):0) / ress.data.results.rtotal_duration)*100)+'%'):'%'
  3275. let sleep_durationTemp = [];
  3276. let obj1 = {};
  3277. obj1.name = '睡眠时间';
  3278. obj1.value = Math.ceil(sleep_durationCount / 60);
  3279. sleep_durationTemp.push(obj1);
  3280. obj1 = {};
  3281. obj1.name = '清醒时间';
  3282. obj1.value = Math.ceil(parseFloat(ress.data.results.rawake_duration) / 60);
  3283. sleep_durationTemp.push(obj1);
  3284. let zdPointTemp = [];
  3285. let rdt_arrTemp = [];
  3286. let rrh_arrTemp = [];
  3287. let rhx_arrTemp = [];
  3288. let rmove_arrTemp = [];
  3289. let rsleep_arrTemp = [];
  3290. let rsleep_arr_all_Temp = [];
  3291. if(ress.data.results.rrh_arr){
  3292. rdt_arrTemp = that.splitN(ress.data.results.rdt_arr.split(","),100);
  3293. }
  3294. if(ress.data.results.rrh_arr){
  3295. rrh_arrTemp = that.splitN(ress.data.results.rrh_arr.split(","),100);
  3296. }
  3297. if(ress.data.results.rhx_arr){
  3298. rhx_arrTemp = that.splitN(ress.data.results.rhx_arr.split(","),100);
  3299. }
  3300. if(ress.data.results.rmove_arr){
  3301. rmove_arrTemp = that.splitN(ress.data.results.rmove_arr.split(","),100);
  3302. }
  3303. if(ress.data.results.rsleep_arr){
  3304. rsleep_arrTemp = that.splitN(ress.data.results.rsleep_arr.split(","),100);
  3305. }
  3306. if(ress.data.results.rsleep_arr){
  3307. rsleep_arr_all_Temp = ress.data.results.rsleep_arr.split(",");
  3308. }
  3309. console.log("rdt_arrTemp="+JSON.stringify(rdt_arrTemp));
  3310. console.log("rrh_arrTemp="+JSON.stringify(rrh_arrTemp));
  3311. console.log("rhx_arrTemp="+JSON.stringify(rhx_arrTemp));
  3312. console.log("rmove_arrTemp="+JSON.stringify(rmove_arrTemp));
  3313. console.log("rsleep_arrTemp="+JSON.stringify(rsleep_arrTemp));
  3314. console.log("rsleep_arr_all_Temp="+JSON.stringify(rsleep_arr_all_Temp));
  3315. console.log("sleep_durationTemp="+JSON.stringify(sleep_durationTemp));
  3316. that.setData({
  3317. rdt_arr: ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],
  3318. rrh_arr: ress.data.results.rrh_arr?ress.data.results.rrh_arr.split(','):[],
  3319. rhx_arr: ress.data.results.rhx_arr?ress.data.results.rhx_arr.split(','):[],
  3320. rsnoring_arr: ress.data.results.rsnoring_arr?ress.data.results.rsnoring_arr.split(','):[],
  3321. routbed_arr: ress.data.results.routbed_arr?ress.data.results.routbed_arr.split(','):[],
  3322. rmove_arr: ress.data.results.rmove_arr?ress.data.results.rmove_arr.split(','):[],
  3323. rhxstop_arr: ress.data.results.rhxstop_arr?ress.data.results.rhxstop_arr.split(','):[],
  3324. rsleep_arr: ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(','):[],
  3325. rsnoring_arrFrequency: that.getFrequency(ress.data.results.rsnoring_arr?ress.data.results.rsnoring_arr.split(','):[],1),
  3326. routbed_arrFrequency: that.getFrequency(ress.data.results.routbed_arr?ress.data.results.routbed_arr.split(','):[],0),
  3327. rmove_arrFrequency: that.getFrequency(ress.data.results.rmove_arr?ress.data.results.rmove_arr.split(','):[],1),
  3328. rhxstop_arrFrequency: that.getFrequency(ress.data.results.rhxstop_arr?ress.data.results.rhxstop_arr.split(','):[],1),
  3329. rdeep_duration: that.convertTimeToHoursAndMinutes(ress.data.results.rdeep_duration),
  3330. rlight_duration: ress.data.results.rlight_duration,
  3331. rin_duration: ress.data.results.rin_duration,
  3332. rawake_duration: ress.data.results.rawake_duration,
  3333. ravg_hx_value: ress.data.results.ravg_hx_value,
  3334. ravg_hx_desc: ress.data.results.ravg_hx_desc,
  3335. ravg_rh_value: ress.data.results.ravg_rh_value,
  3336. ravg_rh_desc: ress.data.results.ravg_rh_desc,
  3337. rscore_value: ress.data.results.rscore_value,
  3338. rscore_desc: ress.data.results.rscore_desc,
  3339. rsn: ress.data.results.rsn,
  3340. rdate: ress.data.results.rdate,
  3341. rtotal_duration: that.convertTimeToHoursAndMinutes(ress.data.results.rtotal_duration),//睡眠总时长,单位小时分钟
  3342. rinbed_duration: that.convertTimeToHoursAndMinutes(ress.data.results.rinbed_duration),//在床时长,单位小时分钟
  3343. rgobed_time: ress.data.results.rgobed_time,//上床时间
  3344. routbed_time: ress.data.results.routbed_time,//离床时间
  3345. rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
  3346. sleepHourSub: that.getTimeDiffInHours(ress.data.results.rgobed_time,ress.data.results.routbed_time),
  3347. routbed_count_value: ress.data.results.routbed_count_value,//离床次数
  3348. rsn: ress.data.results.rsn,
  3349. zdPointT:zdPointTemp,
  3350. rdt_arrNew:rdt_arrTemp,
  3351. rrh_arrNew:rrh_arrTemp,
  3352. rhx_arrNew:rhx_arrTemp,
  3353. rmove_arrNew:rmove_arrTemp,
  3354. rsleep_arrNew:rsleep_arrTemp,
  3355. rsleep_arr_all_New:rsleep_arr_all_Temp,
  3356. durationData:durationDataTemp,
  3357. sleep_duration:sleep_durationTemp,
  3358. sleep_efficiency:sleep_efficiency_temp,
  3359. sleep_durationCountA:that.convertTimeToHoursAndMinutes(sleep_durationCount?sleep_durationCount.toString():'0'),
  3360. sns:res.data,
  3361. hotelname:res.data[0].hn,
  3362. rdeep_duration_efficiency:rdeep_duration_efficiency_temp,
  3363. rlight_duration_efficiency:rlight_duration_efficiency_temp,
  3364. rin_duration_efficiency:rin_duration_efficiency_temp,
  3365. pushReportId:ress.data.results.rdid,
  3366. rrs_duration:that.convertTimeToHoursAndMinutes(ress.data.results.rrs_duration?ress.data.results.rrs_duration.toString():'0'),
  3367. routbed_count_value:ress.data.results.routbed_count_value,
  3368. rsleep_eff_value:ress.data.results.rsleep_eff_value,
  3369. });
  3370. that.getDateTimeJsonData(sn?sn:res.data[0].sn);
  3371. // resolve(ress.data); // 请求成功,使用 resolve 返回数据
  3372. console.log('ress.data.results-'+ress.data.results)
  3373. if(!ress.data.results || ress.data.results == ''){
  3374. wx.showModal({
  3375. title: '提示',
  3376. content: '无数据',
  3377. showCancel: false
  3378. });
  3379. return;
  3380. }
  3381. }else{
  3382. wx.showModal({
  3383. title: '提示',
  3384. content: '无数据',
  3385. showCancel: false
  3386. });
  3387. }
  3388. } catch (error) {
  3389. console.error(error);
  3390. }
  3391. console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
  3392. console.log("");
  3393. },
  3394. fail: function (error) {
  3395. wx.showToast({
  3396. title: "无数据",
  3397. icon: "error",
  3398. mask: true,
  3399. });
  3400. }
  3401. });
  3402. }
  3403. // that.startInterval();
  3404. } catch (error) {
  3405. console.error(error);
  3406. }
  3407. },
  3408. });
  3409. wx.request({
  3410. url: `${aipushApi}/getha`, //
  3411. method: 'POST',
  3412. // header: {
  3413. // 'content-type': 'application/json', // 默认值
  3414. // 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
  3415. // },
  3416. data:{
  3417.     "locations":hotelcode,"room":(hotelcode && hotelcode.includes('hotel'))?roomcode:"","token":token_push
  3418. },
  3419. success(res) {
  3420. if(!res || !res.data){
  3421. that.setData({
  3422. isLoading: false,
  3423. });
  3424. return;
  3425. }
  3426. var resData = res.data
  3427. console.log('res.data.睡眠报告.ha='+JSON.stringify(resData));
  3428. if (res.data.code == "400") {
  3429. console.error("400错误!");
  3430. return;
  3431. }
  3432. if (res.data.code == "401") {
  3433. console.error("401错误!");
  3434. return;
  3435. }
  3436. homeApi_https = resData.loc;
  3437. token = resData.token;
  3438. },
  3439. fail: function (error) {
  3440. console.error('error', error);
  3441. that.setData({
  3442. isLoading: false,
  3443. });
  3444. }
  3445. });
  3446. },
  3447. convertTimeToHoursAndMinutes: function(timeWithText,flag) {
  3448. if(!timeWithText) return;
  3449. // 移除'分钟'两个字
  3450. var minutesStr = timeWithText.replace('分钟', '');
  3451. var minutes = parseInt(minutesStr); // 将字符串转换为整数
  3452. if (isNaN(minutes)) {
  3453. // 如果转换失败,则可能是输入的不是有效的数字
  3454. console.error('Invalid minutes format');
  3455. return;
  3456. }
  3457. var hours = Math.floor(minutes / 60); // 整除60得到小时数
  3458. var remainingMinutes = minutes % 60; // 取余得到剩余的分钟数
  3459. // 如果小时数或分钟数小于10,前面补0
  3460. // var formattedHours = hours < 10 ? '0' + hours : hours;
  3461. var formattedHours = hours;
  3462. // var formattedMinutes = remainingMinutes < 10 ? '0' + remainingMinutes : remainingMinutes;
  3463. var formattedMinutes = remainingMinutes;
  3464. // 拼接小时和分钟,形成HH:mm格式
  3465. var formattedTime = '';
  3466. if(flag){
  3467. formattedTime = formattedHours + 'H ' + formattedMinutes + 'M';
  3468. }else{
  3469. formattedTime = formattedHours + '小时' + formattedMinutes;
  3470. }
  3471. // 更新数据
  3472. // this.setData({
  3473. // formattedTime: formattedTime
  3474. // });
  3475. return formattedTime;
  3476. },
  3477. getDateTimeJsonData: function(sn) {
  3478. var that = this;
  3479. var sourceFourthTemp = [];
  3480. wx.request({
  3481. url: `${aipushApi}/getdatefromsn`, //
  3482. method: 'POST',
  3483. // header: {
  3484. // 'content-type': 'application/json', // 默认值
  3485. // 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
  3486. // },
  3487. data:{
  3488.     "sn":sn,"token":token_push
  3489. },
  3490. success(res) {
  3491. if(!res || !res.data || !res.data.results){
  3492. return;
  3493. }
  3494. var resDataSn = res.data.results
  3495. console.log('resDataSn===='+JSON.stringify(resDataSn))
  3496. var tt = 0;
  3497. resDataSn.forEach(function(item, index) {
  3498. wx.request({
  3499. url: `${aipushApi}/getimefromsn`, //
  3500. method: 'POST',
  3501. // header: {
  3502. // 'content-type': 'application/json', // 默认值
  3503. // 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
  3504. // },
  3505. data:{
  3506.     "sn":sn,"date":item.rdate,"token":token_push
  3507. },
  3508. success(ress) {
  3509. if(!ress || !ress.data || !ress.data.results){
  3510. return;
  3511. }
  3512. var resDataItem = ress.data.results;
  3513. resDataItem.forEach(function(item_item, index) {
  3514. item_item.text = item_item.durations;
  3515. item_item.reportId = item_item.rpids;
  3516. });
  3517. var json = {};
  3518. json.text = item.rdate;
  3519. json.children = resDataItem;
  3520. sourceFourthTemp.push(json);
  3521. console.log('sourceFourthTemp0='+JSON.stringify(sourceFourthTemp));
  3522. if (tt == (resDataSn.length - 1)) {
  3523. console.log('sourceFourthTemp='+JSON.stringify(sourceFourthTemp));
  3524. // 使用 sort 方法进行排序
  3525. sourceFourthTemp.sort(function(a, b) {
  3526. // 将字符串转换为 Date 对象
  3527. let dateA = new Date(a.text);
  3528. let dateB = new Date(b.text);
  3529. if (dateA < dateB) {
  3530. return 1;
  3531. }
  3532. if (dateA > dateB) {
  3533. return -1;
  3534. }
  3535. // 如果日期相等,返回 0
  3536. return 0;
  3537. });
  3538. console.log('sourceFourthTemp1='+JSON.stringify(sourceFourthTemp));
  3539. //初始化弹出面板
  3540. var array = that.data.arrayFourth;
  3541. array[0] = sourceFourthTemp;
  3542. array[1] = array[0][0].children;
  3543. that.setData({
  3544. valueFourth: [0, 0],
  3545. sourceFourth: sourceFourthTemp,
  3546. arrayFourth: array,
  3547. })
  3548. tt = 0;
  3549. }
  3550. tt++
  3551. },
  3552. fail: function (error) {
  3553. console.error('error', error);
  3554. }
  3555. });
  3556. });
  3557. },
  3558. fail: function (error) {
  3559. console.error('error', error);
  3560. } ,
  3561. complete: function (e) {
  3562. }
  3563. });
  3564. },
  3565. // 在全局或者组件中定义函数
  3566. fontSize: function(res) {
  3567. const clientWidth = wx.getSystemInfoSync().windowWidth; // 获取屏幕宽度
  3568. if (!clientWidth) return;
  3569. let fontSize = clientWidth / 1920; // 假设以1920为基准宽度
  3570. return res * fontSize;
  3571. },
  3572. /**
  3573. * 生命周期函数--监听页面加载
  3574. */
  3575. onShow: function(options) {
  3576. var that = this;
  3577. console.log("that.data.month + 1", that.data.month + 1)
  3578. var clickDate = String(that.data.year) + String(that.data.month) + String(that.data.date)
  3579. clickDate = String(parseInt(clickDate) + 100)
  3580. // that.getTargetData(clickDate)
  3581. that.setData({
  3582. clickDate: clickDate,
  3583. // ec000: {
  3584. // onInit: that.initChart000
  3585. // },
  3586. ec00: {
  3587. onInit: that.initChart00
  3588. },
  3589. ec0: {
  3590. onInit: that.initChart0
  3591. },
  3592. ec: {
  3593. onInit: that.initChart
  3594. },
  3595. ec1: {
  3596. onInit: that.initChart1
  3597. },
  3598. ec2: {
  3599. onInit: that.initChart2
  3600. },
  3601. ec3: {
  3602. onInit: that.initChart3
  3603. },
  3604. ec4: {
  3605. onInit: that.initChart4
  3606. },
  3607. ec5: {
  3608. onInit: that.initChart5
  3609. },
  3610. ec6: {
  3611. onInit: that.initChart6
  3612. },
  3613. ec7: {
  3614. onInit: that.initChart7
  3615. },
  3616. ec8: {
  3617. onInit: that.initChart8
  3618. },
  3619. ec81: {
  3620. onInit: that.initChart81
  3621. },
  3622. ec9: {
  3623. onInit: that.initChart9
  3624. },
  3625. ec10: {
  3626. onInit: that.initChart10
  3627. },
  3628. ec11: {
  3629. onInit: that.initChart11
  3630. },
  3631. });
  3632. },
  3633. onLoad(option){
  3634. var that = this;
  3635. console.log("data页面");
  3636. // wx.clearStorage();
  3637. console.log('option.res='+JSON.stringify(wx.getStorageSync('res')));
  3638. if(!wx.getStorageSync('res') || !wx.getStorageSync('res').result){
  3639. wx.showModal({
  3640. title: '提示',
  3641. content: '请先扫描房间二维码',
  3642. showCancel: false
  3643. });
  3644. setTimeout(function() {
  3645. wx.reLaunch({
  3646. url: '/pages/scan/scan',
  3647. })
  3648. }, 2000) // 设置延时时间,单位为毫秒
  3649. }else if(wx.getStorageSync('res').result.split('|').length != 2){
  3650. wx.showModal({
  3651. title: '提示',
  3652. content: '房间二维码不正确,请重新扫码',
  3653. showCancel: false
  3654. });
  3655. setTimeout(function() {
  3656. wx.reLaunch({
  3657. url: '/pages/scan/scan',
  3658. })
  3659. }, 2000) // 设置延时时间,单位为毫秒
  3660. }else{
  3661. let hotelcodeTemp = '';
  3662. let roomcodeTemp = '';
  3663. hotelcodeTemp = wx.getStorageSync('res').result.split('|')[0];
  3664. roomcodeTemp = wx.getStorageSync('res').result.split('|')[1];
  3665. this.getData(null,hotelcodeTemp,roomcodeTemp,null);
  3666. // const result = await this.getData();
  3667. // console.log('result='+JSON.stringify(result));
  3668. this.drawProgressCircle();
  3669. // 获取系统信息
  3670. const systemInfo = wx.getSystemInfoSync();
  3671. const windowWidth = systemInfo.windowWidth; // 窗口宽度
  3672. // 计算canvas的宽度和高度
  3673. const canvasWidth = windowWidth; // 可以根据需求调整canvas的宽度
  3674. const canvasHeight = windowWidth * 0.5; // 假设高度是宽度的一半,可以根据需求调整
  3675. // var now = new Date(); // 创建一个Date对象,表示当前的日期和时间
  3676. // var year = now.getFullYear(); // 获取年份
  3677. // var month = now.getMonth() + 1; // 获取月份(注意月份是从0开始的,所以需要+1)
  3678. // var date = now.getDate(); // 获取日期
  3679. // var hours = now.getHours(); // 获取小时
  3680. // var minutes = now.getMinutes(); // 获取分钟
  3681. // var seconds = now.getSeconds(); // 获取秒
  3682. // month = month < 10 ? '0' + month : month;
  3683. // date = date < 10 ? '0' + date : date;
  3684. // hours = hours < 10 ? '0' + hours : hours;
  3685. // minutes = minutes < 10 ? '0' + minutes : minutes;
  3686. // seconds = seconds < 10 ? '0' + seconds : seconds;
  3687. // // 拼接日期和时间字符串
  3688. // var currentDateTime = year + '-' + month + '-' + date + ' ' + hours + ':' + minutes + ':' + seconds;
  3689. // console.log(currentDateTime);
  3690. // var currentDate = year + '-' + month + '-' + date;
  3691. // var currentTime = hours + ':' + minutes + ':' + seconds;
  3692. // this.selectComponent('#mychart-dom-bar00').init((canvas, width, height) => {
  3693. // that.initChart00(canvas, width, height)
  3694. // });
  3695. // 设置canvas的宽高
  3696. this.setData({
  3697. // currentDate: currentDate,
  3698. // currentTime: currentTime,
  3699. canvasWidth: canvasWidth,
  3700. canvasHeight: canvasHeight,
  3701. hotelcode: hotelcodeTemp,
  3702. roomcode: roomcodeTemp,
  3703. // roomname: wx.getStorageSync('roomname'),
  3704. // arrayFourth: array,
  3705. });
  3706. }
  3707. // else if(!this.data.home_room.includes(wx.getStorageSync('res').result)){
  3708. // wx.showModal({
  3709. // title: '提示',
  3710. // content: '房间二维码不正确,请重新扫描',
  3711. // showCancel: false
  3712. // });
  3713. // setTimeout(function() {
  3714. // wx.reLaunch({
  3715. // url: '/pages/scan/scan',
  3716. // })
  3717. // }, 2000) // 设置延时时间,单位为毫秒
  3718. // }
  3719. // else if(this.data.home_room.includes(wx.getStorageSync('res').result) && wx.getStorageSync('res').result.includes('辰悦颐养斋')){
  3720. // else if(wx.getStorageSync('res').result.includes('辰悦颐养斋')){
  3721. // homeApi = "http://zhh.aidsleep.cn";
  3722. // homeApi_http = "http://zhh.aidsleep.cn";
  3723. // homeApi_http_port = "9123";
  3724. // homeApi_https = "https://zhh.aidsleep.cn";
  3725. // }
  3726. this.drawCircle();
  3727. },
  3728. mounted() {
  3729. },
  3730. /**
  3731. * 生命周期函数--监听页面隐藏
  3732. */
  3733. onHide: function() {
  3734. // wx.clearStorage();
  3735. // this.clearInterval();
  3736. },
  3737. /**
  3738. * 生命周期函数--监听页面卸载
  3739. */
  3740. onUnload: function() {
  3741. // wx.clearStorage();
  3742. // this.clearInterval();
  3743. },
  3744. /**
  3745. * 页面相关事件处理函数--监听用户下拉动作
  3746. */
  3747. onPullDownRefresh: function() {
  3748. },
  3749. /**
  3750. * 页面上拉触底事件的处理函数
  3751. */
  3752. onReachBottom: function() {
  3753. },
  3754. /**
  3755. * 用户点击右上角分享
  3756. */
  3757. onShareAppMessage: function() {
  3758. }
  3759. })