"use strict";(wx["webpackJsonp"]=wx["webpackJsonp"]||[]).push([[420],{4513:function(e,n,o){var s=o(8774),r=o(2688),a=o(5861),t=o(9439),c=o(7294),i=o(1515),l=o(2954),_=o.n(l),m={roomsPage:"index-module__roomsPage___a4jYP",roomList:"index-module__roomList___b33tH",roomCard:"index-module__roomCard___uSnYu",roomCardHeader:"index-module__roomCardHeader___q6uUs",roomNameRow:"index-module__roomNameRow___eH_Px",roomIcon:"index-module__roomIcon___GMrrO",roomName:"index-module__roomName___nvw31",roomStatus:"index-module__roomStatus___XkgPS",statusActive:"index-module__statusActive___Th1f7",statusAlarm:"index-module__statusAlarm___gTw3t",statusMaintenance:"index-module__statusMaintenance___KenKf",statusInactive:"index-module__statusInactive___TlDAO",roomInfo:"index-module__roomInfo___sxqsW",infoItem:"index-module__infoItem___lbZHf",infoIcon:"index-module__infoIcon___s0C9V",infoText:"index-module__infoText___Bqg63",roomDesc:"index-module__roomDesc___Xe2aE",roomCode:"index-module__roomCode___Jo17s",loadingWrap:"index-module__loadingWrap___GhtDa",loadingText:"index-module__loadingText___pc6DM",errorWrap:"index-module__errorWrap___Bps4U",errorIcon:"index-module__errorIcon___LOvxH",errorText:"index-module__errorText___CKzHr",retryBtn:"index-module__retryBtn___PTNG1",emptyWrap:"index-module__emptyWrap___al9PY",emptyIcon:"index-module__emptyIcon___utdxE",emptyText:"index-module__emptyText___DX9m7"},d=o(5387),u=o(5487),x=o(195),f=o(151),h=o(5893),v=function(){var e=(0,c.useState)([]),n=(0,t.Z)(e,2),o=n[0],s=n[1],v=(0,c.useState)([]),N=(0,t.Z)(v,2),p=N[0],j=N[1],g=(0,c.useState)([]),I=(0,t.Z)(g,2),T=I[0],G=I[1],y=(0,c.useState)(!0),w=(0,t.Z)(y,2),P=w[0],C=w[1],S=(0,c.useState)(""),b=(0,t.Z)(S,2),D=b[0],W=b[1],Z=(0,c.useCallback)((0,a.Z)((0,r.Z)().m(function e(){var n,o,a,c,i,l;return(0,r.Z)().w(function(e){while(1)switch(e.p=e.n){case 0:return e.p=0,W(""),e.n=1,Promise.all([(0,d.A)().catch(function(){return[]}),(0,u.PW)().catch(function(){return[]}),(0,x.uA)({openOnly:!0}).catch(function(){return[]})]);case 1:n=e.v,o=(0,t.Z)(n,3),a=o[0],c=o[1],i=o[2],s(a),j(c),G(i),e.n=3;break;case 2:e.p=2,l=e.v,console.error("[Rooms] \u6570\u636e\u52a0\u8f7d\u5931\u8d25:",l),W(l instanceof Error?l.message:"\u6570\u636e\u52a0\u8f7d\u5931\u8d25");case 3:return e.p=3,C(!1),e.f(3);case 4:return e.a(2)}},e,null,[[0,2,3,4]])})),[]);(0,c.useEffect)(function(){Z()},[Z]),(0,l.useDidShow)(function(){o.length>0&&Z()}),(0,l.usePullDownRefresh)(function(){Z().then(function(){return _().stopPullDownRefresh()})});var A=function(e){_().navigateTo({url:"/pages/rooms/detail/index?id=".concat(e)})},H=function(e){switch(e){case"active":return m.statusActive;case"alarm":return m.statusAlarm;case"maintenance":return m.statusMaintenance;default:return m.statusInactive}};return P?(0,h.jsx)(i.G7,{className:m.roomsPage,children:(0,h.jsx)(i.G7,{className:m.loadingWrap,children:(0,h.jsx)(i.xv,{className:m.loadingText,children:"\u52a0\u8f7d\u4e2d..."})})}):D?(0,h.jsx)(i.G7,{className:m.roomsPage,children:(0,h.jsxs)(i.G7,{className:m.errorWrap,children:[(0,h.jsx)(i.xv,{className:m.errorIcon,children:"\u26a0\ufe0f"}),(0,h.jsx)(i.xv,{className:m.errorText,children:D}),(0,h.jsx)(i.G7,{className:m.retryBtn,onClick:Z,children:(0,h.jsx)(i.xv,{style:{color:"#fff"},children:"\u91cd\u8bd5"})})]})}):0===o.length?(0,h.jsx)(i.G7,{className:m.roomsPage,children:(0,h.jsxs)(i.G7,{className:m.emptyWrap,children:[(0,h.jsx)(i.xv,{className:m.emptyIcon,children:"\ud83c\udfe0"}),(0,h.jsx)(i.xv,{className:m.emptyText,children:"\u6682\u65e0\u8695\u623f\u6570\u636e"})]})}):(0,h.jsx)(i.G7,{className:m.roomsPage,children:(0,h.jsx)(i.G7,{className:m.roomList,children:o.map(function(e){var n=p.filter(function(n){return n.roomId===e.id}),o=n.filter(function(e){return"online"===e.onlineStatus}).length,s=T.filter(function(e){return e.deviceKey&&n.some(function(n){return n.deviceKey===e.deviceKey})});return(0,h.jsxs)(i.G7,{className:m.roomCard,onClick:function(){return A(e.id)},children:[(0,h.jsxs)(i.G7,{className:m.roomCardHeader,children:[(0,h.jsxs)(i.G7,{className:m.roomNameRow,children:[(0,h.jsx)(i.xv,{className:m.roomIcon,children:"\ud83c\udfe0"}),(0,h.jsx)(i.xv,{className:m.roomName,children:e.name})]}),(0,h.jsx)(i.G7,{className:"".concat(m.roomStatus," ").concat(H(e.status)),children:(0,f.rZ)(e.status)})]}),(0,h.jsxs)(i.G7,{className:m.roomInfo,children:[(0,h.jsxs)(i.G7,{className:m.infoItem,children:[(0,h.jsx)(i.xv,{className:m.infoIcon,children:"\ud83d\udce1"}),(0,h.jsxs)(i.xv,{className:m.infoText,children:["\u8bbe\u5907 ",o,"/",n.length]})]}),s.length>0&&(0,h.jsxs)(i.G7,{className:m.infoItem,children:[(0,h.jsx)(i.xv,{className:m.infoIcon,children:"\ud83d\udd14"}),(0,h.jsxs)(i.xv,{className:m.infoText,style:{color:"#f53f3f"},children:["\u544a\u8b66 ",s.length]})]}),e.location&&(0,h.jsxs)(i.G7,{className:m.infoItem,children:[(0,h.jsx)(i.xv,{className:m.infoIcon,children:"\ud83d\udccd"}),(0,h.jsx)(i.xv,{className:m.infoText,children:e.location})]})]}),e.description&&(0,h.jsx)(i.xv,{className:m.roomDesc,children:e.description}),e.code&&(0,h.jsxs)(i.xv,{className:m.roomCode,children:["\u7f16\u7801: ",e.code]})]},e.id)})})})},N=v,p={navigationBarTitleText:"\u8695\u623f",enablePullDownRefresh:!0},j=(0,s.R4)(N,"pages/rooms/index",{root:{cn:[]}},p||{});N&&N.behaviors&&(j.behaviors=(j.behaviors||[]).concat(N.behaviors));Page(j)}},function(e){var n=function(n){return e(e.s=n)};e.O(0,[107,216,592],function(){return n(4513)});e.O()}]);