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

贝因美

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