work.nvue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. <template>
  2. <view class="nv-work">
  3. <image class="banner" src="../../static/bg.png"></image>
  4. <view class="selectTap">
  5. <uni-icons color="#fff" type="home" size="16"></uni-icons>
  6. <picker mode="selector" :value="pickeIndex" range-key="robotName" :range="pickerList" @change="changePicker">
  7. <text class="t1">{{robotName}}</text>
  8. </picker>
  9. <uni-icons color="#fff" type="bottom" size="16"></uni-icons>
  10. </view>
  11. <view class="nv-video" elevation="3px">
  12. <view class="top">
  13. <text @click="changeVideo(1)" :class="[{active:Aindex == 1},{t2:true}]">可见光视频</text>
  14. <text class="t1"></text>
  15. <text @click="changeVideo(2)" :class="[{active:Aindex == 2},{t2:true}]">红外视频</text>
  16. </view>
  17. <view class="videoBox">
  18. <video controls="true" :enable-play-gesture="true" class="myVideo" object-fit="fill" :src="videoSrc" @error="videoErrorCallback" :autoplay="true"
  19. ></video>
  20. </view>
  21. </view>
  22. <view class="nv-list" elevation="3px">
  23. <view class="top">
  24. <view class="top-v">
  25. <text class="icons">&#xe6f9;</text>
  26. <text class="t2 ">环境</text>
  27. </view>
  28. <view>
  29. <image src="/static/loadings.gif" v-if="!refreshShow" mode="" style="width: 32rpx;height: 32rpx;"></image>
  30. <uni-icons @click="refresh" v-if="refreshShow" class="" type="refreshempty" color="#999" size="24"></uni-icons>
  31. </view>
  32. </view>
  33. <view class="center">
  34. <view class="ul">
  35. <view class="li" v-for="(item,index) in envirList" :key="index">
  36. <text class="icon">{{filterType(item.type)}}</text>
  37. <text class="t1">{{item.name}}</text>
  38. <view class="vt2">
  39. <text class="t2" :style="{color:item.isWarning ?'#ED8B5A':''}">{{item.value || '-'}}</text>
  40. <!-- <text class="t3">{{item.unit}}</text> -->
  41. </view>
  42. </view>
  43. <view class="empty" v-if="envirList.length== 0 && !loading">
  44. <text class="icon emptyicon">&#xe604;</text>
  45. <text class="e-t1">暂无数据</text>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <!-- <view v-if="!Token">
  51. <button @click="login">暂未登录</button>
  52. </view> -->
  53. <uni-popup ref="popupqx" type="dialog">
  54. <uni-popup-dialog mode="base" title="提示" content="是否开启系统通知权限功能" :duration="2000" @confirm="confirmQx">
  55. </uni-popup-dialog>
  56. </uni-popup>
  57. <uni-popup ref="popup" :mask-click="false">
  58. <view style="background: #ffffff;">
  59. <text style="padding: 40rpx;padding-top: 60rpx;padding-bottom: 60rpx;font-size: 22rpx;color: #666666;;">无数据,请先关注机器人</text>
  60. <button type="primary" size="mini" @click="confirmGo" style="color: #ffffff;background: #0581FD;border: none;border-radius: 0;">去关注</button>
  61. </view>
  62. </uni-popup>
  63. </view>
  64. </template>
  65. <script>
  66. var domModule = weex.requireModule('dom');
  67. domModule.addRule('fontFace', {
  68. 'fontFamily': "iconfont",
  69. 'src': "url('/static/iconfont.ttf')"
  70. })
  71. var bitmap = null;
  72. import permision from "@/js_sdk/wa-permission/permission.js"
  73. import {
  74. BeforeNavigateTo
  75. } from '../../common/utils.js'
  76. import {
  77. mapGetters
  78. } from 'vuex'
  79. import {
  80. getRobotList,
  81. addTask,
  82. getEnvData,getReadNum
  83. } from '@/common/api.js'
  84. export default {
  85. data() {
  86. return {
  87. showEmplty: false,
  88. robotName: '-',
  89. robotData: null,
  90. pickerList: [],
  91. loading:false,
  92. pickeIndex:0,
  93. step:1,
  94. Aindex: 1,
  95. videoSrc: '',
  96. envirList: [],
  97. refreshShow:true
  98. }
  99. },
  100. onLoad() {
  101. // this.$nextTick(() => {
  102. // if (!this.Token) {
  103. // uni.reLaunch({
  104. // url: '/pages/native/login'
  105. // })
  106. // } else {
  107. // //this.judgeIosPermission()
  108. // }
  109. // })
  110. var that = this;
  111. setInterval(function(){
  112. if(uni.getStorageSync("getRealNews")==1){
  113. getReadNum({
  114. userId: that.$store.state.Token
  115. }).then(res => {
  116. if(res==0){
  117. uni.hideTabBarRedDot({ //隐藏红点
  118. index: 2
  119. })
  120. }else{
  121. uni.showTabBarRedDot({ //显示红点
  122. index: 2
  123. })
  124. }
  125. }).catch(e => {
  126. console.log(e)
  127. })
  128. }
  129. },5000)
  130. uni.$off('DpopLog1');
  131. uni.$on('DpopLog1', (data) => {
  132. addTask({
  133. robotId: this.robotData.robotId
  134. }).then(res => {
  135. uni.showToast({
  136. title: '操作成功',
  137. duration: 2000
  138. })
  139. }).catch(e => {
  140. console.log(e)
  141. })
  142. });
  143. uni.$off('xBpopLog2');
  144. uni.$on('xBpopLog2', (data) => {
  145. setTimeout(() =>{
  146. const csubNVue1 = uni.getSubNVueById('DpopLog1')
  147. csubNVue1.show('fade-in', 300, () => {
  148. });
  149. },300)
  150. });
  151. uni.$off('backhomes');
  152. uni.$on("backhomes",() =>{console.log("work++++++++++++++++++++++++")
  153. this.robotName = ""
  154. this.envirList = []
  155. this.pickerList = []
  156. this.getRobotList()
  157. })
  158. //uni.preloadPage({url: "/pages/native/work/inProcess"});
  159. },
  160. mounted() {
  161. this.getRobotList()
  162. },
  163. onReady() {
  164. this.$refs.ani.init({
  165. })
  166. },
  167. onShow() {
  168. if(this.pickerList.length >0){
  169. this.Aindex = 1
  170. this.changePicker(1)
  171. }else{
  172. this.Aindex = 1
  173. this.videoSrc = `rtsp://admin:admin@192.168.1.1:554/h265/ch01/main/av_stream`
  174. this.$refs.popup.open()
  175. }
  176. this.getEnvData()
  177. },
  178. computed: {
  179. ...mapGetters([
  180. 'Token'
  181. ]),
  182. },
  183. onNavigationBarButtonTap(e) {
  184. uni.navigateTo({
  185. url:'/pages/webview/popSelect'
  186. })
  187. },
  188. methods: {
  189. confirmGo(value) {
  190. this.$refs.popup.close()
  191. uni.navigateTo({
  192. url:'/pages/native/robot'
  193. })
  194. },
  195. refresh(){
  196. this.refreshShow = false;
  197. var that = this;
  198. setTimeout(function(){
  199. that.getEnvData()
  200. },800)
  201. },
  202. getRobotList(){
  203. getRobotList().then(res => {
  204. this.pickerList = res.filter(item =>{
  205. return item.followed == 1
  206. }) || []
  207. if(this.pickerList.length >0){
  208. this.robotName = this.pickerList[0].robotName
  209. this.robotData = this.pickerList[0]
  210. // console.log(this.robotData)
  211. //this.videoSrc = 'rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov'
  212. this.videoSrc = `rtsp://${this.robotData.ptzLoginUser}:${this.robotData.ptzPassword}@${this.robotData.domainName}:554/h265/ch01/main/av_stream`
  213. this.getEnvData()
  214. this.$refs.popup.close()
  215. }
  216. else{
  217. this.$refs.popup.open()
  218. this.robotName = null
  219. this.robotData = null
  220. this.videoSrc = `rtsp://admin:admin@192.168.1.1:554/h265/ch01/main/av_stream`
  221. }
  222. })
  223. },
  224. getEnvData() {
  225. getEnvData({
  226. robotId: this.robotData.robotId
  227. }).then(res => {
  228. this.envirList = res
  229. this.loading = false
  230. this.refreshShow = true;
  231. }).catch(e => {
  232. this.envirList = []
  233. this.loading = false
  234. this.refreshShow = true;
  235. console.log(e)
  236. })
  237. },
  238. changeVideo(index) {
  239. this.Aindex = index
  240. index == 1 ?
  241. this.videoSrc =
  242. `rtsp://${this.robotData.ptzLoginUser}:${this.robotData.ptzPassword}@${this.robotData.ip}:554/h265/ch01/main/av_stream` :
  243. this.videoSrc =
  244. `rtsp://${this.robotData.ptzLoginUser}:${this.robotData.ptzPassword}@${this.robotData.ip}:554/h265/ch02/main/av_stream`
  245. },
  246. changePicker(e) {
  247. let data = this.pickerList[e.detail.value]
  248. this.Aindex = 1
  249. this.pickeIndex = e.detail.value
  250. this.robotData = data
  251. this.robotName = data.robotName
  252. this.videoSrc = `rtsp://${data.ptzLoginUser}:${data.ptzPassword}@${data.ip}:554/h264/ch01/main/av_stream`
  253. this.getEnvData()
  254. console.log(this.videoSrc)
  255. },
  256. videoErrorCallback(e) {
  257. console.log(e)
  258. },
  259. confirmQx() { //权限设置
  260. permision.gotoAppPermissionSetting()
  261. },
  262. async judgeIosPermission() {
  263. permision.requestAndroidPermission('android.permission.BROADCAST_WAP_PUSH').then(res => {
  264. console.log(res)
  265. })
  266. },
  267. login() {
  268. BeforeNavigateTo({
  269. url: '/pages/native/login'
  270. }, true)
  271. },
  272. filterType(type) {
  273. switch (type) {
  274. case 'HUMIDITY':
  275. return '\ue871';
  276. case 'TEMPERATURE':
  277. return '\ue71a';
  278. case 'CO':
  279. return '\ue723'
  280. case 'O3':
  281. return '\ue6e0'
  282. case 'SF6':
  283. return '\ue71e'
  284. case 'FIRE':
  285. return '\ue669'
  286. case 'O2':
  287. return '\ue635'
  288. case 'MQ':
  289. return '\ue625'
  290. case 'LIGHT':
  291. return '\ue673'
  292. case 'PM':
  293. return '\uea32'
  294. case 'CO2':
  295. return '\ueb95'
  296. case 'AIRPRESSURE':
  297. return '\ue668'
  298. case 'RAININESS':
  299. return '\ue600'
  300. case 'WINDDIRECTION':
  301. return '\ue783'
  302. case 'WINDPOWER':
  303. return '\ue696'
  304. case 'WINDSPEED':
  305. return '\ue606'
  306. case 'ANXIOUSBURNTFLAVOUR':
  307. return '\ue614'
  308. case 'RAINFALL':
  309. return '\uea2e'
  310. case 'PM10':
  311. return '\ue8d5'
  312. default :
  313. return '\ue613'
  314. }
  315. }
  316. }
  317. }
  318. </script>
  319. <style scoped lang="scss">
  320. .icon {
  321. font-family: iconfont;
  322. font-size: 26px;
  323. color: #108EE9;
  324. opacity: 0.7;
  325. }
  326. .icons {
  327. font-family: iconfont;
  328. color: #0581FD;
  329. font-size: 26px;
  330. }
  331. .empty{
  332. width: 750rpx;
  333. height: 500rpx;
  334. align-items: center;
  335. justify-content: center;
  336. .e-t1{
  337. font-size: 28rpx;
  338. color: #0099FF;
  339. padding:20rpx;
  340. }
  341. .emptyicon{
  342. font-size: 80px !important;
  343. }
  344. }
  345. .nv-work {
  346. .banner {
  347. width: 750rpx;
  348. height: 348rpx;
  349. background: #0581FD;
  350. }
  351. .selectTap {
  352. position: absolute;
  353. top: 20rpx;
  354. z-index: 99999;
  355. left: 20rpx;
  356. align-items: center;
  357. display: flex;
  358. flex-direction: row;
  359. .t1 {
  360. color: #fff;
  361. font-size: 28rpx;
  362. padding: 0 10rpx 0 5rpx;
  363. }
  364. }
  365. .nv-video {
  366. position: absolute;
  367. background-color: #FFFFFF;
  368. border-radius: 18rpx;
  369. box-shadow: 1px 2px 10px 0px #E5E5E5;
  370. top: 80rpx;
  371. z-index: 99999;
  372. left: 20rpx;
  373. right: 20rpx;
  374. .videoBox {
  375. .myVideo {
  376. width: 680rpx;
  377. height: 360rpx;
  378. }
  379. width: 680rpx;
  380. padding-bottom: 30rpx;
  381. margin:0 20rpx;
  382. }
  383. .top {
  384. display: flex;
  385. flex-direction: row;
  386. align-items: center;
  387. padding: 30rpx 22rpx;
  388. .t1 {
  389. width: 2px;
  390. height: 16px;
  391. margin: 0 10rpx;
  392. background: #0581FD;
  393. border-radius: 2px;
  394. }
  395. .t2 {
  396. color: #666;
  397. font-size: 28rpx;
  398. }
  399. .active {
  400. color: #333;
  401. font-weight: bold;
  402. }
  403. }
  404. }
  405. .nv-list {
  406. z-index: 99999;
  407. margin: 240rpx 20rpx 50rpx 20rpx;
  408. background-color: #FFFFFF;
  409. border-radius: 18rpx;
  410. box-shadow: 1px 2px 10px 0px #E5E5E5;
  411. .top {
  412. display: flex;
  413. flex-direction: row;
  414. border-bottom: 1px solid #E5E5E5;
  415. justify-content: space-between;
  416. align-items: center;
  417. padding: 20rpx 0;
  418. margin: 0rpx 22rpx 0 22rpx;
  419. .top-v{
  420. flex-direction: row;
  421. align-items: center;
  422. }
  423. .active{
  424. animation-name: ares;
  425. animation-duration: 1s;
  426. animation-iteration-count: 3;
  427. }
  428. .t2 {
  429. color: #333;
  430. font-size: 30rpx;
  431. font-weight: bold;
  432. padding-left: 10rpx;
  433. }
  434. }
  435. .center {
  436. .ul {
  437. display: flex;
  438. flex-direction: row;
  439. flex-wrap: wrap;
  440. padding-bottom: 35rpx;
  441. text-align: center;
  442. .li {
  443. margin-top: 35rpx;
  444. align-items: center;
  445. text-align: center;
  446. justify-content: center;
  447. display: flex;
  448. flex-direction: column;
  449. width: 177.5rpx;
  450. .vt2{
  451. display: flex;
  452. flex-direction: row;
  453. align-items: center;
  454. justify-content: center;
  455. }
  456. .t1 {
  457. color: #0581FD;
  458. font-size: 22rpx;
  459. margin-top: 5rpx;
  460. }
  461. .t3{
  462. font-size: 22rpx;
  463. color: #999;
  464. }
  465. .t2 {
  466. color: #58B453;
  467. font-size: 24rpx;
  468. margin-top: 5rpx;
  469. }
  470. }
  471. }
  472. }
  473. }
  474. }
  475. @keyframes ares {
  476. 0%{
  477. transform:rotate(0deg);
  478. }
  479. 100%{
  480. transform:rotate(360deg);
  481. }
  482. }
  483. </style>