提交 1f34634d authored 作者: 羊富学's avatar 羊富学

前端校验

上级 6fee9609
...@@ -23,7 +23,7 @@ Page({ ...@@ -23,7 +23,7 @@ Page({
onLoad(options) { onLoad(options) {
this.cameraContext = wx.createCameraContext() this.cameraContext = wx.createCameraContext()
this.cameraContext.setZoom({ this.cameraContext.setZoom({
zoom: 1 zoom: 2
}) })
this.cameraFrame() this.cameraFrame()
// this.cameraFrameApi() // this.cameraFrameApi()
...@@ -45,37 +45,37 @@ Page({ ...@@ -45,37 +45,37 @@ Page({
width: frame.width width: frame.width
}) })
// 实时帧渲染到canvas // 实时帧渲染到canvas
await wx.canvasPutImageData({ // await wx.canvasPutImageData({
canvasId: 'myCanvas', // canvasId: 'myCanvas',
x:0, // x:0,
y:0, // y:0,
width: frame.width, // width: frame.width,
height: frame.height, // height: frame.height,
data: new Uint8ClampedArray(frame.data), // data: new Uint8ClampedArray(frame.data),
}) // })
const fileData = await wx.canvasToTempFilePath({ // const fileData = await wx.canvasToTempFilePath({
canvasId: 'myCanvas', // canvasId: 'myCanvas',
x: frame.width / 4, // x: frame.width / 4,
y: frame.height / 4, // y: frame.height / 4,
width: frame.width / 2, // width: frame.width / 2,
height: frame.height / 3, // height: frame.height / 3,
quality: 'high', // quality: 'high',
fileType: 'jpg', // fileType: 'jpg',
destWidth: frame.width / 2, // destWidth: frame.width / 2,
destHeight: frame.height / 3, // destHeight: frame.height / 3,
}) // })
const base = fileSystem.readFileSync(fileData.tempFilePath, 'base64') // const base = fileSystem.readFileSync(fileData.tempFilePath, 'base64')
// console.log('qr_result',flag,5555,base); // console.log('qr_result',flag,5555,base);
const qr_result = await that.handleCodeAnalysis(base) // const qr_result = await that.handleCodeAnalysis(base)
console.log('qr_result',flag,5555,qr_result.data); // console.log('qr_result',flag,5555,qr_result.data);
// 前端校验取消 // 前端校验取消
// const data = new Uint8ClampedArray(frame.data); const data = new Uint8ClampedArray(frame.data);
// // const nData = data.slice(data.length / 4, data.length / 4 * 3) // // const nData = data.slice(data.length / 4, data.length / 4 * 3)
// const qr_result = qrcode.decodefrank(frame.width, frame.height, data) const qian_result = qrcode.decodefrank(frame.width, frame.height, data)
// console.log('qe_result',qr_result) console.log('qe_result',qian_result,999)
// console.log('qr_result.data.codeinfo',qr_result.data.codeinfo) // console.log('qr_result.data.codeinfo',qr_result.data.codeinfo)
if (qr_result.data.codeinfo) { if (qian_result) {
// 原图(默认放大两倍) // 原图(默认放大两倍)
const photo1 = await that.handleTakePoto(that.cameraContext, 1) const photo1 = await that.handleTakePoto(that.cameraContext, 1)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论