123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514 |
- <template>
- <view class="nv-work">
- <image class="banner" src="../../static/bg.png"></image>
- <view class="selectTap">
- <uni-icons color="#fff" type="home" size="16"></uni-icons>
- <picker mode="selector" :value="pickeIndex" range-key="robotName" :range="pickerList" @change="changePicker">
- <text class="t1">{{robotName}}</text>
- </picker>
- <uni-icons color="#fff" type="bottom" size="16"></uni-icons>
- </view>
- <view class="nv-video" elevation="3px">
- <view class="top">
- <text @click="changeVideo(1)" :class="[{active:Aindex == 1},{t2:true}]">可见光视频</text>
- <text class="t1"></text>
- <text @click="changeVideo(2)" :class="[{active:Aindex == 2},{t2:true}]">红外视频</text>
- </view>
- <view class="videoBox">
- <video controls="true" :enable-play-gesture="true" class="myVideo" object-fit="fill" :src="videoSrc" @error="videoErrorCallback" :autoplay="true"
- ></video>
- </view>
- </view>
- <view class="nv-list" elevation="3px">
- <view class="top">
- <view class="top-v">
- <text class="icons"></text>
- <text class="t2 ">环境</text>
- </view>
- <view>
- <image src="/static/loadings.gif" v-if="!refreshShow" mode="" style="width: 32rpx;height: 32rpx;"></image>
- <uni-icons @click="refresh" v-if="refreshShow" class="" type="refreshempty" color="#999" size="24"></uni-icons>
- </view>
- </view>
- <view class="center">
- <view class="ul">
- <view class="li" v-for="(item,index) in envirList" :key="index">
- <text class="icon">{{filterType(item.type)}}</text>
- <text class="t1">{{item.name}}</text>
- <view class="vt2">
- <text class="t2" :style="{color:item.isWarning ?'#ED8B5A':''}">{{item.value || '-'}}</text>
- <!-- <text class="t3">{{item.unit}}</text> -->
- </view>
- </view>
- <view class="empty" v-if="envirList.length== 0 && !loading">
- <text class="icon emptyicon"></text>
- <text class="e-t1">暂无数据</text>
- </view>
- </view>
- </view>
- </view>
- <!-- <view v-if="!Token">
- <button @click="login">暂未登录</button>
- </view> -->
- <uni-popup ref="popupqx" type="dialog">
- <uni-popup-dialog mode="base" title="提示" content="是否开启系统通知权限功能" :duration="2000" @confirm="confirmQx">
- </uni-popup-dialog>
- </uni-popup>
- <uni-popup ref="popup" :mask-click="false">
- <view style="background: #ffffff;">
- <text style="padding: 40rpx;padding-top: 60rpx;padding-bottom: 60rpx;font-size: 22rpx;color: #666666;;">无数据,请先关注机器人</text>
- <button type="primary" size="mini" @click="confirmGo" style="color: #ffffff;background: #0581FD;border: none;border-radius: 0;">去关注</button>
- </view>
- </uni-popup>
- </view>
- </template>
- <script>
- var domModule = weex.requireModule('dom');
- domModule.addRule('fontFace', {
- 'fontFamily': "iconfont",
- 'src': "url('/static/iconfont.ttf')"
- })
- var bitmap = null;
- import permision from "@/js_sdk/wa-permission/permission.js"
- import {
- BeforeNavigateTo
- } from '../../common/utils.js'
- import {
- mapGetters
- } from 'vuex'
- import {
- getRobotList,
- addTask,
- getEnvData,getReadNum
- } from '@/common/api.js'
- export default {
- data() {
- return {
- showEmplty: false,
- robotName: '-',
- robotData: null,
- pickerList: [],
- loading:false,
- pickeIndex:0,
- step:1,
- Aindex: 1,
- videoSrc: '',
- envirList: [],
- refreshShow:true
- }
- },
- onLoad() {
- // this.$nextTick(() => {
- // if (!this.Token) {
- // uni.reLaunch({
- // url: '/pages/native/login'
- // })
- // } else {
- // //this.judgeIosPermission()
- // }
- // })
- var that = this;
- setInterval(function(){
- if(uni.getStorageSync("getRealNews")==1){
- getReadNum({
- userId: that.$store.state.Token
- }).then(res => {
- if(res==0){
- uni.hideTabBarRedDot({ //隐藏红点
- index: 2
- })
- }else{
- uni.showTabBarRedDot({ //显示红点
- index: 2
- })
- }
- }).catch(e => {
- console.log(e)
- })
- }
- },5000)
- uni.$off('DpopLog1');
- uni.$on('DpopLog1', (data) => {
- addTask({
- robotId: this.robotData.robotId
- }).then(res => {
- uni.showToast({
- title: '操作成功',
- duration: 2000
- })
- }).catch(e => {
- console.log(e)
- })
- });
- uni.$off('xBpopLog2');
- uni.$on('xBpopLog2', (data) => {
- setTimeout(() =>{
- const csubNVue1 = uni.getSubNVueById('DpopLog1')
- csubNVue1.show('fade-in', 300, () => {
- });
- },300)
- });
- uni.$off('backhomes');
- uni.$on("backhomes",() =>{console.log("work++++++++++++++++++++++++")
- this.robotName = ""
- this.envirList = []
- this.pickerList = []
- this.getRobotList()
- })
- //uni.preloadPage({url: "/pages/native/work/inProcess"});
- },
- mounted() {
- this.getRobotList()
- },
- onReady() {
- this.$refs.ani.init({
- })
- },
- onShow() {
- if(this.pickerList.length >0){
- this.Aindex = 1
- this.changePicker(1)
- }else{
- this.Aindex = 1
- this.videoSrc = `rtsp://admin:admin@192.168.1.1:554/h265/ch01/main/av_stream`
- this.$refs.popup.open()
- }
- this.getEnvData()
- },
- computed: {
- ...mapGetters([
- 'Token'
- ]),
- },
- onNavigationBarButtonTap(e) {
- uni.navigateTo({
- url:'/pages/webview/popSelect'
- })
- },
- methods: {
- confirmGo(value) {
- this.$refs.popup.close()
- uni.navigateTo({
- url:'/pages/native/robot'
- })
- },
- refresh(){
- this.refreshShow = false;
- var that = this;
- setTimeout(function(){
- that.getEnvData()
- },800)
- },
- getRobotList(){
- getRobotList().then(res => {
- this.pickerList = res.filter(item =>{
- return item.followed == 1
- }) || []
- if(this.pickerList.length >0){
- this.robotName = this.pickerList[0].robotName
- this.robotData = this.pickerList[0]
- // console.log(this.robotData)
- //this.videoSrc = 'rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov'
- this.videoSrc = `rtsp://${this.robotData.ptzLoginUser}:${this.robotData.ptzPassword}@${this.robotData.domainName}:554/h265/ch01/main/av_stream`
- this.getEnvData()
- this.$refs.popup.close()
- }
- else{
- this.$refs.popup.open()
- this.robotName = null
- this.robotData = null
- this.videoSrc = `rtsp://admin:admin@192.168.1.1:554/h265/ch01/main/av_stream`
- }
- })
- },
- getEnvData() {
- getEnvData({
- robotId: this.robotData.robotId
- }).then(res => {
- this.envirList = res
- this.loading = false
- this.refreshShow = true;
- }).catch(e => {
- this.envirList = []
- this.loading = false
- this.refreshShow = true;
- console.log(e)
- })
- },
- changeVideo(index) {
- this.Aindex = index
- index == 1 ?
- this.videoSrc =
- `rtsp://${this.robotData.ptzLoginUser}:${this.robotData.ptzPassword}@${this.robotData.ip}:554/h265/ch01/main/av_stream` :
- this.videoSrc =
- `rtsp://${this.robotData.ptzLoginUser}:${this.robotData.ptzPassword}@${this.robotData.ip}:554/h265/ch02/main/av_stream`
- },
- changePicker(e) {
- let data = this.pickerList[e.detail.value]
- this.Aindex = 1
- this.pickeIndex = e.detail.value
- this.robotData = data
- this.robotName = data.robotName
- this.videoSrc = `rtsp://${data.ptzLoginUser}:${data.ptzPassword}@${data.ip}:554/h264/ch01/main/av_stream`
- this.getEnvData()
- console.log(this.videoSrc)
- },
- videoErrorCallback(e) {
- console.log(e)
- },
- confirmQx() { //权限设置
- permision.gotoAppPermissionSetting()
- },
- async judgeIosPermission() {
- permision.requestAndroidPermission('android.permission.BROADCAST_WAP_PUSH').then(res => {
- console.log(res)
- })
- },
- login() {
- BeforeNavigateTo({
- url: '/pages/native/login'
- }, true)
- },
- filterType(type) {
- switch (type) {
- case 'HUMIDITY':
- return '\ue871';
- case 'TEMPERATURE':
- return '\ue71a';
- case 'CO':
- return '\ue723'
- case 'O3':
- return '\ue6e0'
- case 'SF6':
- return '\ue71e'
- case 'FIRE':
- return '\ue669'
- case 'O2':
- return '\ue635'
- case 'MQ':
- return '\ue625'
- case 'LIGHT':
- return '\ue673'
- case 'PM':
- return '\uea32'
- case 'CO2':
- return '\ueb95'
- case 'AIRPRESSURE':
- return '\ue668'
- case 'RAININESS':
- return '\ue600'
- case 'WINDDIRECTION':
- return '\ue783'
- case 'WINDPOWER':
- return '\ue696'
- case 'WINDSPEED':
- return '\ue606'
- case 'ANXIOUSBURNTFLAVOUR':
- return '\ue614'
- case 'RAINFALL':
- return '\uea2e'
- case 'PM10':
- return '\ue8d5'
- default :
- return '\ue613'
- }
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .icon {
- font-family: iconfont;
- font-size: 26px;
- color: #108EE9;
- opacity: 0.7;
- }
- .icons {
- font-family: iconfont;
- color: #0581FD;
- font-size: 26px;
- }
- .empty{
- width: 750rpx;
- height: 500rpx;
- align-items: center;
- justify-content: center;
- .e-t1{
- font-size: 28rpx;
- color: #0099FF;
- padding:20rpx;
- }
- .emptyicon{
- font-size: 80px !important;
- }
- }
- .nv-work {
- .banner {
- width: 750rpx;
- height: 348rpx;
- background: #0581FD;
- }
- .selectTap {
- position: absolute;
- top: 20rpx;
- z-index: 99999;
- left: 20rpx;
- align-items: center;
- display: flex;
- flex-direction: row;
- .t1 {
- color: #fff;
- font-size: 28rpx;
- padding: 0 10rpx 0 5rpx;
- }
- }
- .nv-video {
- position: absolute;
- background-color: #FFFFFF;
- border-radius: 18rpx;
- box-shadow: 1px 2px 10px 0px #E5E5E5;
- top: 80rpx;
- z-index: 99999;
- left: 20rpx;
- right: 20rpx;
- .videoBox {
- .myVideo {
- width: 680rpx;
- height: 360rpx;
- }
- width: 680rpx;
- padding-bottom: 30rpx;
- margin:0 20rpx;
- }
- .top {
- display: flex;
- flex-direction: row;
- align-items: center;
- padding: 30rpx 22rpx;
- .t1 {
- width: 2px;
- height: 16px;
- margin: 0 10rpx;
- background: #0581FD;
- border-radius: 2px;
- }
- .t2 {
- color: #666;
- font-size: 28rpx;
- }
- .active {
- color: #333;
- font-weight: bold;
- }
- }
- }
- .nv-list {
- z-index: 99999;
- margin: 240rpx 20rpx 50rpx 20rpx;
- background-color: #FFFFFF;
- border-radius: 18rpx;
- box-shadow: 1px 2px 10px 0px #E5E5E5;
- .top {
- display: flex;
- flex-direction: row;
- border-bottom: 1px solid #E5E5E5;
- justify-content: space-between;
- align-items: center;
- padding: 20rpx 0;
- margin: 0rpx 22rpx 0 22rpx;
- .top-v{
- flex-direction: row;
- align-items: center;
- }
- .active{
- animation-name: ares;
- animation-duration: 1s;
- animation-iteration-count: 3;
- }
- .t2 {
- color: #333;
- font-size: 30rpx;
- font-weight: bold;
- padding-left: 10rpx;
- }
- }
- .center {
- .ul {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- padding-bottom: 35rpx;
- text-align: center;
- .li {
- margin-top: 35rpx;
- align-items: center;
- text-align: center;
- justify-content: center;
- display: flex;
- flex-direction: column;
- width: 177.5rpx;
- .vt2{
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center;
- }
- .t1 {
- color: #0581FD;
- font-size: 22rpx;
- margin-top: 5rpx;
- }
- .t3{
- font-size: 22rpx;
- color: #999;
- }
- .t2 {
- color: #58B453;
- font-size: 24rpx;
- margin-top: 5rpx;
- }
- }
- }
- }
- }
- }
- @keyframes ares {
- 0%{
- transform:rotate(0deg);
- }
- 100%{
- transform:rotate(360deg);
- }
- }
- </style>
|