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

贝因美

上级 1f34634d
......@@ -22,9 +22,9 @@ Page({
*/
onLoad(options) {
this.cameraContext = wx.createCameraContext()
this.cameraContext.setZoom({
zoom: 2
})
// this.cameraContext.setZoom({
// zoom: 1
// })
this.cameraFrame()
// this.cameraFrameApi()
},
......@@ -45,37 +45,41 @@ Page({
width: frame.width
})
// 实时帧渲染到canvas
// await wx.canvasPutImageData({
// canvasId: 'myCanvas',
// x:0,
// y:0,
// width: frame.width,
// height: frame.height,
// data: new Uint8ClampedArray(frame.data),
// })
// const fileData = await wx.canvasToTempFilePath({
// canvasId: 'myCanvas',
// x: frame.width / 4,
// y: frame.height / 4,
// width: frame.width / 2,
// height: frame.height / 3,
// quality: 'high',
// fileType: 'jpg',
// destWidth: frame.width / 2,
// destHeight: frame.height / 3,
await wx.canvasPutImageData({
canvasId: 'myCanvas',
x:0,
y:0,
width: frame.width,
height: frame.height,
data: new Uint8ClampedArray(frame.data),
})
const fileData = await wx.canvasToTempFilePath({
canvasId: 'myCanvas',
x: frame.width / 4,
y: frame.height / 4,
width: frame.width / 2,
height: frame.height / 3,
quality: 'high',
fileType: 'jpg',
destWidth: frame.width / 2,
destHeight: frame.height / 3,
})
// this.setData({
// src:fileData.tempFilePath
// })
// const base = fileSystem.readFileSync(fileData.tempFilePath, 'base64')
const base = fileSystem.readFileSync(fileData.tempFilePath, 'base64')
// console.log('qr_result',flag,5555,base);
// const qr_result = await that.handleCodeAnalysis(base)
// console.log('qr_result',flag,5555,qr_result.data);
const qr_result = await that.handleCodeAnalysis(base)
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 qian_result = qrcode.decodefrank(frame.width, frame.height, data)
console.log('qe_result',qian_result,999)
// const qian_result = qrcode.decodefrank(frame.width, frame.height, data)
// console.log('qe_result',qian_result,999)
// console.log('qr_result.data.codeinfo',qr_result.data.codeinfo)
if (qian_result) {
if (qr_result.data.codeinfo) {
// 原图(默认放大两倍)
const photo1 = await that.handleTakePoto(that.cameraContext, 1)
......
......@@ -2,8 +2,8 @@
<view wx:if="{{!showPage}}" style="height: 100vh;width: 100vw;position: relative;z-index: 99;">
<!-- <image src="{{src}}" mode="widthFix" style="position: absolute;top: 0px;left: 0px;z-index: 9999;"/> -->
<camera device-position="back" frame-size="high" flash="on" style="width: 100%; height: 100%;" mode="normal">
<view class="prompt">
<image src="/assets/imgs/拍照框.png" style="width: 25%;" mode="widthFix" />
<view class="prompt" style="position: absolute;top: 50%;left: 50%;transform: translate(-50%,-50%);z-index: 999999;">
<image src="/assets/imgs/拍照框.png" style="position: relative;z-index: 99999999;" style="width: 25%;" mode="widthFix" />
<text>请把二维码放置拍照框内</text>
</view>
</camera>
......@@ -25,5 +25,5 @@
</view>
<view style="visibility: hidden;position: fixed;top: 99999px;left: 0px;">
<canvas canvas-id="myCanvas" id="myCanvas" style="width:{{width}}px;height:{{height}}px;" />
<canvas canvas-id="myCanvas" id="myCanvas" style="width:{{500}}px;height:{{500}}px;" />
</view>
......@@ -41,7 +41,8 @@
"minifyWXML": true,
"showES6CompileOption": false,
"useCompilerPlugins": false,
"condition": true
"condition": true,
"compileWorklet": false
},
"compileType": "miniprogram",
"libVersion": "2.25.3",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论