data.js 130 KB

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