hldy_app/unpackage/dist/dev/.nvue/pages/ceshianzhuo.js

584 lines
20 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { _ as _export_sfc, r as requireNativePlugin, f as formatAppLog } from "../_plugin-vue_export-helper.js";
import { resolveComponent, openBlock, createElementBlock, createElementVNode, createCommentVNode, createVNode, withCtx, createTextVNode } from "vue";
const _style_0 = { "center-column": { "": { "display": "flex", "flexDirection": "column", "alignItems": "center" } }, "button-group": { "": { "display": "flex", "flexDirection": "row", "flexWrap": "wrap", "justifyContent": "center", "marginTop": 40, "width": 620 } }, "button": { "": { "marginTop": 6, "marginRight": 6, "marginBottom": 6, "marginLeft": 6, "paddingTop": 8, "paddingRight": 12, "paddingBottom": 8, "paddingLeft": 12, "minWidth": "120px", "height": 44, "borderRadius": 6, "borderWidth": 1, "borderStyle": "solid", "borderColor": "#dddddd", "backgroundColor": "#ffffff" } } };
const _sfc_main = {
data() {
return {
phoneNumber: "1234567890",
isAlarming: false,
isRecording: false,
// 录屏状态
isTalking: false
// 对讲状态
};
},
onLoad() {
const globalEvent = requireNativePlugin && requireNativePlugin("globalEvent");
if (globalEvent && globalEvent.addEventListener) {
globalEvent.addEventListener("myEvent", (e) => {
formatAppLog("log", "at pages/ceshianzhuo.nvue:73", "myEvent", e);
});
}
},
methods: {
/* ------------------ 原有功能 ------------------ */
handleTelEvent(event) {
formatAppLog("log", "at pages/ceshianzhuo.nvue:80", "Tel event detail:", event.detail);
},
switchDisplay(mode) {
this.$refs.monitor && this.$refs.monitor.switchDisplayModeFragment(mode);
},
startAlarm() {
this.isAlarming = true;
this.$refs.monitor.startOrStopManualAlarm(this.isAlarming, (res) => {
formatAppLog("log", "at pages/ceshianzhuo.nvue:91", "startAlarm callback:", res);
});
},
stopAlarm() {
this.isAlarming = false;
this.$refs.monitor.startOrStopManualAlarm(this.isAlarming, (res) => {
formatAppLog("log", "at pages/ceshianzhuo.nvue:97", "stopAlarm callback:", res);
});
},
flipImage(type) {
this.$refs.monitor.changeImageSwitch(type, (res) => {
formatAppLog("log", "at pages/ceshianzhuo.nvue:103", "flipImage callback:", res);
});
},
resumeOrPause() {
this.$refs.monitor.resumeOrPause && this.$refs.monitor.resumeOrPause();
},
changeQuality() {
this.$refs.monitor.changeQuality && this.$refs.monitor.changeQuality();
},
test() {
this.$refs.monitor && this.$refs.monitor.test && this.$refs.monitor.test();
},
/* ------------------ 新增:截图/录屏/对讲 调用方法 ------------------ */
// 1. 截图(调用)
doSnapshot() {
if (!this.$refs.monitor || !this.$refs.monitor.snapShot) {
uni.showToast({
title: "组件不支持 snapShot()",
icon: "none"
});
return;
}
try {
this.$refs.monitor.snapShot((res) => {
formatAppLog("log", "at pages/ceshianzhuo.nvue:134", "snapShot callback:", res);
this._handleSnapshotResultFromNative(res);
});
uni.showToast({
title: "正在截屏...",
icon: "none",
duration: 800
});
} catch (err) {
formatAppLog("error", "at pages/ceshianzhuo.nvue:143", "snapShot 调用失败", err);
uni.showToast({
title: "snapShot 调用失败",
icon: "none"
});
}
},
// 2. 开始录屏(调用)
doStartRecord() {
if (!this.$refs.monitor || !this.$refs.monitor.startRecord) {
uni.showToast({
title: "组件不支持 startRecord()",
icon: "none"
});
return;
}
try {
this.$refs.monitor.startRecord((res) => {
formatAppLog("log", "at pages/ceshianzhuo.nvue:163", "startRecord callback:", res);
});
this.isRecording = true;
uni.showToast({
title: "录屏已开始",
icon: "none"
});
} catch (err) {
formatAppLog("error", "at pages/ceshianzhuo.nvue:171", "startRecord 调用失败", err);
uni.showToast({
title: "startRecord 调用失败",
icon: "none"
});
}
},
// 3. 停止录屏(调用)
doStopRecord() {
if (!this.$refs.monitor || !this.$refs.monitor.stopRecord) {
uni.showToast({
title: "组件不支持 stopRecord()",
icon: "none"
});
return;
}
try {
this.$refs.monitor.stopRecord((res) => {
formatAppLog("log", "at pages/ceshianzhuo.nvue:191", "stopRecord callback:", res);
this._handleRecordResultFromNative(res);
});
} catch (err) {
formatAppLog("error", "at pages/ceshianzhuo.nvue:196", "stopRecord 调用失败", err);
uni.showToast({
title: "stopRecord 调用失败",
icon: "none"
});
}
},
// 4. 开始对讲(调用)
doOpenTalk() {
if (!this.$refs.monitor || !this.$refs.monitor.openTalk) {
uni.showToast({
title: "组件不支持 openTalk()",
icon: "none"
});
return;
}
try {
this.$refs.monitor.openTalk((res) => {
formatAppLog("log", "at pages/ceshianzhuo.nvue:215", "openTalk callback:", res);
});
this.isTalking = true;
uni.showToast({
title: "尝试建立对讲连接...",
icon: "none"
});
} catch (err) {
formatAppLog("error", "at pages/ceshianzhuo.nvue:225", "openTalk 调用失败", err);
uni.showToast({
title: "openTalk 调用失败",
icon: "none"
});
}
},
// 5. 停止对讲(调用)
doStopTalk() {
if (!this.$refs.monitor || !this.$refs.monitor.stopTalk) {
uni.showToast({
title: "组件不支持 stopTalk()",
icon: "none"
});
return;
}
try {
this.$refs.monitor.stopTalk((res) => {
formatAppLog("log", "at pages/ceshianzhuo.nvue:244", "stopTalk callback:", res);
});
this.isTalking = false;
} catch (err) {
formatAppLog("error", "at pages/ceshianzhuo.nvue:250", "stopTalk 调用失败", err);
uni.showToast({
title: "stopTalk 调用失败",
icon: "none"
});
}
},
/* ------------------ 事件回调处理(来自原生推送的事件) ------------------ */
// 处理来自模板 @onSnapShot 的事件event.detail
handleSnapShotEvent(event) {
formatAppLog("log", "at pages/ceshianzhuo.nvue:263", "onSnapShot event:", event && event.detail ? event.detail : event);
this._handleSnapshotResultFromNative(event && event.detail ? event.detail : event);
},
// 处理来自模板 @onRecord 的事件event.detail
handleRecordEvent(event) {
formatAppLog("log", "at pages/ceshianzhuo.nvue:270", "onRecord event:", event && event.detail ? event.detail : event);
this._handleRecordResultFromNative(event && event.detail ? event.detail : event);
},
// 处理来自模板 @onTalkStatus 的事件
handleTalkEvent(event) {
const payload = event && event.detail ? event.detail : event;
formatAppLog("log", "at pages/ceshianzhuo.nvue:278", "onTalkStatus event:", payload);
const status = payload && payload.talkStatus;
const tips = payload && payload.tips;
switch ((status || "").toLowerCase()) {
case "loading":
uni.showToast({
title: tips || "对讲连接中...",
icon: "none"
});
this.isTalking = true;
break;
case "playing":
uni.showToast({
title: tips || "对讲已连接",
icon: "none"
});
this.isTalking = true;
break;
case "stopped":
uni.showToast({
title: tips || "对讲已停止",
icon: "none"
});
this.isTalking = false;
break;
case "failed":
uni.showToast({
title: tips || "对讲失败",
icon: "none"
});
this.isTalking = false;
break;
default:
uni.showToast({
title: tips || "对讲状态: " + (status || "unknown"),
icon: "none"
});
break;
}
},
/* ------------------ 原生结果的内部处理函数(统一处理 callback / event ------------------ */
_handleSnapshotResultFromNative(res) {
if (!res) {
uni.showToast({
title: "截图没有返回数据",
icon: "none"
});
return;
}
let payload = res;
if (res.detail)
payload = res.detail;
formatAppLog("log", "at pages/ceshianzhuo.nvue:337", "snapshot payload normalized:", payload);
if (payload.snapShotResult === true || payload.snapShotResult === "true") {
const url = payload.snapShotUrl || payload.snapShotPath || payload.url;
uni.showToast({
title: "截图成功",
icon: "success",
duration: 1200
});
formatAppLog("log", "at pages/ceshianzhuo.nvue:345", "截图地址:", url);
if (url) {
uni.previewImage({
urls: [url]
});
}
} else {
const err = payload.snapShotErrorCode || payload.error || "unknown";
uni.showToast({
title: "截图失败: " + err,
icon: "none",
duration: 2e3
});
formatAppLog("warn", "at pages/ceshianzhuo.nvue:360", "snapshot failed reason:", err, payload);
}
},
_handleRecordResultFromNative(res) {
if (!res) {
uni.showToast({
title: "录屏没有返回数据",
icon: "none"
});
this.isRecording = false;
return;
}
let payload = res;
if (res.detail)
payload = res.detail;
formatAppLog("log", "at pages/ceshianzhuo.nvue:377", "record payload normalized:", payload);
if (payload.recordUrl) {
uni.showToast({
title: "录屏完成",
icon: "success",
duration: 1400
});
formatAppLog("log", "at pages/ceshianzhuo.nvue:386", "录屏地址:", payload.recordUrl);
this.isRecording = false;
} else if (payload.recordFailedReason) {
uni.showToast({
title: "录屏失败: " + payload.recordFailedReason,
icon: "none",
duration: 2e3
});
formatAppLog("warn", "at pages/ceshianzhuo.nvue:395", "record failed reason:", payload.recordFailedReason);
this.isRecording = false;
} else {
if (payload.snapShotResult === true) {
uni.showToast({
title: "录屏操作已完成(返回未知)",
icon: "none"
});
}
this.isRecording = false;
}
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_MonitorView = resolveComponent("MonitorView");
const _component_MonitorControlView = resolveComponent("MonitorControlView");
const _component_button = resolveComponent("button");
return openBlock(), createElementBlock("scroll-view", {
scrollY: true,
showScrollbar: true,
enableBackToTop: true,
bubble: "true",
style: { flexDirection: "column" }
}, [
createElementVNode("div", { class: "center-column" }, [
createCommentVNode(" 视频播放组件,监听原生事件 "),
createVNode(_component_MonitorView, {
ref: "monitor",
init: "5",
style: { "width": "300px", "height": "200px", "margin-top": "20px" },
onOnTel: $options.handleTelEvent,
onOnSnapShot: $options.handleSnapShotEvent,
onOnRecord: $options.handleRecordEvent,
onOnTalkStatus: $options.handleTalkEvent
}, null, 8, ["onOnTel", "onOnSnapShot", "onOnRecord", "onOnTalkStatus"]),
createElementVNode("view", { style: { "display": "flex", "flex-direction": "row", "align-items": "flex-start" } }, [
createCommentVNode(" 云台控制组件 "),
createVNode(
_component_MonitorControlView,
{
ref: "control",
init: "5",
style: { "width": "300px", "height": "300px", "margin-top": "20px" }
},
null,
512
/* NEED_PATCH */
),
createCommentVNode(" 功能按钮 "),
createElementVNode("div", { class: "button-group" }, [
createVNode(_component_button, {
class: "button",
onClick: _cache[0] || (_cache[0] = ($event) => $options.switchDisplay(0))
}, {
default: withCtx(() => [
createTextVNode("原图")
]),
_: 1
/* STABLE */
}),
createVNode(_component_button, {
class: "button",
onClick: _cache[1] || (_cache[1] = ($event) => $options.switchDisplay(1))
}, {
default: withCtx(() => [
createTextVNode("四分屏")
]),
_: 1
/* STABLE */
}),
createVNode(_component_button, {
class: "button",
onClick: _cache[2] || (_cache[2] = ($event) => $options.switchDisplay(2))
}, {
default: withCtx(() => [
createTextVNode("180°全景")
]),
_: 1
/* STABLE */
}),
createVNode(_component_button, {
class: "button",
onClick: _cache[3] || (_cache[3] = ($event) => $options.switchDisplay(3))
}, {
default: withCtx(() => [
createTextVNode("360°全景")
]),
_: 1
/* STABLE */
}),
createVNode(_component_button, {
class: "button",
onClick: _cache[4] || (_cache[4] = ($event) => $options.switchDisplay(4))
}, {
default: withCtx(() => [
createTextVNode("环状全景")
]),
_: 1
/* STABLE */
}),
createVNode(_component_button, {
class: "button",
onClick: $options.startAlarm
}, {
default: withCtx(() => [
createTextVNode("开启手动报警")
]),
_: 1
/* STABLE */
}, 8, ["onClick"]),
createVNode(_component_button, {
class: "button",
onClick: $options.stopAlarm
}, {
default: withCtx(() => [
createTextVNode("停止手动报警")
]),
_: 1
/* STABLE */
}, 8, ["onClick"]),
createVNode(_component_button, {
class: "button",
onClick: _cache[5] || (_cache[5] = ($event) => $options.flipImage(0))
}, {
default: withCtx(() => [
createTextVNode("左右翻转")
]),
_: 1
/* STABLE */
}),
createVNode(_component_button, {
class: "button",
onClick: _cache[6] || (_cache[6] = ($event) => $options.flipImage(1))
}, {
default: withCtx(() => [
createTextVNode("上下翻转")
]),
_: 1
/* STABLE */
}),
createVNode(_component_button, {
class: "button",
onClick: _cache[7] || (_cache[7] = ($event) => $options.flipImage(2))
}, {
default: withCtx(() => [
createTextVNode("中心翻转")
]),
_: 1
/* STABLE */
}),
createVNode(_component_button, {
class: "button",
onClick: _cache[8] || (_cache[8] = ($event) => $options.flipImage(3))
}, {
default: withCtx(() => [
createTextVNode("顺时针90°")
]),
_: 1
/* STABLE */
}),
createVNode(_component_button, {
class: "button",
onClick: _cache[9] || (_cache[9] = ($event) => $options.flipImage(4))
}, {
default: withCtx(() => [
createTextVNode("逆时针90°")
]),
_: 1
/* STABLE */
}),
createVNode(_component_button, {
class: "button",
onClick: _cache[10] || (_cache[10] = ($event) => $options.flipImage(5))
}, {
default: withCtx(() => [
createTextVNode("逆时针180°")
]),
_: 1
/* STABLE */
}),
createVNode(_component_button, {
class: "button",
onClick: _cache[11] || (_cache[11] = ($event) => $options.flipImage(6))
}, {
default: withCtx(() => [
createTextVNode("不翻转")
]),
_: 1
/* STABLE */
}),
createVNode(_component_button, {
class: "button",
onClick: $options.resumeOrPause
}, {
default: withCtx(() => [
createTextVNode("暂停/继续")
]),
_: 1
/* STABLE */
}, 8, ["onClick"]),
createVNode(_component_button, {
class: "button",
onClick: $options.changeQuality
}, {
default: withCtx(() => [
createTextVNode("切换清晰度")
]),
_: 1
/* STABLE */
}, 8, ["onClick"]),
createCommentVNode(" === 新增的功能按钮:截图 / 录屏 / 对讲 === "),
createVNode(_component_button, {
class: "button",
onClick: $options.doSnapshot
}, {
default: withCtx(() => [
createTextVNode("截图")
]),
_: 1
/* STABLE */
}, 8, ["onClick"]),
createVNode(_component_button, {
class: "button",
disabled: $data.isRecording,
onClick: $options.doStartRecord
}, {
default: withCtx(() => [
createTextVNode(" 开始录屏 ")
]),
_: 1
/* STABLE */
}, 8, ["disabled", "onClick"]),
createVNode(_component_button, {
class: "button",
disabled: !$data.isRecording,
onClick: $options.doStopRecord
}, {
default: withCtx(() => [
createTextVNode(" 结束录屏 ")
]),
_: 1
/* STABLE */
}, 8, ["disabled", "onClick"]),
createVNode(_component_button, {
class: "button",
disabled: $data.isTalking,
onClick: $options.doOpenTalk
}, {
default: withCtx(() => [
createTextVNode(" 开始对讲 ")
]),
_: 1
/* STABLE */
}, 8, ["disabled", "onClick"]),
createVNode(_component_button, {
class: "button",
disabled: !$data.isTalking,
onClick: $options.doStopTalk
}, {
default: withCtx(() => [
createTextVNode(" 结束对讲 ")
]),
_: 1
/* STABLE */
}, 8, ["disabled", "onClick"]),
createCommentVNode(" 测试按钮 "),
createVNode(_component_button, {
class: "button",
onClick: $options.test
}, {
default: withCtx(() => [
createTextVNode("test")
]),
_: 1
/* STABLE */
}, 8, ["onClick"])
])
])
])
]);
}
const ceshianzhuo = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["styles", [_style_0]], ["__file", "D:/hldy_app/pages/ceshianzhuo.nvue"]]);
export {
ceshianzhuo as default
};