Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
best_AI
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
常超凡
best_AI
Commits
80829ca8
提交
80829ca8
authored
4月 01, 2024
作者:
羊富学
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
贝因美
上级
88418b24
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
55 行增加
和
12 行删除
+55
-12
beiyinmei.js
pages/beiyinmei/beiyinmei.js
+52
-8
beiyinmei.wxml
pages/beiyinmei/beiyinmei.wxml
+3
-4
没有找到文件。
pages/beiyinmei/beiyinmei.js
浏览文件 @
80829ca8
...
@@ -3,6 +3,8 @@ import qrcode, {
...
@@ -3,6 +3,8 @@ import qrcode, {
height
height
}
from
'../../utils/llqrcodefrankyin.js'
}
from
'../../utils/llqrcodefrankyin.js'
const
base64js
=
require
(
'base64-arraybuffer'
);
Page
({
Page
({
/**
/**
...
@@ -93,16 +95,37 @@ Page({
...
@@ -93,16 +95,37 @@ Page({
const
listener
=
this
.
cameraContext
.
onCameraFrame
(
async
(
frame
)
=>
{
const
listener
=
this
.
cameraContext
.
onCameraFrame
(
async
(
frame
)
=>
{
if
(
flag
)
{
if
(
flag
)
{
flag
=
false
flag
=
false
const
data
=
new
Uint8ClampedArray
(
frame
.
data
);
// 文件系统
// const nData = data.slice(data.length / 4, data.length / 4 * 3)
const
fileSystem
=
wx
.
getFileSystemManager
()
const
qr_result
=
qrcode
.
decodefrank
(
frame
.
width
,
frame
.
height
,
data
)
// 实时帧渲染到canvas
if
(
qr_result
)
{
await
wx
.
canvasPutImageData
({
canvasId
:
'myCanvas'
,
width
:
frame
.
width
,
height
:
frame
.
height
,
data
:
new
Uint8ClampedArray
(
frame
.
data
),
})
const
fileData
=
await
wx
.
canvasToTempFilePath
({
canvasId
:
'myCanvas'
,
x
:
frame
.
width
/
2
-
150
,
y
:
frame
.
height
/
2
-
150
,
width
:
300
,
height
:
300
,
destWidth
:
300
,
destHeight
:
300
,
quality
:
'high'
,
fileType
:
'jpg'
,
})
const
base
=
fileSystem
.
readFileSync
(
fileData
.
tempFilePath
,
'base64'
)
const
qr_result
=
await
that
.
handleCodeAnalysis
(
base
)
// 前端校验取消
// const data = new Uint8ClampedArray(frame.data);
// // const nData = data.slice(data.length / 4, data.length / 4 * 3)
// const qr_result = qrcode.decodefrank(frame.width, frame.height, data)
if
(
qr_result
?.
codeinfo
)
{
that
.
setData
({
that
.
setData
({
height
:
frame
.
height
,
height
:
frame
.
height
,
width
:
frame
.
width
width
:
frame
.
width
})
})
// 文件系统
const
fileSystem
=
wx
.
getFileSystemManager
()
// 原图(默认放大两倍)
// 原图(默认放大两倍)
const
photo1
=
await
that
.
handleTakePoto
()
const
photo1
=
await
that
.
handleTakePoto
()
// 放大图(四倍)
// 放大图(四倍)
...
@@ -117,13 +140,14 @@ Page({
...
@@ -117,13 +140,14 @@ Page({
Promise
.
all
([
that
.
handleApiCheck
(
base64_1
),
that
.
handleApiCheck
(
base64_2
)])
Promise
.
all
([
that
.
handleApiCheck
(
base64_1
),
that
.
handleApiCheck
(
base64_2
)])
.
then
(
value
=>
{
.
then
(
value
=>
{
let
pageType
=
'error'
let
pageType
=
'error'
const
result1
=
value
[
0
],
result2
=
value
[
1
]
const
result1
=
value
[
0
],
result2
=
value
[
1
]
// data.result == 2 为真
// data.result == 2 为真
if
(
result1
.
data
.
result
==
2
&&
result2
.
data
.
result
==
2
)
{
if
(
result1
.
data
.
result
==
2
&&
result2
.
data
.
result
==
2
)
{
pageType
=
'success'
pageType
=
'success'
}
}
that
.
setData
({
that
.
setData
({
showPage
:
pageType
showPage
:
pageType
})
})
})
})
}
else
{
}
else
{
...
@@ -135,6 +159,26 @@ Page({
...
@@ -135,6 +159,26 @@ Page({
listener
.
start
()
listener
.
start
()
},
},
// 后端接口解析二维码
handleCodeAnalysis
(
base64
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
request
({
url
:
'https://www.7856.work:4433/api/Bym_upload/'
,
method
:
'POST'
,
data
:
{
base
:
base64
,
labelCodejson
:
'BeiyinmeiAi'
},
success
(
res
)
{
resolve
(
res
)
},
fail
(
err
)
{
reject
(
err
)
}
})
})
},
// 视频流拍照
// 视频流拍照
async
handleTakePoto
(
context
=
this
.
cameraContext
,
zoom
=
2
,
param
)
{
async
handleTakePoto
(
context
=
this
.
cameraContext
,
zoom
=
2
,
param
)
{
await
context
.
setZoom
({
await
context
.
setZoom
({
...
...
pages/beiyinmei/beiyinmei.wxml
浏览文件 @
80829ca8
...
@@ -23,7 +23,6 @@
...
@@ -23,7 +23,6 @@
</view>
</view>
</view>
</view>
<!-- <view style="visibility: hidden;position: fixed;top: 9999px;left: 0px;">
<view style="visibility: hidden;position: fixed;top: 9999px;left: 0px;">
<canvas canvas-id="myCanvas" id="myCanvas" style="width: {{width}}px;height: {{height}}px;" />
<canvas canvas-id="myCanvas" id="myCanvas" style="width:400px;height: 400px;" />
<canvas canvas-id="myCanvas2" id="myCanvas2" style="width: {{width}}px;height: {{height}}px;" />
</view>
</view> -->
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论