emergencyEvacuationBig.vue 53 KB

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