data.js 124 KB

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