This commit is contained in:
Teng 2025-11-21 10:22:36 +08:00
parent eef328648c
commit aaefe1439a
7 changed files with 18 additions and 1218 deletions

View File

@ -154,7 +154,7 @@
采购单价
</view>
<view class="text-anim" style="margin-top: 5rpx;font-weight: 600;font-size: 34rpx;">
{{showvalue.arrivalPrice?showvalue.arrivalPrice.toFixed(2):showvalue.procurementPrice.toFixed(2)}}
{{showvalue.arrivalPrice?Number(showvalue.arrivalPrice).toFixed(2):Number(showvalue.procurementPrice).toFixed(2)}}
</view>
</view>
<view class="" style="width: 33%;">
@ -523,7 +523,7 @@
</text>
<view class="title-right-big">
{{ v.totalPrice.toFixed(2) }}
{{ Number(v.totalPrice).toFixed(2) }}
</view>
</view>
@ -696,7 +696,7 @@
<text style="font-size: 30rpx;"
:style="{fontWeight:Number(v.arrivalPrice)>0||Number(v.procurementPrice)>0 ?`600`:``}">
{{v.arrivalPrice?v.arrivalPrice.toFixed(2):v.procurementPrice.toFixed(2) }}
{{v.arrivalPrice?Number(v.arrivalPrice).toFixed(2):Number(v.procurementPrice).toFixed(2) }}
</text>
</view>
@ -828,7 +828,7 @@
style="position: absolute;top: 8rpx;left: -35rpx;font-weight: 300;font-size: 28rpx;">
</text>
{{showvalue.totalPrice}}
{{Number(showvalue.totalPrice).toFixed(2) }}
</view>
</view>
<view class="bottom-right-middle">
@ -858,7 +858,7 @@
采购单价
</view>
<view class="right-text">
{{showvalue.arrivalPrice?showvalue.arrivalPrice:showvalue.procurementPrice}}
{{showvalue.arrivalPrice? Number(showvalue.arrivalPrice).toFixed(2):Number(showvalue.procurementPrice).toFixed(2) }}
</view>
</view>
<view class="threeone">
@ -980,7 +980,7 @@
采购单价
<text style="font-weight: 600;color: black;">
{{item.oldPrice.toFixed(2)}}
{{Number(item.oldPrice).toFixed(2)}}
</text>
</view>
@ -996,7 +996,7 @@
<view class="">
到货单价
<text style="font-weight: 600;color: black;">
{{item.newPrice.toFixed(2)}}
{{Number(item.newPrice).toFixed(2)}}
</text>
</view>
@ -1118,9 +1118,14 @@
// console.log("????",showvalue.value.id,gaijia.value)
editPrice({ id: showvalue.value.id, arrivalPrice: gaijia.value }).then((res) => {
// console.log("", showvalue.value.id,gaijia.value)
// console.log("res", res)
console.log("res", res)
if (res.code == 200) {
showvalue.value.arrivalPrice = gaijia.value;
// console.log("000",Number(gaijia.value),Number(showvalue.value.purchaseQuantity))
showvalue.value.totalPrice = Number(gaijia.value) * Number(showvalue.value.purchaseQuantity) ;
plsbuy.value[lefttarget.value].totalPrice = res.result.totalPrice
// showvalue.value.arrivalPrice
// plsbuy.value[lefttarget.value].totalPrice = gaijia.value
opengaijia.value = false;
}
})

View File

@ -21,7 +21,7 @@
<view class="more-one" @click="share">
分享
</view>
<view class="more-one" @click="bebad(v)">
<view class="more-one" v-if="Number(v.status)<=1" @click="bebad(v)">
作废
</view>
</view>
@ -123,7 +123,7 @@
<view class="" :style="Number(v.status)>1?{color: `#1083F8`}:{}">
完结
</view>
<view style="font-size: 25rpx;" v-if="Number(v.status)>0 && v.wjBy ">
<view style="font-size: 25rpx;" v-if="Number(v.status)>1 && v.wjBy ">
{{ "[ " + v.wjBy + " ]" }}
</view>
</view>
@ -265,7 +265,7 @@
采购单价
</view>
<view class="right-text">
{{ showvalue?.procurementPrice.toFixed(2) }}
{{ Number(showvalue?.procurementPrice).toFixed(2) }}
</view>
</view>
<view class="threeone">
@ -1125,7 +1125,7 @@
right: 60rpx;
top: 15rpx;
width: 165rpx;
height: 150rpx;
// height: 150rpx;
background-color: #fff;
z-index: 102;
border-radius: 35rpx;
@ -1138,7 +1138,7 @@
.more-one {
width: 100%;
height: 50%;
height: 50rpx;
display: flex;
justify-content: center;
align-items: center;

View File

@ -1,23 +0,0 @@
import "vue";
function requireNativePlugin(name) {
return weex.requireModule(name);
}
function formatAppLog(type, filename, ...args) {
if (uni.__log__) {
uni.__log__(type, filename, ...args);
} else {
console[type].apply(console, [...args, filename]);
}
}
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
export {
_export_sfc as _,
formatAppLog as f,
requireNativePlugin as r
};

File diff suppressed because one or more lines are too long

View File

@ -1,8 +0,0 @@
Promise.resolve("./pages/camera.js").then((res) => {
res();
});
Promise.resolve("./pages/fullcamera.js").then((res) => {
res();
});
Promise.resolve("./app.css.js").then(() => {
});

View File

@ -1,580 +0,0 @@
import { _ as _export_sfc, r as requireNativePlugin, f as formatAppLog } from "../_plugin-vue_export-helper.js";
import { resolveComponent, openBlock, createElementBlock, createElementVNode, normalizeStyle, createCommentVNode, createVNode } from "vue";
const _style_0 = { "center-column": { "": { "width": 620, "height": 425, "borderRadius": 30, "overflow": "hidden" } } };
const _sfc_main = {
data() {
return {
phoneNumber: "1234567890",
initnumber: 5,
isAlarming: false,
isRecording: false,
// 录屏状态
isTalking: false,
// 对讲状态
// 内部 pending 请求队列,用于在 native 事件到达时把结果返回给特定 reqId
// 结构: { snapshot: [reqId,...], record: [reqId,...], talk: [reqId,...] }
// 注意:这仅用于在 native 事件没有直接 callback 时仍能把结果回传给请求方。
_pendingRequests: {
snapshot: [],
record: [],
talk: []
},
suo: true,
isshow: true
};
},
onLoad() {
const globalEvent = requireNativePlugin && requireNativePlugin("globalEvent");
if (globalEvent && globalEvent.addEventListener) {
globalEvent.addEventListener("myEvent", (e) => {
if (e.recordUrl) {
uni.showToast({
title: "录屏成功",
icon: "success",
// 'success' | 'loading' | 'none'
duration: 1500
});
}
if (e.snapShotUrl) {
uni.showToast({
title: "截屏成功",
icon: "success",
// 'success' | 'loading' | 'none'
duration: 1500
});
}
if (this.suo && e.onVolumeChange) {
if (e.onVolumeChange) {
this.toggleVolume();
}
this.suo = false;
}
});
}
uni.setStorageSync("saveinit", 5);
uni.$on(
"monitor:changeinit",
(number) => {
this.$refs.monitor.initAutoPlay(number);
uni.setStorageSync("saveinit", number);
this.suo = true;
}
);
uni.$on("monitor:isshow", (bool) => this.isshow = bool);
uni.$on("monitor:killView", this.killView);
uni.$on("monitor:doSnapshot", this.doSnapshot);
uni.$on("monitor:startRecord", this.doStartRecord);
uni.$on("monitor:stopRecord", this.doStopRecord);
uni.$on("monitor:openTalk", this.doOpenTalk);
uni.$on("monitor:stopTalk", this.doStopTalk);
uni.$on("monitor:switchDisplay", (payload) => this.switchDisplay(payload));
uni.$on("monitor:startAlarm", this.startAlarm);
uni.$on("monitor:stopAlarm", this.stopAlarm);
uni.$on("monitor:flipImage", (payload) => this.flipImage(payload));
uni.$on("monitor:resumeOrPause", this.resumeOrPause);
uni.$on("monitor:changeQuality", this.changeQuality);
uni.$on("monitor:toggleVolume", this.toggleVolume);
uni.$on("monitor:test", this.test);
},
onUnload() {
uni.$off("monitor:killView", (bool) => this.killView);
uni.$off("monitor:changeinit", (number) => this.initnumber = number);
uni.$off("monitor:isshow", (bool) => this.isshow = bool);
uni.$off("monitor:doSnapshot", this.doSnapshot);
uni.$off("monitor:startRecord", this.doStartRecord);
uni.$off("monitor:stopRecord", this.doStopRecord);
uni.$off("monitor:openTalk", this.doOpenTalk);
uni.$off("monitor:stopTalk", this.doStopTalk);
uni.$off("monitor:switchDisplay", (payload) => this.switchDisplay(payload));
uni.$off("monitor:startAlarm", this.startAlarm);
uni.$off("monitor:stopAlarm", this.stopAlarm);
uni.$off("monitor:flipImage", (payload) => this.flipImage(payload));
uni.$off("monitor:resumeOrPause", this.resumeOrPause);
uni.$off("monitor:changeQuality", this.changeQuality);
uni.$off("monitor:toggleVolume", this.toggleVolume);
uni.$off("monitor:test", this.test);
},
methods: {
/* ------------------ 原有功能 ------------------ */
handleTelEvent(event) {
formatAppLog("log", "at pages/camera.nvue:112", "Tel event detail:", event.detail);
},
killView() {
this.$refs.monitor.killView && this.$refs.monitor.killView();
},
switchDisplay(mode) {
formatAppLog("log", "at pages/camera.nvue:120", "zzzzz", mode);
this.$refs.monitor && this.$refs.monitor.switchDisplayModeFragment(mode);
},
startAlarm() {
this.isAlarming = true;
this.$refs.monitor.startOrStopManualAlarm(this.isAlarming, (res) => {
formatAppLog("log", "at pages/camera.nvue:127", "startAlarm callback:", res);
});
},
stopAlarm() {
this.isAlarming = false;
this.$refs.monitor.startOrStopManualAlarm(this.isAlarming, (res) => {
formatAppLog("log", "at pages/camera.nvue:133", "stopAlarm callback:", res);
});
},
flipImage(type) {
this.$refs.monitor.changeImageSwitch(type, (res) => {
formatAppLog("log", "at pages/camera.nvue:139", "flipImage callback:", res);
});
},
resumeOrPause() {
this.$refs.monitor.resumeOrPause && this.$refs.monitor.resumeOrPause();
},
changeQuality() {
this.$refs.monitor.changeQuality && this.$refs.monitor.changeQuality();
},
toggleVolume() {
this.$refs.monitor.toggleVolume && this.$refs.monitor.toggleVolume();
},
test() {
this.$refs.monitor && this.$refs.monitor.test && this.$refs.monitor.test();
},
/* ------------------ 新增:截图/录屏/对讲 调用方法(支持 payload.reqId ------------------ */
// 1. 截图(调用)
// payload 可选:{ reqId: number }
doSnapshot(payload = {}) {
if (!this.$refs.monitor || !this.$refs.monitor.snapShot) {
uni.showToast({
title: "组件不支持 snapShot()",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`monitor:response:${payload.reqId}`, {
ok: false,
error: "snapShot_not_supported"
});
}
return;
}
if (payload.reqId) {
this._pendingRequests.snapshot.push(payload.reqId);
}
try {
this.$refs.monitor.snapShot((res) => {
formatAppLog("log", "at pages/camera.nvue:185", "snapShot callback:", res);
this._handleSnapshotResultFromNative(res, payload.reqId);
});
uni.showToast({
title: "正在截屏...",
icon: "none",
duration: 800
});
} catch (err) {
formatAppLog("error", "at pages/camera.nvue:194", "snapShot 调用失败", err);
uni.showToast({
title: "snapShot 调用失败",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`monitor:response:${payload.reqId}`, {
ok: false,
error: "snapShot_call_failed",
detail: String(err)
});
}
}
},
// 2. 开始录屏(调用)
// payload 可选:{ reqId: number }
doStartRecord(payload = {}) {
if (!this.$refs.monitor || !this.$refs.monitor.startRecord) {
uni.showToast({
title: "组件不支持 startRecord()",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`monitor:response:${payload.reqId}`, {
ok: false,
error: "startRecord_not_supported"
});
}
return;
}
try {
this.$refs.monitor.startRecord((res) => {
formatAppLog("log", "at pages/camera.nvue:227", "startRecord callback:", res);
if (payload.reqId) {
uni.$emit(`monitor:response:${payload.reqId}`, {
ok: true,
res
});
}
});
this.isRecording = true;
uni.showToast({
title: "录屏已开始",
icon: "none"
});
} catch (err) {
formatAppLog("error", "at pages/camera.nvue:242", "startRecord 调用失败", err);
uni.showToast({
title: "startRecord 调用失败",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`monitor:response:${payload.reqId}`, {
ok: false,
error: "startRecord_call_failed",
detail: String(err)
});
}
}
},
// 3. 停止录屏(调用)
// payload 可选:{ reqId: number }
doStopRecord(payload = {}) {
if (!this.$refs.monitor || !this.$refs.monitor.stopRecord) {
uni.showToast({
title: "组件不支持 stopRecord()",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`monitor:response:${payload.reqId}`, {
ok: false,
error: "stopRecord_not_supported"
});
}
return;
}
if (payload.reqId) {
this._pendingRequests.record.push(payload.reqId);
}
try {
this.$refs.monitor.stopRecord((res) => {
formatAppLog("log", "at pages/camera.nvue:281", "stopRecord callback:", res);
this._handleRecordResultFromNative(res, payload.reqId);
});
} catch (err) {
formatAppLog("error", "at pages/camera.nvue:286", "stopRecord 调用失败", err);
uni.showToast({
title: "stopRecord 调用失败",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`monitor:response:${payload.reqId}`, {
ok: false,
error: "stopRecord_call_failed",
detail: String(err)
});
}
}
},
// 4. 开始对讲(调用)
// payload 可选:{ reqId: number }
doOpenTalk(payload = {}) {
if (!this.$refs.monitor || !this.$refs.monitor.openTalk) {
uni.showToast({
title: "组件不支持 openTalk()",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`monitor:response:${payload.reqId}`, {
ok: false,
error: "openTalk_not_supported"
});
}
return;
}
if (payload.reqId) {
this._pendingRequests.talk.push(payload.reqId);
}
try {
this.$refs.monitor.openTalk((res) => {
formatAppLog("log", "at pages/camera.nvue:323", "openTalk callback:", res);
if (payload.reqId) {
uni.$emit(`monitor:response:${payload.reqId}`, {
ok: true,
res
});
}
});
this.isTalking = true;
uni.showToast({
title: "尝试建立对讲连接...",
icon: "none"
});
} catch (err) {
formatAppLog("error", "at pages/camera.nvue:338", "openTalk 调用失败", err);
uni.showToast({
title: "openTalk 调用失败",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`monitor:response:${payload.reqId}`, {
ok: false,
error: "openTalk_call_failed",
detail: String(err)
});
}
}
},
// 5. 停止对讲(调用)
// payload 可选:{ reqId: number }
doStopTalk(payload = {}) {
if (!this.$refs.monitor || !this.$refs.monitor.stopTalk) {
uni.showToast({
title: "组件不支持 stopTalk()",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`monitor:response:${payload.reqId}`, {
ok: false,
error: "stopTalk_not_supported"
});
}
return;
}
try {
this.$refs.monitor.stopTalk((res) => {
formatAppLog("log", "at pages/camera.nvue:371", "stopTalk callback:", res);
if (payload.reqId) {
uni.$emit(`monitor:response:${payload.reqId}`, {
ok: true,
res
});
}
});
this.isTalking = false;
} catch (err) {
formatAppLog("error", "at pages/camera.nvue:381", "stopTalk 调用失败", err);
uni.showToast({
title: "stopTalk 调用失败",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`monitor:response:${payload.reqId}`, {
ok: false,
error: "stopTalk_call_failed",
detail: String(err)
});
}
}
},
/* ------------------ 事件回调处理(来自原生推送的事件) ------------------ */
// 处理来自模板 @onSnapShot 的事件event.detail
handleSnapShotEvent(event) {
const payload = event && event.detail ? event.detail : event;
formatAppLog("log", "at pages/camera.nvue:401", "onSnapShot event:", payload);
this._handleSnapshotResultFromNative(payload);
},
// 处理来自模板 @onRecord 的事件event.detail
handleRecordEvent(event) {
const payload = event && event.detail ? event.detail : event;
formatAppLog("log", "at pages/camera.nvue:409", "onRecord event:", payload);
this._handleRecordResultFromNative(payload);
},
// 处理来自模板 @onTalkStatus 的事件
handleTalkEvent(event) {
const payload = event && event.detail ? event.detail : event;
formatAppLog("log", "at pages/camera.nvue:416", "onTalkStatus event:", payload);
const status = payload && payload.talkStatus;
const tips = payload && payload.tips;
uni.$emit("monitor:talk:status", payload);
if (this._pendingRequests.talk && this._pendingRequests.talk.length) {
while (this._pendingRequests.talk.length) {
const reqId = this._pendingRequests.talk.shift();
uni.$emit(`monitor:response:${reqId}`, {
ok: true,
payload
});
}
}
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, reqIdFromCallback = null) {
if (!res) {
uni.showToast({
title: "截图没有返回数据",
icon: "none"
});
if (reqIdFromCallback) {
uni.$emit(`monitor:response:${reqIdFromCallback}`, {
ok: false,
error: "no_data"
});
}
return;
}
let payload = res;
if (res.detail)
payload = res.detail;
formatAppLog("log", "at pages/camera.nvue:493", "snapshot payload normalized:", payload);
if (reqIdFromCallback) {
uni.$emit(`monitor:response:${reqIdFromCallback}`, {
ok: !!payload.snapShotResult,
payload
});
}
if (!reqIdFromCallback && this._pendingRequests.snapshot && this._pendingRequests.snapshot.length) {
while (this._pendingRequests.snapshot.length) {
const rid = this._pendingRequests.snapshot.shift();
uni.$emit(`monitor:response:${rid}`, {
ok: !!payload.snapShotResult,
payload
});
}
}
uni.$emit("monitor:snapshot:done", payload);
if (payload.snapShotResult === true || payload.snapShotResult === "true") {
const url = payload.snapShotUrl || payload.snapShotPath || payload.url;
uni.showToast({
title: "截图成功",
icon: "success",
duration: 1200
});
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/camera.nvue:536", "snapshot failed reason:", err, payload);
}
},
_handleRecordResultFromNative(res, reqIdFromCallback = null) {
if (!res) {
uni.showToast({
title: "录屏没有返回数据",
icon: "none"
});
this.isRecording = false;
if (reqIdFromCallback) {
uni.$emit(`monitor:response:${reqIdFromCallback}`, {
ok: false,
error: "no_data"
});
}
return;
}
let payload = res;
if (res.detail)
payload = res.detail;
formatAppLog("log", "at pages/camera.nvue:558", "record payload normalized:", payload);
if (reqIdFromCallback) {
uni.$emit(`monitor:response:${reqIdFromCallback}`, {
ok: !!(payload.recordUrl || payload.snapShotResult),
payload
});
}
if (!reqIdFromCallback && this._pendingRequests.record && this._pendingRequests.record.length) {
while (this._pendingRequests.record.length) {
const rid = this._pendingRequests.record.shift();
uni.$emit(`monitor:response:${rid}`, {
ok: !!(payload.recordUrl || payload.snapShotResult),
payload
});
}
}
uni.$emit("monitor:record:done", payload);
if (payload.recordUrl) {
uni.showToast({
title: "录屏完成",
icon: "success",
duration: 1400
});
this.isRecording = false;
formatAppLog("log", "at pages/camera.nvue:589", "录屏地址:", payload.recordUrl);
} else if (payload.recordFailedReason) {
uni.showToast({
title: "录屏失败: " + payload.recordFailedReason,
icon: "none",
duration: 2e3
});
this.isRecording = false;
formatAppLog("warn", "at pages/camera.nvue:597", "record failed reason:", payload.recordFailedReason);
} 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");
return openBlock(), createElementBlock("scroll-view", {
scrollY: true,
showScrollbar: true,
enableBackToTop: true,
bubble: "true",
style: { flexDirection: "column" }
}, [
createElementVNode(
"div",
{
class: "center-column",
style: normalizeStyle({ height: $data.isshow ? "425px" : "0px" })
},
[
createCommentVNode(" 视频播放组件 "),
createVNode(_component_MonitorView, {
ref: "monitor",
init: "5",
style: { "width": "620px", "height": "425px" },
onOnTel: $options.handleTelEvent,
onOnSnapShot: $options.handleSnapShotEvent,
onOnRecord: $options.handleRecordEvent,
onOnTalkStatus: $options.handleTalkEvent
}, null, 8, ["onOnTel", "onOnSnapShot", "onOnRecord", "onOnTalkStatus"])
],
4
/* STYLE */
)
]);
}
const camera = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["styles", [_style_0]], ["__file", "D:/项目/hldy_app_mini/pages/camera.nvue"]]);
export {
camera as default
};

View File

@ -1,583 +0,0 @@
import { _ as _export_sfc, f as formatAppLog, r as requireNativePlugin } from "../_plugin-vue_export-helper.js";
import { resolveComponent, openBlock, createElementBlock, createElementVNode, normalizeStyle, createCommentVNode, createVNode } from "vue";
const _style_0 = { "center-column": { "": { "width": 800, "height": 500, "overflow": "hidden" } } };
const _sfc_main = {
data() {
return {
phoneNumber: "1234567890",
initnumber: 5,
isAlarming: false,
isRecording: false,
// 录屏状态
isTalking: false,
// 对讲状态
_pendingRequests: {
snapshot: [],
record: [],
talk: []
},
suo: true,
isshow: true,
globalEvent: ""
};
},
onLoad() {
formatAppLog("log", "at pages/fullcamera.nvue:29", "???加载");
this.globalEvent = requireNativePlugin && requireNativePlugin("globalEvent");
if (this.globalEvent && this.globalEvent.addEventListener) {
this.globalEvent.addEventListener("myEvent", (e) => {
if (e.recordUrl) {
uni.showToast({
title: "录屏成功",
icon: "success",
// 'success' | 'loading' | 'none'
duration: 1500
});
}
if (e.snapShotUrl) {
uni.showToast({
title: "截屏成功",
icon: "success",
// 'success' | 'loading' | 'none'
duration: 1500
});
}
if (this.suo && e.onVolumeChange) {
if (e.onVolumeChange) {
this.toggleVolume();
}
this.suo = false;
}
});
}
uni.setStorageSync("saveinit", 5);
uni.$on("fullmonitor:changeinit", (number) => {
this.$refs.monitor.initAutoPlay(number);
uni.setStorageSync("saveinit", number);
this.suo = true;
});
uni.$on("fullmonitor:isshow", (bool) => this.isshow = bool);
uni.$on("fullmonitor:killView", this.killView);
uni.$on("fullmonitor:doSnapshot", this.doSnapshot);
uni.$on("fullmonitor:startRecord", this.doStartRecord);
uni.$on("fullmonitor:stopRecord", this.doStopRecord);
uni.$on("fullmonitor:openTalk", this.doOpenTalk);
uni.$on("fullmonitor:stopTalk", this.doStopTalk);
uni.$on("fullmonitor:switchDisplay", (payload) => this.switchDisplay(payload));
uni.$on("fullmonitor:startAlarm", this.startAlarm);
uni.$on("fullmonitor:stopAlarm", this.stopAlarm);
uni.$on("fullmonitor:flipImage", (payload) => this.flipImage(payload));
uni.$on("fullmonitor:resumeOrPause", this.resumeOrPause);
uni.$on("fullmonitor:changeQuality", this.changeQuality);
uni.$on("fullmonitor:toggleVolume", this.toggleVolume);
uni.$on("fullmonitor:test", this.test);
},
onUnload() {
formatAppLog("log", "at pages/fullcamera.nvue:84", "fullcamera 卸载,清理事件");
if (this.globalEvent && this.globalEvent.removeEventListener) {
this.globalEvent.removeEventListener("myEvent");
}
const events = [
"fullmonitor:killView",
"fullmonitor:changeinit",
"fullmonitor:isshow",
"fullmonitor:doSnapshot",
"fullmonitor:startRecord",
"fullmonitor:stopRecord",
"fullmonitor:openTalk",
"fullmonitor:stopTalk",
"fullmonitor:switchDisplay",
"fullmonitor:startAlarm",
"fullmonitor:stopAlarm",
"fullmonitor:flipImage",
"fullmonitor:resumeOrPause",
"fullmonitor:changeQuality",
"fullmonitor:toggleVolume",
"fullmonitor:test"
];
events.forEach((ev) => uni.$off(ev));
},
methods: {
/* ------------------ 原有功能 ------------------ */
handleTelEvent(event) {
formatAppLog("log", "at pages/fullcamera.nvue:115", "Tel event detail:", event.detail);
},
killView() {
this.$refs.monitor.killView && this.$refs.monitor.killView();
},
switchDisplay(mode) {
formatAppLog("log", "at pages/fullcamera.nvue:123", "zzzzz", mode);
this.$refs.monitor && this.$refs.monitor.switchDisplayModeFragment(mode);
},
startAlarm() {
this.isAlarming = true;
this.$refs.monitor.startOrStopManualAlarm(this.isAlarming, (res) => {
formatAppLog("log", "at pages/fullcamera.nvue:130", "startAlarm callback:", res);
});
},
stopAlarm() {
this.isAlarming = false;
this.$refs.monitor.startOrStopManualAlarm(this.isAlarming, (res) => {
formatAppLog("log", "at pages/fullcamera.nvue:136", "stopAlarm callback:", res);
});
},
flipImage(type) {
this.$refs.monitor.changeImageSwitch(type, (res) => {
formatAppLog("log", "at pages/fullcamera.nvue:142", "flipImage callback:", res);
});
},
resumeOrPause() {
this.$refs.monitor.resumeOrPause && this.$refs.monitor.resumeOrPause();
},
changeQuality() {
this.$refs.monitor.changeQuality && this.$refs.monitor.changeQuality();
},
toggleVolume() {
this.$refs.monitor.toggleVolume && this.$refs.monitor.toggleVolume();
},
test() {
this.$refs.monitor && this.$refs.monitor.test && this.$refs.monitor.test();
},
/* ------------------ 新增:截图/录屏/对讲 调用方法(支持 payload.reqId ------------------ */
// 1. 截图(调用)
// payload 可选:{ reqId: number }
doSnapshot(payload = {}) {
if (!this.$refs.monitor || !this.$refs.monitor.snapShot) {
uni.showToast({
title: "组件不支持 snapShot()",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`fullmonitor:response:${payload.reqId}`, {
ok: false,
error: "snapShot_not_supported"
});
}
return;
}
if (payload.reqId) {
this._pendingRequests.snapshot.push(payload.reqId);
}
try {
this.$refs.monitor.snapShot((res) => {
formatAppLog("log", "at pages/fullcamera.nvue:188", "snapShot callback:", res);
this._handleSnapshotResultFromNative(res, payload.reqId);
});
uni.showToast({
title: "正在截屏...",
icon: "none",
duration: 800
});
} catch (err) {
formatAppLog("error", "at pages/fullcamera.nvue:197", "snapShot 调用失败", err);
uni.showToast({
title: "snapShot 调用失败",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`fullmonitor:response:${payload.reqId}`, {
ok: false,
error: "snapShot_call_failed",
detail: String(err)
});
}
}
},
// 2. 开始录屏(调用)
// payload 可选:{ reqId: number }
doStartRecord(payload = {}) {
if (!this.$refs.monitor || !this.$refs.monitor.startRecord) {
uni.showToast({
title: "组件不支持 startRecord()",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`fullmonitor:response:${payload.reqId}`, {
ok: false,
error: "startRecord_not_supported"
});
}
return;
}
try {
this.$refs.monitor.startRecord((res) => {
formatAppLog("log", "at pages/fullcamera.nvue:230", "startRecord callback:", res);
if (payload.reqId) {
uni.$emit(`fullmonitor:response:${payload.reqId}`, {
ok: true,
res
});
}
});
this.isRecording = true;
uni.showToast({
title: "录屏已开始",
icon: "none"
});
} catch (err) {
formatAppLog("error", "at pages/fullcamera.nvue:245", "startRecord 调用失败", err);
uni.showToast({
title: "startRecord 调用失败",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`fullmonitor:response:${payload.reqId}`, {
ok: false,
error: "startRecord_call_failed",
detail: String(err)
});
}
}
},
// 3. 停止录屏(调用)
// payload 可选:{ reqId: number }
doStopRecord(payload = {}) {
if (!this.$refs.monitor || !this.$refs.monitor.stopRecord) {
uni.showToast({
title: "组件不支持 stopRecord()",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`fullmonitor:response:${payload.reqId}`, {
ok: false,
error: "stopRecord_not_supported"
});
}
return;
}
if (payload.reqId) {
this._pendingRequests.record.push(payload.reqId);
}
try {
this.$refs.monitor.stopRecord((res) => {
formatAppLog("log", "at pages/fullcamera.nvue:284", "stopRecord callback:", res);
this._handleRecordResultFromNative(res, payload.reqId);
});
} catch (err) {
formatAppLog("error", "at pages/fullcamera.nvue:289", "stopRecord 调用失败", err);
uni.showToast({
title: "stopRecord 调用失败",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`fullmonitor:response:${payload.reqId}`, {
ok: false,
error: "stopRecord_call_failed",
detail: String(err)
});
}
}
},
// 4. 开始对讲(调用)
// payload 可选:{ reqId: number }
doOpenTalk(payload = {}) {
if (!this.$refs.monitor || !this.$refs.monitor.openTalk) {
uni.showToast({
title: "组件不支持 openTalk()",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`fullmonitor:response:${payload.reqId}`, {
ok: false,
error: "openTalk_not_supported"
});
}
return;
}
if (payload.reqId) {
this._pendingRequests.talk.push(payload.reqId);
}
try {
this.$refs.monitor.openTalk((res) => {
formatAppLog("log", "at pages/fullcamera.nvue:326", "openTalk callback:", res);
if (payload.reqId) {
uni.$emit(`fullmonitor:response:${payload.reqId}`, {
ok: true,
res
});
}
});
this.isTalking = true;
uni.showToast({
title: "尝试建立对讲连接...",
icon: "none"
});
} catch (err) {
formatAppLog("error", "at pages/fullcamera.nvue:341", "openTalk 调用失败", err);
uni.showToast({
title: "openTalk 调用失败",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`fullmonitor:response:${payload.reqId}`, {
ok: false,
error: "openTalk_call_failed",
detail: String(err)
});
}
}
},
// 5. 停止对讲(调用)
// payload 可选:{ reqId: number }
doStopTalk(payload = {}) {
if (!this.$refs.monitor || !this.$refs.monitor.stopTalk) {
uni.showToast({
title: "组件不支持 stopTalk()",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`fullmonitor:response:${payload.reqId}`, {
ok: false,
error: "stopTalk_not_supported"
});
}
return;
}
try {
this.$refs.monitor.stopTalk((res) => {
formatAppLog("log", "at pages/fullcamera.nvue:374", "stopTalk callback:", res);
if (payload.reqId) {
uni.$emit(`fullmonitor:response:${payload.reqId}`, {
ok: true,
res
});
}
});
this.isTalking = false;
} catch (err) {
formatAppLog("error", "at pages/fullcamera.nvue:384", "stopTalk 调用失败", err);
uni.showToast({
title: "stopTalk 调用失败",
icon: "none"
});
if (payload.reqId) {
uni.$emit(`fullmonitor:response:${payload.reqId}`, {
ok: false,
error: "stopTalk_call_failed",
detail: String(err)
});
}
}
},
/* ------------------ 事件回调处理(来自原生推送的事件) ------------------ */
// 处理来自模板 @onSnapShot 的事件event.detail
handleSnapShotEvent(event) {
const payload = event && event.detail ? event.detail : event;
formatAppLog("log", "at pages/fullcamera.nvue:404", "onSnapShot event:", payload);
this._handleSnapshotResultFromNative(payload);
},
// 处理来自模板 @onRecord 的事件event.detail
handleRecordEvent(event) {
const payload = event && event.detail ? event.detail : event;
formatAppLog("log", "at pages/fullcamera.nvue:412", "onRecord event:", payload);
this._handleRecordResultFromNative(payload);
},
// 处理来自模板 @onTalkStatus 的事件
handleTalkEvent(event) {
const payload = event && event.detail ? event.detail : event;
formatAppLog("log", "at pages/fullcamera.nvue:419", "onTalkStatus event:", payload);
const status = payload && payload.talkStatus;
const tips = payload && payload.tips;
uni.$emit("fullmonitor:talk:status", payload);
if (this._pendingRequests.talk && this._pendingRequests.talk.length) {
while (this._pendingRequests.talk.length) {
const reqId = this._pendingRequests.talk.shift();
uni.$emit(`fullmonitor:response:${reqId}`, {
ok: true,
payload
});
}
}
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, reqIdFromCallback = null) {
if (!res) {
uni.showToast({
title: "截图没有返回数据",
icon: "none"
});
if (reqIdFromCallback) {
uni.$emit(`fullmonitor:response:${reqIdFromCallback}`, {
ok: false,
error: "no_data"
});
}
return;
}
let payload = res;
if (res.detail)
payload = res.detail;
formatAppLog("log", "at pages/fullcamera.nvue:496", "snapshot payload normalized:", payload);
if (reqIdFromCallback) {
uni.$emit(`fullmonitor:response:${reqIdFromCallback}`, {
ok: !!payload.snapShotResult,
payload
});
}
if (!reqIdFromCallback && this._pendingRequests.snapshot && this._pendingRequests.snapshot.length) {
while (this._pendingRequests.snapshot.length) {
const rid = this._pendingRequests.snapshot.shift();
uni.$emit(`fullmonitor:response:${rid}`, {
ok: !!payload.snapShotResult,
payload
});
}
}
uni.$emit("fullmonitor:snapshot:done", payload);
if (payload.snapShotResult === true || payload.snapShotResult === "true") {
const url = payload.snapShotUrl || payload.snapShotPath || payload.url;
uni.showToast({
title: "截图成功",
icon: "success",
duration: 1200
});
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/fullcamera.nvue:539", "snapshot failed reason:", err, payload);
}
},
_handleRecordResultFromNative(res, reqIdFromCallback = null) {
if (!res) {
uni.showToast({
title: "录屏没有返回数据",
icon: "none"
});
this.isRecording = false;
if (reqIdFromCallback) {
uni.$emit(`fullmonitor:response:${reqIdFromCallback}`, {
ok: false,
error: "no_data"
});
}
return;
}
let payload = res;
if (res.detail)
payload = res.detail;
formatAppLog("log", "at pages/fullcamera.nvue:561", "record payload normalized:", payload);
if (reqIdFromCallback) {
uni.$emit(`fullmonitor:response:${reqIdFromCallback}`, {
ok: !!(payload.recordUrl || payload.snapShotResult),
payload
});
}
if (!reqIdFromCallback && this._pendingRequests.record && this._pendingRequests.record.length) {
while (this._pendingRequests.record.length) {
const rid = this._pendingRequests.record.shift();
uni.$emit(`fullmonitor:response:${rid}`, {
ok: !!(payload.recordUrl || payload.snapShotResult),
payload
});
}
}
uni.$emit("fullmonitor:record:done", payload);
if (payload.recordUrl) {
uni.showToast({
title: "录屏完成",
icon: "success",
duration: 1400
});
this.isRecording = false;
formatAppLog("log", "at pages/fullcamera.nvue:592", "录屏地址:", payload.recordUrl);
} else if (payload.recordFailedReason) {
uni.showToast({
title: "录屏失败: " + payload.recordFailedReason,
icon: "none",
duration: 2e3
});
this.isRecording = false;
formatAppLog("warn", "at pages/fullcamera.nvue:600", "record failed reason:", payload.recordFailedReason);
} 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");
return openBlock(), createElementBlock("scroll-view", {
scrollY: true,
showScrollbar: true,
enableBackToTop: true,
bubble: "true",
style: { flexDirection: "column" }
}, [
createElementVNode(
"div",
{
class: "center-column",
style: normalizeStyle({ height: $data.isshow ? "500px" : "0px" })
},
[
createCommentVNode(" 视频播放组件 "),
createVNode(_component_MonitorView, {
ref: "monitor",
init: "5",
style: { "width": "800px", "height": "500px" },
onOnTel: $options.handleTelEvent,
onOnSnapShot: $options.handleSnapShotEvent,
onOnRecord: $options.handleRecordEvent,
onOnTalkStatus: $options.handleTalkEvent
}, null, 8, ["onOnTel", "onOnSnapShot", "onOnRecord", "onOnTalkStatus"])
],
4
/* STYLE */
)
]);
}
const fullcamera = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["styles", [_style_0]], ["__file", "D:/项目/hldy_app_mini/pages/fullcamera.nvue"]]);
export {
fullcamera as default
};