小程序camera组件takePhoto安卓调用无效
发布于 5 年前 作者 qzhao 663 次浏览 来自 问答

现在Camera组件takePhoto方法在IOS上可以正常拍照并进入对应的回调

但安卓却不行,takePhoto后根本不进入fail,complete跟success。

之前还可以,现在所有安卓机型都不行了。

临上线来个这种问题,拜托你们微信的东西能不能稳定点,camera这个组件一直有问题也没看到怎么解决 ,

但外界需求是有的啊,没弄好要么就别丢上来了,搞死开发啊

//拍照功能

takePhoto() {

if (!this.ctx) {

//创建拍照组件

if (wx.createCameraContext()) {

this.ctx = wx.createCameraContext();

//加载结束

} else {

wx.showModal({

title: "提示",

content: "当前微信版本过低,请升级到最新微信版本!"

})

}

}

if (this.data.showResult) {

return

}

console.log("开始拍照");

this.ctx.takePhoto({

quality: 'low',

success: (res) => {

this.setData({

tempSrc: res.tempImagePath

})

this.uploadImg(res.tempImagePath);

},

fail: (error) => {

setTimeout(() => {

this.takePhoto()

}, 1000);

console.log("拍照失败");

},

complete:()=>{

console.log('拍照完成');

}

});

},

1 回复

你好,问题未复现。请提供一下出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

回到顶部