Page({
data: {
},
async getTakePhoto() {
let res = await this.takePhoto();
let data = await this.readFile(res.tempImagePath, 'base64');
this.setData({})
},
wxApiPromise(api, options) {
return new Promise((resolve, reject) => {
api({
...options,
success: resolve,
fail: reject
});
});
},
takePhoto() {
const ctx = wx.createCameraContext();
return this.wxApiPromise(ctx.takePhoto.bind(ctx), { quality: 'high' });
},
readFile(filePath, encoding) {
const fsm = wx.getFileSystemManager();
return this.wxApiPromise(fsm.readFile.bind(fsm), { filePath: filePath, encoding: encoding });
},
onLoad(options) {
},
})