1.util.js
module.exports = {
promisify: api => {
return (options, ...params) => {
return new Promise((resolve, reject) => {
const extras = {
success: resolve,
fail: reject
}
api({
...options,
...extras
}, ...params)
})
}
}
}
2.canvas.js
tosave: function() {
if (that.data.canvasPath) {
//路劲存在,直接保存
that.resaveAlbum();
} else {
/**
* 将网络图片转为本地图片
* **/
const wxGetImageInfo = common.promisify(wx.getImageInfo);
Promise.all([
wxGetImageInfo({
src: that.data.detailInfor.poster
}),
wxGetImageInfo({
src: app.globalData.pageconfInfo.qrcode
})
]).then(res => {
wx.showLoading({
title: '制作之中...',
mask: true
});
/**
* 绘制海报
* **/
that.saveAlbum(res[0].path, res[1].path);
})
}
},