| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531 |
- import * as echarts from '../../ec-canvas/echarts';
- let chart0;
- let chart;
- let chart2;
- let chart3;
- let chart4;
- let chart5;
- let chart6;
- let chart81;
- let chart9;
- let chart10;
- let chart11;
- // 渐变圆环
- let chartCircularProgressBar;//圈圈
- let chartOutOfBed;//离床
- let chartBodyMovementsLine;//体动
- let chartCardiacSystemLine;//心脏系统
- let chartRespiratoryLine;//平均呼吸率
- let chartSnoringLine;//打鼾
- let chartApneaLine;//呼吸暂停
- let chartTimeWaterfall;//深浅睡眠
- // 圈圈>90分极好(绿色)
- // > 75分,(浅绿色)良好
- // 各项睡眠监测数据统计 > 60分,较差(黄色)
- // < 60分,很差(红色)
- function setChartCircularProgressBarOption(chart, data = {}) {
- var rscore_value = data?.rscore_value || 0;
- var checkList = [{
- title: "极好",
- titleColor: "#0BC3AA",
- startColor: "#0AB1C3",
- centerColor: "#0BC3AA",
- endColor: "#36E1CA",
- }, {
- title: "良好",
- titleColor: "#9C43FF",
- startColor: "#8D25FF",
- centerColor: "#A631FF",
- endColor: "#FF8FF0",
- }, {
- title: "较差",
- titleColor: "#FF8F4E",
- startColor: "#EE8B52",
- centerColor: "#FAA472",
- endColor: "#FAA472",
- }, {
- title: "很差",
- titleColor: "#FB717B",
- startColor: "#FB717B",
- centerColor: "#FB717B",
- endColor: "#FF98A0",
- }];
- var checkData = checkList[0];
- if (rscore_value >= 90 && rscore_value <= 100) {
- checkData = checkList[0];
- } else if (rscore_value >= 75 && rscore_value < 90) {
- checkData = checkList[1];
- } else if (rscore_value >= 60 && rscore_value < 75) {
- checkData = checkList[2];
- } else {
- checkData = checkList[3];
- }
- var option = {
- series: [
- {
- type: 'gauge',
- startAngle: -270,
- endAngle: 90,
- legendHoverLink: true,
- min: 0,
- max: 100,
- itemStyle: {
- color: '#58D9F9',
- shadowColor: 'rgba(0,138,255,0.45)',
- shadowBlur: 5,
- shadowOffsetX: 1,
- shadowOffsetY: 1
- },
- progress: {
- show: true,
- roundCap: true,
- width: 10,
- itemStyle: {
- // 进度条样式
- color: {
- // 自定义渐变色
- type: 'linear',
- x: 0.75,
- y: 0.75,
- x2: 0,
- y2: 0.75,
- colorStops: [
- {
- offset: 0,
- color: checkData.startColor // 0% 处的颜色
- },
- {
- offset: 0.5,
- color: checkData.centerColor // 100% 处的颜色
- },
- {
- offset: 1,
- color: checkData.endColor // 100% 处的颜色
- }
- ],
- global: false // 缺省为 false
- }
- }
- },
- pointer: {
- show: false,
- },
- axisLine: {
- roundCap: true,
- lineStyle: {
- width: 10,
- }
- },
- axisTick: {
- show: false // 是否显示分隔线
- },
- splitLine: {
- show: false // 是否显示分隔线
- },
- axisLabel: {
- show: false,
- },
- title: {
- color: checkData.titleColor,
- offsetCenter: [0, '-36%'],
- lineHeight: 15,
- fontSize: 15,
- },
- detail: {
- backgroundColor: '#fff',
- width: '60%',
- lineHeight: 40,
- height: 40,
- color: '#333333',
- offsetCenter: [0, "24%"],
- valueAnimation: true,
- formatter: function (value) {
- return '{value|' + value.toFixed(0) + '}';
- },
- rich: {
- value: {
- fontSize: 30,
- fontWeight: 'bolder',
- color: checkData.titleColor
- },
- }
- },
- data: [
- {
- name: data?.rscore_desc || checkData.title || '无',
- value: data?.rscore_value || 0
- }
- ]
- }
- ]
- };
- chart.setOption(option, true);
- }
- function initChartHumidifier(canvas, width, height, dpr) {
- // this.selectComponent('#mychart-dom-bar00').init((canvas, width, height, dpr) => {
- // 获取组件的 canvas、width、height 后的回调函数
- // 在这里初始化图表
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr // new
- });
- canvas.setChart(chart);
- setChartCircularProgressBarOption(chart);
- // 将图表实例绑定到 this 上,可以在其他成员函数(如 dispose)中访问
- chartCircularProgressBar = chart;
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return chart;
- // });
- };
- function updateChartCircularProgressBarOption(rscore_desc, rscore_value, that) {
- if (chartCircularProgressBar) {
- setChartCircularProgressBarOption(chartCircularProgressBar, { rscore_desc, rscore_value });
- that.setData({
- flushChart00Flag: true
- });
- } else {
- that.selectComponent('#mychart-dom-CircularProgressBar').init((canvas, width, height, dpr) => {
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr // new
- });
- canvas.setChart(chart);
- setChartCircularProgressBarOption(chart, { rscore_desc, rscore_value });
- // 将图表实例绑定到 this 上,可以在其他成员函数(如 dispose)中访问
- chartCircularProgressBar = chart;
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return chart;
- });
- }
- }
- //离床
- function initChartOutOfBed(canvas, width, height, dpr) {
- // this.selectComponent('#mychart-dom-bar00').init((canvas, width, height, dpr) => {
- // 获取组件的 canvas、width、height 后的回调函数
- // 在这里初始化图表
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr // new
- });
- canvas.setChart(chart);
- setChartOutOfBedOption(chart);
- // 将图表实例绑定到 this 上,可以在其他成员函数(如 dispose)中访问
- chartOutOfBed = chart;
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return chart;
- // });
- };
- function setChartOutOfBedOption(chart, data1 = [], data2 = [],) {
- var option = option = {
- tooltip: {
- show: true,
- trigger: 'axis',
- formatter: function (param) {
- return `${param[0] && param[0].value == 1 ? '在床' : '离床'}`
- }
- },
- dataZoom: [
- { // 第一个 dataZoom 组件
- type: 'inside',
- },
- ],
- grid: {
- top: '10rpx',
- left: 0,
- right: '20rpx',
- bottom: 0,
- containLabel: true
- },
- xAxis: {
- type: 'category',
- axisLabel: {
- color: '#6C6970',// 设置 x 轴标签颜色为白色
- fontSize: 10
- },
- boundaryGap: false,
- splitLine: {
- show: false, // 是否显示刻度线
- },
- axisTick: {
- // 不显示Y轴刻度线
- show: false
- },
- data: data1,
- axisLine: {
- // 不显示X轴轴线
- show: false
- }
- },
- yAxis: {
- // Y 轴配置
- type: 'value',
- show: false
- },
- series: [{
- type: 'line',
- name: '睡眠状态',
- smooth: true,
- lineStyle: {
- width: 2,
- color: '#54C68B'
- },
- showSymbol: false,
- areaStyle: {
- opacity: 0.8,
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- {
- offset: 0,
- color: '#B8EBD0'
- },
- {
- offset: 1,
- color: 'rgba(255, 255, 255, 0)'
- }
- ])
- },
- data: data2,
- }]
- };
- chart.setOption(option, true);
- }
- function updateOutOfBed(data1, data2, startSleepTime, endSleepTime, that) {
- if (chartOutOfBed) {
- setChartOutOfBedOption(chartOutOfBed, data1, data2);
- } else {
- that.selectComponent('#chartOutOfBed-dom').init((canvas, width, height, dpr) => {
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr // new
- });
- canvas.setChart(chart);
- setChartOutOfBedOption(chart, data1, data2);
- // 将图表实例绑定到 this 上,可以在其他成员函数(如 dispose)中访问
- chartOutOfBed = chart;
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return chart;
- });
- }
- }
- //体动
- function initChartBodyMovementsLine(canvas, width, height, dpr) {
- // 在这里初始化图表
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr // new
- });
- canvas.setChart(chart);
- setBodyMovementsOption(chart);
- // 将图表实例绑定到 this 上,可以在其他成员函数(如 dispose)中访问
- chartBodyMovementsLine = chart;
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return chart;
- };
- function setBodyMovementsOption(chart, data1 = [], data2 = [],) {
- var option = option = {
- tooltip: {
- show: true,
- trigger: 'axis',
- formatter: function (param) {
- return `${param[0] && param[0].value == 1 ? '体动' : '否'}`
- }
- },
- dataZoom: [
- { // 第一个 dataZoom 组件
- type: 'inside',
- },
- ],
- grid: {
- top: '10rpx',
- left: 0,
- right: '20rpx',
- bottom: 0,
- containLabel: true
- },
- xAxis: {
- type: 'category',
- axisLabel: {
- color: '#6C6970',// 设置 x 轴标签颜色为白色
- fontSize: 10
- },
- boundaryGap: false,
- splitLine: {
- show: false, // 是否显示刻度线
- },
- axisTick: {
- // 不显示Y轴刻度线
- show: false
- },
- data: data1,
- axisLine: {
- // 不显示X轴轴线
- show: false
- }
- },
- yAxis: {
- // Y 轴配置
- type: 'value',
- show: false
- },
- series: [{
- name: '睡眠状态',
- type: 'line',
- smooth: true,
- lineStyle: {
- width: 2,
- color: '#5582FF'
- },
- showSymbol: false,
- areaStyle: {
- opacity: 0.8,
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- {
- offset: 0,
- color: 'rgba(85, 130, 255, 0.5)'
- },
- {
- offset: 1,
- color: 'rgba(149, 177, 255, 0.3)'
- }
- ])
- },
- data: data2,
- }]
- };
- chart.setOption(option, true);
- }
- function updateBodyMovements(data1, data2, startSleepTime, endSleepTime, that) {
- if (chartBodyMovementsLine) {
- setBodyMovementsOption(chartBodyMovementsLine, data1, data2);
- } else {
- that.selectComponent('#chartBodyMovementsLine-dom').init((canvas, width, height, dpr) => {
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr // new
- });
- canvas.setChart(chart);
- setBodyMovementsOption(chart, data1, data2);
- // 将图表实例绑定到 this 上,可以在其他成员函数(如 dispose)中访问
- chartBodyMovementsLine = chart;
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return chart;
- });
- }
- }
- //心脏系统
- function initChartCardiacSystemLine(canvas, width, height, dpr) {
- // 在这里初始化图表
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr // new
- });
- canvas.setChart(chart);
- setCardiacSystemOption(chart);
- // 将图表实例绑定到 this 上,可以在其他成员函数(如 dispose)中访问
- chartCardiacSystemLine = chart;
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return chart;
- };
- function setCardiacSystemOption(chart, data1 = [], data2 = [],) {
- var option = option = {
- tooltip: {
- show: true,
- trigger: 'axis',
- formatter: function (param) {
- return `${(param[0].value || 0) + '次'}`
- }
- },
- dataZoom: [
- { // 第一个 dataZoom 组件
- type: 'inside',
- },
- ],
- grid: {
- top: '20rpx',
- left: '20rpx',
- right: '20rpx',
- bottom: '10rpx',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- axisLabel: {
- color: '#6C6970',// 设置 x 轴标签颜色为白色
- fontSize: 10
- },
- boundaryGap: false,
- splitLine: {
- show: false, // 是否显示刻度线
- },
- axisTick: {
- // 不显示Y轴刻度线
- show: false
- },
- data: data1,
- axisLine: {
- // 不显示X轴轴线
- show: false
- }
- },
- yAxis: {
- type: 'value',
- max: 100,
- min: 0,
- show: true,
- offset: 10,
- splitLine: {
- show: false
- },
- axisLabel: {
- hideOverlap: true,
- fontSize: 10,
- }
- },
- series: [{
- type: 'line',
- smooth: true,
- lineStyle: {
- width: 2,
- color: '#F47893'
- },
- showSymbol: false,
- areaStyle: {
- opacity: 0.8,
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- {
- offset: 0,
- color: 'rgba(244, 120, 147, 0.5)'
- },
- {
- offset: 1,
- color: 'rgba(250, 140, 164, 0.3)'
- }
- ])
- },
- data: data2,
- }]
- };
- chart.setOption(option, true);
- }
- function updateCardiacSystem(data1, data2, that) {
- if (chartCardiacSystemLine) {
- setCardiacSystemOption(chartCardiacSystemLine, data1, data2);
- } else {
- that.selectComponent('#chartCardiacSystemLine-dom').init((canvas, width, height, dpr) => {
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr // new
- });
- canvas.setChart(chart);
- setCardiacSystemOption(chart, data1, data2);
- // 将图表实例绑定到 this 上,可以在其他成员函数(如 dispose)中访问
- chartBodyMovementsLine = chart;
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return chart;
- });
- }
- }
- //平均呼吸率
- function initChartRespiratoryLine(canvas, width, height, dpr) {
- // 在这里初始化图表
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr // new
- });
- canvas.setChart(chart);
- setRespiratoryOption(chart);
- // 将图表实例绑定到 this 上,可以在其他成员函数(如 dispose)中访问
- chartRespiratoryLine = chart;
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return chart;
- };
- function setRespiratoryOption(chart, data1 = [], data2 = [],) {
- var option = option = {
- tooltip: {
- show: true,
- trigger: 'axis',
- formatter: function (param) {
- return `${(param[0].value || 0) + '次'}`
- }
- },
- dataZoom: [
- { // 第一个 dataZoom 组件
- type: 'inside',
- },
- ],
- grid: {
- top: '20rpx',
- left: '20rpx',
- right: '20rpx',
- bottom: '10rpx',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- axisLabel: {
- color: '#6C6970',// 设置 x 轴标签颜色为白色
- fontSize: 10
- },
- boundaryGap: false,
- splitLine: {
- show: false, // 是否显示刻度线
- },
- axisTick: {
- // 不显示Y轴刻度线
- show: false
- },
- data: data1,
- axisLine: {
- // 不显示X轴轴线
- show: false
- }
- },
- yAxis: {
- type: 'value',
- max: 24,
- min: 0,
- show: true,
- offset: 10,
- splitLine: {
- show: false
- },
- axisLabel: {
- hideOverlap: true,
- fontSize: 10,
- }
- },
- series: [{
- type: 'line',
- smooth: true,
- lineStyle: {
- width: 2,
- color: '#06A9AD'
- },
- showSymbol: false,
- areaStyle: {
- opacity: 0.8,
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- {
- offset: 0,
- color: 'rgba(186, 246, 231, 1)'
- },
- {
- offset: 1,
- color: 'rgba(255, 255, 255, 0)'
- }
- ])
- },
- data: data2,
- }]
- };
- chart.setOption(option, true);
- }
- function updateRespiratory(data1, data2, startSleepTime, endSleepTime, that) {
- if (chartRespiratoryLine) {
- setRespiratoryOption(chartRespiratoryLine, data1, data2);
- } else {
- that.selectComponent('#chartRespiratoryLine-dom').init((canvas, width, height, dpr) => {
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr // new
- });
- canvas.setChart(chart);
- setRespiratoryOption(chart, data1, data2);
- // 将图表实例绑定到 this 上,可以在其他成员函数(如 dispose)中访问
- chartRespiratoryLine = chart;
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return chart;
- });
- }
- }
- //打鼾
- function initSnoringLine(canvas, width, height, dpr) {
- // 在这里初始化图表
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr // new
- });
- canvas.setChart(chart);
- setSnoringOption(chart);
- // 将图表实例绑定到 this 上,可以在其他成员函数(如 dispose)中访问
- chartSnoringLine = chart;
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return chart;
- };
- function setSnoringOption(chart, data1 = [], data2 = [],) {
- var option = option = {
- tooltip: {
- show: true,
- trigger: 'axis',
- formatter: function (param) {
- return `${param[0] && param[0].value == 1 ? '打鼾' : '否'}`
- }
- },
- dataZoom: [
- { // 第一个 dataZoom 组件
- type: 'inside',
- },
- ],
- grid: {
- top: '10rpx',
- left: 0,
- right: '20rpx',
- bottom: 0,
- containLabel: true
- },
- xAxis: {
- type: 'category',
- axisLabel: {
- color: '#6C6970',// 设置 x 轴标签颜色为白色
- fontSize: 10
- },
- boundaryGap: false,
- splitLine: {
- show: false, // 是否显示刻度线
- },
- axisTick: {
- // 不显示Y轴刻度线
- show: false
- },
- data: data1,
- axisLine: {
- // 不显示X轴轴线
- show: false
- }
- },
- yAxis: {
- type: 'value',
- show: false,
- },
- series: [{
- type: 'line',
- smooth: true,
- lineStyle: {
- width: 2,
- color: '#EE8B52'
- },
- showSymbol: false,
- areaStyle: {
- opacity: 0.8,
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- {
- offset: 0,
- color: 'rgba(249, 211, 189, 1)'
- },
- {
- offset: 1,
- color: 'rgba(255, 255, 255, 0)'
- }
- ])
- },
- data: data2,
- }]
- };
- chart.setOption(option, true);
- }
- function updateSnoring(data1, data2, startSleepTime, endSleepTime, that) {
- if (chartSnoringLine) {
- setSnoringOption(chartSnoringLine, data1, data2);
- } else {
- that.selectComponent('#chartSnoringLine-dom').init((canvas, width, height, dpr) => {
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr // new
- });
- canvas.setChart(chart);
- setSnoringOption(chart, data1, data2);
- // 将图表实例绑定到 this 上,可以在其他成员函数(如 dispose)中访问
- chartSnoringLine = chart;
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return chart;
- });
- }
- }
- //呼吸暂停
- function initApneaLine(canvas, width, height, dpr) {
- // 在这里初始化图表
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr // new
- });
- canvas.setChart(chart);
- setApneaOption(chart);
- // 将图表实例绑定到 this 上,可以在其他成员函数(如 dispose)中访问
- chartApneaLine = chart;
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return chart;
- };
- function setApneaOption(chart, data1 = [], data2 = [],) {
- var option = option = {
- tooltip: {
- show: true,
- trigger: 'axis',
- formatter: function (param) {
- return `${param[0] && param[0].value == 1 ? '停止' : '否'}`
- }
- },
- dataZoom: [
- { // 第一个 dataZoom 组件
- type: 'inside',
- },
- ],
- grid: {
- top: '10rpx',
- left: 0,
- right: '20rpx',
- bottom: 0,
- containLabel: true
- },
- xAxis: {
- type: 'category',
- axisLabel: {
- color: '#6C6970',// 设置 x 轴标签颜色为白色
- fontSize: 10
- },
- boundaryGap: false,
- splitLine: {
- show: false, // 是否显示刻度线
- },
- axisTick: {
- // 不显示Y轴刻度线
- show: false
- },
- data: data1,
- axisLine: {
- // 不显示X轴轴线
- show: false
- }
- },
- yAxis: {
- type: 'value',
- show: false,
- },
- series: [{
- type: 'line',
- smooth: true,
- lineStyle: {
- width: 2,
- color: '#6086EF'
- },
- showSymbol: false,
- areaStyle: {
- opacity: 0.8,
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- {
- offset: 0,
- color: 'rgba(96, 134, 239, 1)'
- },
- {
- offset: 1,
- color: 'rgba(255, 255, 255, 0)'
- }
- ])
- },
- data: data2,
- }]
- };
- chart.setOption(option, true);
- }
- function updateApnea(data1, data2, startSleepTime, endSleepTime, that) {
- if (chartApneaLine) {
- setApneaOption(chartApneaLine, data1, data2);
- } else {
- that.selectComponent('#chartApneaLine-dom').init((canvas, width, height, dpr) => {
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr // new
- });
- canvas.setChart(chart);
- setApneaOption(chart, data1, data2);
- // 将图表实例绑定到 this 上,可以在其他成员函数(如 dispose)中访问
- chartApneaLine = chart;
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return chart;
- });
- }
- }
- //深浅睡眠
- function timestampToHHMM(timestamp) {
- let date = new Date(timestamp); // 注意:JavaScript中的Date是以毫秒为单位的
- let hours = date.getHours().toString().padStart(2, '0'); // 获取小时数,并补零
- let minutes = date.getMinutes().toString().padStart(2, '0'); // 获取分钟数,并补零
- return hours + ':' + minutes;
- }
- // 自定义图形
- function renderItem(params, api) {
- var categoryIndex = api.value(0);
- var startX = api.coord([api.value(1), categoryIndex])[0];
- var endX = api.coord([api.value(2), categoryIndex])[0];
- var centerY = api.coord([
- api.value(1) + (api.value(2) - api.value(1)) / 2,
- categoryIndex
- ])[1]; // 取中间点的y坐标
- var height = api.size([0, 1])[1] * 1;
- var width = endX - startX;
- // 创建一个矩形
- var rect = {
- x: startX,
- y: centerY - height / 2,
- r: 2,
- width: width,
- height: height
- };
- // 返回的图形对象
- return {
- type: 'rect',
- shape: rect,
- style: api.style()
- };
- }
- function initChartTimeWaterfall(canvas, width, height, dpr) {
- // 在这里初始化图表
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr // new
- });
- canvas.setChart(chart);
- setTimeWaterfallOption(chart);
- // 将图表实例绑定到 this 上,可以在其他成员函数(如 dispose)中访问
- chartTimeWaterfall = chart;
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return chart;
- };
- function setTimeWaterfallOption(chart, startTime = new Date().getTime(), data = [], categories = ['深睡', '中睡', '浅睡', '清醒']) {
- var option =
- option = {
- tooltip: {
- show: true,
- formatter: function (params) {
- return params.marker + params.name + ': ' + params.value[3] + ' m';
- }
- },
- dataZoom: [
- {
- type: 'inside',
- filterMode: 'weakFilter'
- }
- ],
- grid: {
- top: 0,
- bottom: 0,
- height: 160,
- containLabel: false
- },
- xAxis: {
- type: 'value',
- scale: true,
- splitLine: {
- show: false // 是否显示刻度线
- },
- axisLabel: {
- color: '#6C6970',// 设置 x 轴标签颜色为白色
- fontSize: 10,
- formatter: function (val) {
- return timestampToHHMM(val || startTime);
- }
- }
- },
- yAxis: {
- show: false,
- data: categories
- },
- series: [
- {
- type: 'custom',
- renderItem: renderItem,
- itemStyle: {
- opacity: 1
- },
- encode: {
- x: [1, 2],
- y: 0
- },
- data: data
- }
- ]
- };
- chart.setOption(option, true);
- }
- function updateTimeWaterfall(startTime = new Date().getTime(), data, that) {
- console.log("updateTimeWaterfall========>", data);
- if (chartTimeWaterfall) {
- setTimeWaterfallOption(chartTimeWaterfall, startTime, data);
- } else {
- that.selectComponent('#chartTimeWaterfall-dom').init((canvas, width, height, dpr) => {
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr // new
- });
- canvas.setChart(chart);
- setTimeWaterfallOption(chart, startTime, data);
- // 将图表实例绑定到 this 上,可以在其他成员函数(如 dispose)中访问
- chartTimeWaterfall = chart;
- // 注意这里一定要返回 chart 实例,否则会影响事件处理等
- return chart;
- });
- }
- }
- // subpages/data/data.js
- function addZero(str) {
- if (String(str).length == 1) {
- return "0" + String(str);
- } else {
- return String(str);
- }
- }
- function flushChart0(data) {
- var option = {
- series: [
- {
- name: '进度',
- type: 'pie',
- radius: ['50%', '70%'],
- avoidLabelOverlap: false,
- label: {
- show: true,
- position: 'center'
- },
- emphasis: {
- label: {
- show: true,
- fontSize: '30',
- fontWeight: 'bold'
- }
- },
- labelLine: {
- show: false
- },
- data: data
- }
- ]
- };
- chart0.setOption(option, true);
- }
- function flushChart(data) {
- var option = {
- backgroundColor: '#0c1041',
- // title: {
- // text: '当天睡眠时间曲线图',
- // left: 'center',
- // color: '#ffffff',
- // backgroundColor: '#ff0000'
- // },
- color: ["#62c4d9"],
- legend: {
- data: ['睡眠时间'],
- top: 20,
- left: 'right',
- backgroundColor: '#0c1041',
- textStyle: {
- color: '#fff',
- }
- },
- grid: {
- containLabel: true
- },
- tooltip: {
- show: true,
- trigger: 'axis'
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- axisLine: {
- lineStyle: {
- color: '#fff',
- width: 1,//这里是为了突出显示加上的
- }
- }
- },
- yAxis: {
- name: "时长",
- x: 'center',
- type: 'value',
- axisLine: {
- lineStyle: {
- color: '#fff',
- width: 1,//这里是为了突出显示加上的
- }
- // splitLine: {
- // lineStyle: {
- // type: 'dashed'
- // }
- }
- // show: false
- },
- series: [{
- name: '睡眠时间',
- type: 'line',
- smooth: true,
- data: data,
- color: '#62c4d9'
- }]
- };
- chart.setOption(option, true);
- }
- function flushChart2(data) {
- var option = {
- // title: {
- // text: '睡眠状态监测',
- // left: 'center',
- // textStyle: {
- // color: '#ffffff', // 字体颜色
- // fontStyle: 'normal', // 字体风格
- // // fontWeight: 'bold', // 字体粗细
- // fontFamily: 'sans-serif', // 字体族
- // fontSize: 18 // 字体大小
- // },
- // backgroundColor: '#57f7ff'
- // },
- tooltip: {
- trigger: 'item'
- },
- legend: {
- orient: 'vertical',
- left: 'left',
- },
- series: [{
- type: 'pie',
- radius: '55%',
- data: data ? data : []
- }],
- graphic: [{
- type: 'text',
- left: '2%', // 文本水平位置,这里设置为居中,你可以根据需要调整
- top: '84%', // 文本垂直位置,这里设置为距离顶部 10% 的位置,作为左下方的文本
- style: {
- text: '时长(分钟)分析', // 文本内容
- textFill: '#333', // 文本颜色
- textFontSize: 14, // 文本字体大小
- textAlign: 'left', // 文本水平对齐方式
- verticalAlign: 'middle' // 文本垂直对齐方式
- }
- }],
- };
- chart2.setOption(option, true);
- }
- function flushChart3(data1, data2) {
- var option = {
- // title: {
- // text: '睡眠呼吸监测',
- // left: 'center',
- // textStyle: {
- // color: '#ffffff', // 字体颜色
- // fontStyle: 'normal', // 字体风格
- // // fontWeight: 'bold', // 字体粗细
- // fontFamily: 'sans-serif', // 字体族
- // fontSize: 18 // 字体大小
- // },
- // backgroundColor: '#57f7ff'
- // },
- tooltip: {},
- xAxis: {
- data: data1 ? data1 : []
- },
- yAxis: {
- // Y 轴配置
- type: 'value',
- // 设置 Y 轴名称
- name: '单位:次',
- // 设置 Y 轴名称的位置
- nameLocation: 'end', // 可以是 'start'、'middle' 或 'end'
- },
- series: [{
- type: 'line',
- data: data2 ? data2 : []
- }]
- };
- chart3.setOption(option, true);
- }
- function flushChart4(data) {
- var option = {
- // title: {
- // text: '睡眠与清醒时间',
- // left: 'center',
- // textStyle: {
- // color: '#ffffff', // 字体颜色
- // fontStyle: 'normal', // 字体风格
- // // fontWeight: 'bold', // 字体粗细
- // fontFamily: 'sans-serif', // 字体族
- // fontSize: 18 // 字体大小
- // },
- // backgroundColor: '#57f7ff'
- // },
- tooltip: {},
- series: [{
- type: 'gauge',
- // 设置刻度盘的最大值
- max: 24,
- // 设置刻度盘的最小值
- min: 0,
- pointer: {
- width: 5,
- // 可以调整第二个指针的样式以区分
- itemStyle: {
- color: '#FF0000'
- }
- },
- // 刻度盘轴
- axisLine: {
- textStyle: {
- fontSize: 14
- },
- lineStyle: {
- width: 30,
- color: [[0.2, '#80FF80'], [0.8, '#FF8080'], [1, '#8080FF']] // 刻度盘颜色分区
- },
- rich: {
- // 为第一个刻度盘设置刻度颜色
- '0%': {
- color: '#FF0000'
- },
- '50%': {
- color: '#00FF00'
- },
- '100%': {
- color: '#0000FF'
- }
- }
- },
- detail: { formatter: '{value} 小时' },
- data: data ? data : {}
- }
- // ,{
- // type: 'gauge',
- // // 设置刻度盘的最大值
- // max: 24,
- // // 设置刻度盘的最小值
- // min: 0,
- // // 刻度盘轴
- // axisLine: {
- // textStyle: {
- // fontSize: 14
- // },
- // lineStyle: {
- // width: 30,
- // color: [[0.2, '#80FF80'], [0.8, '#FF8080'], [1, '#8080FF']] // 刻度盘颜色分区
- // },
- // rich: {
- // // 为第二个刻度盘设置刻度颜色
- // '0%': {
- // color: '#FFFF00'
- // },
- // '50%': {
- // color: '#00FFFF'
- // },
- // '100%': {
- // color: '#FF00FF'
- // }
- // }
- // },
- // detail: {formatter: '{value} 小时'},
- // data: data2?data2:{}
- // },
- ]
- };
- chart4.setOption(option, true);
- }
- function flushChart5(data1, data2, that) {
- var option = {
- // title: {
- // text: '睡眠状态监测',
- // left: 'center',
- // textStyle: {
- // color: '#ffffff', // 字体颜色
- // fontStyle: 'normal', // 字体风格
- // // fontWeight: 'bold', // 字体粗细
- // fontFamily: 'sans-serif', // 字体族
- // fontSize: 18 // 字体大小
- // },
- // backgroundColor: '#57f7ff'
- // },
- tooltip: {},
- xAxis: {
- data: data1 ? data1 : []
- },
- yAxis: {
- // Y 轴配置
- type: 'value',
- // 设置 Y 轴名称
- name: '单位:次',
- // 设置 Y 轴名称的位置
- nameLocation: 'end', // 可以是 'start'、'middle' 或 'end'
- axisLabel: {
- formatter: function (value) {
- return that.sleepStateChange(value);
- }
- },
- },
- series: [{
- type: 'line',
- data: data2 ? data2 : []
- }]
- };
- chart5.setOption(option, true);
- }
- function flushChart6(data1, data2, startSleepTime, endSleepTime, that) {
- var option = {
- backgroundColor: '#000000', // 设置背景色
- tooltip: {},
- xAxis: {
- data: data1 ? data1 : []
- },
- yAxis: {
- // Y 轴配置
- type: 'value',
- // 设置 Y 轴名称
- name: '睡眠状态',
- // 设置 Y 轴名称的位置
- nameLocation: 'end', // 可以是 'start'、'middle' 或 'end'
- axisLabel: {
- formatter: function (value) {
- return that.sleepStateChange(value);
- }
- }
- },
- series: [{
- type: 'line',
- data: data2 ? data2 : [],
- lineStyle: { // 系列级个性化折线样式
- width: 10,
- type: 'solid',
- color: new echarts.graphic.LinearGradient(0, 0.4, 0.7, 1, [{
- offset: 0,
- color: '#ffb71b'
- }, {
- offset: 0.4,
- color: '#b75cee'
- }, {
- offset: 0.7,
- color: '#66acfc'
- }, {
- offset: 1,
- color: '#3843fa'
- }]),//线条渐变色
- },
- }
- // {
- // name: '分类2',
- // type: 'line',
- // data: data2,
- // lineStyle: { // 系列级个性化折线样式
- // width: 4,
- // type: 'solid',
- // color: new echarts.graphic.LinearGradient(0, 0.4, 0.7, 1, [{
- // offset: 0,
- // color: '#ffb71b'
- // } , {
- // offset: 0.4,
- // color: '#b75cee'
- // }, {
- // offset: 0.7,
- // color: '#66acfc'
- // }, {
- // offset: 1,
- // color: '#3843fa'
- // }]),//线条渐变色
- // },
- // },
- ],
- graphic: [{
- type: 'text',
- left: '5%', // 文本水平位置,这里设置为居中,你可以根据需要调整
- top: '90%', // 文本垂直位置,这里设置为距离顶部 10% 的位置,作为左下方的文本
- style: {
- text: '入睡时间:' + startSleepTime ? startSleepTime : '', // 文本内容
- textFill: '#333', // 文本颜色
- textFontSize: 14, // 文本字体大小
- textAlign: 'left', // 文本水平对齐方式
- verticalAlign: 'middle' // 文本垂直对齐方式
- }
- }, {
- type: 'text',
- right: '5%', // 文本水平位置,这里设置为距离右侧 10% 的位置,作为右下方的文本
- top: '90%', // 文本垂直位置,这里设置为距离底部 10% 的位置
- style: {
- text: '醒来时间:' + endSleepTime ? endSleepTime : '', // 文本内容
- textFill: '#333', // 文本颜色
- textFontSize: 14, // 文本字体大小
- textAlign: 'right', // 文本水平对齐方式
- verticalAlign: 'middle' // 文本垂直对齐方式
- }
- }],
- };
- // var list0 = [];
- // var list10 = [];
- // var list20 = [];
- // var list30 = [];
- // if(data2){
- // for (let i = 0; i < data2.length; i++) {
- // if (data2[i] == '0') {
- // list0.push(data2[i]);
- // }else if (data2[i] == '10') {
- // list10.push(data2[i]);
- // }else if (data2[i] == '20') {
- // list20.push(data2[i]);
- // }else if (data2[i] == '30') {
- // list30.push(data2[i]);
- // }else{
- // }
- // }
- // }
- // var option = {
- // xAxis: {
- // type: 'category',
- // data: data1
- // },
- // yAxis: {
- // type: 'value',
- // axisLabel: {
- // show: true,
- // position: 'buttom' // 分类标签显示在顶部,相当于曲线下方位置
- // }
- // },
- // series: [
- // {
- // name: '清醒',
- // type: 'line',
- // data: list0,
- // itemStyle: {
- // areaColor: new echarts.graphic.LinearGradient(
- // 0, 0, 0, 1,
- // [{ offset: 0, color: 'rgba(255, 0, 0, 0.3)' }, { offset: 1, color: 'rgba(255, 0, 0, 0)' }]
- // )
- // },
- // smooth: true,
- // lineStyle: {
- // color: 'red' // 线条颜色
- // }
- // },
- // {
- // name: '浅睡',
- // type: 'line',
- // data: list10,
- // itemStyle: {
- // areaColor: new echarts.graphic.LinearGradient(
- // 0, 0, 0, 1,
- // [{ offset: 0, color: 'rgba(0, 255, 0, 0.3)' }, { offset: 1, color: 'rgba(0, 255, 0, 0)' }]
- // )
- // },
- // smooth: true,
- // lineStyle: {
- // color: 'green' // 线条颜色
- // }
- // },
- // {
- // name: '中睡',
- // type: 'line',
- // data: list20,
- // itemStyle: {
- // areaColor: new echarts.graphic.LinearGradient(
- // 0, 0, 0, 1,
- // [{ offset: 0, color: 'rgba(0, 255, 0, 0.3)' }, { offset: 1, color: 'rgba(0, 255, 0, 0)' }]
- // )
- // },
- // smooth: true,
- // lineStyle: {
- // color: 'green' // 线条颜色
- // }
- // } ,
- // {
- // name: '深睡',
- // type: 'line',
- // data: list30,
- // itemStyle: {
- // areaColor: new echarts.graphic.LinearGradient(
- // 0, 0, 0, 1,
- // [{ offset: 0, color: 'rgba(0, 255, 0, 0.3)' }, { offset: 1, color: 'rgba(0, 255, 0, 0)' }]
- // )
- // },
- // smooth: true,
- // lineStyle: {
- // color: 'green' // 线条颜色
- // }
- // }
- // // 如果有更多分类,继续添加...
- // ],
- // tooltip: {
- // trigger: 'axis',
- // axisPointer: {
- // type: 'cross',
- // label: {
- // backgroundColor: '#6a7985'
- // }
- // }
- // },
- // graphic: [{
- // type: 'text',
- // left: '5%', // 文本水平位置,这里设置为居中,你可以根据需要调整
- // top: '90%', // 文本垂直位置,这里设置为距离顶部 10% 的位置,作为左下方的文本
- // style: {
- // text: '入睡时间:'+startSleepTime, // 文本内容
- // textFill: '#333', // 文本颜色
- // textFontSize: 14, // 文本字体大小
- // textAlign: 'left', // 文本水平对齐方式
- // verticalAlign: 'middle' // 文本垂直对齐方式
- // }
- // }, {
- // type: 'text',
- // right: '5%', // 文本水平位置,这里设置为距离右侧 10% 的位置,作为右下方的文本
- // top: '90%', // 文本垂直位置,这里设置为距离底部 10% 的位置
- // style: {
- // text: '醒来时间:'+endSleepTime, // 文本内容
- // textFill: '#333', // 文本颜色
- // textFontSize: 14, // 文本字体大小
- // textAlign: 'right', // 文本水平对齐方式
- // verticalAlign: 'middle' // 文本垂直对齐方式
- // }
- // }],
- // };
- chart6.setOption(option, true);
- }
- function flushChart9(data1, data2, startSleepTime, endSleepTime, that) {
- var option = {
- // backgroundColor: rgba(168, 115, 182, 0.5), // 设置背景色
- tooltip: {},
- xAxis: {
- axisLabel: {
- color: '#000' // 设置 x 轴标签颜色为白色
- },
- splitLine: {
- show: false, // 是否显示刻度线
- },
- axisTick: {
- // 不显示Y轴刻度线
- show: false
- },
- axisLine: {
- // 不显示X轴轴线
- show: false
- },
- data: data1 ? data1 : []
- },
- yAxis: {
- // Y 轴配置
- type: 'value',
- // 设置 Y 轴名称
- name: '睡眠状态',
- // 设置 Y 轴名称的位置
- nameLocation: 'end', // 可以是 'start'、'middle' 或 'end'
- axisLine: {
- // 不显示Y轴轴线
- show: false,
- },
- axisTick: {
- // 不显示Y轴刻度线
- show: false
- },
- axisLabel: {
- color: '#000',
- formatter: function (value) {
- return that.sleepRsnoring_arrChange(value);
- }
- },
- splitLine: {
- show: false,// 不显示纵坐标轴的刻度线
- lineStyle: {
- color: 'rgba(222, 222, 222, 0.1)', // 灰色并调整透明度
- width: 1, // 刻度线宽度
- type: 'solid' // 刻度线类型,默认为实线
- }
- },
- },
- series: [{
- type: 'line',
- data: data2 ? data2 : [],
- lineStyle: {
- color: 'rgba(255, 170, 127, 0.8)' // 奶白色,80% 透明度
- },
- showSymbol: false,// 是否显示标记图形
- smooth: true, // 使折线平滑
- markPoint: {
- symbol: 'circle', // 标记的符号为圆圈
- symbolSize: 10, // 标记的大小
- itemStyle: {
- color: 'rgba(255, 170, 127, 0.8)',
- // borderColor: 'blue',
- borderWidth: 1, // 设置边框宽度
- fill: 'none' // 设置填充颜色为无,即空心
- },
- data: [
- // 假设 data[0] 和 data[data.length - 1] 分别是开始和结束的数据点
- { coord: [data1 ? data1[0] : '', data2 ? data2[0] : ''], name: '开始' },
- { coord: [data1 ? data1[data1.length - 1] : '', data2 ? data2[data2.length - 1] : ''], name: '结束' }
- // 如果要添加拐角处的标记,需要手动计算并添加
- ]
- },
- areaStyle: { // 折线下方的区域样式
- color: new echarts.graphic.LinearGradient(
- 0, 0, 0, 1, // 渐变方向
- [ // 渐变颜色
- { offset: 0, color: 'rgba(255, 170, 127, 0.8)' }, // 使用之前定义的渐变
- { offset: 0.9, color: 'rgba(255, 255, 255, 1)' } // 可选,结束颜色
- ]
- ),
- opacity: 0.3 // 区域的不透明度,可以根据需要调整
- },
- }
- ],
- // graphic: [{
- // type: 'text',
- // left: '5%', // 文本水平位置,这里设置为居中,你可以根据需要调整
- // top: '90%', // 文本垂直位置,这里设置为距离顶部 10% 的位置,作为左下方的文本
- // style: {
- // text: '入睡时间:'+startSleepTime?startSleepTime:'', // 文本内容
- // textFill: '#333', // 文本颜色
- // textFontSize: 14, // 文本字体大小
- // textAlign: 'left', // 文本水平对齐方式
- // verticalAlign: 'middle' // 文本垂直对齐方式
- // }
- // }, {
- // type: 'text',
- // right: '5%', // 文本水平位置,这里设置为距离右侧 10% 的位置,作为右下方的文本
- // top: '90%', // 文本垂直位置,这里设置为距离底部 10% 的位置
- // style: {
- // text: '醒来时间:'+endSleepTime?endSleepTime:'', // 文本内容
- // textFill: '#333', // 文本颜色
- // textFontSize: 14, // 文本字体大小
- // textAlign: 'right', // 文本水平对齐方式
- // verticalAlign: 'middle' // 文本垂直对齐方式
- // }
- // }],
- };
- chart9.setOption(option, true);
- }
- function flushChart10(data1, data2, startSleepTime, endSleepTime, that) {
- var option = {
- // backgroundColor: rgba(168, 115, 182, 0.5), // 设置背景色
- tooltip: {},
- xAxis: {
- axisLabel: {
- color: '#000' // 设置 x 轴标签颜色为白色
- },
- splitLine: {
- show: false, // 是否显示刻度线
- },
- axisTick: {
- // 不显示Y轴刻度线
- show: false
- },
- axisLine: {
- // 不显示X轴轴线
- show: false
- },
- data: data1 ? data1 : []
- },
- yAxis: {
- // Y 轴配置
- type: 'value',
- // 设置 Y 轴名称
- name: '睡眠状态',
- // 设置 Y 轴名称的位置
- nameLocation: 'end', // 可以是 'start'、'middle' 或 'end'
- axisLine: {
- // 不显示Y轴轴线
- show: false,
- },
- axisTick: {
- // 不显示Y轴刻度线
- show: false
- },
- axisLabel: {
- color: '#000',
- formatter: function (value) {
- return that.sleepRhxstop_arrChange(value);
- }
- },
- splitLine: {
- show: false,// 不显示纵坐标轴的刻度线
- lineStyle: {
- color: 'rgba(222, 222, 222, 0.1)', // 灰色并调整透明度
- width: 1, // 刻度线宽度
- type: 'solid' // 刻度线类型,默认为实线
- }
- },
- },
- series: [{
- type: 'line',
- data: data2 ? data2 : [],
- lineStyle: {
- color: 'rgba(0, 85, 255, 0.8)' // 奶白色,80% 透明度
- },
- showSymbol: false,// 是否显示标记图形
- smooth: true, // 使折线平滑
- markPoint: {
- symbol: 'circle', // 标记的符号为圆圈
- symbolSize: 10, // 标记的大小
- itemStyle: {
- color: 'rgba(0, 85, 255, 0.8)',
- // borderColor: 'blue',
- borderWidth: 1, // 设置边框宽度
- fill: 'none' // 设置填充颜色为无,即空心
- },
- data: [
- // 假设 data[0] 和 data[data.length - 1] 分别是开始和结束的数据点
- { coord: [data1 ? data1[0] : '', data2 ? data2[0] : ''], name: '开始' },
- { coord: [data1 ? data1[data1.length - 1] : '', data2 ? data2[data2.length - 1] : ''], name: '结束' }
- // 如果要添加拐角处的标记,需要手动计算并添加
- ]
- },
- areaStyle: { // 折线下方的区域样式
- color: new echarts.graphic.LinearGradient(
- 0, 0, 0, 1, // 渐变方向
- [ // 渐变颜色
- { offset: 0, color: 'rgba(0, 85, 255, 0.8)' }, // 使用之前定义的渐变
- { offset: 0.9, color: 'rgba(255, 255, 255, 1)' } // 可选,结束颜色
- ]
- ),
- opacity: 0.3 // 区域的不透明度,可以根据需要调整
- },
- }
- ],
- // graphic: [{
- // type: 'text',
- // left: '5%', // 文本水平位置,这里设置为居中,你可以根据需要调整
- // top: '90%', // 文本垂直位置,这里设置为距离顶部 10% 的位置,作为左下方的文本
- // style: {
- // text: '入睡时间:'+startSleepTime?startSleepTime:'', // 文本内容
- // textFill: '#333', // 文本颜色
- // textFontSize: 14, // 文本字体大小
- // textAlign: 'left', // 文本水平对齐方式
- // verticalAlign: 'middle' // 文本垂直对齐方式
- // }
- // }, {
- // type: 'text',
- // right: '5%', // 文本水平位置,这里设置为距离右侧 10% 的位置,作为右下方的文本
- // top: '90%', // 文本垂直位置,这里设置为距离底部 10% 的位置
- // style: {
- // text: '醒来时间:'+endSleepTime?endSleepTime:'', // 文本内容
- // textFill: '#333', // 文本颜色
- // textFontSize: 14, // 文本字体大小
- // textAlign: 'right', // 文本水平对齐方式
- // verticalAlign: 'middle' // 文本垂直对齐方式
- // }
- // }],
- };
- chart10.setOption(option, true);
- }
- function flushChart11(data1, data2, that) {
- // data2 = data2?data2.map(value => {
- // return value+10;
- // }):[];
- let adjustedData = data2 ? data2.map(value => {
- return 10;
- }) : [];
- // var option = {
- // // title: {
- // // text: '睡眠呼吸监测',
- // // left: 'center',
- // // textStyle: {
- // // color: '#ffffff', // 字体颜色
- // // fontStyle: 'normal', // 字体风格
- // // // fontWeight: 'bold', // 字体粗细
- // // fontFamily: 'sans-serif', // 字体族
- // // fontSize: 18 // 字体大小
- // // },
- // // backgroundColor: '#57f7ff'
- // // },
- // // grid: {
- // // top: '10%',
- // // height: '30%',
- // // },
- // tooltip: {},
- // xAxis: {
- // type: 'category',
- // axisLabel: {
- // color: 'rgba(0, 0, 0, 0.8)' // 设置 x 轴标签颜色为白色
- // },
- // axisTick: {
- // // 不显示Y轴刻度线
- // show: false
- // },
- // axisLine: {
- // // 不显示X轴轴线
- // show: false
- // },
- // splitLine: {
- // show: false, // 是否显示刻度线
- // },
- // data: data1?data1:[]
- // },
- // yAxis: {
- // // Y 轴配置
- // type: 'value',
- // // 设置 Y 轴名称
- // name: '睡眠状态',
- // // 设置 Y 轴名称的位置
- // nameLocation: 'end', // 可以是 'start'、'middle' 或 'end'
- // axisLine: {
- // // 不显示Y轴轴线
- // show: false,
- // },
- // axisTick: {
- // // 不显示Y轴刻度线
- // show: false
- // },
- // axisLabel: {
- // color: '#000',
- // formatter: function (value) {
- // return that.sleepStateChange(value);
- // }
- // },
- // splitLine: {
- // show: false ,// 不显示纵坐标轴的刻度线
- // lineStyle: {
- // color: 'rgba(0, 170, 255, 0.9)', // 灰色并调整透明度
- // width: 1, // 刻度线宽度
- // type: 'solid' // 刻度线类型,默认为实线
- // }
- // },
- // },
- // series: [{
- // type: 'bar',
- // data: data2?data2:[],
- // // barCategoryGap: '50%', // 类别间柱形距离
- // // label: {
- // // show: true,
- // // position: 'top',
- // // formatter: '{b}: {c}'
- // // },
- // stack: 'stackGroup',
- // itemStyle: {
- // color: 'rgba(0,0,0,0)' // 透明颜色
- // },
- // // itemStyle: {
- // // color: function(params) {
- // // // 根据数据或其他条件返回颜色值
- // // // 这里只是简单地返回了一个颜色数组中的颜色
- // // // var colorList = ['#c23531','#2f4554','#61a0a8','#d48265','#91c7ae','#749f83','#ca8622','#bda29a','#6e7074','#546570','#c4ccd3'];
- // // if(params.value == '0'){
- // // return '#e2e2e2'
- // // }else if(params.value == '10'){
- // // return '#8cc4ff'
- // // }else if(params.value == '20'){
- // // return '#a6b2ff'
- // // }else if(params.value == '30'){
- // // return '#9b79ff'
- // // }else{
- // // return '';
- // // }
- // // // return colorList[params.dataIndex % colorList.length];
- // // }
- // // }
- // }]
- // };
- var option = {
- xAxis: {
- type: 'category',
- data: data1 ? data1 : []
- },
- yAxis: {
- type: 'value',
- min: 0, // 确保 Y 轴从 0 开始
- // max 可以根据需要设置,但通常不需要为了固定柱子高度而设置
- axisLabel: {
- color: '#000',
- formatter: function (value) {
- return that.sleepStateChange(value);
- }
- },
- },
- series: [
- // 透明柱子,占满整个柱子空间
- {
- data: data2 ? data2 : [],
- type: 'bar',
- stack: 'stackGroup',
- itemStyle: {
- color: 'rgba(0,0,0,0)' // 透明颜色
- },
- barGap: '-100%', // 设置柱子间距为负值,让柱子紧挨在一起
- barMaxWidth: '30px' // 根据需要调整柱子宽度
- },
- // 有色柱子,只显示上半部分(固定高度)
- {
- data: adjustedData, // 固定高度数据
- type: 'bar',
- stack: 'stackGroup', // 与透明系列使用相同的叠加组名
- itemStyle: {
- color: function (params) {
- console.log('params=' + JSON.stringify(params))
- if (data2 && data2[params.dataIndex] == 0) {
- return '#e2e2e2'
- } else if (data2 && data2[params.dataIndex] == 10) {
- return '#d8c6ff'
- } else if (data2 && data2[params.dataIndex] == 20) {
- return '#c6b3ff'
- } else if (data2 && data2[params.dataIndex] == 30) {
- return '#b090ff'
- } else {
- return '';
- }
- }
- },
- barGap: '-100%', // 保持与透明系列相同的柱子间距
- barMaxWidth: '30px' // 保持与透明系列相同的宽度
- }
- ]
- };
- chart11.setOption(option, true);
- }
- var homeApi = "https://haold.aidsleep.cn";
- var homeApi_http = "http://haold.aidsleep.cn";
- var homeApi_http_port = "8123";
- var homeApi_https = "https://haold.aidsleep.cn";
- const aipushApi = "https://aipush.aidsleep.cn";
- const token_15 = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiN2JlOGE0MDExZjY0NjA2OGUxYjJiZTE4M2Y2NzU0NSIsImlhdCI6MTcxMTYxNDY2NCwiZXhwIjoyMDI2OTc0NjY0fQ.XJ73cXAoEsouTgvgpNVobq9oKdwlJr88TiAFLYlaahE";
- var token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJlZGVjOWI3YWQ0MTQ0ZTIxYWQ1NTE1Nzc5NTkzNjBjNiIsImlhdCI6MTcxMjEzNTM2MywiZXhwIjoyMDI3NDk1MzYzfQ.IfrvdiaVuhCKsdy69JvUYhJ64bnhMT8MI1hN8R38whc";
- const token_push = "b74fd5754c5ef24cf600c39194abdaeb";
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- ecCircularProgressBar: {
- // lazyLoad: true, // 懒加载
- onInit: initChartHumidifier
- },
- ecOutOfBed: {
- // lazyLoad: true, // 懒加载
- onInit: initChartOutOfBed
- },
- ecBodyMovements: {
- // lazyLoad: true, // 懒加载
- onInit: initChartBodyMovementsLine
- },
- ecCardiacSystemLine: {
- // lazyLoad: true, // 懒加载
- onInit: initChartCardiacSystemLine
- },
- ecChartRespiratoryLine: {
- // lazyLoad: true, // 懒加载
- onInit: initChartRespiratoryLine
- },
- ecSnoringLine: {
- // lazyLoad: true, // 懒加载
- onInit: initSnoringLine
- },
- ecApneaLine: {
- // lazyLoad: true, // 懒加载
- onInit: initApneaLine
- },
- ecTimeWaterfall: {
- lazyLoad: true, // 懒加载
- // onInit: initChartTimeWaterfall
- },
- header: false,
- showAuthorizedDialog: false,
- nowDate: [{ //日历的初始化数据
- month: 'current',
- day: new Date().getDate(),
- color: '#ffd700',
- background: 'white'
- }],
- total1: 0,
- total2: 0,
- total3: 0,
- temArr: [],
- humArr: [],
- clickDate: "",
- status: "",
- isShow: false,
- year: addZero(new Date().getFullYear()),
- month: addZero(new Date().getMonth()),
- date: addZero(new Date().getDate()),
- hours: addZero(new Date().getHours()),
- moke_data: {
- "20240414": [
- {
- sleepAllTime: 902,
- sleepFeedback: "很好"
- },
- {
- sleepAllTime: 222,
- sleepFeedback: "疲惫"
- }
- ],
- "20240415": [
- {
- sleepAllTime: 902,
- sleepFeedback: "很好"
- },
- {
- sleepAllTime: 222,
- sleepFeedback: "疲惫"
- },
- {
- sleepAllTime: 902,
- sleepFeedback: "很好"
- },
- {
- sleepAllTime: 222,
- sleepFeedback: "疲惫"
- },
- {
- sleepAllTime: 902,
- sleepFeedback: "很好"
- }
- ]
- },
- rdt_arr: [],
- rrh_arr: [],
- rhx_arr: [],
- rsnoring_arr: [],
- routbed_arr: [],
- rmove_arr: [],
- rhxstop_arr: [],
- rsleep_arr: [],
- rdt_arrNew: [],//睡眠时间轴数据集合
- rrh_arrNew: [],//睡眠心率数据集合
- rhx_arrNew: [],//睡眠呼吸数据集合
- rmove_arrNew: [],//体动状态数据集合,0-否,1-体动状态
- rsleep_arrNew: [],//睡眠状态数据集合,0-清醒,10-浅睡,20-中睡,30-深睡
- rsleep_arr_all_New: [],//睡眠状态数据集合,0-清醒,10-浅睡,20-中睡,30-深睡
- durationData: [], //睡眠时长
- sleep_duration: [], //睡眠和清醒对比
- rdeep_durationFormatA: {},
- rdeep_duration: 0,
- rlight_duration: 0,
- rin_duration: 0,
- rawake_duration: 0,
- rrs_duration: 0,//入睡时长
- routbed_count_value: 0,//离床次数
- rsleep_eff_value: '',//睡眠效率
- rdeep_durationFormat: '',
- rlight_durationFormat: '',
- rin_durationFormat: '',
- rawake_durationFormat: '',
- ravg_hx_value: 0,
- ravg_hx_desc: '',
- ravg_rh_value: 0,
- ravg_rh_desc: '',
- rscore_value: 0,
- rscore_desc: '',
- sleep_efficiency: '',//睡眠效率
- zdTime: ["00:00", "01:00", "02:00", "03:00", "04:00", "05:00",
- , "06:00", "07:00", "08:00", "09:00", "10:00", "11:00"
- , "12:00", "13:00", "14:00", "15:00", "16:00", "17:00"
- , "18:00", "19:00", "20:00", "21:00", "22:00", "23:00"],
- zdPoint: [],
- percentage: 75, // 初始百分比值
- canvasWidth: 0,
- canvasHeight: 0,
- rsn: '',
- rdate: '',
- total_duration: 0,
- rtotal_duration: 0,
- rinbed_duration: 0,
- rgobed_time: 0,
- routbed_time: 0,
- rgobed_routbed: 0,
- sleepHourSub: 0,
- routbed_count_value: 0,
- isButtonClicked: false, // 用来控制按钮是否被点击的标记
- home_room: [
- 'company_laboratory',
- '2802',
- ],
- isButtonPressed: false, // 用来标记按钮是否被按下
- reportDate: '',
- currentDate: '',
- currentTime: '',
- rmove_arrFrequency: 0,//体动次数
- routbed_arrFrequency: 0,//离床次数
- rsnoring_arrFrequency: 0,//打鼾次数
- rhxstop_arrFrequency: 0,//呼吸暂停次数
- sleep_durationCountA: 0,//睡眠时间
- sns: [],
- tvEntityIds: [],
- ifOneMoreTV: false,//数据推送是否有多于一台电视
- selectedValue: '', // 用于存储选中的值
- tvEntityIdsValue: '', // 用于存储选中的值
- selectedIndex: 0, // 默认选中第一个选项
- tvEntityIdsIndex: 0, // 默认选中第一个选项
- hotelcode: '',//酒店编码
- roomcode: '',//房间编码
- rdeep_duration_efficiency: '',//深睡比例
- rlight_duration_efficiency: '',//浅睡比例
- rin_duration_efficiency: '',//中睡比例
- rawake_duration_efficiency: '',//清醒比例
- isLoading: false,
- ec7: '',
- width7: '',
- height7: '',
- ec8: '',
- width8: '',
- height8: '',
- ec1: '',
- width1: '',
- height1: '',
- ec81: '',
- width81: '',
- height81: '',
- ec9: '',
- width9: '',
- height9: '',
- ec10: '',
- width10: '',
- height10: '',
- ec11: '',
- width11: '',
- height11: '',
- flushChart00Flag: false,
- arrayFourth: [[], []],//多级选择数组
- valueFourth: [0, 0],//多级选择结果index
- sourceFourth: [
- {
- id: 1,
- text: '2024-05-24',
- children: [{
- id: 1,
- text: '01:01~01:20',
- reportId: '11111',
- }, {
- id: 2,
- text: '03:05~04:20',
- reportId: '22222',
- }, {
- id: 3,
- text: '05:21~07:20',
- reportId: '33333',
- }]
- },
- {
- id: 2,
- text: '2024-05-23',
- children: [{
- id: 3,
- text: '00:01~03:20',
- reportId: '454545',
- }, {
- id: 4,
- text: '00:03~06:20',
- reportId: '66666',
- }]
- },
- ],//后台读取的所及数据源
- reportId: '',
- hotelname: '',
- roomname: '',
- pushReportId: '',//推送用:reportId
- },
- toWarmReminder(e) {
- const tabName = e.currentTarget.dataset.index || 1;
- wx.navigateTo({
- url: '/subpages/warmReminder/warmReminder?id=' + tabName
- })
- },
- //点击确定选择结果时,保存结果
- bindMultiPickerChange: function (e) {
- var result = e.detail.value;
- var data = this.data.sourceFourth;
- console.info('result=' + result);
- console.info('result[0]=' + result[0]);
- console.info('data[result[0]].text=' + data[Number(result[0])].text);
- console.info('data[result[0]].children[result[1]].text=' + data[Number(result[0])].children[Number(result[1])].text);
- this.setData({
- reportDate: data[Number(result[0])].text,
- rgobed_routbed: data[Number(result[0])].children[Number(result[1])].text,
- reportId: data[Number(result[0])].children[Number(result[1])].reportId,
- });
- this.onPickerDateTimeChange(this.data.reportId);
- },
- //选择列变更时,处理下级数组变更
- bindMultiPickerColumnChange: function (e) {
- var column = e.detail.column;
- var index = e.detail.value;
- var array = this.data.arrayFourth;
- if (column == 0) {
- array[1] = array[column][index].children;
- this.setData({
- arrayFourth: array
- });
- } else if (column == 1) {
- //最后一列不处理
- }
- },
- drawCircle: function () {
- // 创建 canvas 上下文
- const ctx = wx.createCanvasContext('myCanvas');
- // 设置圆环的颜色和样式
- ctx.setStrokeStyle('green'); // 圆环的颜色
- ctx.setLineWidth(20); // 圆环的宽度
- // 绘制外圆
- ctx.beginPath();
- ctx.arc(80, 80, 50, 0, 2 * Math.PI); // 圆心 (100, 100),半径 100
- ctx.stroke(); // 绘制外圆
- // 绘制内圆(与外圆同圆心,但半径小20rpx,即80rpx)
- ctx.beginPath();
- ctx.arc(80, 80, 50, 0, 2 * Math.PI);
- ctx.setFillStyle('white'); // 设置内圆的填充颜色为白色(或者透明,取决于你希望的效果)
- ctx.fill(); // 填充内圆,这样圆环内部就是白色或透明的了
- // 结束绘制并更新 canvas
- ctx.draw();
- },
- startInterval: function () {
- // 使用 setInterval 创建定时任务,每8秒执行一次 this.myMethod 方法
- var that = this;
- this.intervalId = setInterval(() => {
- console.log(Date.now());
- }, 6000);
- },
- clearInterval: function () {
- // 清除定时任务
- if (this.intervalId) {
- clearInterval(this.intervalId);
- this.intervalId = null;
- }
- },
- tvEntityIdsChange: function (e) {
- var that = this;
- console.log('this.data.tvEntityIds_tv=' + JSON.stringify(this.data.tvEntityIds))
- var selectedOption = this.data.tvEntityIds[e.detail.value];
- console.log('selectedOption_tv=' + JSON.stringify(selectedOption))
- if (!this.data.tvEntityIds || !selectedOption) {
- wx.showToast({
- title: '请选择需要推送的电视',
- icon: 'none'
- });
- return;
- }
- this.setData({
- tvEntityIdsIndex: e.detail.value,
- tvEntityIdsValue: selectedOption.friendly_name1,
- });
- this.telScreeProjection(selectedOption.entity_id);
- },
- tvEntityIdChange: function (e) {
- this.telScreeProjection();
- },
- onPickerChange: function (e) {
- var that = this;
- var selectedOption = this.data.sns[e.detail.value];
- this.setData({
- selectedIndex: e.detail.value,
- selectedValue: selectedOption.pos,
- rsn: selectedOption.sn,
- });
- console.log("e.detail.value=" + e.detail.value);
- console.log("selectedOption=" + JSON.stringify(selectedOption));
- this.getData(selectedOption.sn, this.data.hotelcode, this.data.roomcode, null);
- // this.selectComponent('#mychart-dom-bar00').init((canvas, width, height) => {
- that.initChartCircle()
- that.initOutOfBed()
- that.initBodyMovements()
- that.initCardiacSystem()
- that.initChartRespiratory()
- that.initChartSnoring()
- that.initChartApnea()
- that.initTimeWaterfall()
- // });
- // this.selectComponent('#mychart-dom-bar7').init((canvas, width, height) => {
- // that.initChart7(canvas, width, height, null)
- // });
- // this.selectComponent('#mychart-dom-bar8').init((canvas, width, height) => {
- // that.initChart8(canvas, width, height, null)
- // });
- // this.selectComponent('#mychart-dom-bar1').init((canvas, width, height) => {
- // that.initChart1(canvas, width, height, null)
- // });
- // this.selectComponent('#mychart-dom-bar81').init((canvas, width, height) => {
- // that.initChart81(canvas, width, height, null)
- // });
- // this.selectComponent('#mychart-dom-bar9').init((canvas, width, height) => {
- // that.initChart9(canvas, width, height, null)
- // });
- // this.selectComponent('#mychart-dom-bar10').init((canvas, width, height) => {
- // that.initChart10(canvas, width, height, null)
- // });
- // this.selectComponent('#mychart-dom-bar11').init((canvas, width, height) => {
- // that.initChart11(canvas, width, height, null)
- // });
- },
- onPickerDateTimeChange: function (reportId) {
- var that = this;
- // var selectedOption = this.data.sns[e.detail.value];
- // this.setData({
- // selectedIndex: e.detail.value,
- // selectedValue: selectedOption.pos,
- // rsn: selectedOption.sn,
- // });
- // console.log("e.detail.value="+e.detail.value);
- // console.log("selectedOption="+JSON.stringify(selectedOption));
- this.getData(that.data.sn, this.data.hotelcode, this.data.roomcode, reportId);
- // this.selectComponent('#mychart-dom-bar00').init((canvas, width, height) => {
- that.initChartCircle(reportId)
- // });
- // this.selectComponent('#mychart-dom-bar7').init((canvas, width, height) => {
- that.initOutOfBed(reportId)
- that.initBodyMovements(reportId)
- that.initCardiacSystem(reportId)
- that.initChartRespiratory(reportId)
- that.initChartSnoring(reportId)
- that.initChartApnea(reportId)
- that.initTimeWaterfall(reportId)
- // });
- // this.selectComponent('#mychart-dom-bar8').init((canvas, width, height) => {
- // that.initChart8(canvas, width, height, reportId)
- // });
- // this.selectComponent('#mychart-dom-bar1').init((canvas, width, height) => {
- // that.initChart1(canvas, width, height, reportId)
- // });
- // this.selectComponent('#mychart-dom-bar81').init((canvas, width, height) => {
- // that.initChart81(canvas, width, height, reportId)
- // });
- // this.selectComponent('#mychart-dom-bar9').init((canvas, width, height) => {
- // that.initChart9(canvas, width, height, reportId)
- // });
- // this.selectComponent('#mychart-dom-bar10').init((canvas, width, height) => {
- // that.initChart10(canvas, width, height, reportId)
- // });
- // this.selectComponent('#mychart-dom-bar11').init((canvas, width, height) => {
- // that.initChart11(canvas, width, height, reportId)
- // });
- },
- onButtonTap: function () {
- // 切换按钮的样式类
- this.setData({
- isButtonPressed: !this.data.isButtonPressed
- });
- },
- dayClick(event) { //日历点击选择日期
- var that = this;
- var clickDate = String(event.detail.year) + addZero(event.detail.month) + addZero(event.detail.day)
- // that.getTargetData(clickDate)
- console.log("change date", that.data.target_sleep_list)
- flushChart(that.data.target_sleep_list)
- that.setData({
- nowDate: [{
- month: 'current',
- day: event.detail.day,
- color: 'white',
- background: '#82d5f8'
- }, {
- month: 'current',
- day: new Date().getDate(),
- color: '#ffd700',
- background: 'white'
- }],
- clickDate: clickDate,
- ec: {
- onInit: that.construct_sleep_plot
- }
- })
- },
- getTargetData(date) {
- var that = this;
- var sleep_data = wx.getStorageSync("sleep_data")
- console.log("find date is", date)
- if (sleep_data || that.data.moke_data) {
- if (date == "20240414" || date == "20240415") {
- var parse_sleep_data = that.data.moke_data[date]
- } else {
- var parse_sleep_data = JSON.parse(sleep_data)[date]
- }
- var sleep_cnt = 0
- if (parse_sleep_data) {
- sleep_cnt = parse_sleep_data.length;
- }
- var sleep_time = 0.0;
- var sleep_desc = "";
- var sleep_tj_map = {
- '早醒': 0,
- '疲惫': 0,
- '多梦': 0,
- '很好': 0
- };
- var slepp_sugg = "";
- var target_sleep_list = [];
- for (var i in parse_sleep_data) {
- var fix_sleep_tm = (parse_sleep_data[i].sleepAllTime / 60).toFixed(1);
- sleep_time += parseFloat(fix_sleep_tm);
- sleep_tj_map[parse_sleep_data[i].sleepFeedback] += 1
- target_sleep_list.push(parseFloat(fix_sleep_tm))
- }
- for (var j in sleep_tj_map) {
- if (sleep_tj_map[j] > 0) {
- sleep_desc += j + String(sleep_tj_map[j]) + " 次."
- }
- }
- switch (sleep_cnt) {
- case 5:
- slepp_sugg = "继续保持睡前良好状态";
- break;
- case 1:
- slepp_sugg = "学会释放工作压力";
- break;
- case 2:
- slepp_sugg = "睡前一小时不要进行有氧运动";
- break;
- case 3:
- slepp_sugg = "睡前尽量不要摄入高热量餐饮";
- break;
- case 0:
- slepp_sugg = "还未产生睡眠报告";
- break;
- case 4:
- slepp_sugg = "做一些助眠工作";
- break;
- }
- that.setData({
- data_dispaly: true,
- sleep_cnt: sleep_cnt,
- sleep_time: sleep_time.toFixed(1),
- sleep_desc: sleep_desc,
- slepp_sugg: slepp_sugg,
- target_sleep_list: target_sleep_list,
- ec0: { onInit: target_sleep_list },
- ec: { onInit: target_sleep_list },
- ec1: { onInit: target_sleep_list },
- ec2: { onInit: target_sleep_list },
- ec3: { onInit: target_sleep_list },
- ec4: { onInit: target_sleep_list },
- })
- }
- },
- initChartCircle(reportId) {
- var that = this;
- wx.request({
- url: `${aipushApi}` + '/getsn',
- data: {
- // "hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
- // "roomcode":that.data.hotelcode?that.data.roomcode:"nuange",
- "hotelcode": that.data.hotelcode ? that.data.hotelcode : "club",
- "roomcode": that.data.roomcode ? that.data.roomcode : "nuange",
- "token": token_push
- },
- method: 'POST',
- success(res) {
- try {
- if (res && res.data && res.data[0]) {
- that.setData({
- roomname: res.data[0].rn
- });
- console.log("res.data=sn=" + JSON.stringify(res.data));
- wx.request({
- url: `${aipushApi}` + '/getsingle',
- data: {
- "sn": that.data.rsn ? that.data.rsn : res.data[0].sn,
- "rpids": reportId,
- "token": token_push
- },
- method: 'POST',
- success(ress) {
- if (ress && ress.data) {
- // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
- try {
- let rscore_descTemp = [];
- if (ress.data.results.rscore_desc) {
- rscore_descTemp = ress.data.results.rscore_desc;
- }
- let rscore_valueTemp = [];
- if (ress.data.results.rscore_value) {
- rscore_valueTemp = ress.data.results.rscore_value;
- }
- that.setData({
- rscore_desc: rscore_descTemp,
- rscore_value: rscore_valueTemp,
- });
- updateChartCircularProgressBarOption(rscore_descTemp, rscore_valueTemp, that);
- } catch (error) {
- console.error(error);
- }
- // console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
- // console.log("");
- }
- }
- });
- }
- } catch (error) {
- console.error(error);
- }
- },
- })
- },
- initChart(canvas, width, height) {
- var that = this;
- chart = echarts.init(canvas, null, {
- width: width,
- height: height
- });
- console.log("plot in ......")
- canvas.setChart(chart);
- flushChart(that.data.target_sleep_list)
- },
- // 心脏 系统
- initCardiacSystem(reportId) {
- var that = this;
- wx.request({
- url: `${aipushApi}` + '/getsn',
- data: {
- // "hotelcode":that.data.hotelcode?that.data.hotelcode:"club",
- // "roomcode":that.data.hotelcode?that.data.roomcode:"nuange",
- "hotelcode": that.data.hotelcode ? that.data.hotelcode : "club",
- "roomcode": that.data.roomcode ? that.data.roomcode : "nuange",
- "token": token_push
- },
- method: 'POST',
- success(res) {
- try {
- if (res && res.data && res.data[0]) {
- that.setData({
- roomname: res.data[0].rn
- });
- console.log("res.data=sn=" + JSON.stringify(res.data));
- wx.request({
- url: `${aipushApi}` + '/getsingle',
- data: {
- "sn": that.data.rsn ? that.data.rsn : res.data[0].sn,
- "token": token_push,
- "rpids": reportId
- },
- method: 'POST',
- success(ress) {
- if (ress && ress.data) {
- // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
- try {
- let rdt_arrTemp = [];
- if (ress.data.results.rrh_arr) {
- rdt_arrTemp = that.splitN(ress.data.results.rdt_arr.split(","), 100);
- }
- if (ress.data.results.rdate) {
- that.setData({
- reportDate: ress.data.results.rdate
- });
- }
- let rrh_arrTemp = [];
- if (ress.data.results.rrh_arr) {
- rrh_arrTemp = that.splitN(ress.data.results.rrh_arr.split(","), 100);
- }
- that.setData({
- rdt_arrNew: rdt_arrTemp,
- rrh_arrNew: rrh_arrTemp,
- });
- console.log("that.data.rdt_arrNew,that.data.rrh_arrNew=" + that.data.rdt_arrNew + "," + that.data.rrh_arrNew);
- updateCardiacSystem(that.data.rdt_arrNew, that.data.rrh_arrNew, that);
- } catch (error) {
- console.error(error);
- }
- // console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
- // console.log("");
- }
- }
- });
- }
- } catch (error) {
- console.error(error);
- }
- },
- })
- },
- initChart2(canvas, width, height) {
- var that = this;
- wx.request({
- url: `${aipushApi}` + '/getsn',
- data: {
- "hotelcode": that.data.hotelcode ? that.data.hotelcode : "club",
- "roomcode": that.data.roomcode ? that.data.roomcode : "nuange",
- "token": token_push
- },
- method: 'POST',
- success(res) {
- try {
- if (res && res.data && res.data[0]) {
- that.setData({
- roomname: res.data[0].rn
- });
- wx.request({
- url: `${aipushApi}` + '/getsingle',
- data: {
- "sn": res.data[0].sn,
- "token": token_push
- },
- method: 'POST',
- success(ress) {
- if (ress && ress.data) {
- // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
- try {
- let durationDataTemp = [];
- let obj = {};
- obj.name = '深睡';
- obj.value = ress.data.results.rdeep_duration;
- durationDataTemp.push(obj);
- obj = {};
- obj.name = '中睡';
- obj.value = ress.data.results.rin_duration;
- durationDataTemp.push(obj);
- obj = {};
- obj.name = '浅睡';
- obj.value = ress.data.results.rlight_duration;
- durationDataTemp.push(obj);
- obj = {};
- obj.name = '清醒';
- obj.value = ress.data.results.rawake_duration;
- durationDataTemp.push(obj);
- console.log("durationDataTemp=" + JSON.stringify(durationDataTemp));
- that.setData({
- durationData: durationDataTemp,
- });
- chart2 = echarts.init(canvas, null, {
- width: width,
- height: height
- });
- // console.log("plot in ......")
- canvas.setChart(chart2);
- flushChart2(that.data.durationData)
- } catch (error) {
- console.error(error);
- }
- // console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
- // console.log("");
- }
- },
- });
- }
- } catch (error) {
- console.error(error);
- }
- },
- })
- },
- initChart3(canvas, width, height) {
- var that = this;
- wx.request({
- url: `${aipushApi}` + '/getsn',
- data: {
- "hotelcode": that.data.hotelcode ? that.data.hotelcode : "club",
- "roomcode": that.data.roomcode ? that.data.roomcode : "nuange",
- "token": token_push
- },
- method: 'POST',
- success(res) {
- try {
- if (res && res.data && res.data[0]) {
- that.setData({
- roomname: res.data[0].rn
- });
- wx.request({
- url: `${aipushApi}` + '/getsingle',
- data: {
- "sn": res.data[0].sn,
- "token": token_push
- },
- method: 'POST',
- success(ress) {
- if (ress && ress.data) {
- // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
- try {
- let rdt_arrTemp = [];
- if (ress.data.results.rrh_arr) {
- rdt_arrTemp = that.splitN(ress.data.results.rdt_arr.split(","), 100);
- }
- let rhx_arrTemp = [];
- if (ress.data.results.rhx_arr) {
- rhx_arrTemp = that.splitN(ress.data.results.rhx_arr.split(","), 100);
- }
- that.setData({
- rdt_arrNew: rdt_arrTemp,
- rhx_arrNew: rhx_arrTemp,
- });
- chart3 = echarts.init(canvas, null, {
- width: width,
- height: height
- });
- console.log("plot in ......")
- canvas.setChart(chart3);
- flushChart3(that.data.rdt_arrNew, that.data.rhx_arrNew)
- } catch (error) {
- console.error(error);
- }
- // console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1="+that.data.rdt_arrNew+","+that.data.rrh_arrNew);
- // console.log("");
- }
- },
- });
- }
- } catch (error) {
- console.error(error);
- }
- },
- })
- },
- initTimeWaterfall(reportId) {
- var that = this;
- wx.request({
- url: `${aipushApi}` + '/getsn',
- data: {
- "hotelcode": that.data.hotelcode ? that.data.hotelcode : "club",
- "roomcode": that.data.roomcode ? that.data.roomcode : "nuange",
- "token": token_push
- },
- method: 'POST',
- success(res) {
- try {
- if (res && res.data && res.data[0]) {
- that.setData({
- roomname: res.data[0].rn
- });
- wx.request({
- url: `${aipushApi}` + '/getsingle',
- data: {
- "sn": that.data.rsn ? that.data.rsn : res.data[0].sn,
- "token": token_push,
- "rpids": reportId
- },
- method: 'POST',
- success(ress) {
- if (ress && ress.data) {
- try {
- let rdt_arrTemp = [];
- if (ress.data.results.rrh_arr) {
- // rdt_arrTemp = that.splitN(ress.data.results.rdt_arr.split(","), 100);
- rdt_arrTemp = ress.data.results.rdt_arr.split(",");
- }
- // console.log('深浅睡眠11111=======' + JSON.stringify(rdt_arrTemp));
- let rsleep_arr_Temp = [];
- if (ress.data.results.rsleep_arr) {
- // rsleep_arr_Temp = that.splitN(ress.data.results.rsleep_arr.split(","), 100);
- rsleep_arr_Temp = ress.data.results.rsleep_arr.split(",");
- }
- // console.log('深浅睡眠222222=======' + JSON.stringify(rsleep_arr_Temp));
- that.setData({
- rdt_arrNew: rdt_arrTemp,
- rsleep_arr: rsleep_arr_Temp,
- rdeep_duration: ress.data.results.rdeep_duration,
- rlight_duration: ress.data.results.rlight_duration,
- rin_duration: ress.data.results.rin_duration,
- rawake_duration: ress.data.results.rawake_duration,
- rdeep_durationFormat: that.convertTimeToHoursAndMinutes(ress.data.results.rdeep_duration),
- rlight_durationFormat: that.convertTimeToHoursAndMinutes(ress.data.results.rlight_duration),
- rin_durationFormat: that.convertTimeToHoursAndMinutes(ress.data.results.rin_duration),
- rawake_durationFormat: that.convertTimeToHoursAndMinutes(ress.data.results.rawake_duration),
- });
- // console.log('ress.data.results.rdeep_duration=' + ress.data.results.rdeep_duration);
- // console.log('ress.data.results.rlight_duration=' + ress.data.results.rlight_duration);
- // console.log('ress.data.results.rin_duration=' + ress.data.results.rin_duration);
- // console.log('ress.data.results.rawake_duration=' + ress.data.results.rawake_duration);
- // initChartTimeWaterfall();
- that.calculateTheDurationOfDeepSleep();
- // updateTimeWaterfall([that.convertTimeToHoursAndMinutes(ress.data.results.rawake_duration, 2),
- // that.convertTimeToHoursAndMinutes(ress.data.results.rin_duration, 2),
- // that.convertTimeToHoursAndMinutes(ress.data.results.rlight_duration, 2),
- // that.convertTimeToHoursAndMinutes(ress.data.results.rdeep_duration, 2)],
- // [ ress.data.results.rawake_duration || 0,
- // ress.data.results.rin_duration || 0,
- // ress.data.results.rlight_duration || 0,
- // ress.data.results.rdeep_duration || 0,
- // ], that)
- } catch (error) {
- console.error(error);
- }
- console.log("that.data.rsleep_arr=" + that.data.rsleep_arr);
- console.log("");
- }
- },
- });
- }
- } catch (error) {
- console.error(error);
- }
- },
- })
- },
- initChart4(canvas, width, height) {
- var that = this;
- wx.request({
- url: `${aipushApi}` + '/getsn',
- data: {
- "hotelcode": that.data.hotelcode ? that.data.hotelcode : "club",
- "roomcode": that.data.roomcode ? that.data.roomcode : "nuange",
- "token": token_push
- },
- method: 'POST',
- success(res) {
- try {
- if (res && res.data && res.data[0]) {
- that.setData({
- roomname: res.data[0].rn
- });
- wx.request({
- url: `${aipushApi}` + '/getsingle',
- data: {
- "sn": res.data[0].sn,
- "token": token_push
- },
- method: 'POST',
- success(ress) {
- if (ress && ress.data) {
- // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
- try {
- let sleep_durationCount = 0;
- if (ress.data.results.rdeep_duration) {
- sleep_durationCount += parseFloat(ress.data.results.rdeep_duration)
- }
- if (ress.data.results.rlight_duration) {
- sleep_durationCount += parseFloat(ress.data.results.rlight_duration)
- }
- if (ress.data.results.rin_duration) {
- sleep_durationCount += parseFloat(ress.data.results.rin_duration)
- }
- let sleep_durationTemp = [];
- // let data1 = [];
- let obj1 = {};
- obj1.name = '睡眠时间';
- obj1.value = Math.ceil(sleep_durationCount / 60);
- sleep_durationTemp.push(obj1);
- // data1.push(obj1);
- // let data2 = [];
- obj1 = {};
- obj1.name = '清醒时间';
- obj1.value = Math.ceil(parseFloat(ress.data.results.rawake_duration) / 60);
- sleep_durationTemp.push(obj1);
- // data2.push(obj1);
- that.setData({
- sleep_duration: sleep_durationTemp,
- });
- chart4 = echarts.init(canvas, null, {
- width: width,
- height: height
- });
- console.log("plot in ......")
- canvas.setChart(chart4);
- // console.log("that.data.sleep_duration="+JSON.stringify(that.data.sleep_duration))
- flushChart4(that.data.sleep_duration)
- } catch (error) {
- console.error(error);
- }
- console.log("");
- }
- },
- });
- }
- } catch (error) {
- console.error(error);
- }
- },
- })
- },
- initChart5(canvas, width, height) {
- var that = this;
- wx.request({
- url: `${aipushApi}` + '/getsn',
- data: {
- "hotelcode": that.data.hotelcode ? that.data.hotelcode : "club",
- "roomcode": that.data.roomcode ? that.data.roomcode : "nuange",
- "token": token_push
- },
- method: 'POST',
- success(res) {
- if (res && res.data && res.data[0]) {
- that.setData({
- roomname: res.data[0].rn
- });
- try {
- wx.request({
- url: `${aipushApi}` + '/getsingle',
- data: {
- "sn": res.data[0].sn,
- "token": token_push
- },
- method: 'POST',
- success(ress) {
- if (ress && ress.data) {
- // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
- try {
- let rdt_arrTemp = [];
- if (ress.data.results.rrh_arr) {
- rdt_arrTemp = that.splitN(ress.data.results.rdt_arr.split(","), 100);
- }
- let rsleep_arrTemp = [];
- if (ress.data.results.rsleep_arr) {
- rsleep_arrTemp = that.splitN(ress.data.results.rsleep_arr.split(","), 100);
- }
- that.setData({
- rdt_arrNew: rdt_arrTemp,
- rsleep_arrNew: rsleep_arrTemp,
- });
- chart5 = echarts.init(canvas, null, {
- width: width,
- height: height
- });
- console.log("plot in ......")
- canvas.setChart(chart5);
- flushChart5(that.data.rdt_arrNew, that.data.rsleep_arrNew, that)
- } catch (error) {
- console.error(error);
- }
- console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1=" + that.data.rdt_arrNew + "," + that.data.rrh_arrNew);
- console.log("");
- }
- },
- });
- } catch (error) {
- console.error(error);
- }
- }
- },
- })
- },
- initChart6(canvas, width, height) {
- var that = this;
- wx.request({
- url: `${aipushApi}` + '/getsn',
- data: {
- "hotelcode": that.data.hotelcode ? that.data.hotelcode : "club",
- "roomcode": that.data.roomcode ? that.data.roomcode : "nuange",
- "token": token_push
- },
- method: 'POST',
- success(res) {
- try {
- if (res && res.data && res.data[0]) {
- that.setData({
- roomname: res.data[0].rn
- });
- wx.request({
- url: `${aipushApi}` + '/getsingle',
- data: {
- "sn": res.data[0].sn,
- "token": token_push
- },
- method: 'POST',
- success(ress) {
- if (ress && ress.data) {
- // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
- try {
- var rsleep_arr_all_Temp = [];
- if (ress.data.results.rsleep_arr) {
- rsleep_arr_all_Temp = ress.data.results.rsleep_arr.split(",");
- }
- that.setData({
- rdt_arr: that.splitN(ress.data.results.rdt_arr ? ress.data.results.rdt_arr.split(',') : [], 100),
- rsleep_arr_all: that.splitN(rsleep_arr_all_Temp, 100),
- rgobed_time: ress.data.results.rgobed_time,
- routbed_time: ress.data.results.routbed_time,
- rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
- });
- chart6 = echarts.init(canvas, null, {
- width: width,
- height: height
- });
- console.log("plot in ......")
- canvas.setChart(chart6);
- // var list = that.getRsleep_arr(ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(","):[])
- flushChart6(that.data.rdt_arr, that.data.rsleep_arr_all, that.data.rgobed_time, that.data.routbed_time, that)
- } catch (error) {
- console.error(error);
- }
- console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1=" + that.data.rdt_arrNew + "," + that.data.rrh_arrNew);
- console.log("");
- }
- },
- });
- }
- } catch (error) {
- console.error(error);
- }
- },
- })
- },
- initOutOfBed(reportId) {//离床次数
- var that = this;
- wx.request({
- url: `${aipushApi}` + '/getsn',
- data: {
- "hotelcode": that.data.hotelcode ? that.data.hotelcode : "club",
- "roomcode": that.data.roomcode ? that.data.roomcode : "nuange",
- "token": token_push
- },
- method: 'POST',
- success(res) {
- try {
- if (res && res.data && res.data[0]) {
- that.setData({
- roomname: res.data[0].rn
- });
- wx.request({
- url: `${aipushApi}` + '/getsingle',
- data: {
- "sn": that.data.rsn ? that.data.rsn : res.data[0].sn,
- "token": token_push,
- "rpids": reportId || that.data.reportId
- },
- method: 'POST',
- success(ress) {
- if (ress && ress.data) {
- // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
- try {
- var routbed_arr_Temp = [];
- if (ress.data.results.routbed_arr) {
- routbed_arr_Temp = ress.data.results.routbed_arr.split(",");
- }
- that.setData({
- // rdt_arr: that.splitN(ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],100),
- // routbed_arr: that.splitN(routbed_arr_Temp,100),
- rdt_arr: ress.data.results.rdt_arr ? ress.data.results.rdt_arr.split(',') : [],
- routbed_arr: routbed_arr_Temp,
- rgobed_time: ress.data.results.rgobed_time,
- routbed_time: ress.data.results.routbed_time,
- rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
- });
- updateOutOfBed(that.data.rdt_arr, that.data.routbed_arr, that.data.rgobed_time, that.data.routbed_time, that)
- } catch (error) {
- console.error(error);
- }
- console.log("that.data.routbed_arr=" + that.data.routbed_arr);
- console.log("");
- }
- },
- });
- }
- } catch (error) {
- console.error(error);
- }
- },
- })
- },
- initBodyMovements(reportId) {//体动次数
- var that = this;
- wx.request({
- url: `${aipushApi}` + '/getsn',
- data: {
- "hotelcode": that.data.hotelcode ? that.data.hotelcode : "club",
- "roomcode": that.data.roomcode ? that.data.roomcode : "nuange",
- "token": token_push
- },
- method: 'POST',
- success(res) {
- try {
- if (res && res.data && res.data[0]) {
- that.setData({
- roomname: res.data[0].rn
- });
- wx.request({
- url: `${aipushApi}` + '/getsingle',
- data: {
- "sn": that.data.rsn ? that.data.rsn : res.data[0].sn,
- "token": token_push,
- "rpids": reportId || that.data.reportId
- },
- method: 'POST',
- success(ress) {
- if (ress && ress.data) {
- // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
- try {
- var rmove_arr_Temp = [];
- if (ress.data.results.rmove_arr) {
- rmove_arr_Temp = ress.data.results.rmove_arr.split(",");
- }
- that.setData({
- rdt_arr: that.splitN(ress.data.results.rdt_arr ? ress.data.results.rdt_arr.split(',') : [], 100),
- rmove_arr: that.splitN(rmove_arr_Temp, 100),
- rgobed_time: ress.data.results.rgobed_time,
- routbed_time: ress.data.results.routbed_time,
- rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
- });
- updateBodyMovements(that.data.rdt_arr, that.data.rmove_arr, that.data.rgobed_time, that.data.routbed_time, that)
- } catch (error) {
- console.error(error);
- }
- console.log("c8_that.data.rmove_arr=" + that.data.rmove_arr);
- console.log("");
- }
- },
- });
- }
- } catch (error) {
- console.error(error);
- }
- },
- })
- },
- initChartRespiratory(reportId) {//平均呼吸率
- var that = this;
- wx.request({
- url: `${aipushApi}` + '/getsn',
- data: {
- "hotelcode": that.data.hotelcode ? that.data.hotelcode : "club",
- "roomcode": that.data.roomcode ? that.data.roomcode : "nuange",
- "token": token_push
- },
- method: 'POST',
- success(res) {
- try {
- if (res && res.data && res.data[0]) {
- that.setData({
- roomname: res.data[0].rn
- });
- wx.request({
- url: `${aipushApi}` + '/getsingle',
- data: {
- "sn": that.data.rsn ? that.data.rsn : res.data[0].sn,
- "token": token_push,
- "rpids": reportId
- },
- method: 'POST',
- success(ress) {
- if (ress && ress.data) {
- // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
- try {
- var rhx_arr_Temp = [];
- if (ress.data.results.rhx_arr) {
- rhx_arr_Temp = ress.data.results.rhx_arr.split(",");
- }
- that.setData({
- rdt_arr: that.splitN(ress.data.results.rdt_arr ? ress.data.results.rdt_arr.split(',') : [], 100),
- rhx_arr: that.splitN(rhx_arr_Temp, 100),
- rgobed_time: ress.data.results.rgobed_time,
- routbed_time: ress.data.results.routbed_time,
- rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
- });
- updateRespiratory(that.data.rdt_arr, that.data.rhx_arr, that.data.rgobed_time, that.data.routbed_time, that)
- } catch (error) {
- console.error(error);
- }
- console.log("c81_that.data.ravg_hx_value=" + that.data.ravg_hx_value);
- console.log("");
- }
- },
- });
- }
- } catch (error) {
- console.error(error);
- }
- },
- })
- },
- initChartSnoring(reportId) {//打鼾
- var that = this;
- wx.request({
- url: `${aipushApi}` + '/getsn',
- data: {
- "hotelcode": that.data.hotelcode ? that.data.hotelcode : "club",
- "roomcode": that.data.roomcode ? that.data.roomcode : "nuange",
- "token": token_push
- },
- method: 'POST',
- success(res) {
- try {
- if (res && res.data && res.data[0]) {
- that.setData({
- roomname: res.data[0].rn
- });
- wx.request({
- url: `${aipushApi}` + '/getsingle',
- data: {
- "sn": that.data.rsn ? that.data.rsn : res.data[0].sn,
- "token": token_push,
- "rpids": reportId
- },
- method: 'POST',
- success(ress) {
- if (ress && ress.data) {
- // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
- try {
- var rsnoring_arr_Temp = [];
- if (ress.data.results.rsnoring_arr) {
- rsnoring_arr_Temp = ress.data.results.rsnoring_arr.split(",");
- }
- that.setData({
- rdt_arr: that.splitN(ress.data.results.rdt_arr ? ress.data.results.rdt_arr.split(',') : [], 100),
- rsnoring_arr: that.splitN(rsnoring_arr_Temp, 100),
- rgobed_time: ress.data.results.rgobed_time,
- routbed_time: ress.data.results.routbed_time,
- rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
- });
- updateSnoring(that.data.rdt_arr, that.data.rsnoring_arr, that.data.rgobed_time, that.data.routbed_time, that)
- } catch (error) {
- console.error(error);
- }
- console.log("c8_that.data.rmove_arr=" + that.data.rmove_arr);
- console.log("");
- }
- },
- });
- }
- } catch (error) {
- console.error(error);
- }
- },
- })
- },
- initChartApnea(reportId) {//呼吸暂停
- var that = this;
- wx.request({
- url: `${aipushApi}` + '/getsn',
- data: {
- "hotelcode": that.data.hotelcode ? that.data.hotelcode : "club",
- "roomcode": that.data.roomcode ? that.data.roomcode : "nuange",
- "token": token_push
- },
- method: 'POST',
- success(res) {
- try {
- if (res && res.data && res.data[0]) {
- that.setData({
- roomname: res.data[0].rn
- });
- wx.request({
- url: `${aipushApi}` + '/getsingle',
- data: {
- "sn": that.data.rsn ? that.data.rsn : res.data[0].sn,
- "token": token_push,
- "rpids": reportId
- },
- method: 'POST',
- success(ress) {
- if (ress && ress.data) {
- // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
- try {
- var rhxstop_arr_Temp = [];
- if (ress.data.results.rhxstop_arr) {
- rhxstop_arr_Temp = ress.data.results.rhxstop_arr.split(",");
- }
- that.setData({
- rdt_arr: that.splitN(ress.data.results.rdt_arr ? ress.data.results.rdt_arr.split(',') : [], 100),
- rhxstop_arr: that.splitN(rhxstop_arr_Temp, 100),
- rgobed_time: ress.data.results.rgobed_time,
- routbed_time: ress.data.results.routbed_time,
- rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
- });
- updateApnea(that.data.rdt_arr, that.data.rhxstop_arr, that.data.rgobed_time, that.data.routbed_time, that)
- } catch (error) {
- console.error(error);
- }
- console.log("c8_that.data.rhxstop_arr=" + that.data.rhxstop_arr);
- console.log("");
- }
- },
- });
- }
- } catch (error) {
- console.error(error);
- }
- },
- })
- },
- getRsleep_arr(list) {
- if (list) {
- console.log("getRsleep_arr_list1==" + JSON.stringify(list));
- for (let i = 0; i < list.length; i++) {
- if (list[i] == '0') {
- list[i] = '清醒';
- } else if (list[i] == '10') {
- list[i] = '浅睡';
- } else if (list[i] == '20') {
- list[i] = '中睡';
- } else if (list[i] == '30') {
- list[i] = '深睡';
- } else {
- list[i] = '其他';
- }
- }
- }
- console.log("getRsleep_arr_list2==" + JSON.stringify(list));
- },
- getFrequency(list) {//获取
- if (list) {
- console.log("getRsleep_arr_list1==" + JSON.stringify(list));
- for (let i = 0; i < list.length; i++) {
- if (list[i] == '0') {
- list[i] = '清醒';
- } else if (list[i] == '10') {
- list[i] = '浅睡';
- } else if (list[i] == '20') {
- list[i] = '中睡';
- } else if (list[i] == '30') {
- list[i] = '深睡';
- } else {
- list[i] = '其他';
- }
- }
- }
- console.log("getRsleep_arr_list2==" + JSON.stringify(list));
- },
- initChart12(canvas, width, height) {//体动次数
- var that = this;
- wx.request({
- url: `${aipushApi}` + '/getsn',
- data: {
- "hotelcode": that.data.hotelcode ? that.data.hotelcode : "club",
- "roomcode": that.data.roomcode ? that.data.roomcode : "nuange",
- "token": token_push
- },
- method: 'POST',
- success(res) {
- try {
- if (res && res.data && res.data[0]) {
- that.setData({
- roomname: res.data[0].rn
- });
- wx.request({
- url: `${aipushApi}` + '/getsingle',
- data: {
- "sn": res.data[0].sn,
- "token": token_push
- },
- method: 'POST',
- success(ress) {
- if (ress && ress.data) {
- // console.log('ress.data-getsingle='+JSON.stringify(ress.data.results));
- try {
- var rsnoring_arr_Temp = [];
- if (ress.data.results.rsnoring_arr) {
- rsnoring_arr_Temp = ress.data.results.rsnoring_arr.split(",");
- }
- that.setData({
- rdt_arr: that.splitN(ress.data.results.rdt_arr ? ress.data.results.rdt_arr.split(',') : [], 100),
- rsnoring_arr: that.splitN(rsnoring_arr_Temp, 100),
- rgobed_time: ress.data.results.rgobed_time,
- routbed_time: ress.data.results.routbed_time,
- rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
- });
- chart9 = echarts.init(canvas, null, {
- width: width,
- height: height
- });
- console.log("plot in ......")
- canvas.setChart(chart9);
- // var list = that.getRsleep_arr(ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(","):[])
- flushChart9(that.data.rdt_arr, that.data.rsnoring_arr, that.data.rgobed_time, that.data.routbed_time, that)
- } catch (error) {
- console.error(error);
- }
- console.log("c8_that.data.rmove_arr=" + that.data.rmove_arr);
- console.log("");
- }
- },
- });
- }
- } catch (error) {
- console.error(error);
- }
- },
- })
- },
- sleepStateChange(data) {
- console.log("change-data==" + data)
- switch (data) {
- case 0:
- return '清醒';
- case 10:
- return '浅睡';
- case 20:
- return '中睡';
- case 30:
- return '深睡';
- default:
- return '';
- }
- },
- sleepRoutbed_arrChange(data) {
- console.log("change-data==" + data)
- switch (data) {
- case 0:
- return '离床';
- case 1:
- return '在床';
- default:
- return '';
- }
- },
- sleepRmove_arrChange(data) {
- console.log("change-data==" + data)
- switch (data) {
- case 0:
- return '否';
- case 1:
- return '体动';
- default:
- return '';
- }
- },
- sleepRsnoring_arrChange(data) {
- console.log("change-data==" + data)
- switch (data) {
- case 0:
- return '否';
- case 1:
- return '打鼾';
- default:
- return '';
- }
- },
- sleepRhxstop_arrChange(data) {
- console.log("change-data==" + data)
- switch (data) {
- case 0:
- return '否';
- case 1:
- return '停止';
- default:
- return '';
- }
- },
- splitN(originalArray, n) {
- if (!originalArray) return [];
- // 计算每份的大小
- let chunkSize = Math.ceil(originalArray.length / n);
- // 分割数组并获取每份的最后一个元素
- let lastElements = [];
- for (let i = 0; i < originalArray.length; i += chunkSize) {
- let chunk = originalArray.slice(i, i + chunkSize);
- lastElements.push(chunk[chunk.length - 1]);
- }
- // 输出每份的最后一个元素
- console.log('lastElements=' + lastElements);
- return lastElements;
- },
- takePortionDateData(rdt_arrArray, originalArray, n) {
- if (!rdt_arrArray || !originalArray) return [];
- var portionDateData = [];
- var portionData = [];
- for (let i = 0; i < originalArray.length; i++) {
- if (originalArray[i] == n) {
- portionDateData.push(rdt_arrArray[i]);
- portionData.push(originalArray[i]);
- } else {
- }
- }
- console.log('portionDateData=' + JSON.stringify(portionDateData));
- return portionDateData;
- },
- takePortionData(originalArray, n) {
- if (!originalArray) return [];
- var portionData = [];
- for (let i = 0; i < originalArray.length; i++) {
- if (originalArray[i] == n) {
- portionData.push(originalArray[i])
- } else {
- }
- }
- console.log('portionData=' + JSON.stringify(portionData));
- return portionData;
- },
- getFrequency(list, o) {//获取次数
- if (!list) return 0;
- let frequency = 0;
- for (let i = 0; i < list.length; i++) {
- if (list[i] == o) frequency++;
- }
- console.log('frequency=' + frequency);
- return frequency;
- },
- getTimeDiffInHours: function (startTimeStr, endTimeStr) {
- // 假设两个时间都是同一天的,这里我们使用当前日期作为基准
- if (!startTimeStr || !endTimeStr) return null;
- const now = new Date();
- const startDate = new Date(now.getFullYear(), now.getMonth(), now.getDate(), ...startTimeStr.split(':').map(Number));
- const endDate = new Date(now.getFullYear(), now.getMonth(), now.getDate(), ...endTimeStr.split(':').map(Number));
- // 处理跨天的情况
- if (endDate < startDate) {
- endDate.setDate(endDate.getDate() + 1); // 将结束时间设置为第二天的同一时间
- }
- // 计算时间差(毫秒)
- const diffInMs = endDate - startDate;
- // 转换为小时
- const diffInHours = diffInMs / (1000 * 60 * 60);
- return diffInHours;
- },
- drawProgressCircle: function () {
- const ctx = wx.createCanvasContext('progressCircleCanvas');
- // 假设屏幕的宽度为 windowWidth px
- const windowWidth = wx.getSystemInfoSync().windowWidth;
- // 假设你有一个以 rpx 为单位的值
- const valueInRpx = 300;
- // 计算对应的 px 值
- const valueInPx = (valueInRpx / 750) * windowWidth;
- const radius = 60; // 圆的半径
- const centerX = valueInPx; // 圆心的x坐标
- const centerY = valueInPx / 2; // 圆心的y坐标
- const strokeWidth = 10; // 进度条的宽度
- const percentage = this.data.percentage; // 进度百分比
- // 绘制外圆
- ctx.beginPath();
- ctx.arc(centerX, centerY, radius, 0, 2 * Math.PI);
- ctx.setStrokeStyle('#46ff81'); // 外圆颜色
- ctx.setLineWidth(strokeWidth * 2); // 外圆线宽
- ctx.stroke();
- // 绘制内圆(进度条背景)
- ctx.beginPath();
- ctx.arc(centerX, centerY, radius - strokeWidth, 0, 2 * Math.PI);
- ctx.setStrokeStyle('#e0e0e0'); // 内圆颜色
- ctx.setLineWidth(strokeWidth); // 内圆线宽
- ctx.stroke();
- // 绘制进度条
- ctx.beginPath();
- ctx.arc(centerX, centerY, radius - strokeWidth, -0.5 * Math.PI, -0.5 * Math.PI + 2 * Math.PI * (percentage / 100));
- ctx.setStrokeStyle('#007aff'); // 进度条颜色
- ctx.setLineWidth(strokeWidth);
- ctx.setLineCap('round'); // 设置线条端点的样式为圆形
- ctx.stroke();
- // 绘制中心圆点
- ctx.beginPath();
- ctx.arc(centerX, centerY, 5, 0, 2 * Math.PI);
- ctx.setFillStyle('#ffffff');
- ctx.fill();
- // 绘制完成,将内容渲染到canvas中
- ctx.draw();
- },
- // 假设你有一个方法来更新进度条的值
- updateProgress: function (newPercentage) {
- this.setData({
- percentage: newPercentage
- });
- this.drawProgressCircle(); // 重新绘制进度条
- },
- buttonClicked: function () {
- var that = this;
- // 切换按钮的点击状态
- this.setData({
- isButtonClicked: !that.data.isButtonClicked,
- });
- // 在这里可以添加其他点击后的逻辑,比如调用接口等
- },
- telScreeProjection: function (tvEntityId) {
- var that = this;
- that.setData({
- isLoading: true,
- });
- wx.request({
- url: `${aipushApi}` + '/getbigreport',
- method: 'POST',
- header: {
- 'content-type': 'application/json', // 默认值
- 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
- },
- data: {
- "sn": that.data.rsn, "tokens": token_push
- },
- success(ress) {
- console.log('wx.getStorageSync(tvEntityId)=' + wx.getStorageSync('tvEntityId'));
- console.log('tvEntityId=' + JSON.stringify(tvEntityId));
- let tvEntityIdss = tvEntityId ? tvEntityId : wx.getStorageSync('tvEntityId')
- if (ress && ress.data && tvEntityIdss) {
- console.log("ress.data==" + JSON.stringify(ress.data.url));
- console.log("tvEntityIdss==" + tvEntityIdss);
- wx.request({
- // url: `${homeApi_http}`+':'+`${homeApi_http_port}`+'/api/services/media_player/play_media', //http
- // url: `${homeApi_https}`+'/api/services/media_player/play_media', //https
- url: `${homeApi_https}` + '/api/services/media_player/select_source', //https
- method: 'POST',
- header: {
- 'content-type': 'application/json', // 默认值
- 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
- },
- data: {
- "entity_id": tvEntityIdss,
- // "media_content_id": ress.data.url,
- // "media_content_id": 'https://alifei01.cfp.cn/creative/vcg/800/new/VCG41175510742.jpg',
- // "media_content_id": 'https://alifei01.cfp.cn/creative/vcg/veer/1600water/veer-368621010.jpg',
- // "media_content_type": "image/jpeg/png",
- "source": "X浏览器"
- },
- success(res) {
- that.setData({
- isLoading: false,
- });
- if (res && res.data) {
- var resData = res.data
- console.log('res-推送=' + JSON.stringify(res));
- console.log('res.data-推送=' + JSON.stringify(resData));
- wx.showToast({
- title: "推送成功",
- icon: "success",
- mask: true,
- });
- } else {
- wx.showToast({
- title: '推送失败',
- icon: 'none'
- });
- }
- },
- fail: function (error) {
- // 请求失败后的回调函数
- console.error('推送失败', error);
- // 在这里处理请求失败的情况,比如显示错误信息给用户
- that.setData({
- isLoading: false,
- });
- wx.showToast({
- title: '推送失败',
- icon: 'none'
- });
- }
- });
- } else {
- that.setData({
- isLoading: false,
- });
- wx.showToast({
- title: '找不到电视,推送失败',
- icon: 'none'
- });
- }
- },
- });
- },
- getData(sn, hotelcode, roomcode, reportId) {
- var that = this;
- wx.request({
- url: `${aipushApi}` + '/getsn',
- data: {
- "hotelcode": hotelcode ? hotelcode : "club",
- "roomcode": roomcode ? roomcode : "nuange",
- "token": token_push
- },
- method: 'POST',
- success(res) {
- try {
- // that.setData({
- // airText: now.category, //空气质量
- // airValue: now.aqi //空气指数
- // })
- if (res && res.data && res.data[0]) {
- that.setData({
- roomname: res.data[0].rn
- });
- console.log("res.data-sn=" + JSON.stringify(res.data));
- wx.request({
- url: `${aipushApi}` + '/getsingle',
- data: {
- "sn": sn ? sn : res.data[0].sn,
- "token": token_push,
- "rpids": reportId
- },
- method: 'POST',
- success(ress) {
- try {
- if (ress && ress.data) {
- console.log('ress.data-getsingle=' + JSON.stringify(ress.data.results));
- // that.setData({
- // airText: now.category, //空气质量
- // airValue: now.aqi //空气指数
- // })
- // rdt_arr = ress.data.results.rdt_arr //睡眠时间轴数据集合
- // rrh_arr = ress.data.results.rdt_arr//睡眠心率数据集合
- // rhx_arr = ress.data.results.rhx_arr//睡眠呼吸数据集合
- // rsnoring_arr = ress.data.results.rsnoring_arr//睡眠打鼾数据集合,0-否,1-打鼾状态
- // routbed_arr = ress.data.results.routbed_arr//离床状态数据集合,0-离床,1-在床
- // rmove_arr = ress.data.results.rmove_arr//体动状态数据集合,0-否,1-体动状态
- // rhxstop_arr = ress.data.results.rhxstop_arr//呼吸停止状态数据集合
- // rsleep_arr = ress.data.results.rsleep_arr//睡眠状态数据集合,0-清醒,10-浅睡,20-中睡,30-深睡
- // rdeep_duration = ress.data.results.rdeep_duration//深睡时长,单位分钟
- // rlight_duration = ress.data.results.rlight_duration//浅睡时长,单位分钟
- // rin_duration = ress.data.results.rin_duration//中睡时长,单位分钟
- // rawake_duration = ress.data.results.rawake_duration//清醒时长,单位分钟
- // ravg_hx_value = ress.data.results.ravg_hx_value//呼吸平均值
- // ravg_hx_desc = ress.data.results.ravg_hx_desc//呼吸平均值评分描述
- // ravg_rh_value = ress.data.results.ravg_rh_value//心率平均值
- // ravg_rh_desc = ress.data.results.ravg_rh_desc//心率平均值评分描述
- // rscore_value = ress.data.results.rscore_value//睡眠报告得分值
- // rscore_desc = ress.data.results.rscore_desc//睡眠报告得分评比描述
- // that.setData({
- // rdt_arr: ress.data.results.rdt_arr?ress.data.results.rdt_arr.split(','):[],
- // rrh_arr: ress.data.results.rrh_arr?ress.data.results.rrh_arr.split(','):[],
- // rhx_arr: ress.data.results.rhx_arr?ress.data.results.rhx_arr.split(','):[],
- // rsnoring_arr: ress.data.results.rsnoring_arr?ress.data.results.rsnoring_arr.split(','):[],
- // routbed_arr: ress.data.results.routbed_arr?ress.data.results.routbed_arr.split(','):[],
- // rmove_arr: ress.data.results.rmove_arr?ress.data.results.rmove_arr.split(','):[],
- // rhxstop_arr: ress.data.results.rhxstop_arr?ress.data.results.rhxstop_arr.split(','):[],
- // rsleep_arr: ress.data.results.rsleep_arr?ress.data.results.rsleep_arr.split(','):[],
- // rdeep_duration: ress.data.results.rdeep_duration,
- // rlight_duration: ress.data.results.rlight_duration,
- // rin_duration: ress.data.results.rin_duration,
- // rawake_duration: ress.data.results.rawake_duration,
- // ravg_hx_value: ress.data.results.ravg_hx_value,
- // ravg_hx_desc: ress.data.results.ravg_hx_desc,
- // ravg_rh_value: ress.data.results.ravg_rh_value,
- // ravg_rh_desc: ress.data.results.ravg_rh_desc,
- // rscore_value: ress.data.results.rscore_value,
- // rscore_desc: ress.data.results.rscore_desc,
- // rsn: ress.data.results.rsn,
- // rdate: ress.data.results.rdate,
- // rtotal_duration: ress.data.results.rtotal_duration,//睡眠总时长,单位分钟
- // rinbed_duration: ress.data.results.rinbed_duration,//在床时长,单位分钟
- // rgobed_time: ress.data.results.rgobed_time,//上床时间
- // routbed_time: ress.data.results.routbed_time,//离床时间
- // routbed_count_value: ress.data.results.routbed_count_value,//离床次数
- // rsn: ress.data.results.rsn,
- // });
- let durationDataTemp = [];
- let obj = {};
- obj.name = '深睡';
- obj.value = ress.data.results.rdeep_duration;
- durationDataTemp.push(obj);
- obj = {};
- obj.name = '浅睡';
- obj.value = ress.data.results.rlight_duration;
- durationDataTemp.push(obj);
- obj = {};
- obj.name = '中睡';
- obj.value = ress.data.results.rin_duration;
- durationDataTemp.push(obj);
- obj = {};
- obj.name = '清醒';
- obj.value = ress.data.results.rawake_duration;
- durationDataTemp.push(obj);
- console.log("durationDataTemp=" + JSON.stringify(durationDataTemp));
- let sleep_durationCount = 0;
- if (ress.data.results.rdeep_duration) {
- sleep_durationCount += parseFloat(ress.data.results.rdeep_duration)
- }
- if (ress.data.results.rlight_duration) {
- sleep_durationCount += parseFloat(ress.data.results.rlight_duration)
- }
- if (ress.data.results.rin_duration) {
- sleep_durationCount += parseFloat(ress.data.results.rin_duration)
- }
- let sleep_efficiency_temp = ress.data.results.rtotal_duration ? (Math.ceil((sleep_durationCount / ress.data.results.rtotal_duration) * 100) + '%') : '%'
- 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) + '%') : '%'
- 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) + '%') : '%'
- 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) + '%') : '%'
- let rawake_duration_efficiency_temp = ress.data.results.rtotal_duration ? (Math.ceil(((ress.data.results.rawake_duration ? parseFloat(ress.data.results.rawake_duration) : 0) / ress.data.results.rtotal_duration) * 100) + '%') : '%'
- let sleep_durationTemp = [];
- let obj1 = {};
- obj1.name = '睡眠时间';
- obj1.value = Math.ceil(sleep_durationCount / 60);
- sleep_durationTemp.push(obj1);
- obj1 = {};
- obj1.name = '清醒时间';
- obj1.value = Math.ceil(parseFloat(ress.data.results.rawake_duration) / 60);
- sleep_durationTemp.push(obj1);
- let zdPointTemp = [];
- let rdt_arrTemp = [];
- let rrh_arrTemp = [];
- let rhx_arrTemp = [];
- let rmove_arrTemp = [];
- let rsleep_arrTemp = [];
- let rsleep_arr_all_Temp = [];
- if (ress.data.results.rrh_arr) {
- rdt_arrTemp = that.splitN(ress.data.results.rdt_arr.split(","), 100);
- }
- if (ress.data.results.rrh_arr) {
- rrh_arrTemp = that.splitN(ress.data.results.rrh_arr.split(","), 100);
- }
- if (ress.data.results.rhx_arr) {
- rhx_arrTemp = that.splitN(ress.data.results.rhx_arr.split(","), 100);
- }
- if (ress.data.results.rmove_arr) {
- rmove_arrTemp = that.splitN(ress.data.results.rmove_arr.split(","), 100);
- }
- if (ress.data.results.rsleep_arr) {
- rsleep_arrTemp = that.splitN(ress.data.results.rsleep_arr.split(","), 100);
- }
- if (ress.data.results.rsleep_arr) {
- rsleep_arr_all_Temp = ress.data.results.rsleep_arr.split(",");
- }
- console.log("rdt_arrTemp=" + JSON.stringify(rdt_arrTemp));
- console.log("rrh_arrTemp=" + JSON.stringify(rrh_arrTemp));
- console.log("rhx_arrTemp=" + JSON.stringify(rhx_arrTemp));
- console.log("rmove_arrTemp=" + JSON.stringify(rmove_arrTemp));
- console.log("rsleep_arrTemp=" + JSON.stringify(rsleep_arrTemp));
- console.log("rsleep_arr_all_Temp=" + JSON.stringify(rsleep_arr_all_Temp));
- console.log("sleep_durationTemp=" + JSON.stringify(sleep_durationTemp));
- that.setData({
- rdt_arr: ress.data.results.rdt_arr ? ress.data.results.rdt_arr.split(',') : [],
- rrh_arr: ress.data.results.rrh_arr ? ress.data.results.rrh_arr.split(',') : [],
- rhx_arr: ress.data.results.rhx_arr ? ress.data.results.rhx_arr.split(',') : [],
- rsnoring_arr: ress.data.results.rsnoring_arr ? ress.data.results.rsnoring_arr.split(',') : [],
- routbed_arr: ress.data.results.routbed_arr ? ress.data.results.routbed_arr.split(',') : [],
- rmove_arr: ress.data.results.rmove_arr ? ress.data.results.rmove_arr.split(',') : [],
- rhxstop_arr: ress.data.results.rhxstop_arr ? ress.data.results.rhxstop_arr.split(',') : [],
- rsleep_arr: ress.data.results.rsleep_arr ? ress.data.results.rsleep_arr.split(',') : [],//睡眠状态数据集合,0-清醒,10-浅睡,20-中睡,30-深睡
- rsnoring_arrFrequency: that.getFrequency(ress.data.results.rsnoring_arr ? ress.data.results.rsnoring_arr.split(',') : [], 1),
- routbed_arrFrequency: that.getFrequency(ress.data.results.routbed_arr ? ress.data.results.routbed_arr.split(',') : [], 0),
- rmove_arrFrequency: that.getFrequency(ress.data.results.rmove_arr ? ress.data.results.rmove_arr.split(',') : [], 1),
- rhxstop_arrFrequency: that.getFrequency(ress.data.results.rhxstop_arr ? ress.data.results.rhxstop_arr.split(',') : [], 1),
- rdeep_durationFormatA: that.convertTimeToHoursAndMinutes(ress.data.results.rdeep_duration),
- rlight_duration: ress.data.results.rlight_duration,
- rin_duration: ress.data.results.rin_duration,
- rawake_duration: ress.data.results.rawake_duration,
- ravg_hx_value: ress.data.results.ravg_hx_value,
- ravg_hx_desc: ress.data.results.ravg_hx_desc,
- ravg_rh_value: ress.data.results.ravg_rh_value,
- ravg_rh_desc: ress.data.results.ravg_rh_desc,
- rscore_value: ress.data.results.rscore_value,
- rscore_desc: ress.data.results.rscore_desc,
- rsn: ress.data.results.rsn,
- rdate: ress.data.results.rdate,
- total_duration: ress.data.results.rtotal_duration,
- rtotal_duration: that.convertTimeToHoursAndMinutes(ress.data.results.rtotal_duration),//睡眠总时长,单位小时分钟
- rinbed_duration: that.convertTimeToHoursAndMinutes(ress.data.results.rinbed_duration),//在床时长,单位小时分钟
- rgobed_time: ress.data.results.rgobed_time,//上床时间
- routbed_time: ress.data.results.routbed_time,//离床时间
- rgobed_routbed: ress.data.results.rgobed_time + '~' + ress.data.results.routbed_time,
- sleepHourSub: that.getTimeDiffInHours(ress.data.results.rgobed_time, ress.data.results.routbed_time),
- routbed_count_value: ress.data.results.routbed_count_value,//离床次数
- rsn: ress.data.results.rsn,
- zdPointT: zdPointTemp,
- rdt_arrNew: rdt_arrTemp,
- rrh_arrNew: rrh_arrTemp,
- rhx_arrNew: rhx_arrTemp,
- rmove_arrNew: rmove_arrTemp,
- rsleep_arrNew: rsleep_arrTemp,
- rsleep_arr_all_New: rsleep_arr_all_Temp,
- durationData: durationDataTemp,
- sleep_duration: sleep_durationTemp,
- sleep_efficiency: sleep_efficiency_temp,
- sleep_durationCountA: that.convertTimeToHoursAndMinutes(sleep_durationCount ? sleep_durationCount.toString() : '0'),
- sns: res.data,
- tvEntityIds: wx.getStorageSync('tvEntityIds'),
- ifOneMoreTV: (wx.getStorageSync('tvEntityIds') && wx.getStorageSync('tvEntityIds').length > 1),
- hotelname: res.data[0].hn,
- rdeep_duration_efficiency: rdeep_duration_efficiency_temp,
- rlight_duration_efficiency: rlight_duration_efficiency_temp,
- rin_duration_efficiency: rin_duration_efficiency_temp,
- rawake_duration_efficiency: rawake_duration_efficiency_temp,
- pushReportId: ress.data.results.rdid,
- rrs_duration: that.convertTimeToHoursAndMinutes(ress.data.results.rrs_duration ? ress.data.results.rrs_duration.toString() : '0'),
- routbed_count_value: ress.data.results.routbed_count_value,
- rsleep_eff_value: ress.data.results.rsleep_eff_value,
- });
- that.getDateTimeJsonData(sn ? sn : res.data[0].sn);
- // resolve(ress.data); // 请求成功,使用 resolve 返回数据
- console.log('ress.data.results-' + ress.data.results)
- if (!ress.data.results || ress.data.results == '') {
- wx.showModal({
- title: '提示',
- content: '无数据',
- showCancel: false
- });
- return;
- }
- } else {
- wx.showModal({
- title: '提示',
- content: '无数据',
- showCancel: false
- });
- }
- } catch (error) {
- console.error(error);
- }
- console.log("that.data.rdt_arrNew1,that.data.rrh_arrNew1=" + that.data.rdt_arrNew + "," + that.data.rrh_arrNew);
- console.log("");
- },
- fail: function (error) {
- wx.showToast({
- title: "无数据",
- icon: "error",
- mask: true,
- });
- }
- });
- }
- // that.startInterval();
- } catch (error) {
- console.error(error);
- }
- },
- });
- wx.request({
- url: `${aipushApi}/getha`, //
- method: 'POST',
- // header: {
- // 'content-type': 'application/json', // 默认值
- // 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
- // },
- data: {
- "locations": hotelcode, "room": (hotelcode && hotelcode.includes('hotel')) ? roomcode : "", "token": token_push
- },
- success(res) {
- if (!res || !res.data) {
- that.setData({
- isLoading: false,
- });
- return;
- }
- var resData = res.data
- console.log('res.data.睡眠报告.ha=' + JSON.stringify(resData));
- if (res.data.code == "400") {
- console.error("400错误!");
- return;
- }
- if (res.data.code == "401") {
- console.error("401错误!");
- return;
- }
- homeApi_https = resData.loc;
- token = resData.token;
- },
- fail: function (error) {
- console.error('error', error);
- that.setData({
- isLoading: false,
- });
- }
- });
- },
- convertTimeToHoursAndMinutes: function (timeWithText, flag = 0) {
- if (!timeWithText) return;
- // 移除'分钟'两个字
- var minutesStr = timeWithText.replace('分钟', '');
- var minutes = parseInt(minutesStr); // 将字符串转换为整数
- if (isNaN(minutes)) {
- // 如果转换失败,则可能是输入的不是有效的数字
- console.error('Invalid minutes format');
- return;
- }
- var hours = Math.floor(minutes / 60); // 整除60得到小时数
- var remainingMinutes = minutes % 60; // 取余得到剩余的分钟数
- // 如果小时数或分钟数小于10,前面补0
- // var formattedHours = hours < 10 ? '0' + hours : hours;
- var formattedHours = hours;
- // var formattedMinutes = remainingMinutes < 10 ? '0' + remainingMinutes : remainingMinutes;
- var formattedMinutes = remainingMinutes;
- // 拼接小时和分钟,形成HH:mm格式
- var formattedTime = '';
- if (flag == 1) {
- formattedTime = formattedHours + 'H ' + formattedMinutes + 'M';
- } else if (flag == 2) {
- formattedTime = formattedHours + '{units|小时}' + formattedMinutes + '{units|分钟}';
- } else {
- formattedTime = {
- formattedHours,
- formattedMinutes
- };
- }
- // 更新数据
- // this.setData({
- // formattedTime: formattedTime
- // });
- return formattedTime;
- },
- getDateTimeJsonData: function (sn) {
- var that = this;
- var sourceFourthTemp = [];
- wx.request({
- url: `${aipushApi}/getdatefromsn`, //
- method: 'POST',
- // header: {
- // 'content-type': 'application/json', // 默认值
- // 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
- // },
- data: {
- "sn": sn, "token": token_push
- },
- success(res) {
- if (!res || !res.data || !res.data.results) {
- return;
- }
- var resDataSn = res.data.results
- // console.log('resDataSn====' + JSON.stringify(resDataSn))
- var tt = 0;
- resDataSn.forEach(function (item, index) {
- wx.request({
- url: `${aipushApi}/getimefromsn`, //
- method: 'POST',
- // header: {
- // 'content-type': 'application/json', // 默认值
- // 'Authorization': 'Bearer ' + token // 在头部设置认证信息,例如使用Bearer Token
- // },
- data: {
- "sn": sn, "date": item.rdate, "token": token_push
- },
- success(ress) {
- if (!ress || !ress.data || !ress.data.results) {
- return;
- }
- var resDataItem = ress.data.results;
- resDataItem.forEach(function (item_item, index) {
- item_item.text = item_item.durations;
- item_item.reportId = item_item.rpids;
- });
- var json = {};
- json.text = item.rdate;
- json.children = resDataItem;
- sourceFourthTemp.push(json);
- // console.log('sourceFourthTemp0=' + JSON.stringify(sourceFourthTemp));
- if (tt == (resDataSn.length - 1)) {
- // console.log('sourceFourthTemp=' + JSON.stringify(sourceFourthTemp));
- // 使用 sort 方法进行排序
- sourceFourthTemp.sort(function (a, b) {
- // 将字符串转换为 Date 对象
- let dateA = new Date(a.text);
- let dateB = new Date(b.text);
- if (dateA < dateB) {
- return 1;
- }
- if (dateA > dateB) {
- return -1;
- }
- // 如果日期相等,返回 0
- return 0;
- });
- // console.log('sourceFourthTemp1=' + JSON.stringify(sourceFourthTemp));
- //初始化弹出面板
- var array = that.data.arrayFourth;
- array[0] = sourceFourthTemp;
- array[1] = array[0][0].children;
- that.setData({
- valueFourth: [0, 0],
- sourceFourth: sourceFourthTemp,
- arrayFourth: array,
- })
- tt = 0;
- }
- tt++
- },
- fail: function (error) {
- console.error('error', error);
- }
- });
- });
- },
- fail: function (error) {
- console.error('error', error);
- },
- complete: function (e) {
- }
- });
- },
- // 在全局或者组件中定义函数
- fontSize: function (res) {
- const clientWidth = wx.getSystemInfoSync().windowWidth; // 获取屏幕宽度
- if (!clientWidth) return;
- let fontSize = clientWidth / 1920; // 假设以1920为基准宽度
- return res * fontSize;
- },
- calculateTheDurationOfDeepSleep() {
- var that = this;
- // var totalDuration = this.data.total_duration;
- // var timePeriod = this.data.rdt_arrNew;
- var sleepData = this.data.rsleep_arr;//睡眠状态数据集合,0-清醒,10-浅睡,20-中睡,30-深睡
- // console.log("睡眠总时长=>", totalDuration);
- // console.log("睡眠时间片段=>", timePeriod);
- // console.log("睡眠时间片段=>", timePeriod.length);
- // console.log("睡眠数据=>", sleepData);
- // console.log("睡眠数据=>", sleepData.length);
- var awakeColor = [{ offset: 0, color: '#F7E3BA' }, { offset: 1, color: '#F7E3BA' }];;
- var lightSleepColor = [{ offset: 0, color: '#AAD09F' }, { offset: 1, color: '#AAD09F' }];
- var sleptInColor = [{ offset: 0, color: '#75BDE0' }, { offset: 1, color: '#75BDE0' }];
- var deepSleepColor = [{ offset: 0, color: '#3D7299' }, { offset: 1, color: '#3D7299' }];
- // var linearGradient = new echarts.graphic.LinearGradient(
- // 0, 0, 0, 1, // 方向从左到右
- // [
- // { offset: 0, color: '#FDBE25' }, // 渐变开始的颜色
- // { offset: 1, color: '#FD7778' } // 渐变结束的颜色
- // ]
- // );
- // var item = {
- // name: { name: '清醒', color: '#7b9ce1' },
- // value: [index, baseTime, (baseTime += duration), duration],
- // itemStyle: {
- // normal: {
- // color: linearGradient,
- // }
- // }
- // };
- // var sleepData = ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "0", "0", "0", "0", "0", "0", "0", "0", "0", "10", "10", "10", "10", "10", "10", "10", "20", "20", "20", "20", "20", "20", "20", "20", "30", "30", "30", "30", "30", "30", "30", "30", "30"];//睡眠状态数据集合,0-清醒,10-浅睡,20-中睡,30-深睡
- // 状态映射
- const statusMap = {
- "0": "清醒",
- "10": "浅睡",
- "20": "中睡",
- "30": "深睡"
- };
- // 状态映射
- const statusColorMap = {
- "20": awakeColor,
- "0": lightSleepColor,
- "10": sleptInColor,
- "30": deepSleepColor
- };
- // 状态映射
- const statusIndexMap = {
- "20": 3,
- "0": 2,
- "10": 1,
- "30": 0
- };
- // 初始化变量 reportDate
- // let dateString = '2024/09/14 23:20:00';
- let dateString = `${that.data.reportDate.replaceAll("-", "/")} ${that.data.rgobed_time + ":00"}`;
- let date = new Date(dateString);
- let startTime = date.getTime(); // 基准时间,这里设为午夜开始
- console.log("时间=》", timestampToHHMM(startTime));
- let currentTime = startTime;
- let currentState = sleepData[0];
- let timePeriods = [];
- // 遍历睡眠数据数组
- for (let i = 0; i < sleepData.length; i++) {
- // 如果当前状态与前一个状态不同,则记录前一个时间段
- if (i > 0 && sleepData[i] !== sleepData[i - 1]) {
- // 计算前一个时间段的结束时间(注意这里不需要减去一分钟,因为 currentTime 还未递增)
- let endTime = currentTime;
- // 计算前一个时间段的持续时间(分钟)
- let duration = Math.floor((endTime - startTime) / (1000 * 60));
- // 记录时间段
- if (duration > 0) {
- var linearGradient = new echarts.graphic.LinearGradient(
- 0, 0, 0, 1, // 方向从左到右
- statusColorMap[sleepData[i - 1]]
- );
- timePeriods.push({
- name: statusMap[sleepData[i - 1]],// 使用前一个状态
- value: [statusIndexMap[sleepData[i - 1]], startTime, endTime, duration],
- itemStyle: {
- normal: {
- color: linearGradient,
- }
- },
- // startTime: new Date(startTime), // 转换为 Date 对象以便更易于阅读
- // endTime: new Date(endTime),
- // durationMinutes: duration
- });
- }
- // 更新当前状态和开始时间
- currentState = sleepData[i];
- startTime = currentTime;
- }
- // 递增时间(每分钟)
- currentTime += 1000 * 60;
- // 处理最后一个时间段(如果数组不是以状态变化结束的话)
- if (i === sleepData.length - 1) {
- let endTime = currentTime;
- let duration = Math.floor((endTime - startTime) / (1000 * 60));
- if (duration > 0) {
- var linearGradient = new echarts.graphic.LinearGradient(
- 0, 0, 0, 1, // 方向从左到右
- statusColorMap[currentState]
- );
- timePeriods.push({
- name: statusMap[currentState],// 使用前一个状态
- value: [statusIndexMap[currentState], startTime, endTime, duration],
- itemStyle: {
- normal: {
- color: linearGradient,
- }
- },
- // startTime: new Date(startTime), // 转换为 Date 对象以便更易于阅读
- // endTime: new Date(endTime),
- // durationMinutes: duration
- });
- }
- }
- }
- updateTimeWaterfall(startTime, timePeriods, that)
- // console.log("睡眠数据最终=>", dateString);
- // console.log("睡眠数据最终=>", startTime);
- console.log("睡眠数据最终=>", JSON.stringify(timePeriods));
- },
- authorizationSuccessful() {
- console.log("授权成功");
- this.setData({ showAuthorizedDialog: false })
- this.showData();
- },
- onReady() {
- if (!wx.getStorageSync('hasAuth')) {
- this.setData({ showAuthorizedDialog: true })
- } else {
- this.showData();
- }
- },
- showData() {
- let hotelcodeTemp = wx.getStorageSync("hotelEmpower");
- let roomcodeTemp = wx.getStorageSync("roomEmpower");
- // hotelcodeTemp = wx.getStorageSync('res').result.split('|')[0];
- // roomcodeTemp = wx.getStorageSync('res').result.split('|')[1];
- this.getData(null, hotelcodeTemp, roomcodeTemp, this.data.reportId);
- // 设置canvas的宽高
- this.setData({
- hotelcode: hotelcodeTemp,
- roomcode: roomcodeTemp,
- });
- this.initChartCircle(this.data.reportId);
- this.initOutOfBed(this.data.reportId);
- this.initBodyMovements(this.data.reportId);
- this.initCardiacSystem(this.data.reportId);
- this.initChartRespiratory(this.data.reportId);
- this.initChartSnoring(this.data.reportId);
- this.initChartApnea(this.data.reportId);
- this.initTimeWaterfall(this.data.reportId);
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onShow: function () {
- var that = this;
- console.log("that.data.month + 1", that.data.month + 1)
- var clickDate = String(that.data.year) + String(that.data.month) + String(that.data.date)
- clickDate = String(parseInt(clickDate) + 100)
- // that.getTargetData(clickDate)
- that.setData({
- clickDate: clickDate,
- });
- },
- onLoad(options) {
- var that = this;
- if (options.rpids) {
- that.setData({
- reportId: options.rpids
- })
- }
- // var that = this;
- // console.log("data页面");
- // wx.clearStorage();
- // console.log('option.res=' + JSON.stringify(wx.getStorageSync('res')));
- // if (!wx.getStorageSync('res') || !wx.getStorageSync('res').result) {
- // wx.showModal({
- // title: '提示',
- // content: '请先扫描房间二维码',
- // showCancel: false
- // });
- // setTimeout(function () {
- // wx.reLaunch({
- // url: '/pages/scan/scan',
- // })
- // }, 2000) // 设置延时时间,单位为毫秒
- // }
- // else if (wx.getStorageSync('res').result.split('|').length != 2) {
- // wx.showModal({
- // title: '提示',
- // content: '房间二维码不正确,请重新扫码',
- // showCancel: false
- // });
- // setTimeout(function () {
- // wx.reLaunch({
- // url: '/pages/scan/scan',
- // })
- // }, 2000) // 设置延时时间,单位为毫秒
- // }
- // else if(!this.data.home_room.includes(wx.getStorageSync('res').result)){
- // wx.showModal({
- // title: '提示',
- // content: '房间二维码不正确,请重新扫描',
- // showCancel: false
- // });
- // setTimeout(function() {
- // wx.reLaunch({
- // url: '/pages/scan/scan',
- // })
- // }, 2000) // 设置延时时间,单位为毫秒
- // }
- // else if(this.data.home_room.includes(wx.getStorageSync('res').result) && wx.getStorageSync('res').result.includes('辰悦颐养斋')){
- // else if(wx.getStorageSync('res').result.includes('辰悦颐养斋')){
- // homeApi = "http://zhh.aidsleep.cn";
- // homeApi_http = "http://zhh.aidsleep.cn";
- // homeApi_http_port = "9123";
- // homeApi_https = "https://zhh.aidsleep.cn";
- // }
- // this.drawCircle();
- },
- mounted() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- // wx.clearStorage();
- // this.clearInterval();
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- // wx.clearStorage();
- // this.clearInterval();
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|