图片保存修改
This commit is contained in:
@@ -5,13 +5,13 @@
|
|||||||
:style="{ width: canvasW + 'px', height: canvasH + 'px' }"></canvas>
|
:style="{ width: canvasW + 'px', height: canvasH + 'px' }"></canvas>
|
||||||
<!-- #ifdef MP-WEIXIN -->
|
<!-- #ifdef MP-WEIXIN -->
|
||||||
<image v-else lazy-load :src="tempFilePath" mode="widthFix" style="width: 100%;" class="is-response"
|
<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"
|
<!-- <button v-if="openSettingBtnHidden" class="purple_btn btn_box" hover-class="none" open-type="openSetting"
|
||||||
@opensetting='handleSetting'>请开启保存权限</button> -->
|
@opensetting='handleSetting'>请开启保存权限</button> -->
|
||||||
<!-- #endif -->
|
<!-- #endif -->
|
||||||
<!-- #ifndef MP-WEIXIN -->
|
<!-- #ifndef MP-WEIXIN -->
|
||||||
<image v-else lazy-load :src="tempFilePath" mode="widthFix" style="width: 100%;" class="is-response"
|
<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 -->
|
<!-- #endif -->
|
||||||
</view>
|
</view>
|
||||||
<view class="u-flex bg-fff u-flex" >
|
<view class="u-flex bg-fff u-flex" >
|
||||||
@@ -158,6 +158,7 @@
|
|||||||
let _QrCode = await _this.getImageInfo({
|
let _QrCode = await _this.getImageInfo({
|
||||||
imgSrc: _this.QrSrc
|
imgSrc: _this.QrSrc
|
||||||
}); //二维码或太阳码
|
}); //二维码或太阳码
|
||||||
|
console.log(_imgInfo)
|
||||||
let r = [_imgInfo.width, _imgInfo.height];
|
let r = [_imgInfo.width, _imgInfo.height];
|
||||||
let q = [_QrCode.width, _QrCode.height];
|
let q = [_QrCode.width, _QrCode.height];
|
||||||
let imgW = C_W - (C_P * 2.5);
|
let imgW = C_W - (C_P * 2.5);
|
||||||
@@ -272,6 +273,7 @@
|
|||||||
return new Promise((resolve, errs) => {
|
return new Promise((resolve, errs) => {
|
||||||
uni.getImageInfo({
|
uni.getImageInfo({
|
||||||
src: imgSrc,
|
src: imgSrc,
|
||||||
|
crossOrigin: 'anonymous',
|
||||||
success: function(image) {
|
success: function(image) {
|
||||||
resolve(image);
|
resolve(image);
|
||||||
},
|
},
|
||||||
@@ -285,29 +287,34 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
getNewImage() {
|
getNewImage() {
|
||||||
|
console.log(_this.CanvasID)
|
||||||
uni.canvasToTempFilePath({
|
uni.canvasToTempFilePath({
|
||||||
canvasId: _this.CanvasID,
|
canvasId: _this.CanvasID,
|
||||||
quality: 1,
|
quality: 1,
|
||||||
complete: res => {
|
complete: res => {
|
||||||
// #ifdef H5
|
console.log(res)
|
||||||
let ua = navigator.userAgent.toLowerCase();
|
if ( res.tempFilePath) {
|
||||||
if (ua.indexOf('micromessenger') !== -1) {
|
// #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.tempFilePath = res.tempFilePath;
|
||||||
_this.$emit('success', res);
|
_this.$emit('success', res);
|
||||||
} else {
|
// #endif
|
||||||
_this.$emit('successH5', res.tempFilePath);
|
_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()
|
uni.hideLoading()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -379,11 +379,14 @@
|
|||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
},
|
},
|
||||||
successH5(haibaoImg) {
|
successH5(haibaoImg) {
|
||||||
this.haibaoImgH5 = haibaoImg
|
if ( haibaoImg ) {
|
||||||
uni.previewImage({
|
this.haibaoImgH5 = haibaoImg
|
||||||
urls: [haibaoImg],
|
uni.previewImage({
|
||||||
current: 1,
|
urls: [haibaoImg],
|
||||||
})
|
current: 1,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
showModal() {
|
showModal() {
|
||||||
// #ifndef H5
|
// #ifndef H5
|
||||||
@@ -396,6 +399,7 @@
|
|||||||
this.modalName = 'Image';
|
this.modalName = 'Image';
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
let ua = navigator.userAgent.toLowerCase();
|
let ua = navigator.userAgent.toLowerCase();
|
||||||
if (ua.indexOf('micromessenger') !== -1) {
|
if (ua.indexOf('micromessenger') !== -1) {
|
||||||
@@ -420,7 +424,6 @@
|
|||||||
current: 1,
|
current: 1,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
},
|
},
|
||||||
@@ -476,6 +479,7 @@
|
|||||||
//获取背景图
|
//获取背景图
|
||||||
getBgImg() {
|
getBgImg() {
|
||||||
this.$u.get('app/banner/selectBannerList?classify=5').then(res => {
|
this.$u.get('app/banner/selectBannerList?classify=5').then(res => {
|
||||||
|
console.log(res)
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
this.bgImg = res.data[0].imageUrl
|
this.bgImg = res.data[0].imageUrl
|
||||||
this.tuiguang = res.data[0].describes
|
this.tuiguang = res.data[0].describes
|
||||||
@@ -691,6 +695,7 @@
|
|||||||
// 保存图片
|
// 保存图片
|
||||||
async onSaveImg() {
|
async onSaveImg() {
|
||||||
this.showModal();
|
this.showModal();
|
||||||
|
|
||||||
return
|
return
|
||||||
// #ifndef MP-WEIXIN
|
// #ifndef MP-WEIXIN
|
||||||
this.showModal();
|
this.showModal();
|
||||||
|
|||||||
Reference in New Issue
Block a user