emergencyEvacuationBig.vue 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064
  1. <!-- 应急疏散 -->
  2. <template>
  3. <view id="emergencyEvacuationBig">
  4. <view class="setUpEvacuation" v-if="pageType == 1">
  5. <view class="evacuation-max-box">
  6. <view class="picker-max-box">
  7. <view class="picker-title-box">
  8. <view></view>
  9. <view>学院楼栋</view>
  10. </view>
  11. <picker @change="buildingChange" :range-key="'name'" :value="id" :range="buildingList">
  12. <view class="picker-min-box">
  13. <view>{{buildingName?buildingName:'请选择学院楼栋'}}</view>
  14. <img src="@/images/icon_06.png">
  15. </view>
  16. </picker>
  17. </view>
  18. <view class="picker-max-box">
  19. <view class="picker-title-box">
  20. <view></view>
  21. <view>楼层</view>
  22. </view>
  23. <picker @change="floorChange" :disabled="!buildingId" :range-key="'name'" :value="id"
  24. :range="floorList">
  25. <view class="picker-min-box">
  26. <view>{{floorName?floorName:'请选择楼层'}}</view>
  27. <img src="@/images/icon_06.png">
  28. </view>
  29. </picker>
  30. </view>
  31. <view class="picker-max-box">
  32. <view class="picker-title-box">
  33. <view></view>
  34. <view>实验室</view>
  35. </view>
  36. <picker @change="fjListChange" :disabled="!floorId" :range-key="'subName'" :value="subId"
  37. :range="fjListArray">
  38. <view class="picker-min-box">
  39. <view>{{subName?subName:'请选择实验室'}}</view>
  40. <img src="@/images/icon_06.png">
  41. </view>
  42. </picker>
  43. </view>
  44. </view>
  45. <view class="setUpEvacuation-bottom-button" @click="confirmBtn">确认</view>
  46. </view>
  47. <view class="implementEvacuation" v-if="pageType == 2">
  48. <view class="evacuation-max-box">
  49. <!-- 头部 -->
  50. <view class="evacuation-title-box">
  51. <view class="evacuation-title-name-box">{{subName}}</view>
  52. <view class="site"><img src="@/images/icon_14.png">{{address}}</view>
  53. </view>
  54. <!-- 地图部分 -->
  55. <view class="roadmap">
  56. <view class="roadmap_t">
  57. <view class="monito_li_r_l"></view>
  58. <view class="monito_li_r_r_button" @click="goAllPage">全屏</view>
  59. </view>
  60. <view class="evacuation-map-box">
  61. <view class="emergencyEvacuationBigFullScreen-page" v-if="mapType"
  62. :style="'width:'+mapWidth+'rpx;height:'+mapHeight+'rpx;transform: scale('+zoomData+');margin-top:-'+mapHeight/2+'rpx;margin-left:-'+mapWidth/2+'rpx;'">
  63. <view class="map-max-box" :style="'width:'+mapWidth+'rpx;height:'+mapHeight+'rpx;'">
  64. <view class="map-max-for-box for-map-box" v-if="item.type == 1"
  65. v-for="(item,index) in mapList":key="index"
  66. :class="!item.policeType && checkSubId ==item.subId ? 'room-type-one':(
  67. item.policeType && checkSubId !=item.subId ? 'room-type-two':(
  68. item.policeType && checkSubId ==item.subId ? 'room-type-three':(
  69. !item.loginAdmin ? 'room-type-noe':'')))"
  70. :style="'top:'+item.y+'rpx;left:'+item.x+'rpx;width:'+(item.w-4)+'rpx;height:'+(item.h-4)+'rpx;'">
  71. <view class="map-max-for-min-box">
  72. <view class="map-for-name-p" :style="'margin-top:'+((item.h/2)-20)+'rpx;'">
  73. {{item.roomType == '-99'?item.roomName:item.subName}}</view>
  74. <view class="map-for-num-p">({{item.roomNum}})</view>
  75. <view class="position-box" src="@/images/evacuation3_2/icon_sysbjt_m.png"
  76. :class="minItem.toward=='top'?'center-move-door-p-t':(minItem.toward=='bottom'?'center-move-door-p-b':(minItem.toward=='left'?'center-move-door-p-l':(minItem.toward=='right'?'center-move-door-p-r':'')))"
  77. v-for="(minItem,minIndex) in item.doorList" :key="minIndex"
  78. :style="'top:'+minItem.y+'rpx;left:'+minItem.x+'rpx;width:'+minItem.w+'rpx;height:'+minItem.h+'rpx;'">
  79. </view>
  80. </view>
  81. </view>
  82. <view class="map-max-for-box for-map-box-one" v-if="item.type == 2" v-for="(item,index) in mapList"
  83. :key="index" :style="'top:'+item.y+'rpx;left:'+item.x+'rpx;width:'+item.w+'rpx;height:'+item.h+'rpx;'">
  84. <view class="map-max-for-min-box">
  85. <view class="position-box"
  86. :class="minItem.state=='1'&&minItem.openType?'lightTopOn':(minItem.state=='1'&&!minItem.openType?'lightTopOff':
  87. (minItem.state=='2'&&minItem.openType?'lightBottomOn':(minItem.state=='2'&&!minItem.openType?'lightBottomOff':
  88. (minItem.state=='3'&&minItem.openType?'lightLeftOn':(minItem.state=='3'&&!minItem.openType?'lightLeftOff':
  89. (minItem.state=='4'&&minItem.openType?'lightRightOn':(minItem.state=='4'&&!minItem.openType?'lightRightOff':'')))))))"
  90. v-for="(minItem,minIndex) in item.lightList" :key="minIndex"
  91. :style="'top:'+minItem.y+'rpx;left:'+minItem.x+'rpx;width:'+minItem.w+'rpx;height:'+minItem.h+'rpx;'">
  92. </view>
  93. </view>
  94. </view>
  95. <view class="map-max-for-box for-map-box-two" v-if="item.type == 3" v-for="(item,index) in mapList"
  96. :key="index" :class="item.roomCheckType?'for-map-box-two-check':''"
  97. :style="'top:'+item.y+'rpx;left:'+item.x+'rpx;width:'+item.w+'rpx;height:'+item.h+'rpx;'">
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. <!-- 一键灭火 -->
  104. <view class="outfire" v-if='fireType'>
  105. <view class="outfire_li" v-if="!fireListType">
  106. <img src="@/images/icon_sy_wt.png">
  107. <text style="color: #FF7B1A;">设备已离线,请及时处理。</text>
  108. </view>
  109. <view class="outfire_li" v-if="fireStartType">
  110. <img src="@/images/icon_sy_mhwc.png">
  111. <text style="color: #FF2333;">灭火中,灭火程序将于<text>{{conductCountdown}}</text>秒后结束</text>
  112. </view>
  113. <view class="outfire_li" v-if="outfireEnd">
  114. <img src="@/images/icon_sy_mhwc.png">
  115. <text style="color: #FF2333;">灭火完成,请您及时补充灭火设备耗材</text>
  116. </view>
  117. <template v-if="fireListType">
  118. <view class="outfire_li">
  119. <img v-if='!outfireData.smoke' src="@/images/icon_yw_zc.png">
  120. <img v-if='outfireData.smoke' src="@/images/icon_yw_yc.png">
  121. <text
  122. :class="outfireData.smoke?'abnormal':'normal'">{{outfireData.smoke?'有烟雾':'无烟雾'}}</text>
  123. </view>
  124. <view class="outfire_li">
  125. <img v-if='!outfireData.temperature' src="@/images/icon_wd_zc.png">
  126. <img v-if='outfireData.temperature' src="@/images/icon_wd_yc.png">
  127. <text
  128. :class="outfireData.temperature?'abnormal':'normal'">{{outfireData.temperature?'温度异常':'温度正常'}}</text>
  129. </view>
  130. <view class="outfire_li">
  131. <img v-if='!outfireData.fire' src="@/images/icon_hy_zc.png">
  132. <img v-if='outfireData.fire' src="@/images/icon_hy_yc.png">
  133. <text :class="outfireData.fire?'abnormal':'normal'">{{outfireData.fire?'发现火焰':'无火焰'}}</text>
  134. </view>
  135. </template>
  136. <view v-if="fireListType"
  137. :class="fireListType?'outfire_yes_btn':'outfire_no_btn'" @click="outfireFun()">一键灭火
  138. </view>
  139. </view>
  140. <!-- 视频部分 -->
  141. <view class="video-max-box" v-if="urlList[0]">
  142. <video v-for="(item,index) in urlList" :key="index" :id="urlList.id" :src="item.url"
  143. :poster="videoCover" :custom-cache='false' :autoplay="true" :controls="true"
  144. :enable-danmu="false" :muted="true" :show-fullscreen-btn="true" :show-center-play-btn="false"
  145. :show-play-btn="false" @error="videoErrorCallback">
  146. </video>
  147. </view>
  148. <view class="bottom-button-box">
  149. <view @click="shadeTypeClick()">语音广播</view>
  150. <view @click="evacuationButton(1)" v-if="isEvacuate">执行疏散</view>
  151. <view @click="evacuationButton(2)" v-if="!isEvacuate">结束疏散</view>
  152. </view>
  153. </view>
  154. <!-- 语音广播-->
  155. <view class="shade-max-big-box" v-if="broadcastType">
  156. <view class="null-box" @click="shadeTypeClick()"></view>
  157. <!-- 语音广播-执行疏散 -->
  158. <view class="broadcast">
  159. <view class="broadcast_t">语音广播<label>选择喇叭位置</label></view>
  160. <!-- 按钮部分 -->
  161. <view class="trumpet-max-box">
  162. <view @click="trumpetClick(index)" class="trumpet-for-box"
  163. :class="item.type?'trumpet-color-a':'trumpet-color-b'" v-for="(item,index) in trumpetList"
  164. :key="index">
  165. <img src="@/images/icon_sskz_zc.png" v-if="!item.type">
  166. <img src="@/images/icon_sskz_xz.png" v-if="item.type">
  167. {{item.name}}
  168. </view>
  169. </view>
  170. <view class="broadcast_m">
  171. <view class="broadcast_m_t" :class="liveType?'broadcast_m_t_back_a':'broadcast_m_t_back_b'"
  172. @longpress.stop="recordButton" @touchmove.stop="cancelButton" @touchend.stop="sendButton">
  173. {{liveType?'松开发送':'按住说话'}}
  174. </view>
  175. <view class="broadcast_m_b" v-if="!liveType">按住说话,录入广播内容</view>
  176. <view class="broadcast_m_b" v-if="liveType">松开发送,向上滑动取消发送</view>
  177. </view>
  178. </view>
  179. </view>
  180. <!-- 一键灭火遮罩-->
  181. <view class="shade-outfire" v-if="dialogVisible">
  182. <view class="null-box" @click="dialogOutfire()"></view>
  183. <view class="shade-outfire-n">
  184. <img class="shade-outfire-n-t" src="@/images/icon_mh.png" />
  185. <view class="shade-outfire-n-m">一键灭火启动中,倒计时<text>{{countdown}}</text>秒</view>
  186. <view class="shade-outfire-n-b" @click="cancelOutfire()">放弃一键灭火</view>
  187. </view>
  188. </view>
  189. </view>
  190. <view></view>
  191. </view>
  192. </template>
  193. <script>
  194. import $mqtt from '@/utils/mqtt.min.js';
  195. import {
  196. config
  197. } from '@/api/request/config.js'
  198. import {
  199. lablayout,
  200. evacuate,
  201. closure,
  202. lineEvacuate,
  203. getRedis,
  204. getDeviceList,
  205. textParseUrlIps,
  206. laboratoryInfo,
  207. getCameraByFloor,
  208. lineEvacuateTow,
  209. treeselectByUser,
  210. getBuilding,
  211. getDeviceListBySub,
  212. GetStartList,
  213. firedeviceStatus,
  214. firedeviceStatusTiming,
  215. firedeviceStart,
  216. firedeviceCancel
  217. } from '@/api/index.js'
  218. import {
  219. getBuildOrFloorList,
  220. getFloorData,
  221. getRedisEvacuation,
  222. openLight,
  223. closeLight,
  224. executeEvacuation,
  225. endEvacuation
  226. } from '@/api/index.js'
  227. export default {
  228. data() {
  229. return {
  230. videoCover: uni.getStorageSync('videoCover'),
  231. //页面状态
  232. pageType: "1",
  233. deptIndex: 0,
  234. //院系楼栋数据
  235. buildingList: [],
  236. buildingName: "",
  237. buildingId: "",
  238. //楼层数据
  239. floorList: [],
  240. floorName: "",
  241. floorId: "",
  242. //实验室
  243. fjListArray: [],
  244. //疏散方向
  245. buttonArray: [{
  246. name: "向左疏散",
  247. id: "1"
  248. },
  249. {
  250. name: "向右疏散",
  251. id: "2"
  252. },
  253. {
  254. name: "两侧疏散",
  255. id: "0"
  256. },
  257. ],
  258. buttonArrayIndex: "2",
  259. //视频数据
  260. urlList: [],
  261. //布局数据
  262. fjList: [],
  263. lightList: [{
  264. id: "5",
  265. type: false,
  266. },
  267. {
  268. id: "2",
  269. type: false,
  270. },
  271. {
  272. id: "3",
  273. type: false,
  274. },
  275. {
  276. id: "4",
  277. type: false,
  278. },
  279. {
  280. id: "1",
  281. type: false,
  282. },
  283. {
  284. id: "6",
  285. type: false,
  286. },
  287. ],
  288. //接收参数
  289. subId: "",
  290. subName: "",
  291. title: "",
  292. type: "",
  293. //喇叭数据
  294. trumpetList: [],
  295. //广播相关
  296. liveType: false,
  297. sendLock: true, //发送锁,当为true时上锁,false时解锁发送
  298. recorderManager: wx.getRecorderManager(),
  299. isEvacuate: true, //疏散按钮控制,当为true时候执行疏散
  300. //滑动记录
  301. startPoint: {},
  302. //摄像头信息
  303. deptId: '',
  304. itemData: {
  305. hardwareNUM: '',
  306. name: '',
  307. },
  308. broadcastType: false,
  309. address: "",
  310. videoHardwareNUM: [], //实验室和楼道摄像头编码
  311. countdown: '', //倒计时
  312. timer2: null, //倒计时
  313. dialogVisible: false, //一键灭火弹出层
  314. conductCountdown: '',
  315. timer3: null, //倒计时
  316. outfireEnd: false, //灭火结束状态
  317. //新布局地图相关数据
  318. zoomData: null,
  319. mapType:false,
  320. mapList: [],
  321. mapWidth: null, //40边框距离
  322. mapHeight: null, //40边框距离
  323. //新MQTT
  324. floorClient: {},
  325. evacuationTopic: "lab/newexit/line", //疏散
  326. //灭火设备MQTT相关
  327. fireClient:{},
  328. fireTopic:"lab/fireDevice/Warn",//传感器状态异常
  329. fireOnlineTopic:"lab/fireDevice/isOnline",//设备是否在线
  330. firePerformTopic:"lab/fireDevice/executing",//是否正在执行灭火操作
  331. fireType:false,//有无火焰设备状态
  332. fireListType:false,//灭火设备在线离线
  333. fireCode:null,// //灭火设备code
  334. fireStartType:false, //灭火启动状态
  335. outfireData: {}, //一键灭火
  336. }
  337. },
  338. onLoad(option) {
  339. this.treeselectByUser();
  340. //一键灭火正式使用需要注销
  341. // this.itemData.subjectId=85
  342. // this.firedeviceStatus();
  343. },
  344. onShow() {
  345. },
  346. onUnload() {
  347. },
  348. methods: {
  349. //全屏疏散页面
  350. goAllPage() {
  351. let obj = {
  352. buildingId:this.buildingId,
  353. floorId:this.floorId
  354. }
  355. uni.navigateTo({
  356. url: '/pages/emergencyEvacuationBigFullScreen?item='+encodeURIComponent(JSON.stringify(obj)),
  357. });
  358. },
  359. //一键灭火-查询设备状态
  360. async firedeviceStatus() {
  361. let _this = this;
  362. const {data} = await firedeviceStatus(_this.itemData.subjectId)
  363. if (data.code == 200) {
  364. if(data.data.isexist){//是否有灭火设备
  365. this.$set(this,'fireType',data.data.isexist);
  366. if(data.data.online){
  367. _this.outfireData = data.data
  368. _this.$set(this,'fireListType',data.data.online);
  369. _this.$set(this,'fireCode',data.data.fireDevice.deviceCode);
  370. _this.offMQTT('on');
  371. if(data.data.temperature && data.data.smoke){
  372. if(!this.fireStartType){
  373. this.$set(this,'fireStartType',true);
  374. this.$set(this,'fireListType',false);
  375. this.sendCode2(data.data.timeDifference);
  376. }
  377. }
  378. }else{
  379. this.$set(this,'fireListType',false);
  380. this.$set(this,'fireCode',null);
  381. this.offMQTT('on');
  382. }
  383. }else{
  384. this.$set(this,'fireType',false);
  385. this.offMQTT('on');
  386. }
  387. }
  388. },
  389. //启动灭火设备
  390. async firedeviceStart() {
  391. let _this = this;
  392. let obj={
  393. subjectId:_this.itemData.subjectId,
  394. deviceCode:_this.fireCode
  395. }
  396. const {data} = await firedeviceStart(obj)
  397. if (data.code == 200) {
  398. if (data.data.online) {
  399. _this.dialogVisible = true;
  400. _this.countdown = data.data.waitTime;//灭火倒计时
  401. _this.sendCode() //倒计时
  402. } else {
  403. wx.showToast({
  404. title: '一键灭火启动失败!',
  405. icon: "none",
  406. duration: 6000
  407. });
  408. }
  409. }
  410. },
  411. //取消灭火设备
  412. async firedeviceCancel() {
  413. let _this = this;
  414. const {data} = await firedeviceCancel(_this.itemData.subjectId)
  415. if (data.code == 200) {
  416. wx.showToast({
  417. title: '放弃一键灭火失败!',
  418. icon: "none",
  419. duration: 6000
  420. });
  421. }
  422. },
  423. //一键灭火按钮
  424. outfireFun() {
  425. let _this = this;
  426. uni.showModal({
  427. title: "是否确认执行一键灭火?",
  428. content: '该操作存在风险,请您务必确认实验室内人员已安全撤离?',
  429. cancelColor: "#999",
  430. confirmColor: "#0183FA",
  431. success: function(res) {
  432. if (res.confirm) {
  433. console.log('用户点击确定');
  434. _this.firedeviceStart(); //启动灭火设备
  435. } else if (res.cancel) {
  436. console.log('用户点击取消');
  437. }
  438. }
  439. });
  440. },
  441. //一键灭火弹出层关闭
  442. dialogOutfire() {
  443. this.dialogVisible = !this.dialogVisible
  444. this.clearTimer(); //关闭定时器
  445. },
  446. //取消一键灭火
  447. cancelOutfire() {
  448. this.dialogVisible = false;
  449. this.clearTimer(); //关闭定时器
  450. this.firedeviceCancel()
  451. },
  452. //倒计时
  453. sendCode() {
  454. let _this = this;
  455. _this.loading(); //启动定时器
  456. _this.timer2 = setInterval(() => {
  457. //创建定时器
  458. if (_this.countdown === 1) {
  459. _this.clearTimer(); //关闭定时器
  460. } else {
  461. _this.loading();
  462. }
  463. }, 1000);
  464. },
  465. loading() {
  466. //启动定时器
  467. this.countdown--; //定时器减1
  468. },
  469. clearTimer() {
  470. //清除定时器
  471. clearInterval(this.timer2);
  472. this.timer2 = null;
  473. this.dialogVisible = false;
  474. this.countdown = 6;
  475. },
  476. //进行中倒计时
  477. sendCode2(time) {
  478. let _this = this;
  479. _this.$set(self,'conductCountdown',time);
  480. _this.loading2(); //启动定时器
  481. _this.timer3 = setInterval(() => {
  482. //创建定时器
  483. if (_this.conductCountdown === 1) {
  484. _this.clearTimer2(); //关闭定时器
  485. _this.outfireEnd = true; //灭火倒计时结束
  486. } else {
  487. _this.loading2();
  488. }
  489. }, 1000);
  490. },
  491. loading2() {
  492. //启动定时器
  493. this.conductCountdown--; //定时器减1
  494. },
  495. clearTimer2() {
  496. //清除定时器
  497. clearInterval(this.timer3);
  498. this.timer3 = null;
  499. },
  500. //获取楼栋数据
  501. async treeselectByUser(option) {
  502. const { data } = await getBuildOrFloorList({type:2,parentId:''})
  503. this.$set(this, 'buildingList', data.data);
  504. this.$set(this, 'buildingName', "");
  505. this.$set(this, 'buildingId', "");
  506. this.$set(this, 'deptId', "");
  507. this.$set(this, 'floorList', []);
  508. this.$set(this, 'floorName', "");
  509. this.$set(this, 'floorId', "");
  510. this.$set(this, 'fjListArray', []);
  511. this.$set(this, 'subName', "");
  512. this.$set(this, 'subId', "");
  513. },
  514. //获取楼层数据
  515. async getBuilding(buildingId) {
  516. const { data } = await getBuildOrFloorList({type:3,parentId:buildingId})
  517. this.$set(this, 'floorList', data.data);
  518. this.$set(this, 'floorName', "");
  519. this.$set(this, 'floorId', "");
  520. this.$set(this, 'fjListArray', []);
  521. this.$set(this, 'subName', "");
  522. this.$set(this, 'subId', "");
  523. },
  524. //楼栋选中
  525. buildingChange(e) {
  526. this.$set(this, 'buildingName', this.buildingList[e.detail.value].name);
  527. this.$set(this, 'buildingId', this.buildingList[e.detail.value].id);
  528. this.$set(this, 'deptId', this.buildingList[e.detail.value].id);
  529. this.getBuilding(this.buildingList[e.detail.value].id);
  530. },
  531. //楼层选中
  532. floorChange(e) {
  533. this.$set(this, 'floorName', this.floorList[e.detail.value].name);
  534. this.$set(this, 'floorId', this.floorList[e.detail.value].id);
  535. this.getBuildingData();
  536. },
  537. //实验室选择
  538. fjListChange(e) {
  539. this.$set(this, 'subName', this.fjListArray[e.detail.value].subName);
  540. this.$set(this, 'subId', this.fjListArray[e.detail.value].subId);
  541. this.$set(this.itemData, 'subjectId', this.fjListArray[e.detail.value].subId);
  542. },
  543. getAppExitLine() {
  544. let list = [{
  545. type: "lab/exit/line"
  546. }, {
  547. type: "lab/fireDevice/Warn/"
  548. }];
  549. getApp().appMqttOn(1, list);
  550. },
  551. getAppOutfire() {
  552. // let list = [{type:"lab/fireDevice/Warn/"}]
  553. let list = [{
  554. type: "lab/function/data"
  555. }];
  556. getApp().appMqttOn(1, list);
  557. },
  558. shadeTypeClick() {
  559. this.broadcastType = !this.broadcastType
  560. },
  561. //获取实验室摄像头
  562. async laboratoryInfo() {
  563. let _this = this;
  564. const {
  565. data
  566. } = await laboratoryInfo(_this.itemData.subjectId);
  567. if (data.code == 200) {
  568. let list = data.data[0];
  569. list.labHardwareVOList.forEach(function(item) {
  570. if (item.hardwareTypeEnum.enumName == 'VIDEO_MONITOR') {
  571. console.log(item.hardwareNUM)
  572. _this.videoHardwareNUM.push(item.hardwareNUM)
  573. }
  574. })
  575. this.getCameraByFloor();
  576. }
  577. },
  578. //获取楼层摄像头列表
  579. async getCameraByFloor() {
  580. let _this = this;
  581. const {
  582. data
  583. } = await getCameraByFloor({
  584. floorId: this.floorId
  585. })
  586. if (data.code == 200) {
  587. if (data.data[0]) {
  588. let list = _this.videoHardwareNUM.concat(data.data)
  589. let qc = []
  590. for (var i = 0; i < list.length - 1; i++) {
  591. for (var j = i + 1; j < list.length; j++) {
  592. if (list[i] === list[j]) {
  593. list.splice(j, 1);
  594. j--;
  595. }
  596. }
  597. }
  598. this.GetStartList(list);
  599. } else {
  600. this.GetStartList(_this.videoHardwareNUM);
  601. }
  602. }
  603. },
  604. async GetStartList(rows) {
  605. let self = this;
  606. let list = "";
  607. for (let i = 0; i < rows.length; i++) {
  608. list = list + rows[i] + ","
  609. }
  610. let obj = {
  611. page: "1",
  612. count: "100",
  613. deviceIds: list,
  614. };
  615. const {
  616. data
  617. } = await GetStartList(obj)
  618. if (data.code == 200) {
  619. let list = [];
  620. for (let i = 0; i < data.data.length; i++) {
  621. let text = uni.getStorageSync('cameraUrl');
  622. let url = data.data[i].result.body.data.hls;
  623. url = url.split("rtp/");
  624. let newUrl = text + 'rtp/' + url[1];
  625. let obj = {
  626. name: "楼道监控" + (i + 1),
  627. id: data.data[i].result.body.data.deviceID,
  628. url: newUrl,
  629. }
  630. list.push(obj)
  631. }
  632. this.urlList = list;
  633. }
  634. },
  635. //点击选择喇叭
  636. trumpetClick(index) {
  637. this.trumpetList[index].type = !this.trumpetList[index].type
  638. let _this = this;
  639. if (_this.trumpetList[index].type == true) {
  640. _this.trumpetList.forEach(function(item2) {
  641. if (item2.deviceSn == _this.trumpetList[index].deviceSn) {
  642. item2.type = true
  643. } else {
  644. item2.type = false
  645. }
  646. })
  647. }
  648. },
  649. //录制
  650. recordButton(e) {
  651. console.log("按下")
  652. let self = this;
  653. let num = 0;
  654. for (let i = 0; i < self.trumpetList.length; i++) {
  655. if (self.trumpetList[i].type) {
  656. num++
  657. }
  658. }
  659. if (num == 0) {
  660. uni.showToast({
  661. title: '请选择喇叭',
  662. icon: "none",
  663. mask: true,
  664. duration: 2000
  665. });
  666. return
  667. }
  668. this.liveType = true;
  669. console.log('录制', e)
  670. this.startPoint = e.touches[0]; //记录长按时开始点信息,后面用于计算上划取消时手指滑动的距离。
  671. const options = {
  672. duration: 10000,
  673. sampleRate: 16000,
  674. numberOfChannels: 1,
  675. encodeBitRate: 48000,
  676. format: 'mp3',
  677. frameSize: 50
  678. }
  679. this.recorderManager.start(options); //开始录音
  680. this.recorderManager.onStart(() => {
  681. console.log('recorder start')
  682. })
  683. this.recorderManager.onError((res) => {
  684. console.log(res);
  685. })
  686. wx.showToast({
  687. title: "正在录音,上划取消发送",
  688. icon: "none",
  689. duration: 60000 //先定义个60秒,后面可以手动调用wx.hideToast()隐藏
  690. });
  691. this.sendLock = false; //长按时是不上锁的。
  692. },
  693. //取消
  694. cancelButton(e) {
  695. console.log("移动")
  696. let self = this;
  697. let num = 0;
  698. for (let i = 0; i < self.trumpetList.length; i++) {
  699. if (self.trumpetList[i].type) {
  700. num++
  701. }
  702. }
  703. if (num == 0) {
  704. return
  705. }
  706. this.liveType = false;
  707. console.log('取消', e)
  708. let moveLenght = e.touches[e.touches.length - 1].clientY - this.startPoint.clientY; //移动距离
  709. if (Math.abs(moveLenght) > 50) {
  710. wx.showToast({
  711. title: "松开手指,取消发送",
  712. icon: "none",
  713. duration: 60000
  714. });
  715. this.sendLock = true; //触发了上滑取消发送,上锁
  716. } else {
  717. wx.showToast({
  718. title: "正在录音,上划取消发送",
  719. icon: "none",
  720. duration: 60000
  721. });
  722. this.sendLock = false; //上划距离不足,依然可以发送,不上锁
  723. }
  724. },
  725. //发送
  726. sendButton(e) {
  727. console.log("松开")
  728. let self = this;
  729. let num = 0;
  730. for (let i = 0; i < self.trumpetList.length; i++) {
  731. if (self.trumpetList[i].type) {
  732. num++
  733. }
  734. }
  735. if (num == 0) {
  736. return
  737. }
  738. this.liveType = false;
  739. console.log('发送', e)
  740. wx.hideToast(); //结束录音、隐藏Toast提示框
  741. this.recorderManager.stop(); //结束录音
  742. this.recorderManager.onStop((res) => {
  743. if (!this.sendLock) {
  744. console.log('1', this.recorderManager)
  745. this.uploadImg(res.tempFilePath);
  746. }
  747. console.log('停止录音', res.tempFilePath)
  748. console.log("sendLock", this.sendLock);
  749. })
  750. },
  751. //上传MP3
  752. async uploadImg(tempFilePaths) {
  753. var self = this;
  754. uni.uploadFile({
  755. url: config.base_url + '/file/upload', //仅为示例,非真实的接口地址
  756. header: {
  757. 'Authorization': uni.getStorageSync('token')
  758. },
  759. filePath: tempFilePaths,
  760. name: 'file',
  761. formData: {
  762. 'user': 'test'
  763. },
  764. success: (uploadFileRes) => {
  765. let res = JSON.parse(uploadFileRes.data);
  766. if (res.code == 200) {
  767. console.log("上传成功", res)
  768. self.textParseUrlIps(config.base_url + '/' + res.data.url);
  769. } else {
  770. uni.showToast({
  771. title: res.msg,
  772. icon: "none",
  773. mask: true,
  774. duration: 2000
  775. });
  776. }
  777. },
  778. fail: err => {
  779. uni.hideLoading()
  780. },
  781. complete: () => {}
  782. });
  783. },
  784. //发送语音
  785. async textParseUrlIps(text) {
  786. let self = this;
  787. let newList = [];
  788. for (let i = 0; i < self.trumpetList.length; i++) {
  789. if (self.trumpetList[i].type) {
  790. let obj = {
  791. sn: self.trumpetList[i].deviceSn,
  792. port: self.trumpetList[i].port,
  793. deviceIp: self.trumpetList[i].deviceIp,
  794. type: "",
  795. name: "",
  796. speed: "",
  797. params: {
  798. tid: "",
  799. vol: self.trumpetList[i].deviceVol,
  800. urls: []
  801. }
  802. };
  803. newList.push(obj);
  804. }
  805. }
  806. const {
  807. data
  808. } = await textParseUrlIps(newList, text)
  809. if (data.code == 200) {
  810. uni.showToast({
  811. title: '发送成功',
  812. icon: "none",
  813. mask: true,
  814. duration: 2000
  815. });
  816. }
  817. },
  818. //监听应急疏散数据变更
  819. getMqttLineData(val) {
  820. console.log('收到疏散MQTT')
  821. let self = this;
  822. if (val.EXIT_LINE_MESSAGE) {
  823. console.log('数据改变')
  824. this.evacuate();
  825. } else {
  826. console.log('应急疏散已结束')
  827. uni.showToast({
  828. title: '应急疏散已结束',
  829. icon: "none",
  830. mask: true,
  831. duration: 2000
  832. });
  833. setTimeout(function() {
  834. uni.navigateBack();
  835. }, 2000);
  836. }
  837. },
  838. /* 确认 */
  839. confirmBtn() {
  840. if (!this.subId) {
  841. uni.showToast({
  842. title: '请选择实验室',
  843. icon: "none",
  844. mask: true,
  845. duration: 2000
  846. });
  847. return
  848. }
  849. this.$set(this,'address',this.buildingName + '' + this.floorName);
  850. this.$set(this,'pageType',2);
  851. this.getDeviceList();
  852. this.laboratoryInfo();
  853. this.firedeviceStatus();
  854. },
  855. //执行疏散
  856. async lineEvacuate() {
  857. if (!this.subId) {
  858. uni.showToast({
  859. title: '请选择实验室',
  860. icon: "none",
  861. mask: true,
  862. duration: 2000
  863. });
  864. return
  865. }
  866. if (!this.buttonArrayIndex) {
  867. uni.showToast({
  868. title: '请选择疏散路线',
  869. icon: "none",
  870. mask: true,
  871. duration: 2000
  872. });
  873. return
  874. }
  875. const {
  876. data
  877. } = await lineEvacuate(this.subId, this.buttonArray[this.buttonArrayIndex].id)
  878. if (data.code == 200) {
  879. if (data.data) {
  880. console.log('执行疏散')
  881. this.initialization(data.data);
  882. }
  883. }
  884. },
  885. //获取喇叭列表
  886. async getDeviceList() {
  887. let obj = {
  888. subId: this.itemData.subjectId,
  889. floorId: this.floorId,
  890. page: 1,
  891. pageSize: 100,
  892. };
  893. const {
  894. data
  895. } = await getDeviceListBySub(obj)
  896. if (data.code == 200) {
  897. for (let i = 0; i < data.data.length; i++) {
  898. data.data[i].type = false;
  899. }
  900. this.$set(this, 'trumpetList', data.data)
  901. }
  902. },
  903. //摄像头切换
  904. scrollBoxClick(index) {
  905. this.videoIndex = index;
  906. },
  907. /*新疏散相关接口*/
  908. //地图数据
  909. async getBuildingData() {
  910. let self = this;
  911. const {
  912. data
  913. } = await getFloorData(this.floorId)
  914. console.log('data', data)
  915. if (data.code == 200) {
  916. if (data.data.buildFloorLayoutVoList[0]) {
  917. let list = JSON.parse(data.data.labExitLineVertex.layoutJoinData)
  918. this.zoomCalculate(list, 348, 668);
  919. for (let i = 0; i < list.length; i++) {
  920. if (list[i].type == '2') {
  921. //楼道
  922. for (let o = 0; o < list[i].lightList.length; o++) {
  923. list[i].lightList[o].openType = false;
  924. }
  925. } else if (list[i].type == '1') {
  926. for (let o = 0; o < data.data.buildFloorLayoutVoList.length; o++) {
  927. if (list[i].key == data.data.buildFloorLayoutVoList[o].pointName) {
  928. list[i].id = data.data.buildFloorLayoutVoList[o].id;
  929. list[i].buildId = data.data.buildFloorLayoutVoList[o].buildId;
  930. list[i].floorId = data.data.buildFloorLayoutVoList[o].floorId;
  931. list[i].roomType = data.data.buildFloorLayoutVoList[o].roomType;
  932. list[i].roomName = data.data.buildFloorLayoutVoList[o].roomName;
  933. list[i].roomNum = data.data.buildFloorLayoutVoList[o].roomNum;
  934. list[i].subName = data.data.buildFloorLayoutVoList[o].subName;
  935. list[i].subId = data.data.buildFloorLayoutVoList[o].subId;
  936. list[i].online = data.data.buildFloorLayoutVoList[o].online;
  937. list[i].loginAdmin = data.data.buildFloorLayoutVoList[o].loginAdmin;
  938. list[i].policeType = false;
  939. }
  940. }
  941. } else if (list[i].type == 3) {
  942. list[i].roomCheckType = false;
  943. }
  944. }
  945. let subList = [];
  946. for (let o = 0; o < data.data.buildFloorLayoutVoList.length; o++) {
  947. if(data.data.buildFloorLayoutVoList[o].loginAdmin){
  948. subList.push(data.data.buildFloorLayoutVoList[o])
  949. }
  950. }
  951. this.$set(this,'fjListArray', subList);
  952. this.$set(this, 'mapList', JSON.parse(JSON.stringify(list)));
  953. // this.$set(this, 'shadeMapList', JSON.parse(JSON.stringify(list)));
  954. this.$set(this, 'mapType', true);
  955. setTimeout(function() {
  956. self.getRedisEvacuation();
  957. }, 500);
  958. }
  959. }
  960. },
  961. //获取疏散数据
  962. async getRedisEvacuation() {
  963. let self = this;
  964. let obj = {
  965. buildId: this.buildingId,
  966. floorId: this.floorId,
  967. }
  968. const {
  969. data
  970. } = await getRedisEvacuation(obj)
  971. if (data.code == 200) {
  972. if (data.data.doorPointNames) {
  973. for (let o = 0; o < self.mapList.length; o++) {
  974. if (self.mapList[o].type == 2) {
  975. for (let x = 0; x < self.mapList[o].lightList.length; x++) {
  976. let num = 0;
  977. for (let i = 0; i < data.data.lightPointSet.length; i++) {
  978. if (data.data.lightPointSet[i]) { //处理后端返回的异常的NULL
  979. if (self.mapList[o].lightList[x].key == data.data.lightPointSet[i].key) {
  980. num++
  981. }
  982. }
  983. }
  984. console.log('灯',num)
  985. self.mapList[o].lightList[x].openType = num != 0;
  986. }
  987. }
  988. }
  989. for (let i = 0; i < data.data.doorPointNames.length; i++) {
  990. for (let o = 0; o < self.mapList.length; o++) {
  991. if (self.mapList[o].type == 3) {
  992. if (data.data.doorPointNames[i] == self.mapList[o].key) {
  993. self.mapList[o].roomCheckType = true;
  994. }
  995. }
  996. }
  997. }
  998. this.$forceUpdate();
  999. }
  1000. };
  1001. },
  1002. //缩放计算
  1003. zoomCalculate(list, height, width) {
  1004. let maxWidth = 0
  1005. let maxHeight = 0
  1006. let zoomData = 1;
  1007. for (let i = 0; i < list.length; i++) {
  1008. if ((list[i].x + list[i].w) > maxWidth) {
  1009. maxWidth = list[i].x + list[i].w
  1010. }
  1011. if ((list[i].y + list[i].h) > maxHeight) {
  1012. maxHeight = list[i].y + list[i].h
  1013. }
  1014. }
  1015. //处理等值数据
  1016. if(maxHeight == height){
  1017. maxHeight--
  1018. }
  1019. if(maxWidth == width){
  1020. maxWidth--
  1021. }
  1022. this.$set(this, 'mapWidth', maxWidth);
  1023. this.$set(this, 'mapHeight', maxHeight);
  1024. //缩放判断
  1025. if(maxHeight>height&&maxWidth>width){
  1026. if((maxHeight-height)>(maxWidth-width)){
  1027. zoomData = height/maxHeight;
  1028. this.$set(this,'zoomData',height/maxHeight);
  1029. }else{
  1030. zoomData = width / maxWidth;
  1031. this.$set(this,'zoomData',width / maxWidth);
  1032. }
  1033. }else if(maxHeight<height&&maxWidth<width){
  1034. if((height-maxHeight)>(width-maxWidth)){
  1035. zoomData = width / maxWidth;
  1036. this.$set(this,'zoomData',width / maxWidth);
  1037. }else{
  1038. zoomData = height / maxHeight;
  1039. this.$set(this,'zoomData',height / maxHeight);
  1040. }
  1041. }else if(maxHeight<height&&maxWidth>width){
  1042. zoomData = width / maxWidth;
  1043. this.$set(this,'zoomData',width / maxWidth);
  1044. }else if(maxHeight>height&&maxWidth<width){
  1045. zoomData = height / maxHeight;
  1046. this.$set(this,'zoomData',height / maxHeight);
  1047. }
  1048. },
  1049. //结束疏散
  1050. evacuationButton() {
  1051. let self = this;
  1052. uni.showModal({
  1053. content: '确认'+(this.isEvacuate?'执行':'结束')+'疏散吗?',
  1054. cancelColor: "#999",
  1055. confirmColor: "#0183FA",
  1056. success: function(res) {
  1057. if (res.confirm) {
  1058. if(self.isEvacuate){
  1059. self.executeEvacuation();
  1060. }else{
  1061. self.endEvacuation();
  1062. }
  1063. console.log('用户点击确定');
  1064. } else if (res.cancel) {
  1065. console.log('用户点击取消');
  1066. }
  1067. }
  1068. });
  1069. },
  1070. //开始疏散
  1071. async executeEvacuation(){
  1072. let self = this;
  1073. let doorPointNames = [];
  1074. for(let i=0;i<self.mapList.length;i++){
  1075. if(self.mapList[i].type == 3){
  1076. doorPointNames.push(self.mapList[i].key)
  1077. }
  1078. }
  1079. let obj = {
  1080. buildId:this.buildingId,
  1081. floorId:this.floorId,
  1082. subId: this.subId,
  1083. badPointNames:[],
  1084. doorPointNames:doorPointNames,
  1085. }
  1086. const { data } = await executeEvacuation(obj)
  1087. console.log('data', data)
  1088. if (data.code == 200) {
  1089. this.$set(this,'isEvacuate',false);
  1090. uni.showToast({
  1091. title: '执行成功',
  1092. icon: "none",
  1093. mask: true,
  1094. duration: 2000
  1095. });
  1096. }
  1097. },
  1098. //结束疏散
  1099. async endEvacuation(){
  1100. let self = this;
  1101. let obj = {
  1102. buildId:this.buildingId,
  1103. floorId:this.floorId,
  1104. }
  1105. const { data } = await endEvacuation(obj)
  1106. console.log('data', data)
  1107. if (data.code == 200) {
  1108. this.$set(this,'isEvacuate',true);
  1109. uni.showToast({
  1110. title: '执行成功',
  1111. icon: "none",
  1112. mask: true,
  1113. duration: 2000
  1114. });
  1115. }
  1116. },
  1117. /*MQTT*/
  1118. //订阅
  1119. onMQTT() {
  1120. let self = this;
  1121. const mqttOptions = {
  1122. keepalive: 30,
  1123. clean: true, //保留会话
  1124. connectTimeout: 60000, // 超时时间
  1125. reconnectPeriod: 5000, // 重连间隔
  1126. clientId: uni.getStorageSync('token') + 'lab/function/data',
  1127. username: uni.getStorageSync('mqttUrl'),
  1128. password: uni.getStorageSync('mqttUrl'),
  1129. }
  1130. const connectUrl = uni.getStorageSync('mqttUrl');
  1131. self.floorClient = $mqtt.connect('wxs://' + connectUrl, mqttOptions);
  1132. self.floorClient.on('connect', () => {
  1133. self.floorClient.subscribe(self.evacuationTopic + self.floorId, (err) => {
  1134. if (!err) {
  1135. console.log("疏散-订阅成功", )
  1136. self.getBuildingData();
  1137. }
  1138. });
  1139. self.floorClient.subscribe(self.fireTopic+self.fireCode, (err) => {
  1140. if (!err) {
  1141. console.log("火灾传感器状态-订阅成功:" + self.fireTopic+self.fireCode);
  1142. }
  1143. });
  1144. self.floorClient.subscribe(self.fireOnlineTopic+self.fireCode, (err) => {
  1145. if (!err) {
  1146. console.log("火灾设备是否在线-订阅成功:" + self.fireOnlineTopic+self.fireCode);
  1147. }
  1148. });
  1149. self.floorClient.subscribe(self.firePerformTopic+self.fireCode, (err) => {
  1150. if (!err) {
  1151. console.log("火灾是否正在执行灭火操作-订阅成功:" + self.firePerformTopic+self.fireCode);
  1152. }
  1153. });
  1154. });
  1155. // 自动重连
  1156. this.floorClient.on('reconnect', (msg) => {
  1157. console.log('自动重连-reconnect-1', msg)
  1158. });
  1159. // 错误
  1160. this.floorClient.on('error', () => {
  1161. console.log('错误-error-1')
  1162. });
  1163. // 断开
  1164. this.floorClient.on('end', () => {
  1165. console.log('断开-end-1')
  1166. });
  1167. // 掉线
  1168. this.floorClient.on('offline', (msg) => {
  1169. console.log('掉线-offline-1', msg)
  1170. });
  1171. // 收到消息
  1172. this.floorClient.on('message', (topic, message) => {
  1173. let data = JSON.parse(message)
  1174. if (data) {
  1175. if (topic == (this.evacuationTopic + this.floorId)) {
  1176. console.log('疏散通知', data)
  1177. //疏散消息
  1178. if (data.data == 'FLOOR_EXITLINE') {
  1179. this.getRedisEvacuation();
  1180. } else if (data.data == 'FLOOR_OVER_EXITLINE') {
  1181. uni.showToast({
  1182. title: '疏散已结束',
  1183. icon: "none",
  1184. mask: true,
  1185. duration: 2000
  1186. });
  1187. setTimeout(function() {
  1188. self.getBuildingData();
  1189. }, 2000);
  1190. }
  1191. }else if(topic == (self.fireTopic + self.fireCode)){
  1192. //传感器状态
  1193. console.log('传感器状态');
  1194. self.firedeviceStatus();
  1195. }else if(topic == (self.fireOnlineTopic + self.fireCode)){
  1196. //设备在线状态
  1197. console.log('设备在线状态');
  1198. }else if(topic == (self.firePerformTopic + self.fireCode)){
  1199. //灭火执行操作
  1200. if(data.fireStatus == 1){
  1201. if(!self.fireStartType){
  1202. self.$set(self,'fireStartType',true);
  1203. self.$set(self,'fireStartText','灭火中');
  1204. self.sendCode2(data.direTime);
  1205. }else if(data.fireStatus == 0){
  1206. self.msgError('一键灭火启动失败')
  1207. }
  1208. }
  1209. }
  1210. }
  1211. });
  1212. // 全局监听是否有关闭mqtt的消息的事件
  1213. uni.$on('closeMqtt', () => {
  1214. this.floorClient.end(true); // 主动断开连接
  1215. })
  1216. },
  1217. //关闭MQTT连接
  1218. offMQTT(type) {
  1219. let self = this;
  1220. if (this.floorClient.unsubscribe) {
  1221. this.floorClient.unsubscribe(this.evacuationTopic + this.floorId, error => {
  1222. if (error) {
  1223. console.log('疏散连接-关闭错误', error)
  1224. }
  1225. });
  1226. if(self.fireCode){
  1227. this.floorClient.unsubscribe(self.fireTopic+self.fireCode, error => {
  1228. if (error) {
  1229. console.log('火灾传感器状态-MQTT断开报错=>', error)
  1230. }
  1231. })
  1232. this.floorClient.unsubscribe(self.fireOnlineTopic+self.fireCode, error => {
  1233. if (error) {
  1234. console.log('火灾设备是否在线-MQTT断开报错=>', error)
  1235. }
  1236. })
  1237. this.floorClient.unsubscribe(self.firePerformTopic+self.fireCode, error => {
  1238. if (error) {
  1239. console.log('火灾是否正在执行灭火操作-MQTT断开报错=>', error)
  1240. }
  1241. })
  1242. }
  1243. this.floorClient.end(true);
  1244. this.$set(this, 'floorClient', {});
  1245. }
  1246. if (type) {
  1247. this.onMQTT();
  1248. }
  1249. },
  1250. },
  1251. beforeDestroy() {
  1252. this.offMQTT();
  1253. //断开mqtt连接
  1254. // getApp().offMQTT();
  1255. //删除应急疏散监听
  1256. // getApp().deleteLineData();
  1257. }
  1258. }
  1259. </script>
  1260. <style lang="stylus" scoped>
  1261. #emergencyEvacuationBig {
  1262. height: 100%;
  1263. width: 100%;
  1264. display: flex;
  1265. flex-direction: column;
  1266. overflow-y: scroll;
  1267. .setUpEvacuation {
  1268. flex: 1;
  1269. display: flex;
  1270. flex-direction: column;
  1271. overflow-y: scroll;
  1272. .evacuation-max-box {
  1273. width: 710rpx;
  1274. margin: 20rpx 20rpx;
  1275. background: #fff;
  1276. border-radius: 20rpx;
  1277. padding: 20rpx 0;
  1278. .picker-max-box {
  1279. .picker-title-box {
  1280. padding: 0 20rpx;
  1281. display: flex;
  1282. view {
  1283. line-height: 80rpx;
  1284. font-size: 28rpx;
  1285. }
  1286. view:nth-child(1) {
  1287. color: red;
  1288. }
  1289. view:nth-child(2) {}
  1290. view:nth-child(3) {
  1291. color: #999;
  1292. }
  1293. }
  1294. .picker-min-box {
  1295. display: flex;
  1296. height: 80rpx;
  1297. width: 667rpx;
  1298. border: 1rpx solid #a2a2a2;
  1299. border-radius: 10rpx;
  1300. margin: 0 20rpx;
  1301. view {
  1302. flex: 1;
  1303. line-height: 80rpx;
  1304. padding: 0 20rpx;
  1305. color: #999;
  1306. font-size: 28rpx;
  1307. overflow: hidden;
  1308. }
  1309. img {
  1310. width: 24rpx;
  1311. height: 12rpx;
  1312. margin: 35rpx 23rpx;
  1313. }
  1314. }
  1315. }
  1316. }
  1317. }
  1318. .implementEvacuation {
  1319. flex: 1;
  1320. display: flex;
  1321. flex-direction: column;
  1322. overflow-y: scroll;
  1323. .evacuation-max-box {
  1324. width: 710rpx;
  1325. margin: 20rpx 20rpx;
  1326. /* background #fff */
  1327. border-radius: 20rpx;
  1328. padding: 20rpx 0 30rpx;
  1329. .evacuation-title-box {
  1330. // height:150rpx;
  1331. //border-bottom:1rpx solid #dedede;
  1332. background: #FFFFFF;
  1333. border-radius: 20rpx;
  1334. padding: 34rpx 22rpx;
  1335. box-sizing: border-box;
  1336. .evacuation-title-name-box {
  1337. font-size: 30rpx;
  1338. font-family: PingFang SC;
  1339. font-weight: 500;
  1340. color: #333333;
  1341. line-height: 30rpx;
  1342. }
  1343. .site {
  1344. font-size: 28rpx;
  1345. font-family: PingFang SC;
  1346. font-weight: 500;
  1347. color: #999999;
  1348. line-height: 30rpx;
  1349. margin-top: 32rpx;
  1350. display: flex;
  1351. justify-content: flex-start;
  1352. align-items: center;
  1353. >img {
  1354. width: 28rpx;
  1355. height: 30rpx;
  1356. margin-right: 18rpx;
  1357. }
  1358. }
  1359. }
  1360. /* 一键灭火 */
  1361. .outfire {
  1362. width: 710rpx;
  1363. height: 80rpx;
  1364. background: #FFFFFF;
  1365. border-radius: 20rpx;
  1366. margin: 20rpx 0;
  1367. padding: 0 10rpx;
  1368. box-sizing: border-box;
  1369. display: flex;
  1370. justify-content: space-between;
  1371. align-items: center;
  1372. .outfire_li {
  1373. display: flex;
  1374. justify-content: flex-start;
  1375. align-items: center;
  1376. >img {
  1377. width: 24rpx;
  1378. height: 30rpx;
  1379. margin-right: 12rpx;
  1380. }
  1381. .normal {
  1382. font-size: 24rpx;
  1383. font-family: PingFang SC;
  1384. font-weight: 500;
  1385. color: #333333;
  1386. }
  1387. .abnormal {
  1388. font-size: 24rpx;
  1389. font-family: PingFang SC;
  1390. font-weight: 500;
  1391. color: #F11C00;
  1392. }
  1393. }
  1394. .outfire_li:nth-of-type(1) {
  1395. >img {
  1396. width: 30rpx;
  1397. height: 28rpx;
  1398. margin-right: 12rpx;
  1399. }
  1400. }
  1401. .outfire_yes_btn {
  1402. width: 120rpx;
  1403. height: 40rpx;
  1404. font-size: 24rpx;
  1405. font-family: PingFang SC;
  1406. font-weight: 500;
  1407. color: #F21C00;
  1408. line-height: 40rpx;
  1409. border: 1px solid #F21C00;
  1410. border-radius: 8rpx;
  1411. text-align: center;
  1412. margin-left: 54rpx;
  1413. }
  1414. .outfire_no_btn {
  1415. width: 120rpx;
  1416. height: 40rpx;
  1417. font-size: 24rpx;
  1418. font-family: PingFang SC;
  1419. font-weight: 500;
  1420. color: #CCCCCC;
  1421. line-height: 40rpx;
  1422. border: 1px solid #E0E0E0;
  1423. border-radius: 8rpx;
  1424. text-align: center;
  1425. margin-left: 54rpx;
  1426. }
  1427. }
  1428. .evacuation-scroll-box {
  1429. height: 95rpx;
  1430. overflow-x: scroll;
  1431. overflow-y: hidden;
  1432. white-space: nowrap;
  1433. margin: 0 20rpx;
  1434. view {
  1435. line-height: 95rpx;
  1436. font-size: 28rpx;
  1437. display: inline-block;
  1438. margin-right: 45rpx;
  1439. }
  1440. .scroll-box-color {
  1441. color: #0183FA;
  1442. }
  1443. }
  1444. .evacuation-video-box {
  1445. width: 668rpx;
  1446. height: 341rpx;
  1447. margin: 0 auto;
  1448. position: relative;
  1449. video {
  1450. position: absolute;
  1451. top: 0;
  1452. left: 0;
  1453. width: 668rpx;
  1454. height: 341rpx;
  1455. margin: 0 auto;
  1456. }
  1457. .video-a {
  1458. z-index: 100;
  1459. }
  1460. .video-b {
  1461. z-index: 0;
  1462. }
  1463. }
  1464. /* 路线图 */
  1465. .roadmap {
  1466. width: 710rpx;
  1467. height: 464rpx;
  1468. background: #FFFFFF;
  1469. border-radius: 20rpx;
  1470. padding: 20rpx 20rpx 0;
  1471. box-sizing: border-box;
  1472. margin-top: 20rpx;
  1473. .roadmap_t {
  1474. font-size: 30rpx;
  1475. font-family: PingFang SC;
  1476. font-weight: 500;
  1477. color: #333333;
  1478. line-height: 30rpx;
  1479. display: flex;
  1480. .monito_li_r_l {
  1481. flex: 1;
  1482. line-height: 61rpx;
  1483. font-size: 28rpx;
  1484. }
  1485. .monito_li_r_r_button {
  1486. width: 100rpx;
  1487. text-align: center;
  1488. line-height: 61rpx;
  1489. font-size: 28rpx;
  1490. color: #0183FA;
  1491. }
  1492. .monito_li_r {
  1493. width: 380rpx;
  1494. font-size: 24rpx;
  1495. font-family: PingFang SC;
  1496. font-weight: 500;
  1497. color: #0183FA;
  1498. line-height: 80rpx;
  1499. display: flex;
  1500. justify-content: flex-end;
  1501. align-items: center;
  1502. >img {
  1503. width: 9rpx;
  1504. height: 22rpx;
  1505. margin-left: 20rpx;
  1506. }
  1507. .evacuation-title-button-box {
  1508. display: flex;
  1509. overflow: hidden;
  1510. view {
  1511. line-height: 61rpx;
  1512. font-size: 28rpx;
  1513. }
  1514. .colorA {
  1515. color: #0183FA;
  1516. }
  1517. .colorB {
  1518. color: #0183FA;
  1519. }
  1520. img {
  1521. margin: 28rpx 20rpx 0;
  1522. width: 24rpx;
  1523. height: 9rpx;
  1524. }
  1525. }
  1526. }
  1527. }
  1528. .evacuation-map-box {
  1529. width: 668rpx;
  1530. height: 348rpx;
  1531. margin: 0 auto;
  1532. overflow: hidden;
  1533. border: 1rpx solid #E0E0E0;
  1534. margin-top: 20rpx;
  1535. position: relative;
  1536. .emergencyEvacuationBigFullScreen-page {
  1537. // overflow: scroll;
  1538. overflow: hidden;
  1539. position: absolute;
  1540. top: 50%;
  1541. left: 50%;
  1542. .map-max-box {
  1543. position: relative;
  1544. .map-max-for-box {
  1545. position: absolute;
  1546. display: flex;
  1547. flex-direction: column;
  1548. .map-max-for-min-box {
  1549. position: relative;
  1550. .position-box {
  1551. position: absolute;
  1552. }
  1553. .map-for-name-p {
  1554. padding: 0 10rpx;
  1555. height: 20rpx;
  1556. line-height: 20rpx;
  1557. font-size: 14rpx;
  1558. text-align: center;
  1559. color: #333;
  1560. overflow: hidden;
  1561. text-overflow: ellipsis;
  1562. white-space: nowrap;
  1563. }
  1564. .map-for-num-p {
  1565. padding: 0 10rpx;
  1566. height: 20rpx;
  1567. line-height: 20rpx;
  1568. font-size: 14rpx;
  1569. text-align: center;
  1570. color: #333;
  1571. overflow: hidden;
  1572. text-overflow: ellipsis;
  1573. white-space: nowrap;
  1574. }
  1575. .center-move-door-p-t {
  1576. background: url("../images/evacuation3_2/icon_sysbjt_m.png") !important;
  1577. background-size: 100% !important;
  1578. transform: rotate(180deg);
  1579. }
  1580. .center-move-door-p-b {
  1581. background: url("../images/evacuation3_2/icon_sysbjt_m.png") !important;
  1582. background-size: 100% !important;
  1583. }
  1584. .center-move-door-p-l {
  1585. background: url("../images/evacuation3_2/icon_sysbjt_m.png") !important;
  1586. background-size: 100% !important;
  1587. transform: rotate(90deg);
  1588. }
  1589. .center-move-door-p-r {
  1590. background: url("../images/evacuation3_2/icon_sysbjt_m.png") !important;
  1591. background-size: 100% !important;
  1592. transform: rotateZ(270deg);
  1593. }
  1594. .lightTopOn {
  1595. background: url("../images/evacuation3_2//icon_sjt.png");
  1596. background-size: 100%;
  1597. }
  1598. .lightTopOff {
  1599. background: url("../images/evacuation3_2//icon_shang_hs.png");
  1600. background-size: 100%;
  1601. }
  1602. .lightBottomOn {
  1603. background: url("../images/evacuation3_2//icon_xjt.png");
  1604. background-size: 100%;
  1605. }
  1606. .lightBottomOff {
  1607. background: url("../images/evacuation3_2//icon_xia_hs.png");
  1608. background-size: 100%;
  1609. }
  1610. .lightLeftOn {
  1611. background: url("../images/evacuation3_2//icon_zuo.png");
  1612. background-size: 100%;
  1613. }
  1614. .lightLeftOff {
  1615. background: url("../images/evacuation3_2//icon_zou_hs.png");
  1616. background-size: 100%;
  1617. }
  1618. .lightRightOn {
  1619. background: url("../images/evacuation3_2//icon_yuo.png");
  1620. background-size: 100%;
  1621. }
  1622. .lightRightOff {
  1623. background: url("../images/evacuation3_2//icon_you_hs.png");
  1624. background-size: 100%;
  1625. }
  1626. }
  1627. }
  1628. .for-map-box {
  1629. border: 2rpx solid #fff;
  1630. background: #CEF2FD;
  1631. }
  1632. .for-map-box-one {
  1633. background: #CEFDD5;
  1634. }
  1635. .for-map-box-two {
  1636. background: url("../images/evacuation3_2/icon_yjtd.png") center center no-repeat #006400;
  1637. background-size: 60rpx 60rpx;
  1638. }
  1639. .for-map-box-two-check {
  1640. background: url("../images/evacuation3_2/icon_yjtd.png") center center no-repeat rgba(50, 205, 50, 1);
  1641. background-size: 80rpx 80rpx;
  1642. }
  1643. .room-type-one {
  1644. //选中
  1645. background: rgba(178, 235, 255, 1);
  1646. }
  1647. .room-type-two {
  1648. //报警
  1649. background: rgba(232, 0, 0, 0.4);
  1650. box-shadow: 0 0 10rpx 1rpx #E80000 inset;
  1651. }
  1652. .room-type-three {
  1653. //选中报警
  1654. background: rgba(178, 235, 255, 1);
  1655. box-shadow: 0 0 10rpx 1rpx #E80000 inset;
  1656. }
  1657. }
  1658. }
  1659. }
  1660. }
  1661. .video-max-box {
  1662. width: 710rpx;
  1663. height: 780rpx;
  1664. overflow-y: scroll;
  1665. background: #FFFFFF;
  1666. border-radius: 20rpx;
  1667. padding: 22rpx 30rpx 30rpx;
  1668. box-sizing: border-box;
  1669. margin-top: 20rpx;
  1670. margin-bottom: 120rpx;
  1671. video {
  1672. width: 645rpx;
  1673. height: 355rpx;
  1674. }
  1675. }
  1676. .bottom-button-box {
  1677. position: absolute;
  1678. bottom: 20rpx;
  1679. display: flex;
  1680. width: 670rpx;
  1681. margin: 20rpx;
  1682. view {
  1683. width: 335rpx;
  1684. height: 100rpx;
  1685. line-height: 100rpx;
  1686. text-align: center;
  1687. color: #fff;
  1688. font-size: 28rpx;
  1689. }
  1690. view:nth-child(1) {
  1691. border-top-left-radius: 50rpx;
  1692. border-bottom-left-radius: 50rpx;
  1693. background: #FF9C00;
  1694. }
  1695. view:nth-child(2) {
  1696. border-top-right-radius: 50rpx;
  1697. border-bottom-right-radius: 50rpx;
  1698. background: #0183FA;
  1699. }
  1700. }
  1701. }
  1702. .live-button {
  1703. width: 650rpx;
  1704. height: 100rpx;
  1705. line-height: 100rpx;
  1706. text-align: center;
  1707. font-size: 28rpx;
  1708. margin: 50rpx auto 0;
  1709. border-radius: 20rpx;
  1710. }
  1711. .live-color-a {
  1712. color: #fff;
  1713. background: #FF8686;
  1714. }
  1715. .live-color-b {
  1716. color: #fff;
  1717. background: #25C95B;
  1718. }
  1719. /* 语音广播 */
  1720. .shade-max-big-box {
  1721. height: 100%;
  1722. width: 100%;
  1723. position: fixed;
  1724. display: flex;
  1725. flex-direction: column;
  1726. z-index: 10;
  1727. background: rgba(0, 0, 0, 0.2);
  1728. .null-box {
  1729. flex: 1;
  1730. }
  1731. /* 语音广播-执行疏散 */
  1732. .broadcast {
  1733. width: 100%;
  1734. // height: 532rpx;
  1735. background: #FFFFFF;
  1736. border-top-left-radius: 20rpx;
  1737. border-top-right-radius: 20rpx;
  1738. padding:22rpx 30rpx 30rpx;
  1739. box-sizing: border-box;
  1740. margin-top: 20rpx;
  1741. .broadcast_t {
  1742. font-size: 30rpx;
  1743. font-family: PingFang SC;
  1744. font-weight: 500;
  1745. color: #333333;
  1746. line-height: 30rpx;
  1747. >label {
  1748. font-size: 24rpx;
  1749. font-family: PingFang SC;
  1750. font-weight: 500;
  1751. color: #999999;
  1752. line-height: 30rpx;
  1753. margin-left: 16rpx;
  1754. }
  1755. }
  1756. .trumpet-max-box {
  1757. display: flex;
  1758. justify-content: flex-start;
  1759. margin-top: 22rpx;
  1760. flex-wrap: wrap;
  1761. .trumpet-for-box {
  1762. display: inline-block;
  1763. width: 200rpx;
  1764. height: 60rpx;
  1765. line-height: 60rpx;
  1766. font-size: 24rpx;
  1767. text-align: center;
  1768. cursor: pointer;
  1769. overflow: hidden;
  1770. border: 1rpx solid #E0E0E0;
  1771. border-radius: 10rpx;
  1772. color: #E0E0E0;
  1773. display: flex;
  1774. justify-content: center;
  1775. margin-right: 20rpx;
  1776. margin-bottom: 10rpx;
  1777. >img {
  1778. width: 36rpx;
  1779. height: 34rpx;
  1780. margin: 12rpx 20rpx 0 25rpx;
  1781. }
  1782. }
  1783. .trumpet-color-a {
  1784. border: 1px solid #0183FA;
  1785. color: #0183FA;
  1786. }
  1787. .trumpet-color-b {
  1788. border: 1px solid #CCCCCC;
  1789. color: #999;
  1790. }
  1791. }
  1792. .broadcast_m {
  1793. width: 100%;
  1794. .broadcast_m_t {
  1795. width: 142rpx;
  1796. height: 142rpx;
  1797. margin: 30rpx 0 0 258rpx;
  1798. position: relative;
  1799. font-size: 24rpx;
  1800. font-family: PingFang SC;
  1801. font-weight: 500;
  1802. line-height: 170rpx;
  1803. text-align: center;
  1804. >img {
  1805. width: 142rpx;
  1806. height: 142rpx;
  1807. position: absolute;
  1808. }
  1809. >label {
  1810. width: 100%;
  1811. font-size: 24rpx;
  1812. font-family: PingFang SC;
  1813. font-weight: 500;
  1814. color: #0183FA;
  1815. line-height: 24rpx;
  1816. display: inline-block;
  1817. text-align: center;
  1818. position: absolute;
  1819. top: 76rpx;
  1820. }
  1821. /* 按下 */
  1822. .press_color {
  1823. color: #FFFFFF;
  1824. }
  1825. /* 松开 */
  1826. .slip_color {
  1827. color: #0183FA;
  1828. }
  1829. }
  1830. .broadcast_m_t_back_a {
  1831. background: url(@/images/icon_sskz_skfs.png);
  1832. background-size: 100%;
  1833. color: #FFFFFF;
  1834. }
  1835. .broadcast_m_t_back_b {
  1836. background: url(@/images/icon_sskz_azsh.png);
  1837. background-size: 100%;
  1838. color: #0183FA;
  1839. }
  1840. .broadcast_m_b {
  1841. font-size: 24rpx;
  1842. font-family: PingFang SC;
  1843. font-weight: 500;
  1844. color: #999999;
  1845. line-height: 24rpx;
  1846. text-align: center;
  1847. margin-top: 14rpx;
  1848. }
  1849. }
  1850. /* 疏散按钮 */
  1851. .evacuation-button-box {
  1852. width: 650rpx;
  1853. height: 100rpx;
  1854. background: #0183FA;
  1855. color: #fff;
  1856. text-align center;
  1857. line-height: 100rpx;
  1858. font-size: 28rpx;
  1859. margin: 88rpx auto 0;
  1860. border-radius: 20rpx;
  1861. }
  1862. }
  1863. }
  1864. /* 一键灭火 */
  1865. .shade-outfire {
  1866. height: 100%;
  1867. width: 100%;
  1868. position: fixed;
  1869. display: flex;
  1870. flex-direction: column;
  1871. z-index: 10;
  1872. background: rgba(0, 0, 0, 0.2);
  1873. .null-box {
  1874. flex: 1;
  1875. }
  1876. /* 语音广播-执行疏散 */
  1877. .shade-outfire-n {
  1878. width: 625rpx;
  1879. height: 450rpx;
  1880. background: #FFFFFF;
  1881. border-radius: 20rpx;
  1882. position: absolute;
  1883. top: 370rpx;
  1884. left: 62rpx;
  1885. .shade-outfire-n-t {
  1886. width: 172rpx;
  1887. height: 172rpx;
  1888. margin: 38rpx 0 0 226rpx;
  1889. }
  1890. .shade-outfire-n-m {
  1891. font-size: 30rpx;
  1892. font-family: PingFang SC;
  1893. font-weight: 500;
  1894. color: #E30000;
  1895. line-height: 84rpx;
  1896. text-align: center;
  1897. border-bottom: 1px solid #E0E0E0;
  1898. >text {
  1899. font-size: 40rpx;
  1900. }
  1901. }
  1902. .shade-outfire-n-b {
  1903. width: 402rpx;
  1904. height: 82rpx;
  1905. background: #FFFFFF;
  1906. border: 2rpx solid #0183FA;
  1907. border-radius: 10rpx;
  1908. font-size: 28rpx;
  1909. line-height: 82rpx;
  1910. font-family: PingFang SC;
  1911. font-weight: 500;
  1912. color: #0183FA;
  1913. text-align: center;
  1914. margin: 30rpx 0 0 112rpx;
  1915. }
  1916. }
  1917. }
  1918. }
  1919. .setUpEvacuation-bottom-button {
  1920. width: 650rpx;
  1921. height: 100rpx;
  1922. background: #0183FA;
  1923. color:#fff;
  1924. text-align: center;
  1925. line-height: 100rpx;
  1926. font-size: 28rpx;
  1927. margin: 50rpx auto;
  1928. border-radius: 20rpx;
  1929. }
  1930. }
  1931. </style>