图片保存修改

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()
}
},