109 lines
3.5 KiB
JavaScript
109 lines
3.5 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const api_common = require("../../api/common.js");
|
|
const _sfc_main = {
|
|
data() {
|
|
return {
|
|
inviteImage: null,
|
|
imageLoading: false
|
|
};
|
|
},
|
|
mounted() {
|
|
this.getSharePoster();
|
|
},
|
|
methods: {
|
|
// 查询分享模版
|
|
async getSharePoster() {
|
|
this.imageLoading = true;
|
|
const resp = await api_common.getSharePoster();
|
|
if (resp && resp.bizcode === 100) {
|
|
const data = resp.data[0];
|
|
const generateResp = await api_common.generateSharePoster({ id: data.id });
|
|
if (generateResp && generateResp.bizcode === 100) {
|
|
this.inviteImage = generateResp.data;
|
|
}
|
|
}
|
|
this.imageLoading = false;
|
|
},
|
|
saveBaseImgFile() {
|
|
common_vendor.index.showLoading({
|
|
title: "保存中..."
|
|
});
|
|
const currentBase64 = this.inviteImage;
|
|
const bitmap = new plus.nativeObj.Bitmap("base64");
|
|
bitmap.loadBase64Data(
|
|
currentBase64,
|
|
() => {
|
|
const url = "_doc/" + (/* @__PURE__ */ new Date()).getTime() + ".png";
|
|
bitmap.save(
|
|
url,
|
|
{
|
|
overwrite: false
|
|
// 是否覆盖
|
|
},
|
|
(i) => {
|
|
common_vendor.index.saveImageToPhotosAlbum({
|
|
filePath: url,
|
|
success: () => {
|
|
common_vendor.index.hideLoading();
|
|
this.$refs.uToastRef.show({
|
|
type: "success",
|
|
message: "图片保存到相册成功"
|
|
});
|
|
bitmap.clear();
|
|
}
|
|
});
|
|
},
|
|
(e) => {
|
|
common_vendor.index.hideLoading();
|
|
common_vendor.index.__f__("log", "at pages/invite_friends/invite_friends.vue:72", "图片保存失败", e);
|
|
this.$refs.uToastRef.show({
|
|
type: "error",
|
|
message: "图片保存失败"
|
|
});
|
|
bitmap.clear();
|
|
}
|
|
);
|
|
},
|
|
(e) => {
|
|
common_vendor.index.hideLoading();
|
|
common_vendor.index.__f__("log", "at pages/invite_friends/invite_friends.vue:83", "图片保存失败", e);
|
|
this.$refs.uToastRef.show({
|
|
type: "error",
|
|
message: "图片保存失败"
|
|
});
|
|
bitmap.clear();
|
|
}
|
|
);
|
|
}
|
|
}
|
|
};
|
|
if (!Array) {
|
|
const _easycom_up_image2 = common_vendor.resolveComponent("up-image");
|
|
const _easycom_up_toast2 = common_vendor.resolveComponent("up-toast");
|
|
(_easycom_up_image2 + _easycom_up_toast2)();
|
|
}
|
|
const _easycom_up_image = () => "../../uni_modules/uview-plus/components/u-image/u-image.js";
|
|
const _easycom_up_toast = () => "../../uni_modules/uview-plus/components/u-toast/u-toast.js";
|
|
if (!Math) {
|
|
(_easycom_up_image + _easycom_up_toast)();
|
|
}
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return {
|
|
a: common_vendor.p({
|
|
loading: $data.imageLoading,
|
|
src: $data.inviteImage,
|
|
width: "100%",
|
|
height: "460",
|
|
bgColor: "#f1f6ff00",
|
|
shape: "square",
|
|
radius: "10"
|
|
}),
|
|
b: common_vendor.o((...args) => $options.saveBaseImgFile && $options.saveBaseImgFile(...args)),
|
|
c: common_vendor.sr("uToastRef", "2c3d3045-1")
|
|
};
|
|
}
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-2c3d3045"]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/invite_friends/invite_friends.js.map
|