Fix:2712 【地标好物】地标好物分享图片下方增加一个保存图片按钮,点击后直接保存图片,替换掉长按保存图片功能
This commit is contained in:
@@ -14,10 +14,10 @@
|
||||
:src="posterImage"
|
||||
alt="tp"
|
||||
class="poster-image"
|
||||
show-menu-by-longpress
|
||||
:show-menu-by-longpress="false"
|
||||
mode="widthFix"
|
||||
/>
|
||||
<view class="keep">长按图片可以保存到手机</view>
|
||||
<view class="v12-primary v12-white-text v12-radius-100 share-btn" @click="saveImg(posterImage)">保存图片</view>
|
||||
</view>
|
||||
<view class="mask"></view>
|
||||
</view>
|
||||
@@ -28,15 +28,45 @@ import { getShareImg } from "@/api/product";
|
||||
|
||||
export default {
|
||||
name: "StorePoster",
|
||||
data: function() {
|
||||
data: function () {
|
||||
return {
|
||||
canvasStatus: false,
|
||||
posterImage: "",
|
||||
posterImageStatus: false
|
||||
posterImageStatus: false,
|
||||
};
|
||||
},
|
||||
mounted: function() {},
|
||||
mounted: function () {},
|
||||
methods: {
|
||||
saveImg(url) {
|
||||
uni.showLoading({
|
||||
mask:true,
|
||||
})
|
||||
uni.downloadFile({
|
||||
url: url, // 文件的下载地址
|
||||
success(res) {
|
||||
if (res.statusCode === 200) {
|
||||
let tempFilePath = res.tempFilePath; // 临时文件路径
|
||||
uni.saveImageToPhotosAlbum({
|
||||
filePath: tempFilePath,
|
||||
success:(success)=> {
|
||||
uni.showToast({
|
||||
title: "保存成功",
|
||||
icon: "none",
|
||||
mask: true,
|
||||
});
|
||||
},
|
||||
fail(err) {
|
||||
uni.showToast({
|
||||
title: "保存失败,请重新尝试",
|
||||
icon: "none",
|
||||
mask: true,
|
||||
});
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
posterImageClose() {
|
||||
this.posterImageStatus = false;
|
||||
this.canvasStatus = false;
|
||||
@@ -44,9 +74,9 @@ export default {
|
||||
},
|
||||
savePosterPath(id) {
|
||||
uni.showLoading({ title: "海报生成中", mask: true });
|
||||
|
||||
|
||||
getShareImg(id)
|
||||
.then(res => {
|
||||
.then((res) => {
|
||||
this.canvasStatus = true;
|
||||
this.posterImage = res.data;
|
||||
this.posterImageStatus = true;
|
||||
@@ -54,12 +84,17 @@ export default {
|
||||
.finally(() => {
|
||||
uni.hideLoading();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="less" lang="less">
|
||||
.share-btn{
|
||||
text-align: center;
|
||||
padding: 10rpx 0;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
.poster-first {
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user