暂存code
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const utils_inviteBase64 = require("../../utils/inviteBase64.js");
|
||||
const _sfc_main = {
|
||||
data() {
|
||||
return {};
|
||||
@@ -15,61 +16,82 @@ const _sfc_main = {
|
||||
// const response = await uni.$httpHeader.post(mergeImage,params);
|
||||
// this.saveHeadImgFile(response.data);
|
||||
// },
|
||||
saveHeadImgFile(base64Data) {
|
||||
if (!base64Data) {
|
||||
return;
|
||||
}
|
||||
const fsm = common_vendor.index.getFileSystemManager();
|
||||
const filePath = `${common_vendor.index.env.USER_DATA_PATH}/your-image-name.png`;
|
||||
fsm.writeFile({
|
||||
filePath,
|
||||
data: base64Data.split(",")[1],
|
||||
// 去掉base64的头部信息
|
||||
encoding: "base64",
|
||||
success: function(res) {
|
||||
common_vendor.index.saveImageToPhotosAlbum({
|
||||
filePath,
|
||||
success: function() {
|
||||
common_vendor.index.showToast({
|
||||
title: "图片保存到相册成功",
|
||||
icon: "success"
|
||||
saveBaseImgFile() {
|
||||
common_vendor.index.showLoading({
|
||||
title: "保存中..."
|
||||
});
|
||||
const currentBase64 = utils_inviteBase64.base64;
|
||||
const bitmap = new plus.nativeObj.Bitmap("base64");
|
||||
bitmap.loadBase64Data(
|
||||
currentBase64,
|
||||
() => {
|
||||
const url = "_doc/" + (/* @__PURE__ */ new Date()).getTime() + ".png";
|
||||
bitmap.save(
|
||||
url,
|
||||
{
|
||||
overwrite: false
|
||||
// 是否覆盖
|
||||
// quality: 'quality' // 图片清晰度
|
||||
},
|
||||
(i) => {
|
||||
common_vendor.index.saveImageToPhotosAlbum({
|
||||
filePath: url,
|
||||
success: () => {
|
||||
common_vendor.index.hideLoading();
|
||||
this.$refs.uToastRef.show({
|
||||
type: "success",
|
||||
message: "图片保存到相册成功"
|
||||
});
|
||||
bitmap.clear();
|
||||
}
|
||||
});
|
||||
},
|
||||
fail: function(err) {
|
||||
common_vendor.index.showToast({
|
||||
title: "图片保存失败",
|
||||
icon: "error"
|
||||
(e) => {
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.__f__("log", "at pages/invite_friends/invite_friends.vue:74", "图片保存失败", e);
|
||||
this.$refs.uToastRef.show({
|
||||
type: "error",
|
||||
message: "图片保存失败"
|
||||
});
|
||||
bitmap.clear();
|
||||
}
|
||||
});
|
||||
);
|
||||
},
|
||||
fail: function(err) {
|
||||
common_vendor.index.showToast({
|
||||
title: "图片保存失败",
|
||||
icon: "error"
|
||||
(e) => {
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.__f__("log", "at pages/invite_friends/invite_friends.vue:85", "图片保存失败", e);
|
||||
this.$refs.uToastRef.show({
|
||||
type: "error",
|
||||
message: "图片保存失败"
|
||||
});
|
||||
bitmap.clear();
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!Array) {
|
||||
const _easycom_up_image2 = common_vendor.resolveComponent("up-image");
|
||||
_easycom_up_image2();
|
||||
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_image + _easycom_up_toast)();
|
||||
}
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return {
|
||||
a: common_vendor.p({
|
||||
src: "/static/invite/bg.png",
|
||||
width: "60",
|
||||
height: "60",
|
||||
bgColor: "#f1f6ff00"
|
||||
width: "100%",
|
||||
height: "460",
|
||||
bgColor: "#f1f6ff00",
|
||||
shape: "square",
|
||||
radius: "10"
|
||||
}),
|
||||
b: common_vendor.o(($event) => $options.saveHeadImgFile(null))
|
||||
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"]]);
|
||||
|
||||
Reference in New Issue
Block a user