base64存储为本地图片资源

// 将base64图片存入本地
bitmapsave(basedata) {
let userInfo =uni.getStorageSync("userInfo");
let header = {
'accessToken': userInfo.accessToken
}
let _self = this;
var bitmap = new plus.nativeObj.Bitmap("test");
bitmap.loadBase64Data(basedata, function(e) {
bitmap.save('_doc/_tmp/ocr' + new Date().getTime() + '.png', {}, function(e) {
// _self.logoSrcs = e.target;
// 身份证正面
// if(_self.currentIndex===2){

uni.showLoading({
title:'上传中'
})
let filePath=e.target
uni.uploadFile({
// 反馈api路径
url: url,
filePath: filePath,
header:header,
name:'files',
success: (res) => {
uni.hideLoading()
let data=JSON.parse(res.data)
let imgUrl=data.data[0].fileUrl;
_self.upload(basedata,imgUrl)
},
fail:(res) => {
uni.hideLoading()
uni.showToast({
title:res.message,
icon:"none"
});
},
});
});
}, function() {
});

},

posted @ 2021-12-29 14:32  前端海  阅读(309)  评论(0编辑  收藏  举报