data.js 129 KB

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