Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
best_AI
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
常超凡
best_AI
Commits
65328492
提交
65328492
authored
4月 22, 2024
作者:
常超凡
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新的修改代码
上级
cd6eff3c
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
67 行增加
和
67 行删除
+67
-67
beiyinmei.js
pages/beiyinmei/beiyinmei.js
+67
-67
没有找到文件。
pages/beiyinmei/beiyinmei.js
浏览文件 @
65328492
// pages/beiyinmei/beiyinmei.js
// pages/beiyinmei/beiyinmei.js
import
qrcode
,
{
import
qrcode
,
{
height
}
from
'../../utils/llqrcodefrankyin.js'
height
}
from
'../../utils/llqrcodefrankyin.js'
// const base64js = require('base64-arraybuffer');
// const base64js = require('base64-arraybuffer');
Page
({
Page
({
/**
/**
* 页面的初始数据
* 页面的初始数据
*/
*/
...
@@ -102,10 +99,6 @@ Page({
...
@@ -102,10 +99,6 @@ Page({
var
result_zy
=
result
[
minindex
][
0
]
var
result_zy
=
result
[
minindex
][
0
]
var
result_sx
=
result
[
minindex
][
1
]
var
result_sx
=
result
[
minindex
][
1
]
var
result_w
=
result
[
minindex
][
2
]
var
result_w
=
result
[
minindex
][
2
]
var
d_result_zy
=
result
[
minindex
][
0
]
var
d_result_sx
=
result
[
minindex
][
1
]
var
result_zoom
=
parseFloat
((
0.85
/
result_w
).
toFixed
(
1
))
var
result_zoom
=
parseFloat
((
0.85
/
result_w
).
toFixed
(
1
))
that
.
setData
({
that
.
setData
({
result_zoom
:
result_zoom
result_zoom
:
result_zoom
...
@@ -113,66 +106,82 @@ Page({
...
@@ -113,66 +106,82 @@ Page({
let
state
=
''
let
state
=
''
let
status
=
''
let
status
=
''
let
state_x
=
''
let
state_x
=
''
console
.
log
(
888888888
);
console
.
log
(
888888888
)
if
(
d_result_zy
>
0.546
||
d_result_zy
<
0.445
||
d_result_sx
>
0.571
||
d_result_sx
<
0.45
)
{
if
(
console
.
log
(
666666
);
result_zy
>
0.588
||
result_zy
<
0.405
||
result_sx
>
0.577
||
console
.
log
(
'识别二维码成功'
);
result_sx
<
0.401
)
{
console
.
log
(
666666
)
tag
=
true
wx
.
showToast
({
title
:
'请把识别二维码对准拍照框'
})
}
else
{
console
.
log
(
'识别二维码成功'
)
// 原图(默认放大两倍)
// 原图(默认放大两倍)
const
photo1
=
await
that
.
handleTakePoto
(
wx
.
createCameraContext
(),
1
)
const
photo1
=
await
that
.
handleTakePoto
(
wx
.
createCameraContext
(),
1
)
// 放大图(四倍)
// 放大图(四倍)
// await new Promise((resovle) => {
// await new Promise((resovle) => {
// setTimeout(() => {
// setTimeout(() => {
// resovle()
// resovle()
// },300)
// },300)
// })
// })
console
.
log
(
'5555'
);
console
.
log
(
'5555'
)
const
photo2
=
await
that
.
handleTakePoto
(
wx
.
createCameraContext
(),
4
,
{
const
photo2
=
await
that
.
handleTakePoto
(
wx
.
createCameraContext
(),
4
,
{
flash
:
'on'
flash
:
'on'
})
}
console
.
log
(
photo2
.
tempImagePath
,
'photo1'
);
)
console
.
log
(
photo2
.
tempImagePath
,
'photo1'
)
// this.setData({
// this.setData({
// src:photo2.tempImagePath
// src:photo2.tempImagePath
// })
// })
// 原图base64
// 原图base64
const
base64_1
=
wx
const
base64_1
=
wx
.
getFileSystemManager
().
readFileSync
(
photo1
.
tempImagePath
,
'base64'
)
.
getFileSystemManager
()
.
readFileSync
(
photo1
.
tempImagePath
,
'base64'
)
// 放大四倍图 base64
// 放大四倍图 base64
const
base64_2
=
wx
const
base64_2
=
wx
.
getFileSystemManager
().
readFileSync
(
photo2
.
tempImagePath
,
'base64'
)
.
getFileSystemManager
()
.
readFileSync
(
photo2
.
tempImagePath
,
'base64'
)
// 请求接口
// 请求接口
Promise
.
all
([
that
.
handleApiCheck
(
base64_1
,
'small'
),
that
.
handleApiCheck
(
base64_2
,
'big'
)])
Promise
.
all
([
.
then
(
value
=>
{
that
.
handleApiCheck
(
base64_1
,
'small'
),
that
.
handleApiCheck
(
base64_2
,
'big'
)
]).
then
((
value
)
=>
{
let
pageType
=
'error'
let
pageType
=
'error'
const
result1
=
value
[
0
],
const
result1
=
value
[
0
],
result2
=
value
[
1
]
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
{
tag
=
true
wx
.
showToast
({
title
:
'请把识别二维码对准拍照框'
,
})
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
tag
=
true
tag
=
true
wx
.
showToast
({
wx
.
showToast
({
title
:
'请把识别二维码对准拍照框'
,
title
:
'请把识别二维码对准拍照框'
})
})
}
}
},
},
fail
(
err
)
{
fail
(
err
)
{
tag
=
true
tag
=
true
console
.
log
(
err
)
;
console
.
log
(
err
)
}
}
})
})
},
},
...
@@ -194,13 +203,12 @@ Page({
...
@@ -194,13 +203,12 @@ Page({
this
.
listener
.
start
()
this
.
listener
.
start
()
},
},
// 视频流(前端判断二维码)
// 视频流(前端判断二维码)
cameraFrame
()
{
cameraFrame
()
{
let
flag
=
true
let
flag
=
true
const
that
=
this
const
that
=
this
const
listener
=
this
.
cameraContext
.
onCameraFrame
(
async
(
frame
)
=>
{
const
listener
=
this
.
cameraContext
.
onCameraFrame
(
async
(
frame
)
=>
{
console
.
log
(
frame
.
width
,
frame
.
height
)
;
console
.
log
(
frame
.
width
,
frame
.
height
)
if
(
flag
)
{
if
(
flag
)
{
flag
=
false
flag
=
false
// 文件系统
// 文件系统
...
@@ -216,7 +224,7 @@ Page({
...
@@ -216,7 +224,7 @@ Page({
y
:
-
frame
.
height
/
4
,
y
:
-
frame
.
height
/
4
,
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'
,
...
@@ -227,7 +235,7 @@ Page({
...
@@ -227,7 +235,7 @@ Page({
quality
:
'high'
,
quality
:
'high'
,
fileType
:
'jpg'
,
fileType
:
'jpg'
,
destWidth
:
frame
.
width
,
destWidth
:
frame
.
width
,
destHeight
:
frame
.
height
,
destHeight
:
frame
.
height
})
})
this
.
setData
({
this
.
setData
({
...
@@ -237,7 +245,7 @@ Page({
...
@@ -237,7 +245,7 @@ Page({
// 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)
...
@@ -245,7 +253,6 @@ Page({
...
@@ -245,7 +253,6 @@ Page({
// 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
(
qr_result
.
data
.
codeinfo
)
{
if
(
qr_result
.
data
.
codeinfo
)
{
// 原图(默认放大两倍)
// 原图(默认放大两倍)
const
photo1
=
await
that
.
handleTakePoto
(
that
.
cameraContext
,
1
)
const
photo1
=
await
that
.
handleTakePoto
(
that
.
cameraContext
,
1
)
// 放大图(四倍)
// 放大图(四倍)
...
@@ -254,22 +261,30 @@ Page({
...
@@ -254,22 +261,30 @@ Page({
// resovle()
// resovle()
// },300)
// },300)
// })
// })
console
.
log
(
'5555'
)
;
console
.
log
(
'5555'
)
const
photo2
=
await
that
.
handleTakePoto
(
that
.
cameraContext
,
4
,
{
const
photo2
=
await
that
.
handleTakePoto
(
that
.
cameraContext
,
4
,
{
flash
:
'on'
flash
:
'on'
})
})
console
.
log
(
photo2
.
tempImagePath
,
'photo1'
)
;
console
.
log
(
photo2
.
tempImagePath
,
'photo1'
)
// this.setData({
// this.setData({
// src:photo2.tempImagePath
// src:photo2.tempImagePath
// })
// })
// 原图base64
// 原图base64
const
base64_1
=
fileSystem
.
readFileSync
(
photo1
.
tempImagePath
,
'base64'
)
const
base64_1
=
fileSystem
.
readFileSync
(
photo1
.
tempImagePath
,
'base64'
)
// 放大四倍图 base64
// 放大四倍图 base64
const
base64_2
=
fileSystem
.
readFileSync
(
photo2
.
tempImagePath
,
'base64'
)
const
base64_2
=
fileSystem
.
readFileSync
(
photo2
.
tempImagePath
,
'base64'
)
// 请求接口
// 请求接口
Promise
.
all
([
that
.
handleApiCheck
(
base64_1
,
'small'
),
that
.
handleApiCheck
(
base64_2
,
'big'
)])
Promise
.
all
([
.
then
(
value
=>
{
that
.
handleApiCheck
(
base64_1
,
'small'
),
that
.
handleApiCheck
(
base64_2
,
'big'
)
]).
then
((
value
)
=>
{
let
pageType
=
'error'
let
pageType
=
'error'
const
result1
=
value
[
0
],
const
result1
=
value
[
0
],
result2
=
value
[
1
]
result2
=
value
[
1
]
...
@@ -286,7 +301,6 @@ Page({
...
@@ -286,7 +301,6 @@ Page({
flag
=
true
flag
=
true
},
750
)
},
750
)
}
}
}
}
})
})
listener
.
start
()
listener
.
start
()
...
@@ -328,7 +342,7 @@ Page({
...
@@ -328,7 +342,7 @@ Page({
return
await
context
.
takePhoto
({
return
await
context
.
takePhoto
({
flash
:
param
?.
flash
||
'off'
,
flash
:
param
?.
flash
||
'off'
,
quality
:
'high'
,
quality
:
'high'
,
selfieMirror
:
param
?.
selfieMirror
||
false
,
selfieMirror
:
param
?.
selfieMirror
||
false
// success(res) {
// success(res) {
// console.log(res,zoom,222222);
// console.log(res,zoom,222222);
// }
// }
...
@@ -359,49 +373,35 @@ Page({
...
@@ -359,49 +373,35 @@ Page({
/**
/**
* 生命周期函数--监听页面初次渲染完成
* 生命周期函数--监听页面初次渲染完成
*/
*/
onReady
()
{
onReady
()
{},
},
/**
/**
* 生命周期函数--监听页面显示
* 生命周期函数--监听页面显示
*/
*/
onShow
()
{
onShow
()
{},
},
/**
/**
* 生命周期函数--监听页面隐藏
* 生命周期函数--监听页面隐藏
*/
*/
onHide
()
{
onHide
()
{},
},
/**
/**
* 生命周期函数--监听页面卸载
* 生命周期函数--监听页面卸载
*/
*/
onUnload
()
{
onUnload
()
{},
},
/**
/**
* 页面相关事件处理函数--监听用户下拉动作
* 页面相关事件处理函数--监听用户下拉动作
*/
*/
onPullDownRefresh
()
{
onPullDownRefresh
()
{},
},
/**
/**
* 页面上拉触底事件的处理函数
* 页面上拉触底事件的处理函数
*/
*/
onReachBottom
()
{
onReachBottom
()
{},
},
/**
/**
* 用户点击右上角分享
* 用户点击右上角分享
*/
*/
onShareAppMessage
()
{
onShareAppMessage
()
{}
}
})
})
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论