alarmInfo.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. <!-- 停用 -->
  2. <template>
  3. <view class="alarm">
  4. <view class="alarm_t">
  5. <view class="alarm_t_t">
  6. <img src="@/images/icon_003.png"/>
  7. <text>2022-01-01 14:00:23</text>
  8. <text>待处理</text>
  9. </view>
  10. <view class="alarm_t_b">化学品名称-未领用带离实验室房间,请尽快确认。</view>
  11. </view>
  12. <view class="alarm_c">
  13. <view class="alarm_c_li">
  14. <text>位置:</text>
  15. <text>实验室名称-楼栋楼层房间号</text>
  16. </view>
  17. <view class="alarm_c_li">
  18. <text>气瓶规格:</text>
  19. <text>10L</text>
  20. </view>
  21. <view class="alarm_c_li">
  22. <text>气体余量:</text>
  23. <text>10Mpa</text>
  24. </view>
  25. <view class="alarm_c_li">
  26. <text>当前使用人:</text>
  27. <text>成双-13666554455</text>
  28. </view>
  29. <view class="alarm_c_li">
  30. <text>气瓶所有人:</text>
  31. <text>李妮妮-13256564545</text>
  32. </view>
  33. <view class="alarm_c_img">
  34. <view>报警抓拍:</view>
  35. <view>
  36. <img src="@/images/icon_01.png"/>
  37. <img src="@/images/icon_01.png"/>
  38. <img src="@/images/icon_01.png"/>
  39. <img src="@/images/icon_01.png"/>
  40. <img src="@/images/icon_01.png"/>
  41. <img src="@/images/icon_01.png"/>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="alarm_b">
  46. <view class="alarm_b_l" @click="MonitorBtn()">查看监控</view>
  47. <view class="alarm_b_r" @click="voiceBtn()">语音广播</view>
  48. </view>
  49. <view class="shade-max-big-box" v-if="broadcastType">
  50. <view class="null-box" @click="voiceBtn()"></view>
  51. <!-- 语音广播-执行疏散 -->
  52. <view class="broadcast">
  53. <view class="broadcast_t">语音广播<label>选择喇叭位置</label></view>
  54. <!-- 按钮部分 -->
  55. <view class="trumpet-max-box">
  56. <view @click="trumpetClick(index)"
  57. class="trumpet-for-box" :class="item.type?'trumpet-color-a':'trumpet-color-b'"
  58. v-for="(item,index) in trumpetList" :key="index">
  59. <img src="@/images/icon_sskz_zc.png" v-if="!item.type"/>
  60. <img src="@/images/icon_sskz_xz.png" v-if="item.type"/>
  61. {{item.name}}
  62. </view>
  63. </view>
  64. <view class="broadcast_m">
  65. <view class="broadcast_m_t" :class="liveType?'broadcast_m_t_back_a':'broadcast_m_t_back_b'" @longpress.stop="recordButton" @touchmove.stop="cancelButton" @touchend.stop="sendButton">
  66. {{liveType?'松开发送':'按住说话'}}
  67. </view>
  68. <view class="broadcast_m_b" v-if="!liveType">按住说话,录入广播内容</view>
  69. <view class="broadcast_m_b" v-if="liveType">松开发送,向上滑动取消发送</view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. import { config,} from '@/api/request/config.js'
  77. import {getDeviceList,textParseUrlIps} from '@/api/index.js'
  78. export default {
  79. data() {
  80. return {
  81. form:{
  82. },
  83. broadcastType:false,
  84. //喇叭数据
  85. trumpetList:[],
  86. //广播相关
  87. liveType:false,
  88. sendLock: true, //发送锁,当为true时上锁,false时解锁发送
  89. recorderManager : wx.getRecorderManager(),
  90. //滑动记录
  91. startPoint:{},
  92. }
  93. },
  94. onLoad(option) {
  95. this.getDeviceList()
  96. },
  97. onShow(){
  98. },
  99. methods:{
  100. MonitorBtn(){
  101. // uni.navigateTo({
  102. // url:'/pages/alarmInfo/alarmInfoMonitor'
  103. // })
  104. },
  105. voiceBtn(){
  106. this.broadcastType = !this.broadcastType
  107. },
  108. //获取喇叭
  109. async getDeviceList(){
  110. let obj ={
  111. floorId:5,
  112. page:1,
  113. pageSize:100,
  114. };
  115. const {data} = await getDeviceList(obj)
  116. if(data.code == 200){
  117. for(let i=0;i<data.data.length;i++){
  118. data.data[i].type = false;
  119. }
  120. this.$set(this,'trumpetList',data.data)
  121. }
  122. },
  123. //点击选择喇叭
  124. trumpetClick(index){
  125. this.trumpetList[index].type = !this.trumpetList[index].type
  126. // let _this=this;
  127. // if(_this.trumpetList[index].type==true){
  128. // _this.trumpetList.forEach(function(item2) {
  129. // if(item2.deviceSn==_this.trumpetList[index].deviceSn){
  130. // item2.type=true
  131. // }else{
  132. // item2.type=false
  133. // }
  134. // })
  135. // }
  136. },
  137. //录制
  138. recordButton(e){
  139. console.log("按下")
  140. let self = this;
  141. let num = 0;
  142. for(let i=0;i<self.trumpetList.length;i++){
  143. if(self.trumpetList[i].type){
  144. num++
  145. }
  146. }
  147. if(num == 0){
  148. uni.showToast({
  149. title: '请选择喇叭',
  150. icon:"none",
  151. mask:true,
  152. duration: 2000
  153. });
  154. return
  155. }
  156. this.liveType=true;
  157. console.log('录制',e)
  158. this.startPoint = e.touches[0];//记录长按时开始点信息,后面用于计算上划取消时手指滑动的距离。
  159. const options = {
  160. duration: 10000,
  161. sampleRate: 16000,
  162. numberOfChannels: 1,
  163. encodeBitRate: 48000,
  164. format: 'mp3',
  165. frameSize: 50
  166. }
  167. this.recorderManager.start(options);//开始录音
  168. this.recorderManager.onStart(() => {
  169. console.log('recorder start')
  170. })
  171. this.recorderManager.onError((res) => {
  172. console.log(res);
  173. })
  174. wx.showToast({
  175. title: "正在录音,上划取消发送",
  176. icon: "none",
  177. duration: 60000//先定义个60秒,后面可以手动调用wx.hideToast()隐藏
  178. });
  179. this.sendLock = false;//长按时是不上锁的。
  180. },
  181. //取消
  182. cancelButton(e){
  183. console.log("移动")
  184. let self = this;
  185. let num = 0;
  186. for(let i=0;i<self.trumpetList.length;i++){
  187. if(self.trumpetList[i].type){
  188. num++
  189. }
  190. }
  191. if(num == 0){
  192. return
  193. }
  194. this.liveType=false;
  195. console.log('取消',e)
  196. let moveLenght = e.touches[e.touches.length - 1].clientY - this.startPoint.clientY; //移动距离
  197. /* if (Math.abs(moveLenght) > 50) {
  198. wx.showToast({
  199. title: "松开手指,取消发送",
  200. icon: "none",
  201. duration: 60000
  202. });
  203. this.sendLock = true;//触发了上滑取消发送,上锁
  204. } else {
  205. wx.showToast({
  206. title: "正在录音,上划取消发送",
  207. icon: "none",
  208. duration: 60000
  209. });
  210. this.sendLock = false;//上划距离不足,依然可以发送,不上锁
  211. } */
  212. },
  213. //发送
  214. sendButton(e){
  215. console.log("松开")
  216. let self = this;
  217. let num = 0;
  218. for(let i=0;i<self.trumpetList.length;i++){
  219. if(self.trumpetList[i].type){
  220. num++
  221. }
  222. }
  223. if(num == 0){
  224. return
  225. }
  226. this.liveType=false;
  227. console.log('发送',e)
  228. wx.hideToast();//结束录音、隐藏Toast提示框
  229. this.recorderManager.stop();//结束录音
  230. this.recorderManager.onStop((res) => {
  231. if(!this.sendLock){
  232. console.log('1', this.recorderManager)
  233. this.uploadImg(res.tempFilePath);
  234. }
  235. console.log('停止录音', res.tempFilePath)
  236. console.log("sendLock",this.sendLock);
  237. })
  238. },
  239. //发送语音
  240. async textParseUrlIps(text){
  241. let self = this;
  242. let newList = [];
  243. for(let i=0;i<self.trumpetList.length;i++){
  244. if(self.trumpetList[i].type){
  245. let obj = {
  246. sn:self.trumpetList[i].deviceSn,
  247. port:self.trumpetList[i].port,
  248. deviceIp:self.trumpetList[i].deviceIp,
  249. type:"",
  250. name:"",
  251. speed:"",
  252. params:{
  253. tid:"",
  254. vol:"",
  255. urls:[]
  256. }
  257. };
  258. newList.push(obj);
  259. }
  260. }
  261. const {data} = await textParseUrlIps(newList,text)
  262. if(data.code == 200){
  263. uni.showToast({
  264. title: '发送成功',
  265. icon:"none",
  266. mask:true,
  267. duration: 2000
  268. });
  269. }
  270. },
  271. }
  272. }
  273. </script>
  274. <style lang="stylus" scoped>
  275. .alarm{
  276. height:100%;
  277. width:100%;
  278. display:flex;
  279. flex-direction:column;
  280. overflow-y:scroll;
  281. .alarm_t{
  282. padding: 0 20rpx;
  283. box-sizing: border-box;
  284. background: #fff;
  285. .alarm_t_t{
  286. display: flex;
  287. justify-content: flex-start;
  288. align-items: center;
  289. height: 80rpx;
  290. border-bottom: 1px solid #e0e0e0;
  291. >img{
  292. width: 30rpx;
  293. height: 30rpx;
  294. margin-right: 22rpx;
  295. }
  296. >text:nth-of-type(1){
  297. width: 586rpx;
  298. font-size: 28rpx;
  299. font-family: PingFang SC;
  300. font-weight: 500;
  301. color: #333333;
  302. line-height: 28rpx;
  303. }
  304. >text:nth-of-type(2){
  305. font-size: 24rpx;
  306. font-family: PingFang SC;
  307. font-weight: 500;
  308. color: #FF9C00;
  309. line-height: 28rpx;
  310. }
  311. }
  312. .alarm_t_b{
  313. font-size: 28rpx;
  314. font-family: PingFang SC;
  315. font-weight: 500;
  316. color: #666666;
  317. line-height: 120rpx;
  318. }
  319. }
  320. .alarm_c{
  321. margin: 20rpx;
  322. padding:0 16rpx;
  323. box-sizing: border-box;
  324. background: #FFFFFF;
  325. border-radius: 20rpx;
  326. .alarm_c_li{
  327. height: 80rpx;
  328. display: flex;
  329. justify-content: space-between;
  330. border-bottom: 1px solid #e0e0e0;
  331. >text{
  332. font-size: 28rpx;
  333. font-family: PingFang SC;
  334. font-weight: 500;
  335. color: #333333;
  336. line-height: 80rpx;
  337. }
  338. >text:nth-of-type(1){}
  339. >text:nth-of-type(2){
  340. color: #666666;
  341. }
  342. }
  343. .alarm_c_img{
  344. display: flex;
  345. justify-content: flex-start;
  346. margin-top: 30rpx;
  347. >view:nth-of-type(1){
  348. width: 184rpx;
  349. display: inline-block;
  350. font-size: 28rpx;
  351. font-family: PingFang SC;
  352. font-weight: 500;
  353. color: #333333;
  354. line-height: 28rpx;
  355. }
  356. >view:nth-of-type(2){
  357. flex: 1;
  358. display: flex;
  359. justify-content: flex-start;
  360. flex-wrap: wrap;
  361. >img{
  362. width: 150rpx;
  363. height: 150rpx;
  364. background: #FFFFFF;
  365. border-radius: 4rpx;
  366. margin-right: 14rpx;
  367. margin-bottom: 20rpx;
  368. }
  369. }
  370. }
  371. }
  372. .alarm_b{
  373. width: 650rpx;
  374. margin-left: 50rpx;
  375. font-size: 30rpx;
  376. font-family: PingFang SC;
  377. font-weight: 500;
  378. color: #FFFFFF;
  379. line-height: 100rpx;
  380. text-align: center;
  381. position: fixed;
  382. bottom: 20rpx;
  383. display: flex;
  384. justify-content: flex-start;
  385. .alarm_b_l{
  386. width: 325rpx;
  387. height: 100rpx;
  388. background: linear-gradient(-45deg, #FA9901, #F28E26);
  389. border-radius: 50rpx 0px 0px 50rpx;
  390. }
  391. .alarm_b_r{
  392. width: 325rpx;
  393. height: 100rpx;
  394. background: linear-gradient(-35deg, #309CFF, #0183FA);
  395. border-radius: 0px 50rpx 50rpx 0px;
  396. }
  397. }
  398. .shade-max-big-box{
  399. height:100%;
  400. width:100%;
  401. position fixed
  402. display flex;
  403. flex-direction column
  404. z-index:10;
  405. background :rgba(0,0,0,0.2);
  406. .null-box{
  407. flex:1;
  408. }
  409. /* 语音广播-执行疏散 */
  410. .broadcast{
  411. width: 100%;
  412. // height: 532rpx;
  413. background: #FFFFFF;
  414. border-top-left-radius :20rpx;
  415. border-top-right-radius :20rpx
  416. padding :22rpx 30rpx 30rpx;
  417. box-sizing :border-box;
  418. margin-top:20rpx;
  419. .broadcast_t{
  420. font-size: 30rpx;
  421. font-family: PingFang SC;
  422. font-weight: 500;
  423. color: #333333;
  424. line-height: 30rpx;
  425. >label{
  426. font-size: 24rpx;
  427. font-family: PingFang SC;
  428. font-weight: 500;
  429. color: #999999;
  430. line-height: 30rpx;
  431. margin-left :16rpx;
  432. }
  433. }
  434. .trumpet-max-box{
  435. display :flex;
  436. justify-content :flex-start;
  437. margin-top :22rpx;
  438. flex-wrap: wrap;
  439. .trumpet-for-box{
  440. display:inline-block;
  441. width:200rpx;
  442. height:60rpx;
  443. line-height:60rpx;
  444. font-size:24rpx;
  445. text-align center;
  446. cursor: pointer;
  447. overflow: hidden;
  448. border: 1rpx solid #E0E0E0;
  449. border-radius:10rpx;
  450. color: #E0E0E0;
  451. display :flex;
  452. justify-content :center;
  453. margin-right :20rpx;
  454. margin-bottom: 10rpx;
  455. >img{
  456. width:36rpx;
  457. height:34rpx;
  458. margin :12rpx 20rpx 0 25rpx;
  459. }
  460. }
  461. .trumpet-color-a{
  462. border:1px solid #0183FA;
  463. color:#0183FA;
  464. }
  465. .trumpet-color-b{
  466. border:1px solid #CCCCCC;
  467. color:#999;
  468. }
  469. }
  470. .broadcast_m{
  471. width :100%;
  472. .broadcast_m_t{
  473. width: 142rpx;
  474. height: 142rpx;
  475. margin :30rpx 0 0 258rpx;
  476. position :relative;
  477. font-size: 24rpx;
  478. font-family: PingFang SC;
  479. font-weight: 500;
  480. line-height: 170rpx;
  481. text-align center
  482. >img{
  483. width: 142rpx;
  484. height: 142rpx;
  485. position :absolute;
  486. }
  487. >label{
  488. width :100%;
  489. font-size: 24rpx;
  490. font-family: PingFang SC;
  491. font-weight: 500;
  492. color: #0183FA;
  493. line-height: 24rpx;
  494. display :inline-block;
  495. text-align :center;
  496. position :absolute;
  497. top:76rpx;
  498. }
  499. /* 按下 */
  500. .press_color{
  501. color: #FFFFFF;
  502. }
  503. /* 松开 */
  504. .slip_color{
  505. color: #0183FA;
  506. }
  507. }
  508. .broadcast_m_t_back_a{
  509. background:url(@/images/icon_sskz_skfs.png);
  510. background-size 100%
  511. color: #FFFFFF;
  512. }
  513. .broadcast_m_t_back_b{
  514. background:url(@/images/icon_sskz_azsh.png);
  515. background-size 100%
  516. color: #0183FA;
  517. }
  518. .broadcast_m_b{
  519. font-size: 24rpx;
  520. font-family: PingFang SC;
  521. font-weight: 500;
  522. color: #999999;
  523. line-height: 24rpx;
  524. text-align center;
  525. margin-top :14rpx;
  526. }
  527. }
  528. /* 疏散按钮 */
  529. .evacuation-button-box{
  530. width:650rpx;
  531. height:100rpx;
  532. background #0183FA
  533. color:#fff;
  534. text-align center;
  535. line-height:100rpx;
  536. font-size:28rpx;
  537. margin:88rpx auto 0;
  538. border-radius:20rpx;
  539. }
  540. }
  541. }
  542. }
  543. /deep/.input-value-border{
  544. display :none !important;
  545. }
  546. </style>