optimize: fortune page share reward

This commit is contained in:
zzc
2026-01-27 21:21:46 +08:00
parent 115562de53
commit eb72b5556b
3 changed files with 111 additions and 98 deletions

View File

@@ -37,8 +37,10 @@ export const uploadImage = (filePath) => {
});
};
export const saveRecordRequest = async (path, targetId, scene) => {
const imageUrl = await uploadImage(path);
export const saveRecordRequest = async (path, targetId, scene, imageUrl) => {
if (!imageUrl) {
imageUrl = await uploadImage(path);
}
const deviceInfo = getDeviceInfo();
saveRecord({
scene,
@@ -57,3 +59,31 @@ export const saveViewRequest = async (shareToken, scene, targetId) => {
deviceInfo,
});
};
export const saveRemoteImageToLocal = (imageUrl) => {
uni.downloadFile({
url: imageUrl,
success: (res) => {
if (res.statusCode === 200) {
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: () => {
uni.hideLoading();
uni.showToast({ title: "已保存到相册" });
},
fail: () => {
uni.hideLoading();
uni.showToast({ title: "保存失败", icon: "none" });
},
});
} else {
uni.hideLoading();
uni.showToast({ title: "下载失败", icon: "none" });
}
},
fail: () => {
uni.hideLoading();
uni.showToast({ title: "下载失败", icon: "none" });
},
});
};