微信版本号:7.0.12
import Taro, { Component } from '[@tarojs](/user/tarojs)/taro';
import {
Camera,
View,
Button
} from '[@tarojs](/user/tarojs)/components';
import './scanCode.less';
export default class ScanCode extends Component {
state = {
showCamera: true
};
//用户拒绝使用摄像头时,展示提示信息
handleScanError = e => {
const { type } = e;
if (type === 'error') {
this.setState({ showCamera: false });
}
};
//重新弹出摄像头授权页面
handleReAuthCamera = () => {
const that = this;
Taro.openSetting({
success: res => {
res.authSetting = {
'scope.camera': true
};
}
}).then(() => that.setState({ showCamera: true }));
};
handleScanCode = e => {
const {
detail: { result }
} = e;
console.log('eee===>', e);
};
render() {
const { showCamera } = this.state;
return (
<View className="scan-view">
<View className="scan-border">
{showCamera ? (
<Camera
className="scan-camera"
mode="scanCode"
onError={this.handleScanError}
onScanCode={this.handleScanCode}
frameSize="small"
resolution="high"
></Camera>
) : (
<View className="scan-reauth">
<Button type="primary" onClick={this.handleReAuthCamera} />
</View>
)}
</View>
</View>
);
}
}
你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)