Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
best_AI
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
常超凡
best_AI
Commits
7959679d
提交
7959679d
authored
3月 28, 2024
作者:
羊富学
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
贝因美接口调试
上级
31d8ff98
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
20 行增加
和
122 行删除
+20
-122
beiyinmei.js
pages/beiyinmei/beiyinmei.js
+18
-117
beiyinmei.wxml
pages/beiyinmei/beiyinmei.wxml
+2
-5
没有找到文件。
pages/beiyinmei/beiyinmei.js
浏览文件 @
7959679d
...
@@ -9,9 +9,6 @@ Page({
...
@@ -9,9 +9,6 @@ Page({
* 页面的初始数据
* 页面的初始数据
*/
*/
data
:
{
data
:
{
img
:
'https://res.wx.qq.com/wxdoc/dist/assets/img/0.4cb08bb4.jpg'
,
setHeight
:
''
,
setWidth
:
''
,
canvas
:
{
canvas
:
{
height
:
100
,
height
:
100
,
width
:
100
width
:
100
...
@@ -22,136 +19,40 @@ Page({
...
@@ -22,136 +19,40 @@ Page({
* 生命周期函数--监听页面加载
* 生命周期函数--监听页面加载
*/
*/
onLoad
(
options
)
{
onLoad
(
options
)
{
const
that
=
this
let
flag
=
true
this
.
cameraContext
=
wx
.
createCameraContext
()
this
.
cameraContext
=
wx
.
createCameraContext
()
//系统基本信息
const
systemInfo
=
wx
.
getSystemInfoSync
();
this
.
setData
({
setHeight
:
systemInfo
.
windowWidth
,
setWidth
:
systemInfo
.
windowHeight
})
let
n
=
1
,
flag
=
true
// const ctx = wx.createCanvasContext('myCanvas');
// wx.chooseImage({
// success: function(res){
// console.log(res);
// ctx.drawImage(res.tempFilePaths[0], (400-50)/2, (300-50)/2, 50,50,0,0,200,200)
// // ctx.drawImage(res.tempFilePaths[0], 0, 0, 150, 150)
// ctx.draw()
// }
// })
// setInterval(() => {
// this.cameraContext.takePhoto({
// success: (res) => {
// console.log(888,res);
// this.checkPictureCode(res.tempImagePath)
// },
// fail(e){
// console.log(e,555);
// }
// })
// },0)
// return
const
listener
=
this
.
cameraContext
.
onCameraFrame
((
frame
)
=>
{
const
listener
=
this
.
cameraContext
.
onCameraFrame
((
frame
)
=>
{
if
(
n
%
25
==
0
&&
flag
)
{
if
(
flag
)
{
flag
=
false
flag
=
false
// this.setData({
// canvas: {
// height: frame.height,
// width: frame.width,
// flag: false
// }
// })
// console.log(frame.data)
// const base64 = wx.arrayBufferToBase64(frame.data)
// console.log(base64);
// that.setData({
// src: 'data:image/jpg;base64,' + base64
// });
const
data
=
new
Uint8ClampedArray
(
frame
.
data
);
const
data
=
new
Uint8ClampedArray
(
frame
.
data
);
const
d
=
qrcode
.
decodefrank
(
frame
.
width
,
frame
.
height
,
data
)
const
d
=
qrcode
.
decodefrank
(
frame
.
width
,
frame
.
height
,
data
)
console
.
log
(
d
);
if
(
d
)
{
if
(
d
)
{
this
.
cameraContext
.
takePhoto
({
wx
.
showToast
({
success
:
(
res
)
=>
{
title
:
'通过'
this
.
setData
({
src
:
res
.
tempImagePath
})
})
console
.
log
(
888
,
res
);
const
base64
=
wx
.
arrayBufferToBase64
(
frame
.
data
)
wx
.
request
({
url
:
'https://www.7856.work:4433/api/Bym_classfily_post/'
,
method
:
'POST'
,
data
:{
device_id
:
'50'
,
base
:
base64
},
},
fail
(
e
)
{
success
(
res
){
console
.
log
(
e
,
555
);
console
.
log
(
res
);
},
fail
(
e
){
console
.
log
(
e
);
}
}
})
})
flag
=
false
}
else
{
}
else
{
flag
=
true
flag
=
true
}
}
console
.
log
(
d
)
return
const
query
=
wx
.
createSelectorQuery
()
query
.
select
(
'#myCanvas'
)
.
fields
({
node
:
true
,
size
:
true
})
.
exec
((
res
)
=>
{
const
canvas
=
res
[
0
].
node
const
ctx
=
canvas
.
getContext
(
'2d'
)
const
imgData
=
canvas
.
createImageData
(
data
,
frame
.
height
,
frame
.
width
)
console
.
log
(
imgData
)
ctx
.
putImageData
(
imgData
,
0
,
0
)
//flag = true
console
.
log
(
imgData
,
4444
);
})
}
}
n
++
})
})
listener
.
start
()
listener
.
start
()
},
},
onScanCode
(
e
)
{
console
.
log
(
e
)
},
checkPictureCode
(
imagePath
)
{
const
that
=
this
wx
.
getImageInfo
({
src
:
imagePath
,
success
(
result
)
{
console
.
log
(
result
,
222
);
const
w
=
result
.
width
;
const
h
=
result
.
height
;
const
canvasContent
=
wx
.
createCanvasContext
(
'myCanvas'
);
canvasContent
.
drawImage
(
imagePath
,
(
w
-
200
)
/
2
,
(
h
-
200
)
/
2
-
50
,
200
,
200
,
0
,
0
,
200
,
200
)
canvasContent
.
draw
()
console
.
log
();
wx
.
canvasGetImageData
({
canvasId
:
'myCanvas'
,
x
:
parseInt
(
0
),
y
:
parseInt
(
0
),
width
:
200
,
height
:
200
,
success
(
data
)
{
let
d
=
qrcode
.
decodefrank
(
200
,
200
,
data
.
data
)
console
.
log
(
'd'
,
d
,
55555
);
}
})
that
.
setData
({
img
:
result
.
path
})
}
})
},
/**
/**
* 生命周期函数--监听页面初次渲染完成
* 生命周期函数--监听页面初次渲染完成
...
...
pages/beiyinmei/beiyinmei.wxml
浏览文件 @
7959679d
<!--pages/beiyinmei/beiyinmei.wxml-->
<!--pages/beiyinmei/beiyinmei.wxml-->
<view style="height: 100vh;width: 100vw;position: relative;z-index: 99;">
<view style="height: 100vh;width: 100vw;position: relative;z-index: 99;">
<camera device-position="back" frame-size="
medium" flash="off" binderror="error" style="width: 100%; height: 300px;" mode="normal" bindscancode="onScanCode
">
<camera device-position="back" frame-size="
small" flash="off" binderror="error" style="width: 100%; height: 100%;" mode="normal
">
<view class="prompt">
<view class="prompt">
<image src="/assets/imgs/拍照框.png" style="width:
4
0%;" mode="widthFix" />
<image src="/assets/imgs/拍照框.png" style="width:
6
0%;" mode="widthFix" />
<text>请把二维码放置拍照框内</text>
<text>请把二维码放置拍照框内</text>
</view>
</view>
</camera>
</camera>
<canvas type="2d" id="myCanvas" canvas-id="myCanvas" style="height:200px;width: 200px;"></canvas>
<image src="{{src}}" mode="widthFix" style="position: fixed; bottom: 100px; width: 100%;" />
</view>
</view>
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论