"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:168", 11111111); common_vendor.index.__f__("log", "at components/pEditor/pEditor.vue:169", 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:197", e); editorCtx.value = e; if (props.editorType == "info") { if (props.editorCotent) { editorCtx.value.initHtml(props.editorCotent, async (videoUrl) => { let res = ""; const fox = common_assets.videoface; res = await editorCtx.value.createCoverThumbnail(fox); showEditor.value = false; return res; }); } else { let html = "

【患者信息】:


【主诉】:


【现病史及既往史】:


【检查】:


【临床诊断】:


【治疗经过及结果】:



"; editorCtx.value.initHtml(html); } } else { if (props.editorCotent) { editorCtx.value.initHtml(props.editorCotent, async (videoUrl) => { let res = ""; const fox = common_assets.videoface; 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:252", "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:303", 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:343", 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; let imgUrl = common_assets.videoface; const fileThumbnail = await editorCtx2.createCoverThumbnail( imgUrl ); resolve([ { videoUrl: url, videoImg: fileThumbnail } ]); } }, fail: (err) => { common_vendor.index.__f__("log", "at components/pEditor/pEditor.vue:430", err); } }); }); } }); }); }); if (videos) { common_vendor.index.hideLoading(); 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:452", 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:466", "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 == "result" }, __props.editorType == "result" ? {} : {}, { f: __props.editorType == "info" }, __props.editorType == "info" ? { g: common_vendor.p({ name: "trash", color: "#6B7280", size: "18" }), h: common_vendor.o(clearMuBan) } : {}, { i: common_vendor.o(ready), j: common_vendor.o(_ctx.focus), k: common_vendor.o(blur), l: common_vendor.p({ placeholder: placeholder.value, eid: "peditor", pasteMode: "origin" }), m: common_vendor.p({ src: common_vendor.unref(common_assets.photoImg), width: "32rpx", height: "32rpx" }), n: !isIOS.value ? 1 : "", o: common_vendor.o(insertImage), p: common_vendor.p({ src: common_vendor.unref(common_assets.videoImg$1), width: "32rpx", height: "32rpx" }), q: !isIOS.value ? 1 : "", r: common_vendor.o(insertVideo), s: __props.editorType == "info" }, __props.editorType == "info" ? { t: common_vendor.p({ src: common_vendor.unref(common_assets.addImg), width: "32rpx", height: "32rpx" }), v: !isIOS.value ? 1 : "", w: common_vendor.o(alertTitle) } : {}, { x: common_vendor.o(confirm), y: common_vendor.p({ name: "close", color: "#4B5563", size: "20" }), z: common_vendor.o(closeTitle), A: common_vendor.o(insertAllWord), B: common_vendor.p({ name: "plus-circle", color: "#3CC7C0", size: "20" }), C: common_vendor.o(insertAllWord), 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(($event) => insertWord("临床诊断")), I: common_vendor.o(($event) => insertWord("治疗经过及结果")), J: common_vendor.o(closeTitle), K: common_vendor.o(openTitle), L: 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