From e48fa711a3664bece9b3e58840a75fe7c05bc47c Mon Sep 17 00:00:00 2001 From: panlinlin <648540858@qq.com> Date: 星期六, 08 五月 2021 17:14:05 +0800 Subject: [PATCH] 添加截图(快照)功能 --- web_src/src/components/channelList.vue | 69 ++++++++++++++++++++++++++-------- 1 files changed, 53 insertions(+), 16 deletions(-) diff --git a/web_src/src/components/channelList.vue b/web_src/src/components/channelList.vue index 324eef4..548bd2c 100644 --- a/web_src/src/components/channelList.vue +++ b/web_src/src/components/channelList.vue @@ -30,9 +30,27 @@ <el-table ref="channelListTable" :data="deviceChannelList" :height="winHeight" border style="width: 100%"> <el-table-column prop="channelId" label="閫氶亾缂栧彿" width="210"> </el-table-column> - <el-table-column prop="channelId" label="璁惧缂栧彿" width="210"> + <el-table-column prop="deviceId" label="璁惧缂栧彿" width="210"> </el-table-column> <el-table-column prop="name" label="閫氶亾鍚嶇О"> + </el-table-column> + <el-table-column label="蹇収" width="80" align="center"> + <template slot-scope="scope"> + <img style="max-height: 3rem;max-width: 4rem;" + :id="scope.row.deviceId + '_' + scope.row.channelId" + :src="getSnap(scope.row)" + @error="getSnapErrorEvent($event.target.id)" + alt=""> +<!-- <el-image--> +<!-- :id="'snapImg_' + scope.row.deviceId + '_' + scope.row.channelId"--> +<!-- :src="getSnap(scope.row)"--> +<!-- @error="getSnapErrorEvent($event, scope.row)"--> +<!-- :fit="'contain'">--> +<!-- <div slot="error" class="image-slot">--> +<!-- <i class="el-icon-picture-outline"></i>--> +<!-- </div>--> +<!-- </el-image>--> + </template> </el-table-column> <el-table-column prop="subCount" label="瀛愯妭鐐规暟"> </el-table-column> @@ -100,7 +118,8 @@ total: 0, beforeUrl: "/deviceList", isLoging: false, - autoList: true + autoList: true, + loadSnap:{} }; }, @@ -122,7 +141,6 @@ } else { this.showSubchannels(); } - }, initParam: function () { this.deviceId = this.$route.params.deviceId; @@ -174,8 +192,6 @@ }).catch(function (error) { console.log(error); }); - - }, //閫氱煡璁惧涓婁紶濯掍綋娴� @@ -190,18 +206,22 @@ method: 'get', url: '/api/play/start/' + deviceId + '/' + channelId }).then(function (res) { - console.log(res.data) - let streamId = res.data.streamId; that.isLoging = false; - if (!!streamId) { - // that.$refs.devicePlayer.play(res.data, deviceId, channelId, itemData.hasAudio); - that.$refs.devicePlayer.openDialog("media", deviceId, channelId, { - streamInfo: res.data, - hasAudio: itemData.hasAudio - }); - that.initData(); - } else { - that.$message.error(res.data); + if (res.data.code == 0) { + + setTimeout(()=>{ + console.log("涓嬭浇鎴浘") + let snapId = deviceId + "_" + channelId; + that.loadSnap[snapId] = 0; + that.getSnapErrorEvent(snapId) + },5000) + that.$refs.devicePlayer.openDialog("media", deviceId, channelId, { + streamInfo: res.data.data, + hasAudio: itemData.hasAudio + }); + that.initData(); + }else { + that.$message.error(res.data.msg); } }).catch(function (e) {}); }, @@ -228,7 +248,24 @@ } }); }, + getSnap: function (row){ + return '/static/snap/' + row.deviceId + '_' + row.channelId + '.jpg' + }, + getSnapErrorEvent: function (id){ + if (typeof (this.loadSnap[id]) != "undefined") { + console.log("涓嬭浇鎴浘" + this.loadSnap[id]) + if (this.loadSnap[id] > 5) { + delete this.loadSnap[id]; + return; + } + setTimeout(()=>{ + this.loadSnap[id] ++ + document.getElementById(id).setAttribute("src", '/static/snap/' + id + '.jpg?' + new Date().getTime()) + },1000) + + } + }, showDevice: function () { this.$router.push(this.beforeUrl).then(() => { this.initParam(); -- Gitblit v1.8.0