Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
best_AI
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
常超凡
best_AI
Commits
88418b24
提交
88418b24
authored
4月 01, 2024
作者:
羊富学
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
贝因美代码优化
上级
2cb1c171
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
71 行增加
和
49 行删除
+71
-49
beiyinmei.js
pages/beiyinmei/beiyinmei.js
+61
-40
beiyinmei.wxml
pages/beiyinmei/beiyinmei.wxml
+10
-9
没有找到文件。
pages/beiyinmei/beiyinmei.js
浏览文件 @
88418b24
...
...
@@ -9,10 +9,9 @@ Page({
* 页面的初始数据
*/
data
:
{
src
:
'https://res.wx.qq.com/wxdoc/dist/assets/img/draw-image.22401fa6.png'
,
height
:
0
,
width
:
0
,
showPage
:
false
showPage
:
''
// '' 为拍照 ,'error'为不通过,'success' 为通过
},
/**
...
...
@@ -91,60 +90,82 @@ Page({
cameraFrame
()
{
let
flag
=
true
const
that
=
this
const
listener
=
this
.
cameraContext
.
onCameraFrame
((
frame
)
=>
{
const
listener
=
this
.
cameraContext
.
onCameraFrame
(
async
(
frame
)
=>
{
if
(
flag
)
{
flag
=
false
const
data
=
new
Uint8ClampedArray
(
frame
.
data
);
const
d
=
qrcode
.
decodefrank
(
frame
.
width
,
frame
.
height
,
data
)
if
(
d
)
{
this
.
cameraContext
.
takePhoto
({
quality
:
'high'
,
selfieMirror
:
false
,
success
(
res
)
{
// flag = true
const
base
=
wx
.
getFileSystemManager
().
readFileSync
(
res
.
tempImagePath
,
'base64'
)
wx
.
request
({
url
:
'https://www.7856.work:4433/api/Bym_classfily_post/'
,
method
:
'POST'
,
data
:
{
device_id
:
'50'
,
base
:
base
},
success
(
rs
)
{
// console.log(rs,9999,rs.data.result,555);
// wx.showToast({
// title: 'dddd过',
// })
if
(
rs
.
data
.
result
==
2
)
{
wx
.
showToast
({
title
:
'通过'
,
icon
:
'success'
})
// const nData = data.slice(data.length / 4, data.length / 4 * 3)
const
qr_result
=
qrcode
.
decodefrank
(
frame
.
width
,
frame
.
height
,
data
)
if
(
qr_result
)
{
that
.
setData
({
showPage
:
true
})
}
else
{
wx
.
showToast
({
title
:
'未通过'
,
icon
:
'error'
height
:
frame
.
height
,
width
:
frame
.
width
})
flag
=
true
}
},
fail
(
e
)
{
console
.
log
(
e
);
// 文件系统
const
fileSystem
=
wx
.
getFileSystemManager
()
// 原图(默认放大两倍)
const
photo1
=
await
that
.
handleTakePoto
()
// 放大图(四倍)
const
photo2
=
await
that
.
handleTakePoto
(
that
.
cameraContext
,
4
)
// 原图base64
const
base64_1
=
fileSystem
.
readFileSync
(
photo1
.
tempImagePath
,
'base64'
)
// 放大四倍图 base64
const
base64_2
=
fileSystem
.
readFileSync
(
photo2
.
tempImagePath
,
'base64'
)
// 请求接口
Promise
.
all
([
that
.
handleApiCheck
(
base64_1
),
that
.
handleApiCheck
(
base64_2
)])
.
then
(
value
=>
{
let
pageType
=
'error'
const
result1
=
value
[
0
],
result2
=
value
[
1
]
// data.result == 2 为真
if
(
result1
.
data
.
result
==
2
&&
result2
.
data
.
result
==
2
)
{
pageType
=
'success'
}
that
.
setData
({
showPage
:
pageType
})
}
})
}
else
{
flag
=
true
}
}
})
listener
.
start
()
},
// 视频流拍照
async
handleTakePoto
(
context
=
this
.
cameraContext
,
zoom
=
2
,
param
)
{
await
context
.
setZoom
({
zoom
})
return
await
context
.
takePhoto
({
quality
:
param
?.
quality
||
'high'
,
selfieMirror
:
param
?.
selfieMirror
||
false
,
})
},
// 接口请求
handleApiCheck
(
base64
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
request
({
url
:
'https://www.7856.work:4433/api/Bym_classfily_post/'
,
method
:
'POST'
,
data
:
{
device_id
:
'50'
,
base
:
base64
},
success
(
res
)
{
resolve
(
res
)
},
fail
(
err
)
{
reject
(
err
)
}
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
...
...
pages/beiyinmei/beiyinmei.wxml
浏览文件 @
88418b24
...
...
@@ -8,21 +8,22 @@
</camera>
</view>
<view wx:
else
class="success-content full">
<view wx:
if="{{showPage == 'success'}}"
class="success-content full">
<view class="content-text">
<image src="/assets/imgs/成功.png" mode="widthFix" style="width: 40%;" />
<image src="/assets/imgs/通过.png" mode="widthFix" style="width: 50%;" />
<!-- <view class="btn" bind:tap="handleBack">返回主页面</view> -->
<!-- <navigator class="btn" open-type="exit" target="miniProgram">点击按钮返回主页</navigator> -->
</view>
</view>
<view style="visibility: hidden;position: fixed;top: 999px;left: 0px;">
<canvas canvas-id="myCanvas" id="myCanvas" style="width: 400px;height: 400px;" />
<view wx:if="{{showPage == 'error'}}" class="success-content full">
<view class="content-text" style="padding-top: 40rpx;">
<!-- <image src="/assets/imgs/成功.png" mode="widthFix" style="width: 40%;" /> -->
<image src="/assets/imgs/未通过.png" mode="widthFix" style="width: 30%;" />
<view style="color: #FFAF38;margin-top: 24rpx;">认证未通过,请扫描实物标签重新认证</view>
</view>
</view>
<!-- <view style="position: fixed;top: 0px;left: 0px;z-index: 999;">
<image src="{{src}}" mode="widthFix"/>
<!-- <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="myCanvas2" id="myCanvas2" style="width: {{width}}px;height: {{height}}px;" />
</view> -->
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论