提交 65328492 authored 作者: 常超凡's avatar 常超凡

新的修改代码

上级 cd6eff3c
// pages/beiyinmei/beiyinmei.js
import qrcode, {
height
} from '../../utils/llqrcodefrankyin.js'
import qrcode, { height } from '../../utils/llqrcodefrankyin.js'
// const base64js = require('base64-arraybuffer');
Page({
/**
* 页面的初始数据
*/
......@@ -102,10 +99,6 @@ Page({
var result_zy = result[minindex][0]
var result_sx = result[minindex][1]
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))
that.setData({
result_zoom: result_zoom
......@@ -113,66 +106,82 @@ Page({
let state = ''
let status = ''
let state_x = ''
console.log(888888888);
if (d_result_zy > 0.546 || d_result_zy < 0.445 || d_result_sx > 0.571 || d_result_sx < 0.45) {
console.log(666666);
console.log('识别二维码成功');
console.log(888888888)
if (
result_zy > 0.588 ||
result_zy < 0.405 ||
result_sx > 0.577 ||
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) => {
// setTimeout(() => {
// resovle()
// },300)
// })
console.log('5555');
const photo2 = await that.handleTakePoto(wx.createCameraContext(), 4, {
console.log('5555')
const photo2 = await that.handleTakePoto(
wx.createCameraContext(),
4,
{
flash: 'on'
})
console.log(photo2.tempImagePath, 'photo1');
}
)
console.log(photo2.tempImagePath, 'photo1')
// this.setData({
// src:photo2.tempImagePath
// })
// 原图base64
const base64_1 = wx
.getFileSystemManager().readFileSync(photo1.tempImagePath, 'base64')
.getFileSystemManager()
.readFileSync(photo1.tempImagePath, 'base64')
// 放大四倍图 base64
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')])
.then(value => {
Promise.all([
that.handleApiCheck(base64_1, 'small'),
that.handleApiCheck(base64_2, 'big')
]).then((value) => {
let pageType = 'error'
const result1 = value[0],
result2 = value[1]
// data.result == 2 为真
if (result1.data.result == 2 && result2.data.result == 2) {
if (
result1.data.result == 2 &&
result2.data.result == 2
) {
pageType = 'success'
}
that.setData({
showPage: pageType
})
})
} else {
tag = true
wx.showToast({
title: '请把识别二维码对准拍照框',
})
}
} catch (error) {
tag = true
wx.showToast({
title: '请把识别二维码对准拍照框',
title: '请把识别二维码对准拍照框'
})
}
},
fail(err) {
tag = true
console.log(err);
console.log(err)
}
})
},
......@@ -194,13 +203,12 @@ Page({
this.listener.start()
},
// 视频流(前端判断二维码)
cameraFrame() {
let flag = true
const that = this
const listener = this.cameraContext.onCameraFrame(async (frame) => {
console.log(frame.width, frame.height);
console.log(frame.width, frame.height)
if (flag) {
flag = false
// 文件系统
......@@ -216,7 +224,7 @@ Page({
y: -frame.height / 4,
width: frame.width,
height: frame.height,
data: new Uint8ClampedArray(frame.data),
data: new Uint8ClampedArray(frame.data)
})
const fileData = await wx.canvasToTempFilePath({
canvasId: 'myCanvas',
......@@ -227,7 +235,7 @@ Page({
quality: 'high',
fileType: 'jpg',
destWidth: frame.width,
destHeight: frame.height,
destHeight: frame.height
})
this.setData({
......@@ -237,7 +245,7 @@ Page({
// console.log('qr_result',flag,5555,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 nData = data.slice(data.length / 4, data.length / 4 * 3)
......@@ -245,7 +253,6 @@ Page({
// console.log('qe_result',qian_result,999)
// console.log('qr_result.data.codeinfo',qr_result.data.codeinfo)
if (qr_result.data.codeinfo) {
// 原图(默认放大两倍)
const photo1 = await that.handleTakePoto(that.cameraContext, 1)
// 放大图(四倍)
......@@ -254,22 +261,30 @@ Page({
// resovle()
// },300)
// })
console.log('5555');
console.log('5555')
const photo2 = await that.handleTakePoto(that.cameraContext, 4, {
flash: 'on'
})
console.log(photo2.tempImagePath, 'photo1');
console.log(photo2.tempImagePath, 'photo1')
// this.setData({
// src:photo2.tempImagePath
// })
// 原图base64
const base64_1 = fileSystem.readFileSync(photo1.tempImagePath, 'base64')
const base64_1 = fileSystem.readFileSync(
photo1.tempImagePath,
'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')])
.then(value => {
Promise.all([
that.handleApiCheck(base64_1, 'small'),
that.handleApiCheck(base64_2, 'big')
]).then((value) => {
let pageType = 'error'
const result1 = value[0],
result2 = value[1]
......@@ -286,7 +301,6 @@ Page({
flag = true
}, 750)
}
}
})
listener.start()
......@@ -328,7 +342,7 @@ Page({
return await context.takePhoto({
flash: param?.flash || 'off',
quality: 'high',
selfieMirror: param?.selfieMirror || false,
selfieMirror: param?.selfieMirror || false
// success(res) {
// console.log(res,zoom,222222);
// }
......@@ -359,49 +373,35 @@ Page({
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
onShow() {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
onShareAppMessage() {}
})
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论