data.js 132 KB

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