work.nvue 9.0 KB

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