"use strict"; var __async = (__this, __arguments, generator) => { return new Promise((resolve, reject) => { var fulfilled = (value) => { try { step(generator.next(value)); } catch (e) { reject(e); } }; var rejected = (value) => { try { step(generator.throw(value)); } catch (e) { reject(e); } }; var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); step((generator = generator.apply(__this, __arguments)).next()); }); }; const common_vendor = require("../../../../common/vendor.js"); const sheep_index = require("../../../index.js"); const sheep_components_sShareModal_canvasPoster_poster_index = require("./poster/index.js"); if (!Array) { const _easycom_l_painter2 = common_vendor.resolveComponent("l-painter"); const _easycom_su_popup2 = common_vendor.resolveComponent("su-popup"); (_easycom_l_painter2 + _easycom_su_popup2)(); } const _easycom_l_painter = () => "../../../../uni_modules/lime-painter/components/l-painter/l-painter.js"; const _easycom_su_popup = () => "../../../ui/su-popup/su-popup.js"; if (!Math) { (_easycom_l_painter + _easycom_su_popup)(); } const _sfc_main = { __name: "index", props: { show: { type: Boolean, default: false }, shareInfo: { type: Object, default: () => { } } }, emits: ["success", "close"], setup(__props, { expose: __expose, emit: __emit }) { const props = __props; const poster = common_vendor.reactive({ css: { // 根节点若无尺寸,自动获取父级节点 width: sheep_index.sheep.$platform.device.windowWidth * 0.9, height: 600 }, views: [] }); const emits = __emit; const onClosePoster = () => { emits("close"); }; const painterRef = common_vendor.ref(); const painterImageUrl = common_vendor.ref(); const renderPoster = () => __async(this, null, function* () { yield painterRef.value.render(common_vendor.unref(poster)); }); const setPainterImageUrl = (path) => { painterImageUrl.value = path; }; const onSavePoster = () => { if (["WechatOfficialAccount", "H5"].includes(sheep_index.sheep.$platform.name)) { sheep_index.sheep.$helper.toast("请长按图片保存"); return; } common_vendor.index.saveImageToPhotosAlbum({ filePath: painterImageUrl.value, success: (res) => { onClosePoster(); sheep_index.sheep.$helper.toast("保存成功"); }, fail: (err) => { sheep_index.sheep.$helper.toast("保存失败"); console.log("图片保存失败:", err); } }); }; function getPoster() { return __async(this, null, function* () { painterImageUrl.value = void 0; poster.views = yield sheep_components_sShareModal_canvasPoster_poster_index.getPosterData({ width: poster.css.width, shareInfo: props.shareInfo }); yield renderPoster(); }); } __expose({ getPoster }); return (_ctx, _cache) => { return common_vendor.e({ a: !!painterImageUrl.value }, !!painterImageUrl.value ? { b: painterImageUrl.value, c: poster.css.height + "px", d: poster.css.width + "px" } : {}, { e: !!painterImageUrl.value }, !!painterImageUrl.value ? { f: common_vendor.o(onClosePoster), g: common_vendor.t(["wechatOfficialAccount", "H5"].includes(common_vendor.unref(sheep_index.sheep).$platform.name) ? "长按图片保存" : "保存图片"), h: common_vendor.o(onSavePoster) } : {}, { i: common_vendor.sr(painterRef, "83ec39d9-1,83ec39d9-0", { "k": "painterRef" }), j: common_vendor.o(setPainterImageUrl), k: common_vendor.p({ isCanvasToTempFilePath: true, pathType: "url", hidden: true }), l: common_vendor.o(onClosePoster), m: common_vendor.p({ show: __props.show, round: "10", type: "center" }) }); }; } }; const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-83ec39d9"]]); wx.createComponent(Component); //# sourceMappingURL=index.js.map