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

最新代码

上级 313080e6
...@@ -7,7 +7,7 @@ App({ ...@@ -7,7 +7,7 @@ App({
extraData: null extraData: null
}, },
// 根据不同产品展示不同的页面背景 // 根据不同产品展示不同的页面背景
page_bg:'', page_bg: '',
onLaunch() { onLaunch() {
// 展示本地存储能力 // 展示本地存储能力
const logs = wx.getStorageSync('logs') || [] const logs = wx.getStorageSync('logs') || []
...@@ -58,6 +58,8 @@ App({ ...@@ -58,6 +58,8 @@ App({
} }
// console.log('到这里extraData',extraData) // console.log('到这里extraData',extraData)
wx.setStorageSync('extraData', strData) wx.setStorageSync('extraData', strData)
wx.setStorageSync('labeljson', JSON.parse(strData)?.cpid_jm || JSON.parse(strData)?.cpid || '')
// wx.setStorageSync('fenggu', JSON.parse(strData)?.company || '') // wx.setStorageSync('fenggu', JSON.parse(strData)?.company || '')
// 启动摄像头预览 // 启动摄像头预览
......
...@@ -11,6 +11,7 @@ Page({ ...@@ -11,6 +11,7 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
src:'https://res.wx.qq.com/wxdoc/dist/assets/img/0.4cb08bb4.jpg',
height: 0, height: 0,
width: 0, width: 0,
showPage: '' // '' 为拍照 ,'error'为不通过,'success' 为通过 showPage: '' // '' 为拍照 ,'error'为不通过,'success' 为通过
...@@ -34,15 +35,20 @@ Page({ ...@@ -34,15 +35,20 @@ Page({
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);
if (flag) { if (flag) {
flag = false flag = false
// 文件系统 // 文件系统
const fileSystem = wx.getFileSystemManager() const fileSystem = wx.getFileSystemManager()
that.setData({
height: frame.height,
width: frame.width
})
// 实时帧渲染到canvas // 实时帧渲染到canvas
await wx.canvasPutImageData({ await wx.canvasPutImageData({
canvasId: 'myCanvas', canvasId: 'myCanvas',
x:0, x:-frame.width / 4,
y:-frame.height/5, y:-frame.height / 3,
width: frame.width, width: frame.width,
height: frame.height, height: frame.height,
data: new Uint8ClampedArray(frame.data), data: new Uint8ClampedArray(frame.data),
...@@ -66,22 +72,28 @@ Page({ ...@@ -66,22 +72,28 @@ Page({
// console.log('qe_result',qr_result) // console.log('qe_result',qr_result)
// 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) {
that.setData({
height: frame.height,
width: frame.width
})
// 原图(默认放大两倍) // 原图(默认放大两倍)
const photo1 = await that.handleTakePoto(that.cameraContext, 1) const photo1 = await that.handleTakePoto(that.cameraContext, 1)
// 放大图(四倍) // 放大图(四倍)
// await new Promise((resovle) => {
// setTimeout(() => {
// resovle()
// },300)
// })
console.log('5555');
const photo2 = await that.handleTakePoto(that.cameraContext, 4,{flash:'on'}) const photo2 = await that.handleTakePoto(that.cameraContext, 4,{flash:'on'})
console.log(photo2.tempImagePath,'photo1');
// this.setData({
// 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), that.handleApiCheck(base64_2)]) Promise.all([that.handleApiCheck(base64_1,'small'), that.handleApiCheck(base64_2,'big')])
.then(value => { .then(value => {
let pageType = 'error' let pageType = 'error'
const result1 = value[0], const result1 = value[0],
...@@ -131,22 +143,33 @@ Page({ ...@@ -131,22 +143,33 @@ Page({
await context.setZoom({ await context.setZoom({
zoom zoom
}) })
if (zoom == 4) {
await new Promise((resovle) => {
setTimeout(() => {
resovle()
},300)
})
}
return await context.takePhoto({ return await context.takePhoto({
flash:param?.flash || 'off', flash:param?.flash || 'off',
quality: param?.quality || 'high', quality:'high',
selfieMirror: param?.selfieMirror || false, selfieMirror: param?.selfieMirror || false,
// success(res) {
// console.log(res,zoom,222222);
// }
}) })
}, },
// 接口请求 // 接口请求
handleApiCheck(base64) { handleApiCheck(base64,type) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
wx.request({ wx.request({
url: 'https://www.7856.work:4433/api/Bym_classfily_post/', url: 'https://www.7856.work:4433/api/Bym_classfily_post/',
method: 'POST', method: 'POST',
data: { data: {
device_id: '50', device_id: '50',
base: base64 base: base64,
type
}, },
success(res) { success(res) {
resolve(res) resolve(res)
......
<!--pages/beiyinmei/beiyinmei.wxml--> <!--pages/beiyinmei/beiyinmei.wxml-->
<view wx:if="{{!showPage}}" style="height: 100vh;width: 100vw;position: relative;z-index: 99;"> <view wx:if="{{!showPage}}" style="height: 100vh;width: 100vw;position: relative;z-index: 99;">
<camera device-position="back" frame-size="medium" flash="auto" style="width: 100%; height: 100%;" mode="normal"> <camera device-position="back" frame-size="high" flash="on" style="width: 100%; height: 100%;" mode="normal">
<view class="prompt"> <view class="prompt">
<image src="/assets/imgs/拍照框.png" style="width: 25%;" mode="widthFix" /> <image src="/assets/imgs/拍照框.png" style="width: 25%;" mode="widthFix" />
<text>请把二维码放置拍照框内</text> <text>请把二维码放置拍照框内</text>
...@@ -24,5 +24,5 @@ ...@@ -24,5 +24,5 @@
</view> </view>
<view style="visibility: hidden;position: fixed;top: 99999px;left: 0px;"> <view style="visibility: hidden;position: fixed;top: 99999px;left: 0px;">
<canvas canvas-id="myCanvas" id="myCanvas" style="width:400px;height: 400px;" /> <canvas canvas-id="myCanvas" id="myCanvas" style="width:500px;height:500px;" />
</view> </view>
...@@ -41,14 +41,13 @@ ...@@ -41,14 +41,13 @@
<canvas canvas-id="myCanvas" style='width:{{frame.width}}px; height:{{frame.height}}px;'></canvas> <canvas canvas-id="myCanvas" style='width:{{frame.width}}px; height:{{frame.height}}px;'></canvas>
<image src="{{src}}" mode="widthFix" style='width: {{windowWidth}}px; height: {{windowWidth}}px;border: 1px solid red; '></image> <image src="{{src}}" mode="widthFix" style='width: {{windowWidth}}px; height: {{windowWidth}}px;border: 1px solid red; '></image>
</view> --> </view> -->
<view class="ai-check-box"> <view class="ai-check-box">
<view class="photo-box"> <view class="photo-box">
<camera wx:if='{{isShowCamera}}' style="height: 100%;width: 100%;" flash="on" devic-position="back" frame-size="large" resolution="high"> <camera wx:if='{{isShowCamera}}' style="height: 100%;width: 100%;" flash="on" devic-position="back" frame-size="large" resolution="high">
</camera> </camera>
<view class="content"> <view class="content">
<text style='font-size:34rpx'>请将识别框对准结构三维码</text> <text style='font-size:34rpx'>请将识别框对准结构三维码</text>
<image src="/assets/imgs/拍照框.png" mode="widthFix" style="margin:75rpx 0; width: 35%;"/> <image src="/assets/imgs/拍照框.png" mode="widthFix" style="margin:80rpx 0; width: 35%; width: 300rpx;"/>
<view class="progress-box"> <view class="progress-box">
<text >请保持结构三维码在识别框内等待进度条完成</text> <text >请保持结构三维码在识别框内等待进度条完成</text>
<progress percent="{{progressNumber}}" active stroke-width="10" show-info color="#0270FF" border-radius='100' active-mode='forwards' style="margin-top: 20rpx;"/> <progress percent="{{progressNumber}}" active stroke-width="10" show-info color="#0270FF" border-radius='100' active-mode='forwards' style="margin-top: 20rpx;"/>
......
...@@ -14,6 +14,7 @@ Page({ ...@@ -14,6 +14,7 @@ Page({
dongtaishuju: 0, dongtaishuju: 0,
phone_model: '', phone_model: '',
benchmarkLevel: 0, benchmarkLevel: 0,
showModal:false,
content: "1.识别时请将整个结构三维码放到识别框中,保持画面清晰稳定直到显示认证结果\r\n2.确保标签与背景保持在同一平面内,便于手机相机聚焦\r\n3.AI验证的标签需要与扫描进入主页的这枚标签一致(否则会提示码不同)", content: "1.识别时请将整个结构三维码放到识别框中,保持画面清晰稳定直到显示认证结果\r\n2.确保标签与背景保持在同一平面内,便于手机相机聚焦\r\n3.AI验证的标签需要与扫描进入主页的这枚标签一致(否则会提示码不同)",
showCover: true, showCover: true,
status_zhi: '', status_zhi: '',
...@@ -112,23 +113,32 @@ Page({ ...@@ -112,23 +113,32 @@ Page({
// console.log('status_zhi',status_zhi) // console.log('status_zhi',status_zhi)
} }
if (this.data.showmodel === true) { if (this.data.showmodel === true) {
wx.showModal({ this.setData({
title: '注意事项:', showModal:true
content: this.data.content,
showCancel: false, // 是否显示取消按钮,默认值 true
// cancelText: '非常自信', // 取消按钮的文字,默认值 '取消'
confirmText: '我已知晓', // 确定按钮的文字,默认值 '确定'
success: function (res) {
if (res.confirm) {
console.log('用户点击确定')
}
},
fail: function (res) {
console.log(res)
}
}) })
// wx.showModal({
// title: '注意事项:',
// content: this.data.content,
// showCancel: false, // 是否显示取消按钮,默认值 true
// // cancelText: '非常自信', // 取消按钮的文字,默认值 '取消'
// confirmText: '我已知晓', // 确定按钮的文字,默认值 '确定'
// success: function (res) {
// if (res.confirm) {
// console.log('用户点击确定')
// }
// },
// fail: function (res) {
// console.log(res)
// }
// })
} }
}, },
handleColseModal(){
this.setData({
showModal:false
})
},
/**ss /**ss
* 跳转到拍照界面 * 跳转到拍照界面
*/ */
......
...@@ -7,21 +7,34 @@ ...@@ -7,21 +7,34 @@
</veiw> --> </veiw> -->
<view class="full" style="position:relative;"> <view class="full" style="position:relative;">
<!-- 背景图片 --> <!-- 背景图片 -->
<image class="full" src="/assets/imgs/index/首页背景{{bg_color}}.jpg" mode='scaleToFill'></image> <image class="full" src="/assets/imgs/index/首页背景{{bg_color}}.jpg" mode='scaleToFill'></image>
<!-- 内容盒子 --> <!-- 内容盒子 -->
<view class="index-content full"> <view class="index-content full">
<image class="title-image" src="/assets/imgs/index/首页标题.png" mode='widthFix' style="width: 90%;"></image> <image class="title-image" src="/assets/imgs/index/首页标题.png" mode='widthFix' style="width: 90%;"></image>
<image src="https://ai.tj5.cc:35437/static/fenggu/AI.png" mode="widthFix" style="margin-top: 40rpx; width: 80%;"/> <image src="https://ai.tj5.cc:35437/static/fenggu/AI.png" mode="widthFix" style="margin-top: 40rpx; width: 80%;" />
<!-- 按钮 --> <!-- 按钮 -->
<view class="btns"> <view class="btns">
<image bindtap="takePhoto" src="https://ai.tj5.cc:35437/static/fenggu/comerz.png" mode="widthFix" style="width: 50%;" /> <image bindtap="takePhoto" src="https://ai.tj5.cc:35437/static/fenggu/comerz.png" mode="widthFix" style="width: 50%;" />
<view class="btn video-btn" bind:tap="handleOpenVideo">查看视频教程</view> <view class="btn video-btn" bind:tap="handleOpenVideo">查看视频教程</view>
<navigator class="btn video-btn" open-type="exit" target="miniProgram">点击按钮返回主页</navigator> <navigator class="btn video-btn" open-type="exit" target="miniProgram">点击按钮返回主页</navigator>
</view>
<!-- 底部文字 -->
<text class="bottom-text">海南天鉴防伪科技有限公司提供技术支持</text>
<!-- modal -->
<view wx:if="{{showModal}}" class="modal-box">
<view class="card">
<view style="margin: 20rpx 0;font-weight: 700;font-size: 38rpx;">注意事项</view>
<view class="context-text">
<text>1. 识别时请将整个结构三维码放到识别框中,保持画面清晰稳定直到显示认证结果</text>
<text>2. 确保标签与背景保持在同一平面内,便于手机相机聚焦</text>
<text>3. AI验证的标签需要与扫描进入主页的这枚标签一致(否则会提示码不同)</text>
</view> </view>
<view style="margin: 20rpx 0;font-weight: 700;font-size: 38rpx;color: #1666cfb4;" bind:tap="handleColseModal">我已知晓</view>
<!-- 底部文字 --> </view>
<text class="bottom-text">海南天鉴防伪科技有限公司提供技术支持</text>
</view> </view>
</view>
</view> </view>
\ No newline at end of file
...@@ -47,4 +47,41 @@ page { ...@@ -47,4 +47,41 @@ page {
width: 100%; width: 100%;
color: #fff; color: #fff;
text-align: center; text-align: center;
}
.modal-box {
position: absolute;
top: 0;
left: 0;
z-index: 999;
width: 100vw;
height: 100vh;
background-color: rgba(0, 0, 0, 0.4);
}
.modal-box .card {
position: absolute;
top: 45%;
left: 50%;
transform: translate(-50%,-50%);
padding: 20rpx 40rpx;
width: 70%;
background-color: #fff;
border-radius: 20rpx;
}
.modal-box .card .context-text {
display: flex;
flex-direction: column;
text-align: left;
text-indent: -28rpx;
margin-left: 38rpx;
color: #999;
padding-bottom: 20rpx;
border-bottom: 2rpx solid #eee;
}
.modal-box .card .context-text text {
margin: 10rpx 0;
} }
\ No newline at end of file
// pages/result/result.js // pages/result/result.js
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
...@@ -8,25 +7,20 @@ Page({ ...@@ -8,25 +7,20 @@ Page({
aiState: 0, //展示成功或失败页面, aiState: 0, //展示成功或失败页面,
time1: '', //本次认证时间 time1: '', //本次认证时间
time2: '', //认证耗时 time2: '', //认证耗时
bg_color:'', bg_color: '',
Labeldiff:0 //展示码不同页面 Labeldiff: 0,//展示码不同页面
}, },
onLoad(options) { onLoad(options) {
const { const { aiState, time1, time2, Labeldiff } = options
aiState, console.log(options, time1)
time1, console.log('options.Labeldiff', options.Labeldiff)
time2,
Labeldiff
} = options
// console.log(options,time1);
console.log('options.Labeldiff',options.Labeldiff)
this.setData({ this.setData({
aiState: aiState || 0, aiState: aiState || 0,
time1: time1 || '', time1: time1 || '',
time2: time2 && (new Date().getTime() - time2) / 1000 || '', time2: (time2 && (new Date().getTime() - time2) / 100) || '',
bg_color: getApp().page_bg, bg_color: getApp().page_bg,
Labeldiff:Labeldiff || 0 Labeldiff: Labeldiff || 0
}) })
}, },
// 返回首页 // 返回首页
...@@ -36,21 +30,16 @@ Page({ ...@@ -36,21 +30,16 @@ Page({
}) })
}, },
// 重新拍照 // 重新拍照
handleGoTakePhoto(){ handleGoTakePhoto() {
wx.reLaunch({ wx.reLaunch({
url: `/pages/cameraTakePhoto/cameraTakePhoto` url: `/pages/cameraTakePhoto/cameraTakePhoto`
}) })
}, },
handleOpenVideo() { handleOpenVideo() {
wx.navigateTo({ wx.navigateTo({
url: '/pages/video/video', url: '/pages/video/video'
}) })
}, },
onReady() { onReady() {},
onShow() {}
}, })
onShow() {
},
})
\ No newline at end of file
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</view> </view>
<image src="/assets/imgs/验证成功底部.png" mode="widthFix" style="width: 100%;" /> <image src="/assets/imgs/验证成功底部.png" mode="widthFix" style="width: 100%;" />
</view> </view>
<!-- 码不同页面 --> <!-- 码不同页面 -->
<view wx:if="{{Labeldiff == 1 }}" class="error-content full"> <view wx:if="{{Labeldiff == 1 }}" class="error-content full">
<view class="content-text"> <view class="content-text">
<image src="/assets/imgs/未通过.png" mode="widthFix" style="width: 30%;" /> <image src="/assets/imgs/未通过.png" mode="widthFix" style="width: 30%;" />
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论