work.nvue 9.8 KB

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