图片保存修改

This commit is contained in:
GaoHao 2024-12-16 16:50:15 +08:00
parent aa7f7f3392
commit 2d61ed447f
2 changed files with 36 additions and 24 deletions

View File

@ -5,13 +5,13 @@
:style="{ width: canvasW + 'px', height: canvasH + 'px' }"></canvas>
<!-- #ifdef MP-WEIXIN -->
<image v-else lazy-load :src="tempFilePath" mode="widthFix" style="width: 100%;" class="is-response"
@longpress="saveqrcode"></image>
@longpress="saveqrcode" crossorigin="Anonymous"></image>
<!-- <button v-if="openSettingBtnHidden" class="purple_btn btn_box" hover-class="none" open-type="openSetting"
@opensetting='handleSetting'>请开启保存权限</button> -->
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
<image v-else lazy-load :src="tempFilePath" mode="widthFix" style="width: 100%;" class="is-response"
@longpress="toSave(tempFilePath)"></image>
@longpress="toSave(tempFilePath)" crossorigin="Anonymous"></image>
<!-- #endif -->
</view>
<view class="u-flex bg-fff u-flex" >
@ -158,6 +158,7 @@
let _QrCode = await _this.getImageInfo({
imgSrc: _this.QrSrc
}); //
console.log(_imgInfo)
let r = [_imgInfo.width, _imgInfo.height];
let q = [_QrCode.width, _QrCode.height];
let imgW = C_W - (C_P * 2.5);
@ -272,6 +273,7 @@
return new Promise((resolve, errs) => {
uni.getImageInfo({
src: imgSrc,
crossOrigin: 'anonymous',
success: function(image) {
resolve(image);
},
@ -285,29 +287,34 @@
});
},
getNewImage() {
console.log(_this.CanvasID)
uni.canvasToTempFilePath({
canvasId: _this.CanvasID,
quality: 1,
complete: res => {
// #ifdef H5
let ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('micromessenger') !== -1) {
console.log(res)
if ( res.tempFilePath) {
// #ifdef H5
let ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('micromessenger') !== -1) {
_this.tempFilePath = res.tempFilePath;
_this.$emit('success', res);
} else {
_this.$emit('successH5', res.tempFilePath);
}
// #endif
// #ifndef H5
_this.tempFilePath = res.tempFilePath;
_this.$emit('success', res);
} else {
_this.$emit('successH5', res.tempFilePath);
// #endif
_this.loading = false;
uni.showToast({
title: '长按图片保存海报',
duration: 1000,
icon: 'none'
});
}
// #endif
// #ifndef H5
_this.tempFilePath = res.tempFilePath;
_this.$emit('success', res);
// #endif
_this.loading = false;
uni.showToast({
title: '长按图片保存海报',
duration: 1000,
icon: 'none'
});
uni.hideLoading()
}
},

View File

@ -379,11 +379,14 @@
uni.hideLoading();
},
successH5(haibaoImg) {
this.haibaoImgH5 = haibaoImg
uni.previewImage({
urls: [haibaoImg],
current: 1,
})
if ( haibaoImg ) {
this.haibaoImgH5 = haibaoImg
uni.previewImage({
urls: [haibaoImg],
current: 1,
})
}
},
showModal() {
// #ifndef H5
@ -396,6 +399,7 @@
this.modalName = 'Image';
}
// #endif
// #ifdef H5
let ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('micromessenger') !== -1) {
@ -420,7 +424,6 @@
current: 1,
})
}
}
// #endif
},
@ -476,6 +479,7 @@
//
getBgImg() {
this.$u.get('app/banner/selectBannerList?classify=5').then(res => {
console.log(res)
if (res.code == 0) {
this.bgImg = res.data[0].imageUrl
this.tuiguang = res.data[0].describes
@ -691,6 +695,7 @@
//
async onSaveImg() {
this.showModal();
return
// #ifndef MP-WEIXIN
this.showModal();