2025-07-29 15:39:33 +08:00

393 lines
15 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const utils_throttle = require("../../utils/throttle.js");
const api_api = require("../../api/api.js");
const uni_modules_svEditor_components_common_utils = require("../../uni_modules/sv-editor/components/common/utils.js");
if (!Array) {
const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
const _easycom_up__image2 = common_vendor.resolveComponent("up--image");
const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
const _easycom_up_popup2 = common_vendor.resolveComponent("up-popup");
(_easycom_u_icon2 + _easycom_up__image2 + _easycom_up_icon2 + _easycom_up_popup2)();
}
const _easycom_u_icon = () => "../../node-modules/uview-plus/components/u-icon/u-icon.js";
const _easycom_up__image = () => "../../node-modules/uview-plus/components/u--image/u--image.js";
const _easycom_up_icon = () => "../../node-modules/uview-plus/components/u-icon/u-icon.js";
const _easycom_up_popup = () => "../../node-modules/uview-plus/components/u-popup/u-popup.js";
if (!Math) {
(_easycom_u_icon + svEditor + _easycom_up__image + _easycom_up_icon + _easycom_up_popup)();
}
const svEditor = () => "../../uni_modules/sv-editor/components/sv-editor/sv-editor.js";
const _sfc_main = {
__name: "pEditor",
props: {
editorType: {
type: String,
default: "info"
},
editorCotent: {
type: String,
default: ""
}
},
emits: ["closeEditor", "changeEditor"],
setup(__props, { emit: __emit }) {
const editorCtx = common_vendor.ref(null);
const keyboardHeight = common_vendor.ref(0);
const editorHeight = common_vendor.ref(300);
common_vendor.ref("病例信息");
const placeholder = common_vendor.ref("患者基本情况,检查结果,诊疗图片或视频");
const showTitle = common_vendor.ref(false);
const props = __props;
common_vendor.watch(() => props.editorType, (newVal) => {
common_vendor.index.__f__("log", "at components/pEditor/pEditor.vue:162", 11111111);
common_vendor.index.__f__("log", "at components/pEditor/pEditor.vue:163", newVal);
if (newVal == "info") {
placeholder.value = "患者基本情况,检查结果,诊疗图片或视频";
} else {
placeholder.value = "分享经验和心得,如:诊断与鉴别诊断易错点,治疗过程难点,病例的相关知识总结及讨论等";
}
}, { immediate: true });
const emits = __emit;
const isIOS = common_vendor.ref(false);
const insertWord = (word) => {
uni_modules_svEditor_components_common_utils.addText(word);
showTitle.value = false;
};
const insertAllWord = () => {
let word = [
"患者信息",
"主诉",
"现病史及既往史:",
"检查",
"临床诊断",
"治疗经过及结果"
];
word.forEach((item) => {
uni_modules_svEditor_components_common_utils.addText(item);
});
showTitle.value = false;
};
const ready = (e) => {
common_vendor.index.__f__("log", "at components/pEditor/pEditor.vue:191", e);
editorCtx.value = e;
if (props.editorType == "info") {
if (props.editorCotent) {
editorCtx.value.initHtml(props.editorCotent, async (videoUrl) => {
let res = "";
const fox = "https://cn.bing.com//th?id=OHR.FlamingosNamibia_ZH-CN3639748956_1920x1080.jpg";
res = await editorCtx.value.createCoverThumbnail(fox);
showEditor.value = false;
return res;
});
} else {
let html = "<p>【患者信息】:</p><br/><p>【主诉】:</p><br/><p>【现病史及既往史】:</p><br/><p>【检查】:</p><br/><p>【临床诊断】:</p><br/><p>【治疗经过及结果】:</p><br/><br/>";
editorCtx.value.initHtml(html);
}
} else {
if (props.editorCotent) {
editorCtx.value.initHtml(props.editorCotent, async (videoUrl) => {
let res = "";
const fox = "https://cn.bing.com//th?id=OHR.FlamingosNamibia_ZH-CN3639748956_1920x1080.jpg";
res = await editorCtx.value.createCoverThumbnail(fox);
showEditor.value = false;
return res;
});
} else {
let html = "";
editorCtx.value.initHtml(html);
}
}
common_vendor.index.hideLoading();
};
const closeSv = utils_throttle.throttle(() => {
emits("closeEditor");
});
const confirm = async () => {
common_vendor.index.__f__("log", "at components/pEditor/pEditor.vue:246", "qqq");
const res = await editorCtx.value.getLastContent();
emits("changeEditor", {
type: props.editorType,
content: res.html
});
};
const blur = () => {
};
const clearMuBan = () => {
editorCtx.value.initHtml("");
};
const updatePosition = (c_keyboardHeight) => {
const toolbarHeight = 50;
const { windowHeight, platform } = common_vendor.index.getSystemInfoSync();
let c_editorHeight = keyboardHeight > 0 ? windowHeight - keyboardHeight - toolbarHeight : windowHeight;
editorHeight.value = c_editorHeight;
keyboardHeight.value = c_keyboardHeight;
};
common_vendor.onLoad(() => {
const platform = common_vendor.index.getSystemInfoSync().platform;
isIOS.value = platform === "ios";
updatePosition(0);
let keyboardHeight2 = 0;
common_vendor.index.onKeyboardHeightChange((res) => {
if (res.height === keyboardHeight2)
return;
const duration = res.height > 0 ? res.duration * 1e3 : 0;
keyboardHeight2 = res.height;
setTimeout(() => {
common_vendor.index.pageScrollTo({
scrollTop: 0,
success() {
updatePosition(keyboardHeight2);
editorCtx.value.scrollView();
}
});
}, duration);
});
});
const generateRandomNumber = () => {
let randomNumber = Math.floor(1e3 + Math.random() * 9e3);
return randomNumber;
};
const getImageFormat = (imageUrl) => {
common_vendor.index.__f__("log", "at components/pEditor/pEditor.vue:297", imageUrl);
const lastDotIndex = imageUrl.lastIndexOf(".");
if (lastDotIndex !== -1) {
return imageUrl.substring(lastDotIndex + 1);
}
return "unknown";
};
const handleUpload = (file) => {
api_api.api.getOss({
scene: 1
}).then((rep) => {
let result = rep.data;
if (result.code == 200) {
let { access_id, dir, policy, signature, host } = result.data;
let time = common_vendor.dayjs().format("YYYYMMDDHHmmss");
let random = generateRandomNumber();
let filename = time + random;
let imgType = "." + getImageFormat(file);
return new Promise((resolve, reject) => {
common_vendor.index.uploadFile({
url: host,
// 仅为示例,非真实的接口地址
filePath: file,
name: "file",
formData: {
OSSAccessKeyId: access_id,
policy,
key: dir + time + random + imgType,
signature
},
success(res) {
if (res.statusCode === 204) {
let url = host + "/" + dir + filename + imgType;
uni_modules_svEditor_components_common_utils.addImage([url]);
}
},
fail: (err) => {
common_vendor.index.__f__("log", "at components/pEditor/pEditor.vue:337", err);
}
});
});
}
});
};
const pFun = (files) => {
common_vendor.index.showLoading({
title: "正在上传图片...",
mask: true
});
let promiseFun = [];
for (let i = 0; i < files.length; i++) {
promiseFun.push(handleUpload(files[i]));
}
Promise.all(promiseFun).then((res) => {
common_vendor.index.hideLoading();
});
};
const insertImage = (file) => {
common_vendor.index.chooseImage({
count: 9,
//默认9
sizeType: ["original", "compressed"],
//可以指定是原图还是压缩图,默认二者都有
sourceType: ["album"],
//从相册选择
extension: [".jpg", ".png", ".jpeg"],
success: function(res) {
pFun(res.tempFilePaths);
}
});
};
const HandleAddVideo = async (file) => {
common_vendor.index.showLoading({
title: "正在上传视频...",
mask: true
});
const videos = await uni_modules_svEditor_components_common_utils.addVideo(async (editorCtx2) => {
return new Promise((resolve) => {
api_api.api.getOss({
scene: 2
}).then((rep) => {
let result = rep.data;
if (result.code == 200) {
let { access_id, dir, policy, signature, host } = result.data;
let time = common_vendor.dayjs().format("YYYYMMDDHHmmss");
let random = generateRandomNumber();
let filename = time + random;
let imgType = "." + getImageFormat(file);
return new Promise((res, reject) => {
common_vendor.index.uploadFile({
url: host,
// 仅为示例,非真实的接口地址
filePath: file,
name: "file",
formData: {
OSSAccessKeyId: access_id,
policy,
key: dir + time + random + imgType,
signature
},
async success(res2) {
if (res2.statusCode === 204) {
let url = host + "/" + dir + filename + imgType;
common_vendor.index.__f__("log", "at components/pEditor/pEditor.vue:410", editorCtx2);
let imgUrl = "https://cn.bing.com//th?id=OHR.FlamingosNamibia_ZH-CN3639748956_1920x1080.jpg";
const fileThumbnail = await editorCtx2.createCoverThumbnail(
imgUrl
);
resolve([
{
videoUrl: url,
videoImg: fileThumbnail
}
]);
}
},
fail: (err) => {
common_vendor.index.__f__("log", "at components/pEditor/pEditor.vue:425", err);
}
});
});
}
});
});
});
if (videos) {
common_vendor.index.showLoading();
common_vendor.index.showToast({ title: "添加视频成功", icon: "none" });
} else {
common_vendor.index.showToast({ title: "添加视频失败", icon: "none" });
}
};
const insertVideo = (file) => {
common_vendor.index.chooseVideo({
count: 5,
//默认9//可以指定是原图还是压缩图,默认二者都有
sourceType: ["album"],
//从相册选择
extension: [".mp4", ".webm", ".ogg"],
success: function(res) {
common_vendor.index.__f__("log", "at components/pEditor/pEditor.vue:447", res.tempFilePath);
HandleAddVideo(res.tempFilePath);
}
});
};
const closeTitle = () => {
showTitle.value = false;
};
const openTitle = () => {
showTitle.value = true;
};
const alertTitle = () => {
common_vendor.index.__f__("log", "at components/pEditor/pEditor.vue:461", "qqqqqq");
showTitle.value = true;
};
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.p({
name: "arrow-left",
color: "#000",
size: "24"
}),
b: common_vendor.o((...args) => common_vendor.unref(closeSv) && common_vendor.unref(closeSv)(...args)),
c: common_vendor.t(__props.editorType == "info" ? "病例信息" : "总结与讨论"),
d: common_vendor.t(__props.editorType == "info" ? "病例信息" : "总结与讨论"),
e: __props.editorType == "info"
}, __props.editorType == "info" ? {
f: common_vendor.p({
name: "trash",
color: "#6B7280",
size: "18"
}),
g: common_vendor.o(clearMuBan)
} : {}, {
h: common_vendor.o(ready),
i: common_vendor.o(_ctx.focus),
j: common_vendor.o(blur),
k: common_vendor.p({
placeholder: placeholder.value,
eid: "peditor",
pasteMode: "origin"
}),
l: common_vendor.p({
src: common_vendor.unref(common_assets.photoImg),
width: "32rpx",
height: "32rpx"
}),
m: common_vendor.o(insertImage),
n: common_vendor.p({
src: common_vendor.unref(common_assets.videoImg$1),
width: "32rpx",
height: "32rpx"
}),
o: common_vendor.o(insertVideo),
p: __props.editorType == "info"
}, __props.editorType == "info" ? {
q: common_vendor.p({
src: common_vendor.unref(common_assets.addImg),
width: "32rpx",
height: "32rpx"
}),
r: common_vendor.o(alertTitle)
} : {}, {
s: common_vendor.o(confirm),
t: keyboardHeight.value > 0,
v: isIOS.value ? keyboardHeight.value : "0px",
w: common_vendor.p({
name: "close",
color: "#4B5563",
size: "20"
}),
x: common_vendor.o(closeTitle),
y: common_vendor.o(insertAllWord),
z: common_vendor.p({
name: "plus-circle",
color: "#3CC7C0",
size: "20"
}),
A: common_vendor.o(insertAllWord),
B: common_vendor.o(($event) => insertWord("患者信息")),
C: common_vendor.o(($event) => insertWord("主诉")),
D: common_vendor.o(($event) => insertWord("现病史及既往史")),
E: common_vendor.o(($event) => insertWord("检查")),
F: common_vendor.o(($event) => insertWord("临床诊断")),
G: common_vendor.o(($event) => insertWord("治疗经过及结果")),
H: common_vendor.o(closeTitle),
I: common_vendor.o(openTitle),
J: common_vendor.p({
round: 10,
zIndex: "999999",
show: showTitle.value,
mode: "bottom"
})
});
};
}
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-a6a7913a"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/components/pEditor/pEditor.js.map