data.js 133 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998
  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. ifOneMoreTV: false,//数据推送是否有多于一台电视
  1664. selectedValue: '', // 用于存储选中的值
  1665. tvEntityIdsValue: '', // 用于存储选中的值
  1666. selectedIndex: 0, // 默认选中第一个选项
  1667. tvEntityIdsIndex: 0, // 默认选中第一个选项
  1668. hotelcode: '',//酒店编码
  1669. roomcode: '',//房间编码
  1670. rdeep_duration_efficiency: '',//深睡比例
  1671. rlight_duration_efficiency: '',//浅睡比例
  1672. rin_duration_efficiency: '',//中睡比例
  1673. isLoading: false,
  1674. ec7: '',
  1675. width7: '',
  1676. height7: '',
  1677. ec8: '',
  1678. width8: '',
  1679. height8: '',
  1680. ec1: '',
  1681. width1: '',
  1682. height1: '',
  1683. ec81: '',
  1684. width81: '',
  1685. height81: '',
  1686. ec9: '',
  1687. width9: '',
  1688. height9: '',
  1689. ec10: '',
  1690. width10: '',
  1691. height10: '',
  1692. ec11: '',
  1693. width11: '',
  1694. height11: '',
  1695. flushChart00Flag:false,
  1696. arrayFourth: [ [], []],//多级选择数组
  1697. valueFourth: [0, 0],//多级选择结果index
  1698. sourceFourth: [
  1699. {
  1700. id: 1,
  1701. text: '2024-05-24',
  1702. children: [{
  1703. id: 1,
  1704. text: '01:01~01:20',
  1705. reportId: '11111',
  1706. }, {
  1707. id: 2,
  1708. text: '03:05~04:20',
  1709. reportId: '22222',
  1710. }, {
  1711. id: 3,
  1712. text: '05:21~07:20',
  1713. reportId: '33333',
  1714. }]
  1715. },
  1716. {
  1717. id: 2,
  1718. text: '2024-05-23',
  1719. children: [{
  1720. id: 3,
  1721. text: '00:01~03:20',
  1722. reportId: '454545',
  1723. }, {
  1724. id: 4,
  1725. text: '00:03~06:20',
  1726. reportId: '66666',
  1727. }]
  1728. },
  1729. ],//后台读取的所及数据源
  1730. reportId: '',
  1731. hotelname: '',
  1732. roomname: '',
  1733. pushReportId: '',//推送用:reportId
  1734. },
  1735. //点击确定选择结果时,保存结果
  1736. bindMultiPickerChange: function (e) {
  1737. var result = e.detail.value;
  1738. var data = this.data.sourceFourth;
  1739. console.info('result='+result);
  1740. console.info('result[0]='+result[0]);
  1741. console.info('data[result[0]].text='+data[Number(result[0])].text);
  1742. console.info('data[result[0]].children[result[1]].text='+data[Number(result[0])].children[Number(result[1])].text);
  1743. this.setData({
  1744. reportDate: data[Number(result[0])].text,
  1745. rgobed_routbed: data[Number(result[0])].children[Number(result[1])].text,
  1746. reportId: data[Number(result[0])].children[Number(result[1])].reportId,
  1747. });
  1748. this.onPickerDateTimeChange(this.data.reportId);
  1749. },
  1750. //选择列变更时,处理下级数组变更
  1751. bindMultiPickerColumnChange: function (e) {
  1752. var column = e.detail.column;
  1753. var index = e.detail.value;
  1754. var array = this.data.arrayFourth;
  1755. if (column == 0) {
  1756. array[1] = array[column][index].children;
  1757. this.setData({
  1758. arrayFourth: array
  1759. });
  1760. } else if (column == 1) {
  1761. //最后一列不处理
  1762. }
  1763. },
  1764. drawCircle: function() {
  1765. // 创建 canvas 上下文
  1766. const ctx = wx.createCanvasContext('myCanvas');
  1767. // 设置圆环的颜色和样式
  1768. ctx.setStrokeStyle('green'); // 圆环的颜色
  1769. ctx.setLineWidth(20); // 圆环的宽度
  1770. // 绘制外圆
  1771. ctx.beginPath();
  1772. ctx.arc(80, 80, 50, 0, 2 * Math.PI); // 圆心 (100, 100),半径 100
  1773. ctx.stroke(); // 绘制外圆
  1774. // 绘制内圆(与外圆同圆心,但半径小20rpx,即80rpx)
  1775. ctx.beginPath();
  1776. ctx.arc(80, 80, 50, 0, 2 * Math.PI);
  1777. ctx.setFillStyle('white'); // 设置内圆的填充颜色为白色(或者透明,取决于你希望的效果)
  1778. ctx.fill(); // 填充内圆,这样圆环内部就是白色或透明的了
  1779. // 结束绘制并更新 canvas
  1780. ctx.draw();
  1781. },
  1782. startInterval: function () {
  1783. // 使用 setInterval 创建定时任务,每8秒执行一次 this.myMethod 方法
  1784. var that = this;
  1785. this.intervalId = setInterval(() => {
  1786. console.log(Date.now());
  1787. }, 6000);
  1788. },
  1789. clearInterval: function () {
  1790. // 清除定时任务
  1791. if (this.intervalId) {
  1792. clearInterval(this.intervalId);
  1793. this.intervalId = null;
  1794. }
  1795. },
  1796. tvEntityIdsChange: function(e) {
  1797. var that = this;
  1798. console.log('this.data.tvEntityIds_tv='+JSON.stringify(this.data.tvEntityIds))
  1799. var selectedOption = this.data.tvEntityIds[e.detail.value];
  1800. console.log('selectedOption_tv='+JSON.stringify(selectedOption))
  1801. if(!this.data.tvEntityIds || !selectedOption){
  1802. wx.showToast({
  1803. title: '请选择需要推送的电视',
  1804. icon: 'none'
  1805. });
  1806. return;
  1807. }
  1808. this.setData({
  1809. tvEntityIdsIndex: e.detail.value,
  1810. tvEntityIdsValue: selectedOption.friendly_name1,
  1811. });
  1812. this.telScreeProjection(selectedOption.entity_id);
  1813. },
  1814. tvEntityIdChange: function(e) {
  1815. this.telScreeProjection();
  1816. },
  1817. onPickerChange: function(e) {
  1818. var that = this;
  1819. var selectedOption = this.data.sns[e.detail.value];
  1820. this.setData({
  1821. selectedIndex: e.detail.value,
  1822. selectedValue: selectedOption.pos,
  1823. rsn: selectedOption.sn,
  1824. });
  1825. console.log("e.detail.value="+e.detail.value);
  1826. console.log("selectedOption="+JSON.stringify(selectedOption));
  1827. this.getData(selectedOption.sn,this.data.hotelcode,this.data.roomcode,null);
  1828. //-----
  1829. //-----
  1830. this.selectComponent('#mychart-dom-bar00').init((canvas, width, height) => {
  1831. that.initChart00(canvas, width, height,null)
  1832. });
  1833. this.selectComponent('#mychart-dom-bar7').init((canvas, width, height) => {
  1834. that.initChart7(canvas, width, height,null)
  1835. });
  1836. this.selectComponent('#mychart-dom-bar8').init((canvas, width, height) => {
  1837. that.initChart8(canvas, width, height,null)
  1838. });
  1839. this.selectComponent('#mychart-dom-bar1').init((canvas, width, height) => {
  1840. that.initChart1(canvas, width, height,null)
  1841. });
  1842. this.selectComponent('#mychart-dom-bar81').init((canvas, width, height) => {
  1843. that.initChart81(canvas, width, height,null)
  1844. });
  1845. this.selectComponent('#mychart-dom-bar9').init((canvas, width, height) => {
  1846. that.initChart9(canvas, width, height,null)
  1847. });
  1848. this.selectComponent('#mychart-dom-bar10').init((canvas, width, height) => {
  1849. that.initChart10(canvas, width, height,null)
  1850. });
  1851. this.selectComponent('#mychart-dom-bar11').init((canvas, width, height) => {
  1852. that.initChart11(canvas, width, height,null)
  1853. });
  1854. },
  1855. onPickerDateTimeChange: function(reportId) {
  1856. var that = this;
  1857. // var selectedOption = this.data.sns[e.detail.value];
  1858. // this.setData({
  1859. // selectedIndex: e.detail.value,
  1860. // selectedValue: selectedOption.pos,
  1861. // rsn: selectedOption.sn,
  1862. // });
  1863. // console.log("e.detail.value="+e.detail.value);
  1864. // console.log("selectedOption="+JSON.stringify(selectedOption));
  1865. this.getData(that.data.sn,this.data.hotelcode,this.data.roomcode,reportId);
  1866. this.selectComponent('#mychart-dom-bar00').init((canvas, width, height) => {
  1867. that.initChart00(canvas, width, height,reportId)
  1868. });
  1869. this.selectComponent('#mychart-dom-bar7').init((canvas, width, height) => {
  1870. that.initChart7(canvas, width, height,reportId)
  1871. });
  1872. this.selectComponent('#mychart-dom-bar8').init((canvas, width, height) => {
  1873. that.initChart8(canvas, width, height,reportId)
  1874. });
  1875. this.selectComponent('#mychart-dom-bar1').init((canvas, width, height) => {
  1876. that.initChart1(canvas, width, height,reportId)
  1877. });
  1878. this.selectComponent('#mychart-dom-bar81').init((canvas, width, height) => {
  1879. that.initChart81(canvas, width, height,reportId)
  1880. });
  1881. this.selectComponent('#mychart-dom-bar9').init((canvas, width, height) => {
  1882. that.initChart9(canvas, width, height,reportId)
  1883. });
  1884. this.selectComponent('#mychart-dom-bar10').init((canvas, width, height) => {
  1885. that.initChart10(canvas, width, height,reportId)
  1886. });
  1887. this.selectComponent('#mychart-dom-bar11').init((canvas, width, height) => {
  1888. that.initChart11(canvas, width, height,reportId)
  1889. });
  1890. },
  1891. onButtonTap: function() {
  1892. // 切换按钮的样式类
  1893. this.setData({
  1894. isButtonPressed: !this.data.isButtonPressed
  1895. });
  1896. },
  1897. dayClick(event) { //日历点击选择日期
  1898. var that = this;
  1899. var clickDate = String(event.detail.year) + addZero(event.detail.month) + addZero(event.detail.day)
  1900. // that.getTargetData(clickDate)
  1901. console.log("change date", that.data.target_sleep_list)
  1902. flushChart(that.data.target_sleep_list)
  1903. that.setData({
  1904. nowDate: [{
  1905. month: 'current',
  1906. day: event.detail.day,
  1907. color: 'white',
  1908. background: '#82d5f8'
  1909. }, {
  1910. month: 'current',
  1911. day: new Date().getDate(),
  1912. color: '#ffd700',
  1913. background: 'white'
  1914. }],
  1915. clickDate: clickDate,
  1916. ec: {
  1917. onInit: that.construct_sleep_plot
  1918. }
  1919. })
  1920. },
  1921. getTargetData(date) {
  1922. var that = this;
  1923. var sleep_data = wx.getStorageSync("sleep_data")
  1924. console.log("find date is", date)
  1925. if (sleep_data || that.data.moke_data){
  1926. if (date == "20240414" || date == "20240415"){
  1927. var parse_sleep_data = that.data.moke_data[date]
  1928. }else{
  1929. var parse_sleep_data = JSON.parse(sleep_data)[date]
  1930. }
  1931. var sleep_cnt = 0
  1932. if (parse_sleep_data){
  1933. sleep_cnt = parse_sleep_data.length;
  1934. }
  1935. var sleep_time = 0.0;
  1936. var sleep_desc = "";
  1937. var sleep_tj_map = {
  1938. '早醒': 0,
  1939. '疲惫': 0,
  1940. '多梦': 0,
  1941. '很好': 0
  1942. };
  1943. var slepp_sugg = "";
  1944. var target_sleep_list = [];
  1945. for (var i in parse_sleep_data){
  1946. var fix_sleep_tm = (parse_sleep_data[i].sleepAllTime / 60).toFixed(1);
  1947. sleep_time += parseFloat(fix_sleep_tm);
  1948. sleep_tj_map[parse_sleep_data[i].sleepFeedback] += 1
  1949. target_sleep_list.push(parseFloat(fix_sleep_tm))
  1950. }
  1951. for(var j in sleep_tj_map){
  1952. if (sleep_tj_map[j] > 0){
  1953. sleep_desc += j + String(sleep_tj_map[j]) + " 次."
  1954. }
  1955. }
  1956. switch (sleep_cnt) {
  1957. case 5:
  1958. slepp_sugg = "继续保持睡前良好状态";
  1959. break;
  1960. case 1:
  1961. slepp_sugg = "学会释放工作压力";
  1962. break;
  1963. case 2:
  1964. slepp_sugg = "睡前一小时不要进行有氧运动";
  1965. break;
  1966. case 3:
  1967. slepp_sugg = "睡前尽量不要摄入高热量餐饮";
  1968. break;
  1969. case 0:
  1970. slepp_sugg = "还未产生睡眠报告";
  1971. break;
  1972. case 4:
  1973. slepp_sugg = "做一些助眠工作";
  1974. break;
  1975. }
  1976. that.setData({
  1977. data_dispaly: true,
  1978. sleep_cnt: sleep_cnt,
  1979. sleep_time: sleep_time.toFixed(1),
  1980. sleep_desc: sleep_desc,
  1981. slepp_sugg: slepp_sugg,
  1982. target_sleep_list: target_sleep_list,
  1983. ec0: {onInit: target_sleep_list},
  1984. ec: {onInit: target_sleep_list},
  1985. ec1: {onInit: target_sleep_list},
  1986. ec2: {onInit: target_sleep_list},
  1987. ec3: {onInit: target_sleep_list},
  1988. ec4: {onInit: target_sleep_list},
  1989. })
  1990. }
  1991. },
  1992. initChart000(canvas, width, height){
  1993. var that = this;
  1994. chart000 = echarts.init(canvas, null, {
  1995. width: width,
  1996. height: height
  1997. });
  1998. console.log("plot in ......")
  1999. canvas.setChart(chart000);
  2000. flushChart000();
  2001. },
  2002. initChart00(canvas, width, height,reportId){
  2003. var that = this;
  2004. wx.request({
  2005. url: `${aipushApi}`+'/getsn',
  2006. data: {
  2007. // "hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2008. // "roomcode":that.data.hotelcode?that.data.roomcode:"nuange",
  2009. "hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2010. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2011. "token":token_push},
  2012. method: 'POST',
  2013. success(res) {
  2014. try {
  2015. if(res && res.data && res.data[0]){
  2016. that.setData({
  2017. roomname: res.data[0].rn
  2018. });
  2019. console.log("res.data=sn="+JSON.stringify(res.data));
  2020. wx.request({
  2021. url: `${aipushApi}`+'/getsingle',
  2022. data: {
  2023. "sn":that.data.rsn?that.data.rsn:res.data[0].sn,
  2024. "rpids":reportId,
  2025. "token":token_push},
  2026. method: 'POST',
  2027. success(ress) {
  2028. if(ress && ress.data){
  2029. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2030. try {
  2031. let rscore_descTemp = [];
  2032. if(ress.data.results.rscore_desc){
  2033. rscore_descTemp = ress.data.results.rscore_desc;
  2034. }
  2035. let rscore_valueTemp = [];
  2036. if(ress.data.results.rscore_value){
  2037. rscore_valueTemp = ress.data.results.rscore_value;
  2038. }
  2039. that.setData({
  2040. rscore_desc:rscore_descTemp,
  2041. rscore_value:rscore_valueTemp,
  2042. });
  2043. chart00 = echarts.init(canvas, null, {
  2044. width: width,
  2045. height: height
  2046. });
  2047. console.log("plot in ......")
  2048. canvas.setChart(chart00);
  2049. flushChart00(rscore_descTemp,rscore_valueTemp,that);
  2050. } catch (error) {
  2051. console.error(error);
  2052. }
  2053. // console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
  2054. // console.log("");
  2055. }
  2056. }
  2057. });
  2058. }
  2059. } catch (error) {
  2060. console.error(error);
  2061. }
  2062. },
  2063. })
  2064. },
  2065. initChart0(canvas, width, height){
  2066. var that = this;
  2067. chart0 = echarts.init(canvas, null, {
  2068. width: width,
  2069. height: height
  2070. });
  2071. console.log("plot in ......")
  2072. canvas.setChart(chart0);
  2073. var percentage = parseFloat(that.data.percentage)
  2074. var unPercentage = 100-percentage;
  2075. var percentages = []
  2076. var obj = {};
  2077. obj.name = '已完成';
  2078. obj.value = percentage;
  2079. percentages.push(obj);
  2080. obj = {};
  2081. obj.name = '未完成';
  2082. obj.value = unPercentage;
  2083. percentages.push(obj);
  2084. console.log("that.data.rdt_arrNew,that.data.rrh_arrNew="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
  2085. flushChart0(percentages);
  2086. },
  2087. initChart(canvas, width, height){
  2088. var that = this;
  2089. chart = echarts.init(canvas, null, {
  2090. width: width,
  2091. height: height
  2092. });
  2093. console.log("plot in ......")
  2094. canvas.setChart(chart);
  2095. flushChart(that.data.target_sleep_list)
  2096. },
  2097. initChart1(canvas, width, height,reportId){
  2098. var that = this;
  2099. wx.request({
  2100. url: `${aipushApi}`+'/getsn',
  2101. data: {
  2102. // "hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2103. // "roomcode":that.data.hotelcode?that.data.roomcode:"nuange",
  2104. "hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2105. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2106. "token":token_push},
  2107. method: 'POST',
  2108. success(res) {
  2109. try {
  2110. if(res && res.data && res.data[0]){
  2111. that.setData({
  2112. roomname: res.data[0].rn
  2113. });
  2114. console.log("res.data=sn="+JSON.stringify(res.data));
  2115. wx.request({
  2116. url: `${aipushApi}`+'/getsingle',
  2117. data: {
  2118. "sn":that.data.rsn?that.data.rsn:res.data[0].sn,
  2119. "token":token_push,
  2120. "rpids":reportId},
  2121. method: 'POST',
  2122. success(ress) {
  2123. if(ress && ress.data){
  2124. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2125. try {
  2126. let rdt_arrTemp = [];
  2127. if(ress.data.results.rrh_arr){
  2128. rdt_arrTemp = that.splitN(ress.data.results.rdt_arr.split(","),100);
  2129. }
  2130. if(ress.data.results.rdate){
  2131. that.setData({
  2132. reportDate: ress.data.results.rdate
  2133. });
  2134. }
  2135. let rrh_arrTemp = [];
  2136. if(ress.data.results.rrh_arr){
  2137. rrh_arrTemp = that.splitN(ress.data.results.rrh_arr.split(","),100);
  2138. }
  2139. that.setData({
  2140. rdt_arrNew:rdt_arrTemp,
  2141. rrh_arrNew:rrh_arrTemp,
  2142. });
  2143. chart1 = echarts.init(canvas, null, {
  2144. width: width,
  2145. height: height
  2146. });
  2147. // console.log("plot in ......")
  2148. canvas.setChart(chart1);
  2149. console.log("that.data.rdt_arrNew,that.data.rrh_arrNew="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
  2150. flushChart1(that.data.rdt_arrNew,that.data.rrh_arrNew);
  2151. } catch (error) {
  2152. console.error(error);
  2153. }
  2154. // console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
  2155. // console.log("");
  2156. }
  2157. }
  2158. });
  2159. }
  2160. } catch (error) {
  2161. console.error(error);
  2162. }
  2163. },
  2164. })
  2165. },
  2166. initChart2(canvas, width, height){
  2167. var that = this;
  2168. wx.request({
  2169. url: `${aipushApi}`+'/getsn',
  2170. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2171. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2172. "token":token_push},
  2173. method: 'POST',
  2174. success(res) {
  2175. try {
  2176. if(res && res.data && res.data[0]){
  2177. that.setData({
  2178. roomname: res.data[0].rn
  2179. });
  2180. wx.request({
  2181. url: `${aipushApi}`+'/getsingle',
  2182. data: {"sn":res.data[0].sn,
  2183. "token":token_push},
  2184. method: 'POST',
  2185. success(ress) {
  2186. if(ress&&ress.data){
  2187. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2188. try {
  2189. let durationDataTemp = [];
  2190. let obj = {};
  2191. obj.name = '深睡';
  2192. obj.value = ress.data.results.rdeep_duration;
  2193. durationDataTemp.push(obj);
  2194. obj = {};
  2195. obj.name = '中睡';
  2196. obj.value = ress.data.results.rin_duration;
  2197. durationDataTemp.push(obj);
  2198. obj = {};
  2199. obj.name = '浅睡';
  2200. obj.value = ress.data.results.rlight_duration;
  2201. durationDataTemp.push(obj);
  2202. obj = {};
  2203. obj.name = '清醒';
  2204. obj.value = ress.data.results.rawake_duration;
  2205. durationDataTemp.push(obj);
  2206. console.log("durationDataTemp="+JSON.stringify(durationDataTemp));
  2207. that.setData({
  2208. durationData:durationDataTemp,
  2209. });
  2210. chart2 = echarts.init(canvas, null, {
  2211. width: width,
  2212. height: height
  2213. });
  2214. // console.log("plot in ......")
  2215. canvas.setChart(chart2);
  2216. flushChart2(that.data.durationData)
  2217. } catch (error) {
  2218. console.error(error);
  2219. }
  2220. // console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
  2221. // console.log("");
  2222. }
  2223. },
  2224. });
  2225. }
  2226. } catch (error) {
  2227. console.error(error);
  2228. }
  2229. },
  2230. })
  2231. },
  2232. initChart3(canvas, width, height){
  2233. var that = this;
  2234. wx.request({
  2235. url: `${aipushApi}`+'/getsn',
  2236. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2237. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2238. "token":token_push},
  2239. method: 'POST',
  2240. success(res) {
  2241. try {
  2242. if(res && res.data && res.data[0]){
  2243. that.setData({
  2244. roomname: res.data[0].rn
  2245. });
  2246. wx.request({
  2247. url: `${aipushApi}`+'/getsingle',
  2248. data: {"sn":res.data[0].sn,
  2249. "token":token_push},
  2250. method: 'POST',
  2251. success(ress) {
  2252. if(ress && ress.data){
  2253. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2254. try {
  2255. let rdt_arrTemp = [];
  2256. if(ress.data.results.rrh_arr){
  2257. rdt_arrTemp = that.splitN(ress.data.results.rdt_arr.split(","),100);
  2258. }
  2259. let rhx_arrTemp = [];
  2260. if(ress.data.results.rhx_arr){
  2261. rhx_arrTemp = that.splitN(ress.data.results.rhx_arr.split(","),100);
  2262. }
  2263. that.setData({
  2264. rdt_arrNew:rdt_arrTemp,
  2265. rhx_arrNew:rhx_arrTemp,
  2266. });
  2267. chart3 = echarts.init(canvas, null, {
  2268. width: width,
  2269. height: height
  2270. });
  2271. console.log("plot in ......")
  2272. canvas.setChart(chart3);
  2273. flushChart3(that.data.rdt_arrNew,that.data.rhx_arrNew)
  2274. } catch (error) {
  2275. console.error(error);
  2276. }
  2277. // console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
  2278. // console.log("");
  2279. }
  2280. },
  2281. });
  2282. }
  2283. } catch (error) {
  2284. console.error(error);
  2285. }
  2286. },
  2287. })
  2288. },
  2289. initChart11(canvas, width, height,reportId){
  2290. var that = this;
  2291. wx.request({
  2292. url: `${aipushApi}`+'/getsn',
  2293. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2294. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2295. "token":token_push},
  2296. method: 'POST',
  2297. success(res) {
  2298. try {
  2299. if(res && res.data && res.data[0]){
  2300. that.setData({
  2301. roomname: res.data[0].rn
  2302. });
  2303. wx.request({
  2304. url: `${aipushApi}`+'/getsingle',
  2305. data: {"sn":that.data.rsn?that.data.rsn:res.data[0].sn,
  2306. "token":token_push,
  2307. "rpids":reportId},
  2308. method: 'POST',
  2309. success(ress) {
  2310. if(ress && ress.data){
  2311. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2312. try {
  2313. let rdt_arrTemp = [];
  2314. if(ress.data.results.rrh_arr){
  2315. rdt_arrTemp = that.splitN(ress.data.results.rdt_arr.split(","),100);
  2316. }
  2317. let rsleep_arr_Temp = [];
  2318. if(ress.data.results.rsleep_arr){
  2319. rsleep_arr_Temp = that.splitN(ress.data.results.rsleep_arr.split(","),100);
  2320. }
  2321. that.setData({
  2322. rdt_arrNew:rdt_arrTemp,
  2323. rsleep_arr:rsleep_arr_Temp,
  2324. rdeep_durationFormat: that.convertTimeToHoursAndMinutes(ress.data.results.rdeep_duration,1),
  2325. rlight_durationFormat: that.convertTimeToHoursAndMinutes(ress.data.results.rlight_duration,1),
  2326. rin_durationFormat: that.convertTimeToHoursAndMinutes(ress.data.results.rin_duration,1),
  2327. rawake_durationFormat: that.convertTimeToHoursAndMinutes(ress.data.results.rawake_duration,1),
  2328. });
  2329. console.log('ress.data.results.rdeep_duration='+ress.data.results.rdeep_duration);
  2330. console.log('ress.data.results.rlight_duration='+ress.data.results.rlight_duration);
  2331. console.log('ress.data.results.rin_duration='+ress.data.results.rin_duration);
  2332. console.log('ress.data.results.rawake_duration='+ress.data.results.rawake_duration);
  2333. chart11 = echarts.init(canvas, null, {
  2334. width: width,
  2335. height: height
  2336. });
  2337. console.log("plot in ......")
  2338. canvas.setChart(chart11);
  2339. flushChart11(that.data.rdt_arrNew,that.data.rsleep_arr,that)
  2340. } catch (error) {
  2341. console.error(error);
  2342. }
  2343. console.log("that.data.rsleep_arr="+that.data.rsleep_arr);
  2344. console.log("");
  2345. }
  2346. },
  2347. });
  2348. }
  2349. } catch (error) {
  2350. console.error(error);
  2351. }
  2352. },
  2353. })
  2354. },
  2355. initChart4(canvas, width, height){
  2356. var that = this;
  2357. wx.request({
  2358. url: `${aipushApi}`+'/getsn',
  2359. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2360. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2361. "token":token_push},
  2362. method: 'POST',
  2363. success(res) {
  2364. try {
  2365. if(res && res.data && res.data[0]){
  2366. that.setData({
  2367. roomname: res.data[0].rn
  2368. });
  2369. wx.request({
  2370. url: `${aipushApi}`+'/getsingle',
  2371. data: {"sn":res.data[0].sn,
  2372. "token":token_push},
  2373. method: 'POST',
  2374. success(ress) {
  2375. if(ress && ress.data){
  2376. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2377. try {
  2378. let sleep_durationCount = 0;
  2379. if(ress.data.results.rdeep_duration){
  2380. sleep_durationCount += parseFloat(ress.data.results.rdeep_duration)
  2381. }
  2382. if(ress.data.results.rlight_duration){
  2383. sleep_durationCount += parseFloat(ress.data.results.rlight_duration)
  2384. }
  2385. if(ress.data.results.rin_duration){
  2386. sleep_durationCount += parseFloat(ress.data.results.rin_duration)
  2387. }
  2388. let sleep_durationTemp = [];
  2389. // let data1 = [];
  2390. let obj1 = {};
  2391. obj1.name = '睡眠时间';
  2392. obj1.value = Math.ceil(sleep_durationCount / 60);
  2393. sleep_durationTemp.push(obj1);
  2394. // data1.push(obj1);
  2395. // let data2 = [];
  2396. obj1 = {};
  2397. obj1.name = '清醒时间';
  2398. obj1.value = Math.ceil(parseFloat(ress.data.results.rawake_duration) / 60);
  2399. sleep_durationTemp.push(obj1);
  2400. // data2.push(obj1);
  2401. that.setData({
  2402. sleep_duration:sleep_durationTemp,
  2403. });
  2404. chart4 = echarts.init(canvas, null, {
  2405. width: width,
  2406. height: height
  2407. });
  2408. console.log("plot in ......")
  2409. canvas.setChart(chart4);
  2410. // console.log("that.data.sleep_duration="+JSON.stringify(that.data.sleep_duration))
  2411. flushChart4(that.data.sleep_duration)
  2412. } catch (error) {
  2413. console.error(error);
  2414. }
  2415. console.log("");
  2416. }
  2417. },
  2418. });
  2419. }
  2420. } catch (error) {
  2421. console.error(error);
  2422. }
  2423. },
  2424. })
  2425. },
  2426. initChart5(canvas, width, height){
  2427. var that = this;
  2428. wx.request({
  2429. url: `${aipushApi}`+'/getsn',
  2430. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2431. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2432. "token":token_push},
  2433. method: 'POST',
  2434. success(res) {
  2435. if(res && res.data && res.data[0]){
  2436. that.setData({
  2437. roomname: res.data[0].rn
  2438. });
  2439. try {
  2440. wx.request({
  2441. url: `${aipushApi}`+'/getsingle',
  2442. data: {"sn":res.data[0].sn,
  2443. "token":token_push},
  2444. method: 'POST',
  2445. success(ress) {
  2446. if(ress && ress.data){
  2447. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2448. try {
  2449. let rdt_arrTemp = [];
  2450. if(ress.data.results.rrh_arr){
  2451. rdt_arrTemp = that.splitN(ress.data.results.rdt_arr.split(","),100);
  2452. }
  2453. let rsleep_arrTemp = [];
  2454. if(ress.data.results.rsleep_arr){
  2455. rsleep_arrTemp = that.splitN(ress.data.results.rsleep_arr.split(","),100);
  2456. }
  2457. that.setData({
  2458. rdt_arrNew:rdt_arrTemp,
  2459. rsleep_arrNew:rsleep_arrTemp,
  2460. });
  2461. chart5 = echarts.init(canvas, null, {
  2462. width: width,
  2463. height: height
  2464. });
  2465. console.log("plot in ......")
  2466. canvas.setChart(chart5);
  2467. flushChart5(that.data.rdt_arrNew,that.data.rsleep_arrNew,that)
  2468. } catch (error) {
  2469. console.error(error);
  2470. }
  2471. console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
  2472. console.log("");
  2473. }
  2474. },
  2475. });
  2476. } catch (error) {
  2477. console.error(error);
  2478. }
  2479. }
  2480. },
  2481. })
  2482. },
  2483. initChart6(canvas, width, height){
  2484. var that = this;
  2485. wx.request({
  2486. url: `${aipushApi}`+'/getsn',
  2487. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2488. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2489. "token":token_push},
  2490. method: 'POST',
  2491. success(res) {
  2492. try {
  2493. if(res && res.data && res.data[0]){
  2494. that.setData({
  2495. roomname: res.data[0].rn
  2496. });
  2497. wx.request({
  2498. url: `${aipushApi}`+'/getsingle',
  2499. data: {"sn":res.data[0].sn,
  2500. "token":token_push},
  2501. method: 'POST',
  2502. success(ress) {
  2503. if(ress && ress.data){
  2504. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2505. try {
  2506. var rsleep_arr_all_Temp = [];
  2507. if(ress.data.results.rsleep_arr){
  2508. rsleep_arr_all_Temp = ress.data.results.rsleep_arr.split(",");
  2509. }
  2510. that.setData({
  2511. rdt_arr: that.splitN(ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],100),
  2512. rsleep_arr_all: that.splitN(rsleep_arr_all_Temp,100),
  2513. rgobed_time: ress.data.results.rgobed_time,
  2514. routbed_time: ress.data.results.routbed_time,
  2515. rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
  2516. });
  2517. chart6 = echarts.init(canvas, null, {
  2518. width: width,
  2519. height: height
  2520. });
  2521. console.log("plot in ......")
  2522. canvas.setChart(chart6);
  2523. // var list = that.getRsleep_arr(ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(","):[])
  2524. flushChart6(that.data.rdt_arr,that.data.rsleep_arr_all,that.data.rgobed_time,that.data.routbed_time,that)
  2525. } catch (error) {
  2526. console.error(error);
  2527. }
  2528. console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
  2529. console.log("");
  2530. }
  2531. },
  2532. });
  2533. }
  2534. } catch (error) {
  2535. console.error(error);
  2536. }
  2537. },
  2538. })
  2539. },
  2540. initChart7(canvas, width, height,reportId){//离床次数
  2541. var that = this;
  2542. wx.request({
  2543. url: `${aipushApi}`+'/getsn',
  2544. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2545. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2546. "token":token_push},
  2547. method: 'POST',
  2548. success(res) {
  2549. try {
  2550. if(res && res.data && res.data[0]){
  2551. that.setData({
  2552. roomname: res.data[0].rn
  2553. });
  2554. wx.request({
  2555. url: `${aipushApi}`+'/getsingle',
  2556. data: {"sn":that.data.rsn?that.data.rsn:res.data[0].sn,
  2557. "token":token_push,
  2558. "rpids":reportId},
  2559. method: 'POST',
  2560. success(ress) {
  2561. if(ress && ress.data){
  2562. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2563. try {
  2564. var routbed_arr_Temp = [];
  2565. if(ress.data.results.routbed_arr){
  2566. routbed_arr_Temp = ress.data.results.routbed_arr.split(",");
  2567. }
  2568. that.setData({
  2569. // rdt_arr: that.splitN(ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],100),
  2570. // routbed_arr: that.splitN(routbed_arr_Temp,100),
  2571. rdt_arr: ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],
  2572. routbed_arr: routbed_arr_Temp,
  2573. rgobed_time: ress.data.results.rgobed_time,
  2574. routbed_time: ress.data.results.routbed_time,
  2575. rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
  2576. });
  2577. chart7 = echarts.init(canvas, null, {
  2578. width: width,
  2579. height: height
  2580. });
  2581. console.log("plot in ......")
  2582. canvas.setChart(chart7);
  2583. // var list = that.getRsleep_arr(ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(","):[])
  2584. // flushChart7(that.takePortionDateData(that.data.rdt_arr,that.data.routbed_arr,0),that.takePortionData(that.data.routbed_arr,0),that.data.routbed_time,that)
  2585. flushChart7(that.data.rdt_arr,that.data.routbed_arr,that.data.routbed_time,that)
  2586. } catch (error) {
  2587. console.error(error);
  2588. }
  2589. console.log("that.data.routbed_arr="+that.data.routbed_arr);
  2590. console.log("");
  2591. }
  2592. },
  2593. });
  2594. }
  2595. } catch (error) {
  2596. console.error(error);
  2597. }
  2598. },
  2599. })
  2600. },
  2601. initChart8(canvas, width, height,reportId){//体动次数
  2602. var that = this;
  2603. wx.request({
  2604. url: `${aipushApi}`+'/getsn',
  2605. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2606. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2607. "token":token_push},
  2608. method: 'POST',
  2609. success(res) {
  2610. try {
  2611. if(res && res.data && res.data[0]){
  2612. that.setData({
  2613. roomname: res.data[0].rn
  2614. });
  2615. wx.request({
  2616. url: `${aipushApi}`+'/getsingle',
  2617. data: {"sn":that.data.rsn?that.data.rsn:res.data[0].sn,
  2618. "token":token_push,
  2619. "rpids":reportId},
  2620. method: 'POST',
  2621. success(ress) {
  2622. if(ress && ress.data){
  2623. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2624. try {
  2625. var rmove_arr_Temp = [];
  2626. if(ress.data.results.rmove_arr){
  2627. rmove_arr_Temp = ress.data.results.rmove_arr.split(",");
  2628. }
  2629. that.setData({
  2630. rdt_arr: that.splitN(ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],100),
  2631. rmove_arr: that.splitN(rmove_arr_Temp,100),
  2632. rgobed_time: ress.data.results.rgobed_time,
  2633. routbed_time: ress.data.results.routbed_time,
  2634. rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
  2635. });
  2636. chart8 = echarts.init(canvas, null, {
  2637. width: width,
  2638. height: height
  2639. });
  2640. console.log("plot in ......")
  2641. canvas.setChart(chart8);
  2642. // var list = that.getRsleep_arr(ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(","):[])
  2643. flushChart8(that.data.rdt_arr,that.data.rmove_arr,that.data.rgobed_time,that.data.routbed_time,that)
  2644. } catch (error) {
  2645. console.error(error);
  2646. }
  2647. console.log("c8_that.data.rmove_arr="+that.data.rmove_arr);
  2648. console.log("");
  2649. }
  2650. },
  2651. });
  2652. }
  2653. } catch (error) {
  2654. console.error(error);
  2655. }
  2656. },
  2657. })
  2658. },
  2659. initChart81(canvas, width, height,reportId){//平均呼吸率
  2660. var that = this;
  2661. wx.request({
  2662. url: `${aipushApi}`+'/getsn',
  2663. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2664. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2665. "token":token_push},
  2666. method: 'POST',
  2667. success(res) {
  2668. try {
  2669. if(res && res.data && res.data[0]){
  2670. that.setData({
  2671. roomname: res.data[0].rn
  2672. });
  2673. wx.request({
  2674. url: `${aipushApi}`+'/getsingle',
  2675. data: {"sn":that.data.rsn?that.data.rsn:res.data[0].sn,
  2676. "token":token_push,
  2677. "rpids":reportId},
  2678. method: 'POST',
  2679. success(ress) {
  2680. if(ress && ress.data){
  2681. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2682. try {
  2683. var rhx_arr_Temp = [];
  2684. if(ress.data.results.rhx_arr){
  2685. rhx_arr_Temp = ress.data.results.rhx_arr.split(",");
  2686. }
  2687. that.setData({
  2688. rdt_arr: that.splitN(ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],100),
  2689. rhx_arr: that.splitN(rhx_arr_Temp,100),
  2690. rgobed_time: ress.data.results.rgobed_time,
  2691. routbed_time: ress.data.results.routbed_time,
  2692. rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
  2693. });
  2694. chart81 = echarts.init(canvas, null, {
  2695. width: width,
  2696. height: height
  2697. });
  2698. console.log("plot in ......")
  2699. canvas.setChart(chart81);
  2700. // var list = that.getRsleep_arr(ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(","):[])
  2701. flushChart81(that.data.rdt_arr,that.data.rhx_arr,that.data.rgobed_time,that.data.routbed_time,that)
  2702. } catch (error) {
  2703. console.error(error);
  2704. }
  2705. console.log("c81_that.data.ravg_hx_value="+that.data.ravg_hx_value);
  2706. console.log("");
  2707. }
  2708. },
  2709. });
  2710. }
  2711. } catch (error) {
  2712. console.error(error);
  2713. }
  2714. },
  2715. })
  2716. },
  2717. initChart9(canvas, width, height,reportId){//体动次数
  2718. var that = this;
  2719. wx.request({
  2720. url: `${aipushApi}`+'/getsn',
  2721. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2722. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2723. "token":token_push},
  2724. method: 'POST',
  2725. success(res) {
  2726. try {
  2727. if(res && res.data && res.data[0]){
  2728. that.setData({
  2729. roomname: res.data[0].rn
  2730. });
  2731. wx.request({
  2732. url: `${aipushApi}`+'/getsingle',
  2733. data: {"sn":that.data.rsn?that.data.rsn:res.data[0].sn,
  2734. "token":token_push,
  2735. "rpids":reportId},
  2736. method: 'POST',
  2737. success(ress) {
  2738. if(ress && ress.data){
  2739. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2740. try {
  2741. var rsnoring_arr_Temp = [];
  2742. if(ress.data.results.rsnoring_arr){
  2743. rsnoring_arr_Temp = ress.data.results.rsnoring_arr.split(",");
  2744. }
  2745. that.setData({
  2746. rdt_arr: that.splitN(ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],100),
  2747. rsnoring_arr: that.splitN(rsnoring_arr_Temp,100),
  2748. rgobed_time: ress.data.results.rgobed_time,
  2749. routbed_time: ress.data.results.routbed_time,
  2750. rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
  2751. });
  2752. chart9 = echarts.init(canvas, null, {
  2753. width: width,
  2754. height: height
  2755. });
  2756. console.log("plot in ......")
  2757. canvas.setChart(chart9);
  2758. // var list = that.getRsleep_arr(ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(","):[])
  2759. flushChart9(that.data.rdt_arr,that.data.rsnoring_arr,that.data.rgobed_time,that.data.routbed_time,that)
  2760. } catch (error) {
  2761. console.error(error);
  2762. }
  2763. console.log("c8_that.data.rmove_arr="+that.data.rmove_arr);
  2764. console.log("");
  2765. }
  2766. },
  2767. });
  2768. }
  2769. } catch (error) {
  2770. console.error(error);
  2771. }
  2772. },
  2773. })
  2774. },
  2775. initChart10(canvas, width, height,reportId){//体动次数
  2776. var that = this;
  2777. wx.request({
  2778. url: `${aipushApi}`+'/getsn',
  2779. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2780. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2781. "token":token_push},
  2782. method: 'POST',
  2783. success(res) {
  2784. try {
  2785. if(res && res.data && res.data[0]){
  2786. that.setData({
  2787. roomname: res.data[0].rn
  2788. });
  2789. wx.request({
  2790. url: `${aipushApi}`+'/getsingle',
  2791. data: {"sn":that.data.rsn?that.data.rsn:res.data[0].sn,
  2792. "token":token_push,
  2793. "rpids":reportId},
  2794. method: 'POST',
  2795. success(ress) {
  2796. if(ress && ress.data){
  2797. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2798. try {
  2799. var rhxstop_arr_Temp = [];
  2800. if(ress.data.results.rhxstop_arr){
  2801. rhxstop_arr_Temp = ress.data.results.rhxstop_arr.split(",");
  2802. }
  2803. that.setData({
  2804. rdt_arr: that.splitN(ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],100),
  2805. rhxstop_arr: that.splitN(rhxstop_arr_Temp,100),
  2806. rgobed_time: ress.data.results.rgobed_time,
  2807. routbed_time: ress.data.results.routbed_time,
  2808. rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
  2809. });
  2810. chart10 = echarts.init(canvas, null, {
  2811. width: width,
  2812. height: height
  2813. });
  2814. console.log("plot in ......")
  2815. canvas.setChart(chart10);
  2816. // var list = that.getRsleep_arr(ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(","):[])
  2817. flushChart10(that.data.rdt_arr,that.data.rhxstop_arr,that.data.rgobed_time,that.data.routbed_time,that)
  2818. } catch (error) {
  2819. console.error(error);
  2820. }
  2821. console.log("c8_that.data.rhxstop_arr="+that.data.rhxstop_arr);
  2822. console.log("");
  2823. }
  2824. },
  2825. });
  2826. }
  2827. } catch (error) {
  2828. console.error(error);
  2829. }
  2830. },
  2831. })
  2832. },
  2833. getRsleep_arr(list){
  2834. if(list){
  2835. console.log("getRsleep_arr_list1=="+JSON.stringify(list));
  2836. for (let i = 0; i < list.length; i++) {
  2837. if (list[i] == '0') {
  2838. list[i] = '清醒';
  2839. }else if (list[i] == '10') {
  2840. list[i] = '浅睡';
  2841. }else if (list[i] == '20') {
  2842. list[i] = '中睡';
  2843. }else if (list[i] == '30') {
  2844. list[i] = '深睡';
  2845. }else{
  2846. list[i] = '其他';
  2847. }
  2848. }
  2849. }
  2850. console.log("getRsleep_arr_list2=="+JSON.stringify(list));
  2851. },
  2852. getFrequency(list){//获取
  2853. if(list){
  2854. console.log("getRsleep_arr_list1=="+JSON.stringify(list));
  2855. for (let i = 0; i < list.length; i++) {
  2856. if (list[i] == '0') {
  2857. list[i] = '清醒';
  2858. }else if (list[i] == '10') {
  2859. list[i] = '浅睡';
  2860. }else if (list[i] == '20') {
  2861. list[i] = '中睡';
  2862. }else if (list[i] == '30') {
  2863. list[i] = '深睡';
  2864. }else{
  2865. list[i] = '其他';
  2866. }
  2867. }
  2868. }
  2869. console.log("getRsleep_arr_list2=="+JSON.stringify(list));
  2870. },
  2871. initChart12(canvas, width, height){//体动次数
  2872. var that = this;
  2873. wx.request({
  2874. url: `${aipushApi}`+'/getsn',
  2875. data: {"hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
  2876. "roomcode":that.data.roomcode?that.data.roomcode:"nuange",
  2877. "token":token_push},
  2878. method: 'POST',
  2879. success(res) {
  2880. try {
  2881. if(res && res.data && res.data[0]){
  2882. that.setData({
  2883. roomname: res.data[0].rn
  2884. });
  2885. wx.request({
  2886. url: `${aipushApi}`+'/getsingle',
  2887. data: {"sn":res.data[0].sn,
  2888. "token":token_push},
  2889. method: 'POST',
  2890. success(ress) {
  2891. if(ress && ress.data){
  2892. // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  2893. try {
  2894. var rsnoring_arr_Temp = [];
  2895. if(ress.data.results.rsnoring_arr){
  2896. rsnoring_arr_Temp = ress.data.results.rsnoring_arr.split(",");
  2897. }
  2898. that.setData({
  2899. rdt_arr: that.splitN(ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],100),
  2900. rsnoring_arr: that.splitN(rsnoring_arr_Temp,100),
  2901. rgobed_time: ress.data.results.rgobed_time,
  2902. routbed_time: ress.data.results.routbed_time,
  2903. rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
  2904. });
  2905. chart9 = echarts.init(canvas, null, {
  2906. width: width,
  2907. height: height
  2908. });
  2909. console.log("plot in ......")
  2910. canvas.setChart(chart9);
  2911. // var list = that.getRsleep_arr(ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(","):[])
  2912. flushChart9(that.data.rdt_arr,that.data.rsnoring_arr,that.data.rgobed_time,that.data.routbed_time,that)
  2913. } catch (error) {
  2914. console.error(error);
  2915. }
  2916. console.log("c8_that.data.rmove_arr="+that.data.rmove_arr);
  2917. console.log("");
  2918. }
  2919. },
  2920. });
  2921. }
  2922. } catch (error) {
  2923. console.error(error);
  2924. }
  2925. },
  2926. })
  2927. },
  2928. sleepStateChange(data){
  2929. console.log("change-data=="+data)
  2930. switch(data) {
  2931. case 0:
  2932. return '清醒';
  2933. case 10:
  2934. return '浅睡';
  2935. case 20:
  2936. return '中睡';
  2937. case 30:
  2938. return '深睡';
  2939. default:
  2940. return '';
  2941. }
  2942. },
  2943. sleepRoutbed_arrChange(data){
  2944. console.log("change-data=="+data)
  2945. switch(data) {
  2946. case 0:
  2947. return '离床';
  2948. case 1:
  2949. return '在床';
  2950. default:
  2951. return '';
  2952. }
  2953. },
  2954. sleepRmove_arrChange(data){
  2955. console.log("change-data=="+data)
  2956. switch(data) {
  2957. case 0:
  2958. return '否';
  2959. case 1:
  2960. return '体动';
  2961. default:
  2962. return '';
  2963. }
  2964. },
  2965. sleepRsnoring_arrChange(data){
  2966. console.log("change-data=="+data)
  2967. switch(data) {
  2968. case 0:
  2969. return '否';
  2970. case 1:
  2971. return '打鼾';
  2972. default:
  2973. return '';
  2974. }
  2975. },
  2976. sleepRhxstop_arrChange(data){
  2977. console.log("change-data=="+data)
  2978. switch(data) {
  2979. case 0:
  2980. return '否';
  2981. case 1:
  2982. return '停止';
  2983. default:
  2984. return '';
  2985. }
  2986. },
  2987. splitN(originalArray,n){
  2988. if(!originalArray) return [];
  2989. // 计算每份的大小
  2990. let chunkSize = Math.ceil(originalArray.length / n);
  2991. // 分割数组并获取每份的最后一个元素
  2992. let lastElements = [];
  2993. for (let i = 0; i < originalArray.length; i += chunkSize) {
  2994. let chunk = originalArray.slice(i, i + chunkSize);
  2995. lastElements.push(chunk[chunk.length - 1]);
  2996. }
  2997. // 输出每份的最后一个元素
  2998. console.log('lastElements='+lastElements);
  2999. return lastElements;
  3000. },
  3001. takePortionDateData(rdt_arrArray,originalArray,n){
  3002. if(!rdt_arrArray || !originalArray) return [];
  3003. var portionDateData = [];
  3004. var portionData = [];
  3005. for (let i = 0; i < originalArray.length; i ++) {
  3006. if(originalArray[i] == n){
  3007. portionDateData.push(rdt_arrArray[i]);
  3008. portionData.push(originalArray[i]);
  3009. } else{
  3010. }
  3011. }
  3012. console.log('portionDateData='+JSON.stringify(portionDateData));
  3013. return portionDateData;
  3014. },
  3015. takePortionData(originalArray,n){
  3016. if(!originalArray) return [];
  3017. var portionData = [];
  3018. for (let i = 0; i < originalArray.length; i ++) {
  3019. if(originalArray[i] == n){
  3020. portionData.push(originalArray[i])
  3021. } else{
  3022. }
  3023. }
  3024. console.log('portionData='+JSON.stringify(portionData));
  3025. return portionData;
  3026. },
  3027. getFrequency(list,o){//获取次数
  3028. if(!list) return 0;
  3029. let frequency = 0;
  3030. for (let i = 0; i < list.length; i++) {
  3031. if(list[i] == o) frequency++;
  3032. }
  3033. console.log('frequency='+frequency);
  3034. return frequency;
  3035. },
  3036. getTimeDiffInHours: function(startTimeStr, endTimeStr) {
  3037. // 假设两个时间都是同一天的,这里我们使用当前日期作为基准
  3038. if(!startTimeStr || !endTimeStr) return null;
  3039. const now = new Date();
  3040. const startDate = new Date(now.getFullYear(), now.getMonth(), now.getDate(), ...startTimeStr.split(':').map(Number));
  3041. const endDate = new Date(now.getFullYear(), now.getMonth(), now.getDate(), ...endTimeStr.split(':').map(Number));
  3042. // 处理跨天的情况
  3043. if (endDate < startDate) {
  3044. endDate.setDate(endDate.getDate() + 1); // 将结束时间设置为第二天的同一时间
  3045. }
  3046. // 计算时间差(毫秒)
  3047. const diffInMs = endDate - startDate;
  3048. // 转换为小时
  3049. const diffInHours = diffInMs / (1000 * 60 * 60);
  3050. return diffInHours;
  3051. },
  3052. drawProgressCircle: function() {
  3053. const ctx = wx.createCanvasContext('progressCircleCanvas');
  3054. // 假设屏幕的宽度为 windowWidth px
  3055. const windowWidth = wx.getSystemInfoSync().windowWidth;
  3056. // 假设你有一个以 rpx 为单位的值
  3057. const valueInRpx = 300;
  3058. // 计算对应的 px 值
  3059. const valueInPx = (valueInRpx / 750) * windowWidth;
  3060. const radius = 60; // 圆的半径
  3061. const centerX = valueInPx; // 圆心的x坐标
  3062. const centerY = valueInPx/2; // 圆心的y坐标
  3063. const strokeWidth = 10; // 进度条的宽度
  3064. const percentage = this.data.percentage; // 进度百分比
  3065. // 绘制外圆
  3066. ctx.beginPath();
  3067. ctx.arc(centerX, centerY, radius, 0, 2 * Math.PI);
  3068. ctx.setStrokeStyle('#46ff81'); // 外圆颜色
  3069. ctx.setLineWidth(strokeWidth * 2); // 外圆线宽
  3070. ctx.stroke();
  3071. // 绘制内圆(进度条背景)
  3072. ctx.beginPath();
  3073. ctx.arc(centerX, centerY, radius - strokeWidth, 0, 2 * Math.PI);
  3074. ctx.setStrokeStyle('#e0e0e0'); // 内圆颜色
  3075. ctx.setLineWidth(strokeWidth); // 内圆线宽
  3076. ctx.stroke();
  3077. // 绘制进度条
  3078. ctx.beginPath();
  3079. ctx.arc(centerX, centerY, radius - strokeWidth, -0.5 * Math.PI, -0.5 * Math.PI + 2 * Math.PI * (percentage / 100));
  3080. ctx.setStrokeStyle('#007aff'); // 进度条颜色
  3081. ctx.setLineWidth(strokeWidth);
  3082. ctx.setLineCap('round'); // 设置线条端点的样式为圆形
  3083. ctx.stroke();
  3084. // 绘制中心圆点
  3085. ctx.beginPath();
  3086. ctx.arc(centerX, centerY, 5, 0, 2 * Math.PI);
  3087. ctx.setFillStyle('#ffffff');
  3088. ctx.fill();
  3089. // 绘制完成,将内容渲染到canvas中
  3090. ctx.draw();
  3091. },
  3092. // 假设你有一个方法来更新进度条的值
  3093. updateProgress: function(newPercentage) {
  3094. this.setData({
  3095. percentage: newPercentage
  3096. });
  3097. this.drawProgressCircle(); // 重新绘制进度条
  3098. },
  3099. buttonClicked: function() {
  3100. var that = this;
  3101. // 切换按钮的点击状态
  3102. this.setData({
  3103. isButtonClicked: !that.data.isButtonClicked,
  3104. });
  3105. // 在这里可以添加其他点击后的逻辑,比如调用接口等
  3106. },
  3107. telScreeProjection: function(tvEntityId) {
  3108. var that = this;
  3109. that.setData({
  3110. isLoading: true,
  3111. });
  3112. wx.request({
  3113. url: `${aipushApi}`+'/getbigreport',
  3114. method: 'POST',
  3115. header: {
  3116. 'content-type': 'application/json', // 默认值
  3117. 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
  3118. },
  3119. data:{
  3120.     "sn":that.data.rsn,"tokens":token_push
  3121. },
  3122. success(ress) {
  3123. console.log('wx.getStorageSync(tvEntityId)='+wx.getStorageSync('tvEntityId'));
  3124. console.log('tvEntityId='+JSON.stringify(tvEntityId));
  3125. let tvEntityIdss = tvEntityId?tvEntityId:wx.getStorageSync('tvEntityId')
  3126. if(ress && ress.data && tvEntityIdss){
  3127. console.log("ress.data=="+JSON.stringify(ress.data.url));
  3128. console.log("tvEntityIdss=="+tvEntityIdss);
  3129. wx.request({
  3130. // url: `${homeApi_http}`+':'+`${homeApi_http_port}`+'/api/services/media_player/play_media', //http
  3131. // url: `${homeApi_https}`+'/api/services/media_player/play_media', //https
  3132. url: `${homeApi_https}`+'/api/services/media_player/select_source', //https
  3133. method: 'POST',
  3134. header: {
  3135. 'content-type': 'application/json', // 默认值
  3136. 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
  3137. },
  3138. data:{
  3139.     "entity_id": tvEntityIdss,
  3140. //     "media_content_id": ress.data.url,
  3141. // "media_content_id": 'https://alifei01.cfp.cn/creative/vcg/800/new/VCG41175510742.jpg',
  3142. // "media_content_id": 'https://alifei01.cfp.cn/creative/vcg/veer/1600water/veer-368621010.jpg',
  3143. //     "media_content_type": "image/jpeg/png",
  3144. "source": "X浏览器"
  3145. },
  3146. success(res) {
  3147. that.setData({
  3148. isLoading: false,
  3149. });
  3150. if(res && res.data){
  3151. var resData = res.data
  3152. console.log('res-推送='+JSON.stringify(res));
  3153. console.log('res.data-推送='+JSON.stringify(resData));
  3154. wx.showToast({
  3155. title: "推送成功",
  3156. icon: "success",
  3157. mask: true,
  3158. });
  3159. }else{
  3160. wx.showToast({
  3161. title: '推送失败',
  3162. icon: 'none'
  3163. });
  3164. }
  3165. },
  3166. fail: function (error) {
  3167. // 请求失败后的回调函数
  3168. console.error('推送失败', error);
  3169. // 在这里处理请求失败的情况,比如显示错误信息给用户
  3170. that.setData({
  3171. isLoading: false,
  3172. });
  3173. wx.showToast({
  3174. title: '推送失败',
  3175. icon: 'none'
  3176. });
  3177. }
  3178. });
  3179. }else{
  3180. that.setData({
  3181. isLoading: false,
  3182. });
  3183. wx.showToast({
  3184. title: '找不到电视,推送失败',
  3185. icon: 'none'
  3186. });
  3187. }
  3188. },
  3189. });
  3190. },
  3191. getData(sn,hotelcode,roomcode,reportId){
  3192. var that = this;
  3193. wx.request({
  3194. url: `${aipushApi}`+'/getsn',
  3195. data: {"hotelcode":hotelcode?hotelcode:"club",
  3196. "roomcode":roomcode?roomcode:"nuange",
  3197. "token":token_push},
  3198. method: 'POST',
  3199. success(res) {
  3200. try {
  3201. // that.setData({
  3202. // airText: now.category, //空气质量
  3203. // airValue: now.aqi //空气指数
  3204. // })
  3205. if(res && res.data && res.data[0]){
  3206. that.setData({
  3207. roomname: res.data[0].rn
  3208. });
  3209. console.log("res.data-sn="+JSON.stringify(res.data));
  3210. wx.request({
  3211. url: `${aipushApi}`+'/getsingle',
  3212. data: {"sn":sn?sn:res.data[0].sn,
  3213. "token":token_push,
  3214. "rpids":reportId},
  3215. method: 'POST',
  3216. success(ress) {
  3217. try {
  3218. if(ress && ress.data){
  3219. console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
  3220. // that.setData({
  3221. // airText: now.category, //空气质量
  3222. // airValue: now.aqi //空气指数
  3223. // })
  3224. // rdt_arr = ress.data.results.rdt_arr //睡眠时间轴数据集合
  3225. // rrh_arr = ress.data.results.rdt_arr//睡眠心率数据集合
  3226. // rhx_arr = ress.data.results.rhx_arr//睡眠呼吸数据集合
  3227. // rsnoring_arr = ress.data.results.rsnoring_arr//睡眠打鼾数据集合,0-否,1-打鼾状态
  3228. // routbed_arr = ress.data.results.routbed_arr//离床状态数据集合,0-离床,1-在床
  3229. // rmove_arr = ress.data.results.rmove_arr//体动状态数据集合,0-否,1-体动状态
  3230. // rhxstop_arr = ress.data.results.rhxstop_arr//呼吸停止状态数据集合
  3231. // rsleep_arr = ress.data.results.rsleep_arr//睡眠状态数据集合,0-清醒,10-浅睡,20-中睡,30-深睡
  3232. // rdeep_duration = ress.data.results.rdeep_duration//深睡时长,单位分钟
  3233. // rlight_duration = ress.data.results.rlight_duration//浅睡时长,单位分钟
  3234. // rin_duration = ress.data.results.rin_duration//中睡时长,单位分钟
  3235. // rawake_duration = ress.data.results.rawake_duration//清醒时长,单位分钟
  3236. // ravg_hx_value = ress.data.results.ravg_hx_value//呼吸平均值
  3237. // ravg_hx_desc = ress.data.results.ravg_hx_desc//呼吸平均值评分描述
  3238. // ravg_rh_value = ress.data.results.ravg_rh_value//心率平均值
  3239. // ravg_rh_desc = ress.data.results.ravg_rh_desc//心率平均值评分描述
  3240. // rscore_value = ress.data.results.rscore_value//睡眠报告得分值
  3241. // rscore_desc = ress.data.results.rscore_desc//睡眠报告得分评比描述
  3242. // that.setData({
  3243. // rdt_arr: ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],
  3244. // rrh_arr: ress.data.results.rrh_arr?ress.data.results.rrh_arr.split(','):[],
  3245. // rhx_arr: ress.data.results.rhx_arr?ress.data.results.rhx_arr.split(','):[],
  3246. // rsnoring_arr: ress.data.results.rsnoring_arr?ress.data.results.rsnoring_arr.split(','):[],
  3247. // routbed_arr: ress.data.results.routbed_arr?ress.data.results.routbed_arr.split(','):[],
  3248. // rmove_arr: ress.data.results.rmove_arr?ress.data.results.rmove_arr.split(','):[],
  3249. // rhxstop_arr: ress.data.results.rhxstop_arr?ress.data.results.rhxstop_arr.split(','):[],
  3250. // rsleep_arr: ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(','):[],
  3251. // rdeep_duration: ress.data.results.rdeep_duration,
  3252. // rlight_duration: ress.data.results.rlight_duration,
  3253. // rin_duration: ress.data.results.rin_duration,
  3254. // rawake_duration: ress.data.results.rawake_duration,
  3255. // ravg_hx_value: ress.data.results.ravg_hx_value,
  3256. // ravg_hx_desc: ress.data.results.ravg_hx_desc,
  3257. // ravg_rh_value: ress.data.results.ravg_rh_value,
  3258. // ravg_rh_desc: ress.data.results.ravg_rh_desc,
  3259. // rscore_value: ress.data.results.rscore_value,
  3260. // rscore_desc: ress.data.results.rscore_desc,
  3261. // rsn: ress.data.results.rsn,
  3262. // rdate: ress.data.results.rdate,
  3263. // rtotal_duration: ress.data.results.rtotal_duration,//睡眠总时长,单位分钟
  3264. // rinbed_duration: ress.data.results.rinbed_duration,//在床时长,单位分钟
  3265. // rgobed_time: ress.data.results.rgobed_time,//上床时间
  3266. // routbed_time: ress.data.results.routbed_time,//离床时间
  3267. // routbed_count_value: ress.data.results.routbed_count_value,//离床次数
  3268. // rsn: ress.data.results.rsn,
  3269. // });
  3270. let durationDataTemp = [];
  3271. let obj = {};
  3272. obj.name = '深睡';
  3273. obj.value = ress.data.results.rdeep_duration;
  3274. durationDataTemp.push(obj);
  3275. obj = {};
  3276. obj.name = '浅睡';
  3277. obj.value = ress.data.results.rlight_duration;
  3278. durationDataTemp.push(obj);
  3279. obj = {};
  3280. obj.name = '中睡';
  3281. obj.value = ress.data.results.rin_duration;
  3282. durationDataTemp.push(obj);
  3283. obj = {};
  3284. obj.name = '清醒';
  3285. obj.value = ress.data.results.rawake_duration;
  3286. durationDataTemp.push(obj);
  3287. console.log("durationDataTemp="+JSON.stringify(durationDataTemp));
  3288. let sleep_durationCount = 0;
  3289. if(ress.data.results.rdeep_duration){
  3290. sleep_durationCount += parseFloat(ress.data.results.rdeep_duration)
  3291. }
  3292. if(ress.data.results.rlight_duration){
  3293. sleep_durationCount += parseFloat(ress.data.results.rlight_duration)
  3294. }
  3295. if(ress.data.results.rin_duration){
  3296. sleep_durationCount += parseFloat(ress.data.results.rin_duration)
  3297. }
  3298. let sleep_efficiency_temp = ress.data.results.rtotal_duration?(Math.ceil((sleep_durationCount / ress.data.results.rtotal_duration)*100)+'%'):'%'
  3299. 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)+'%'):'%'
  3300. 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)+'%'):'%'
  3301. 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)+'%'):'%'
  3302. let sleep_durationTemp = [];
  3303. let obj1 = {};
  3304. obj1.name = '睡眠时间';
  3305. obj1.value = Math.ceil(sleep_durationCount / 60);
  3306. sleep_durationTemp.push(obj1);
  3307. obj1 = {};
  3308. obj1.name = '清醒时间';
  3309. obj1.value = Math.ceil(parseFloat(ress.data.results.rawake_duration) / 60);
  3310. sleep_durationTemp.push(obj1);
  3311. let zdPointTemp = [];
  3312. let rdt_arrTemp = [];
  3313. let rrh_arrTemp = [];
  3314. let rhx_arrTemp = [];
  3315. let rmove_arrTemp = [];
  3316. let rsleep_arrTemp = [];
  3317. let rsleep_arr_all_Temp = [];
  3318. if(ress.data.results.rrh_arr){
  3319. rdt_arrTemp = that.splitN(ress.data.results.rdt_arr.split(","),100);
  3320. }
  3321. if(ress.data.results.rrh_arr){
  3322. rrh_arrTemp = that.splitN(ress.data.results.rrh_arr.split(","),100);
  3323. }
  3324. if(ress.data.results.rhx_arr){
  3325. rhx_arrTemp = that.splitN(ress.data.results.rhx_arr.split(","),100);
  3326. }
  3327. if(ress.data.results.rmove_arr){
  3328. rmove_arrTemp = that.splitN(ress.data.results.rmove_arr.split(","),100);
  3329. }
  3330. if(ress.data.results.rsleep_arr){
  3331. rsleep_arrTemp = that.splitN(ress.data.results.rsleep_arr.split(","),100);
  3332. }
  3333. if(ress.data.results.rsleep_arr){
  3334. rsleep_arr_all_Temp = ress.data.results.rsleep_arr.split(",");
  3335. }
  3336. console.log("rdt_arrTemp="+JSON.stringify(rdt_arrTemp));
  3337. console.log("rrh_arrTemp="+JSON.stringify(rrh_arrTemp));
  3338. console.log("rhx_arrTemp="+JSON.stringify(rhx_arrTemp));
  3339. console.log("rmove_arrTemp="+JSON.stringify(rmove_arrTemp));
  3340. console.log("rsleep_arrTemp="+JSON.stringify(rsleep_arrTemp));
  3341. console.log("rsleep_arr_all_Temp="+JSON.stringify(rsleep_arr_all_Temp));
  3342. console.log("sleep_durationTemp="+JSON.stringify(sleep_durationTemp));
  3343. that.setData({
  3344. rdt_arr: ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],
  3345. rrh_arr: ress.data.results.rrh_arr?ress.data.results.rrh_arr.split(','):[],
  3346. rhx_arr: ress.data.results.rhx_arr?ress.data.results.rhx_arr.split(','):[],
  3347. rsnoring_arr: ress.data.results.rsnoring_arr?ress.data.results.rsnoring_arr.split(','):[],
  3348. routbed_arr: ress.data.results.routbed_arr?ress.data.results.routbed_arr.split(','):[],
  3349. rmove_arr: ress.data.results.rmove_arr?ress.data.results.rmove_arr.split(','):[],
  3350. rhxstop_arr: ress.data.results.rhxstop_arr?ress.data.results.rhxstop_arr.split(','):[],
  3351. rsleep_arr: ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(','):[],
  3352. rsnoring_arrFrequency: that.getFrequency(ress.data.results.rsnoring_arr?ress.data.results.rsnoring_arr.split(','):[],1),
  3353. routbed_arrFrequency: that.getFrequency(ress.data.results.routbed_arr?ress.data.results.routbed_arr.split(','):[],0),
  3354. rmove_arrFrequency: that.getFrequency(ress.data.results.rmove_arr?ress.data.results.rmove_arr.split(','):[],1),
  3355. rhxstop_arrFrequency: that.getFrequency(ress.data.results.rhxstop_arr?ress.data.results.rhxstop_arr.split(','):[],1),
  3356. rdeep_duration: that.convertTimeToHoursAndMinutes(ress.data.results.rdeep_duration),
  3357. rlight_duration: ress.data.results.rlight_duration,
  3358. rin_duration: ress.data.results.rin_duration,
  3359. rawake_duration: ress.data.results.rawake_duration,
  3360. ravg_hx_value: ress.data.results.ravg_hx_value,
  3361. ravg_hx_desc: ress.data.results.ravg_hx_desc,
  3362. ravg_rh_value: ress.data.results.ravg_rh_value,
  3363. ravg_rh_desc: ress.data.results.ravg_rh_desc,
  3364. rscore_value: ress.data.results.rscore_value,
  3365. rscore_desc: ress.data.results.rscore_desc,
  3366. rsn: ress.data.results.rsn,
  3367. rdate: ress.data.results.rdate,
  3368. rtotal_duration: that.convertTimeToHoursAndMinutes(ress.data.results.rtotal_duration),//睡眠总时长,单位小时分钟
  3369. rinbed_duration: that.convertTimeToHoursAndMinutes(ress.data.results.rinbed_duration),//在床时长,单位小时分钟
  3370. rgobed_time: ress.data.results.rgobed_time,//上床时间
  3371. routbed_time: ress.data.results.routbed_time,//离床时间
  3372. rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
  3373. sleepHourSub: that.getTimeDiffInHours(ress.data.results.rgobed_time,ress.data.results.routbed_time),
  3374. routbed_count_value: ress.data.results.routbed_count_value,//离床次数
  3375. rsn: ress.data.results.rsn,
  3376. zdPointT:zdPointTemp,
  3377. rdt_arrNew:rdt_arrTemp,
  3378. rrh_arrNew:rrh_arrTemp,
  3379. rhx_arrNew:rhx_arrTemp,
  3380. rmove_arrNew:rmove_arrTemp,
  3381. rsleep_arrNew:rsleep_arrTemp,
  3382. rsleep_arr_all_New:rsleep_arr_all_Temp,
  3383. durationData:durationDataTemp,
  3384. sleep_duration:sleep_durationTemp,
  3385. sleep_efficiency:sleep_efficiency_temp,
  3386. sleep_durationCountA:that.convertTimeToHoursAndMinutes(sleep_durationCount?sleep_durationCount.toString():'0'),
  3387. sns:res.data,
  3388. tvEntityIds:wx.getStorageSync('tvEntityIds'),
  3389. ifOneMoreTV:(wx.getStorageSync('tvEntityIds') && wx.getStorageSync('tvEntityIds').length>1),
  3390. hotelname:res.data[0].hn,
  3391. rdeep_duration_efficiency:rdeep_duration_efficiency_temp,
  3392. rlight_duration_efficiency:rlight_duration_efficiency_temp,
  3393. rin_duration_efficiency:rin_duration_efficiency_temp,
  3394. pushReportId:ress.data.results.rdid,
  3395. rrs_duration:that.convertTimeToHoursAndMinutes(ress.data.results.rrs_duration?ress.data.results.rrs_duration.toString():'0'),
  3396. routbed_count_value:ress.data.results.routbed_count_value,
  3397. rsleep_eff_value:ress.data.results.rsleep_eff_value,
  3398. });
  3399. that.getDateTimeJsonData(sn?sn:res.data[0].sn);
  3400. // resolve(ress.data); // 请求成功,使用 resolve 返回数据
  3401. console.log('ress.data.results-'+ress.data.results)
  3402. if(!ress.data.results || ress.data.results == ''){
  3403. wx.showModal({
  3404. title: '提示',
  3405. content: '无数据',
  3406. showCancel: false
  3407. });
  3408. return;
  3409. }
  3410. }else{
  3411. wx.showModal({
  3412. title: '提示',
  3413. content: '无数据',
  3414. showCancel: false
  3415. });
  3416. }
  3417. } catch (error) {
  3418. console.error(error);
  3419. }
  3420. console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
  3421. console.log("");
  3422. },
  3423. fail: function (error) {
  3424. wx.showToast({
  3425. title: "无数据",
  3426. icon: "error",
  3427. mask: true,
  3428. });
  3429. }
  3430. });
  3431. }
  3432. // that.startInterval();
  3433. } catch (error) {
  3434. console.error(error);
  3435. }
  3436. },
  3437. });
  3438. wx.request({
  3439. url: `${aipushApi}/getha`, //
  3440. method: 'POST',
  3441. // header: {
  3442. // 'content-type': 'application/json', // 默认值
  3443. // 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
  3444. // },
  3445. data:{
  3446.     "locations":hotelcode,"room":(hotelcode && hotelcode.includes('hotel'))?roomcode:"","token":token_push
  3447. },
  3448. success(res) {
  3449. if(!res || !res.data){
  3450. that.setData({
  3451. isLoading: false,
  3452. });
  3453. return;
  3454. }
  3455. var resData = res.data
  3456. console.log('res.data.睡眠报告.ha='+JSON.stringify(resData));
  3457. if (res.data.code == "400") {
  3458. console.error("400错误!");
  3459. return;
  3460. }
  3461. if (res.data.code == "401") {
  3462. console.error("401错误!");
  3463. return;
  3464. }
  3465. homeApi_https = resData.loc;
  3466. token = resData.token;
  3467. },
  3468. fail: function (error) {
  3469. console.error('error', error);
  3470. that.setData({
  3471. isLoading: false,
  3472. });
  3473. }
  3474. });
  3475. },
  3476. convertTimeToHoursAndMinutes: function(timeWithText,flag) {
  3477. if(!timeWithText) return;
  3478. // 移除'分钟'两个字
  3479. var minutesStr = timeWithText.replace('分钟', '');
  3480. var minutes = parseInt(minutesStr); // 将字符串转换为整数
  3481. if (isNaN(minutes)) {
  3482. // 如果转换失败,则可能是输入的不是有效的数字
  3483. console.error('Invalid minutes format');
  3484. return;
  3485. }
  3486. var hours = Math.floor(minutes / 60); // 整除60得到小时数
  3487. var remainingMinutes = minutes % 60; // 取余得到剩余的分钟数
  3488. // 如果小时数或分钟数小于10,前面补0
  3489. // var formattedHours = hours < 10 ? '0' + hours : hours;
  3490. var formattedHours = hours;
  3491. // var formattedMinutes = remainingMinutes < 10 ? '0' + remainingMinutes : remainingMinutes;
  3492. var formattedMinutes = remainingMinutes;
  3493. // 拼接小时和分钟,形成HH:mm格式
  3494. var formattedTime = '';
  3495. if(flag){
  3496. formattedTime = formattedHours + 'H ' + formattedMinutes + 'M';
  3497. }else{
  3498. formattedTime = formattedHours + '小时' + formattedMinutes;
  3499. }
  3500. // 更新数据
  3501. // this.setData({
  3502. // formattedTime: formattedTime
  3503. // });
  3504. return formattedTime;
  3505. },
  3506. getDateTimeJsonData: function(sn) {
  3507. var that = this;
  3508. var sourceFourthTemp = [];
  3509. wx.request({
  3510. url: `${aipushApi}/getdatefromsn`, //
  3511. method: 'POST',
  3512. // header: {
  3513. // 'content-type': 'application/json', // 默认值
  3514. // 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
  3515. // },
  3516. data:{
  3517.     "sn":sn,"token":token_push
  3518. },
  3519. success(res) {
  3520. if(!res || !res.data || !res.data.results){
  3521. return;
  3522. }
  3523. var resDataSn = res.data.results
  3524. console.log('resDataSn===='+JSON.stringify(resDataSn))
  3525. var tt = 0;
  3526. resDataSn.forEach(function(item, index) {
  3527. wx.request({
  3528. url: `${aipushApi}/getimefromsn`, //
  3529. method: 'POST',
  3530. // header: {
  3531. // 'content-type': 'application/json', // 默认值
  3532. // 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
  3533. // },
  3534. data:{
  3535.     "sn":sn,"date":item.rdate,"token":token_push
  3536. },
  3537. success(ress) {
  3538. if(!ress || !ress.data || !ress.data.results){
  3539. return;
  3540. }
  3541. var resDataItem = ress.data.results;
  3542. resDataItem.forEach(function(item_item, index) {
  3543. item_item.text = item_item.durations;
  3544. item_item.reportId = item_item.rpids;
  3545. });
  3546. var json = {};
  3547. json.text = item.rdate;
  3548. json.children = resDataItem;
  3549. sourceFourthTemp.push(json);
  3550. console.log('sourceFourthTemp0='+JSON.stringify(sourceFourthTemp));
  3551. if (tt == (resDataSn.length - 1)) {
  3552. console.log('sourceFourthTemp='+JSON.stringify(sourceFourthTemp));
  3553. // 使用 sort 方法进行排序
  3554. sourceFourthTemp.sort(function(a, b) {
  3555. // 将字符串转换为 Date 对象
  3556. let dateA = new Date(a.text);
  3557. let dateB = new Date(b.text);
  3558. if (dateA < dateB) {
  3559. return 1;
  3560. }
  3561. if (dateA > dateB) {
  3562. return -1;
  3563. }
  3564. // 如果日期相等,返回 0
  3565. return 0;
  3566. });
  3567. console.log('sourceFourthTemp1='+JSON.stringify(sourceFourthTemp));
  3568. //初始化弹出面板
  3569. var array = that.data.arrayFourth;
  3570. array[0] = sourceFourthTemp;
  3571. array[1] = array[0][0].children;
  3572. that.setData({
  3573. valueFourth: [0, 0],
  3574. sourceFourth: sourceFourthTemp,
  3575. arrayFourth: array,
  3576. })
  3577. tt = 0;
  3578. }
  3579. tt++
  3580. },
  3581. fail: function (error) {
  3582. console.error('error', error);
  3583. }
  3584. });
  3585. });
  3586. },
  3587. fail: function (error) {
  3588. console.error('error', error);
  3589. } ,
  3590. complete: function (e) {
  3591. }
  3592. });
  3593. },
  3594. // 在全局或者组件中定义函数
  3595. fontSize: function(res) {
  3596. const clientWidth = wx.getSystemInfoSync().windowWidth; // 获取屏幕宽度
  3597. if (!clientWidth) return;
  3598. let fontSize = clientWidth / 1920; // 假设以1920为基准宽度
  3599. return res * fontSize;
  3600. },
  3601. /**
  3602. * 生命周期函数--监听页面加载
  3603. */
  3604. onShow: function(options) {
  3605. var that = this;
  3606. console.log("that.data.month + 1", that.data.month + 1)
  3607. var clickDate = String(that.data.year) + String(that.data.month) + String(that.data.date)
  3608. clickDate = String(parseInt(clickDate) + 100)
  3609. // that.getTargetData(clickDate)
  3610. that.setData({
  3611. clickDate: clickDate,
  3612. // ec000: {
  3613. // onInit: that.initChart000
  3614. // },
  3615. ec00: {
  3616. onInit: that.initChart00
  3617. },
  3618. ec0: {
  3619. onInit: that.initChart0
  3620. },
  3621. ec: {
  3622. onInit: that.initChart
  3623. },
  3624. ec1: {
  3625. onInit: that.initChart1
  3626. },
  3627. ec2: {
  3628. onInit: that.initChart2
  3629. },
  3630. ec3: {
  3631. onInit: that.initChart3
  3632. },
  3633. ec4: {
  3634. onInit: that.initChart4
  3635. },
  3636. ec5: {
  3637. onInit: that.initChart5
  3638. },
  3639. ec6: {
  3640. onInit: that.initChart6
  3641. },
  3642. ec7: {
  3643. onInit: that.initChart7
  3644. },
  3645. ec8: {
  3646. onInit: that.initChart8
  3647. },
  3648. ec81: {
  3649. onInit: that.initChart81
  3650. },
  3651. ec9: {
  3652. onInit: that.initChart9
  3653. },
  3654. ec10: {
  3655. onInit: that.initChart10
  3656. },
  3657. ec11: {
  3658. onInit: that.initChart11
  3659. },
  3660. });
  3661. },
  3662. onLoad(option){
  3663. var that = this;
  3664. console.log("data页面");
  3665. // wx.clearStorage();
  3666. console.log('option.res='+JSON.stringify(wx.getStorageSync('res')));
  3667. if(!wx.getStorageSync('res') || !wx.getStorageSync('res').result){
  3668. wx.showModal({
  3669. title: '提示',
  3670. content: '请先扫描房间二维码',
  3671. showCancel: false
  3672. });
  3673. setTimeout(function() {
  3674. wx.reLaunch({
  3675. url: '/pages/scan/scan',
  3676. })
  3677. }, 2000) // 设置延时时间,单位为毫秒
  3678. }else if(wx.getStorageSync('res').result.split('|').length != 2){
  3679. wx.showModal({
  3680. title: '提示',
  3681. content: '房间二维码不正确,请重新扫码',
  3682. showCancel: false
  3683. });
  3684. setTimeout(function() {
  3685. wx.reLaunch({
  3686. url: '/pages/scan/scan',
  3687. })
  3688. }, 2000) // 设置延时时间,单位为毫秒
  3689. }else{
  3690. // const expiresAt = wx.getStorageSync('scanResultExpiresAt');
  3691. // const now = Date.now()
  3692. // if (expiresAt || expiresAt < now) {
  3693. // // 扫码结果已过期
  3694. // wx.showToast({
  3695. // title: '扫码结果失效或已过期,请重新扫码',
  3696. // icon: 'none'
  3697. // });
  3698. // // 清除过期的扫码结果
  3699. // wx.removeStorageSync('scanResultExpiresAt');
  3700. // setTimeout(function() {
  3701. // wx.reLaunch({
  3702. // url: '/pages/scan/scan',
  3703. // })
  3704. // }, 2000) // 设置延时时间,单位为毫秒
  3705. // }else{
  3706. // //续期
  3707. // wx.setStorageSync('scanResultExpiresAt', Date.now() + 2 * 60 * 60 * 1000)
  3708. // }
  3709. let hotelcodeTemp = '';
  3710. let roomcodeTemp = '';
  3711. hotelcodeTemp = wx.getStorageSync('res').result.split('|')[0];
  3712. roomcodeTemp = wx.getStorageSync('res').result.split('|')[1];
  3713. this.getData(null,hotelcodeTemp,roomcodeTemp,null);
  3714. // const result = await this.getData();
  3715. // console.log('result='+JSON.stringify(result));
  3716. this.drawProgressCircle();
  3717. // 获取系统信息
  3718. const systemInfo = wx.getSystemInfoSync();
  3719. const windowWidth = systemInfo.windowWidth; // 窗口宽度
  3720. // 计算canvas的宽度和高度
  3721. const canvasWidth = windowWidth; // 可以根据需求调整canvas的宽度
  3722. const canvasHeight = windowWidth * 0.5; // 假设高度是宽度的一半,可以根据需求调整
  3723. // var now = new Date(); // 创建一个Date对象,表示当前的日期和时间
  3724. // var year = now.getFullYear(); // 获取年份
  3725. // var month = now.getMonth() + 1; // 获取月份(注意月份是从0开始的,所以需要+1)
  3726. // var date = now.getDate(); // 获取日期
  3727. // var hours = now.getHours(); // 获取小时
  3728. // var minutes = now.getMinutes(); // 获取分钟
  3729. // var seconds = now.getSeconds(); // 获取秒
  3730. // month = month < 10 ? '0' + month : month;
  3731. // date = date < 10 ? '0' + date : date;
  3732. // hours = hours < 10 ? '0' + hours : hours;
  3733. // minutes = minutes < 10 ? '0' + minutes : minutes;
  3734. // seconds = seconds < 10 ? '0' + seconds : seconds;
  3735. // // 拼接日期和时间字符串
  3736. // var currentDateTime = year + '-' + month + '-' + date + ' ' + hours + ':' + minutes + ':' + seconds;
  3737. // console.log(currentDateTime);
  3738. // var currentDate = year + '-' + month + '-' + date;
  3739. // var currentTime = hours + ':' + minutes + ':' + seconds;
  3740. // this.selectComponent('#mychart-dom-bar00').init((canvas, width, height) => {
  3741. // that.initChart00(canvas, width, height)
  3742. // });
  3743. // 设置canvas的宽高
  3744. this.setData({
  3745. // currentDate: currentDate,
  3746. // currentTime: currentTime,
  3747. canvasWidth: canvasWidth,
  3748. canvasHeight: canvasHeight,
  3749. hotelcode: hotelcodeTemp,
  3750. roomcode: roomcodeTemp,
  3751. // roomname: wx.getStorageSync('roomname'),
  3752. // arrayFourth: array,
  3753. });
  3754. }
  3755. // else if(!this.data.home_room.includes(wx.getStorageSync('res').result)){
  3756. // wx.showModal({
  3757. // title: '提示',
  3758. // content: '房间二维码不正确,请重新扫描',
  3759. // showCancel: false
  3760. // });
  3761. // setTimeout(function() {
  3762. // wx.reLaunch({
  3763. // url: '/pages/scan/scan',
  3764. // })
  3765. // }, 2000) // 设置延时时间,单位为毫秒
  3766. // }
  3767. // else if(this.data.home_room.includes(wx.getStorageSync('res').result) && wx.getStorageSync('res').result.includes('辰悦颐养斋')){
  3768. // else if(wx.getStorageSync('res').result.includes('辰悦颐养斋')){
  3769. // homeApi = "http://zhh.aidsleep.cn";
  3770. // homeApi_http = "http://zhh.aidsleep.cn";
  3771. // homeApi_http_port = "9123";
  3772. // homeApi_https = "https://zhh.aidsleep.cn";
  3773. // }
  3774. this.drawCircle();
  3775. },
  3776. mounted() {
  3777. },
  3778. /**
  3779. * 生命周期函数--监听页面隐藏
  3780. */
  3781. onHide: function() {
  3782. // wx.clearStorage();
  3783. // this.clearInterval();
  3784. },
  3785. /**
  3786. * 生命周期函数--监听页面卸载
  3787. */
  3788. onUnload: function() {
  3789. // wx.clearStorage();
  3790. // this.clearInterval();
  3791. },
  3792. /**
  3793. * 页面相关事件处理函数--监听用户下拉动作
  3794. */
  3795. onPullDownRefresh: function() {
  3796. },
  3797. /**
  3798. * 页面上拉触底事件的处理函数
  3799. */
  3800. onReachBottom: function() {
  3801. },
  3802. /**
  3803. * 用户点击右上角分享
  3804. */
  3805. onShareAppMessage: function() {
  3806. }
  3807. })