兼容app、小程序图片保存

master
chen 2022-05-26 18:38:22 +08:00
parent 7f3baf2304
commit 058ff7fb02
2 changed files with 28 additions and 2 deletions

View File

@ -68,12 +68,14 @@
.wh44{width: 44rpx;height: 44rpx;} .wh44{width: 44rpx;height: 44rpx;}
button:after{content: none!important;} button:after{content: none!important;}
.borbot{border-bottom: 2rpx solid #E6E6E6;} .borbot{border-bottom: 2rpx solid #EEEEEE;}
.borbot:last-child{border-bottom: none;} .borbot:last-child{border-bottom: none;}
.bbot{border-bottom: 2rpx solid #EEEEEE;} .bbot{border-bottom: 2rpx solid #EEEEEE;}
.tbot{border-top: 2rpx solid #EEEEEE;}
.borbot-df{border: 2rpx solid #DFDFDF;} .borbot-df{border: 2rpx solid #DFDFDF;}
.borbot-cc{border: 2rpx solid #CCCCCC;} .borbot-cc{border: 2rpx solid #CCCCCC;}
.bleft {border-left: 2rpx solid #EEEEEE;} .bleft {border-left: 2rpx solid #EEEEEE;}
.bbt-d9{border-bottom: 2rpx solid #d9d9d9;}
/* 行高 */ /* 行高 */
.line-h30{line-height: 30rpx;} .line-h30{line-height: 30rpx;}

View File

@ -90,10 +90,34 @@ const imgTools = {
* @param {String} src * @param {String} src
*/ */
saveImg(src) { saveImg(src) {
// #ifdef APP-PLUS
uni.saveImageToPhotosAlbum({ uni.saveImageToPhotosAlbum({
filePath: src, filePath: src,
success: ()=> {} success:(resimg)=> {}
}); });
// #endif
// #ifdef MP-WEIXIN
let exist = src.slice(0,4);
if(exist=='http') {
uni.downloadFile({
url: src,
success: (res) => {
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: ()=> {},
fail: () => {
uni.showToast({title:'保存失败',icon:'error'})
}
});
}
})
} else {
wx.saveFile({
tempFilePath: src,
success:(wximg)=> {}
})
}
// #endif
}, },
/** /**
* @description 压缩图片 * @description 压缩图片