"use strict";
const common_vendor = require("../../../../../common/vendor.js");
const _sfc_main = {
  data() {
    return {
      url: ""
    };
  },
  onLoad(options) {
    this.url = options.url;
  },
  methods: {
    //返回上一页
    goBack() {
      common_vendor.wx$1.navigateBack({
        delta: 1
      });
    },
    //保存图片
    saveImage() {
      common_vendor.index.showLoading({
        title: "正在下载图片...",
        mask: true
      });
      common_vendor.index.downloadFile({
        url: this.url,
        success: (downloadRes) => {
          if (downloadRes.statusCode === 200) {
            common_vendor.index.saveImageToPhotosAlbum({
              filePath: downloadRes.tempFilePath,
              success: () => {
                common_vendor.index.hideLoading();
                common_vendor.index.showToast({
                  title: "保存成功",
                  icon: "none",
                  duration: 2e3
                });
              },
              fail: (saveErr) => {
                common_vendor.index.hideLoading();
                common_vendor.index.showToast({
                  title: "保存失败: " + saveErr.errMsg,
                  icon: "none",
                  duration: 2e3
                });
              }
            });
          } else {
            common_vendor.index.hideLoading();
            common_vendor.index.showToast({
              title: "下载失败",
              icon: "none",
              duration: 2e3
            });
          }
        },
        fail: (downloadErr) => {
          common_vendor.index.hideLoading();
          common_vendor.index.showToast({
            title: "下载失败: " + downloadErr.errMsg,
            icon: "none",
            duration: 2e3
          });
        }
      });
    }
  }
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return {
    a: $data.url,
    b: common_vendor.o((...args) => $options.saveImage && $options.saveImage(...args)),
    c: common_vendor.o(() => {
    }),
    d: common_vendor.o((...args) => $options.goBack && $options.goBack(...args))
  };
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-61106fa9"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../../../../.sourcemap/mp-weixin/pages/index/chat/messageComponent/fullscreen/imagePreview.js.map
