提交 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>
// 获取全局应用程序实例对象 // 获取全局应用程序实例对象
// const app = getApp(); // const app = getApp();
var util = require('../../utils/util') var util = require('../../utils/util')
var Counter = 0; var Counter = 0
var take_Count = 0; var take_Count = 0
// 创建页面实例对象 // 创建页面实例对象
Page({ Page({
// 页面的初始数据 // 页面的初始数据
...@@ -16,7 +16,7 @@ Page({ ...@@ -16,7 +16,7 @@ Page({
userInfo: {}, userInfo: {},
hasUserInfo: false, hasUserInfo: false,
mybase64: '', mybase64: '',
temfilePath: "", temfilePath: '',
tag: false, tag: false,
datajson: '', datajson: '',
labelCode: '', labelCode: '',
...@@ -59,59 +59,55 @@ Page({ ...@@ -59,59 +59,55 @@ Page({
longTimeThree: false, longTimeThree: false,
longTimeTakephoto: false, longTimeTakephoto: false,
all_finish: false, all_finish: false,
small_finish: false, small_finish: false
// status_zhi:'' // status_zhi:''
}, },
onLoad: function (options) { onLoad: function (options) {
const param = options.param; const param = options.param
console.log('param1', param) console.log('param1', param)
wx.setStorage({ wx.setStorage({
key: 'param', key: 'param',
data: param data: param
}) })
var that = this var that = this
this.Sounds(); this.Sounds()
const dongtaishuju_chuan = wx.getStorageSync('dongtaishuju') const dongtaishuju_chuan = wx.getStorageSync('dongtaishuju')
//注释长时间不拍照 switch (dongtaishuju_chuan) {
// switch (dongtaishuju_chuan) { case 1:
// case 1: this.Countone_Time()
// this.Countone_Time(); break
// break; case 2:
// case 2: this.Counttwo_Time()
// this.Counttwo_Time(); break
// break; case 3:
// case 3: this.Countthree_Time()
// this.Countthree_Time(); break
// break; default:
// default: console.log('不等于1,2,3次')
// console.log('不等于1,2,3次') this.setData({
// this.setData({ longtime_state: true
// longtime_state: true })
// }) }
// }
var nCounter = 0 var nCounter = 0
const labelInfo = JSON.parse(wx.getStorageSync('extraData')) const labelInfo = wx.getStorageSync('labeljson')
// console.log('labelInfo', labelInfo) console.log('labelInfo', labelInfo)
if (labelInfo) { if (labelInfo) {
const labelCode = labelInfo.cpid_jm || labelInfo.cpid const labelCode = labelInfo
this.setData({ this.setData({
labelCode, labelCode,
dongtaishuju_chuan, dongtaishuju_chuan,
param, param
}) })
// console.log('labelCode', labelCode) // console.log('labelCode', labelCode)
} }
var that = this var that = this
const { const { screenWidth, screenHeight } = wx.getSystemInfoSync()
screenWidth,
screenHeight
} = wx.getSystemInfoSync()
const windowWidth = 750 const windowWidth = 750
const windowHeight = screenHeight / screenWidth * windowWidth const windowHeight = (screenHeight / screenWidth) * windowWidth
this.setData({ this.setData({
windowWidth, windowWidth,
windowHeight, windowHeight
}) })
// console.log('wind', windowWidth, 'height', windowHeight) // console.log('wind', windowWidth, 'height', windowHeight)
this.ctx = wx.createCameraContext() this.ctx = wx.createCameraContext()
...@@ -124,11 +120,11 @@ Page({ ...@@ -124,11 +120,11 @@ Page({
}, 1000) }, 1000)
this.setData({ this.setData({
['frame.width']: frame.width, ['frame.width']: frame.width,
['frame.height']: frame.height, ['frame.height']: frame.height
}) })
var data = new Uint8Array(frame.data); var data = new Uint8Array(frame.data)
// console.log('data', data) // console.log('data', data)
var clamped = new Uint8ClampedArray(data); var clamped = new Uint8ClampedArray(data)
// console.log('clamped', clamped) // console.log('clamped', clamped)
// 实时帧数据添加到Canvas上 // 实时帧数据添加到Canvas上
// console.log('===========') // console.log('===========')
...@@ -136,197 +132,223 @@ Page({ ...@@ -136,197 +132,223 @@ Page({
canvasId: 'myCanvas', canvasId: 'myCanvas',
x: 0, x: 0,
y: 0, y: 0,
width: frame.width, //288 288 width: frame.width, //288 288
height: frame.height, //512 381 height: frame.height, //512 381
data: clamped, data: clamped,
success: (res) => { success: (res) => {
// var inter = setInterval(function () { var inter = setInterval(function () {
// that.setData({ that.setData({
// smsFlag: true, smsFlag: true,
// sendTime: that.data.snsMsgWait, sendTime: that.data.snsMsgWait,
// snsMsgWait: that.data.snsMsgWait - 1 snsMsgWait: that.data.snsMsgWait - 1
// }); })
// console.log('that.data.snsMsgWait', that.data.snsMsgWait) if (
// console.log('that.data.take_state', that.data.take_state) that.data.snsMsgWait === -6 &&
// console.log('that.data.longtime_state', that.data.longtime_state) !that.data.take_state &&
// if (that.data.snsMsgWait === -6 && !that.data.take_state && that.data.longtime_state === true) { that.data.longtime_state === true
// let fail_text = '长时间不拍照1' ) {
// // console.log('fail_text', fail_text) let fail_text = '长时间不拍照1'
// that.setData({ // console.log('fail_text', fail_text)
// longTimeTakephoto: true that.setData({
// }) longTimeTakephoto: true
// // console.log('that.data.takephoto',that.data.takephoto) })
// if (fail_text !== '' && that.data.takephoto !== 'succes') { // console.log('that.data.takephoto',that.data.takephoto)
// // console.log('进行第一次拍照') if (fail_text !== '' && that.data.takephoto !== 'succes') {
// that.takePhoto() // console.log('进行第一次拍照')
// let take_photo_1 = '长时间不拍照2' that.takePhoto()
// let takephoto = 'succes' let take_photo_1 = '长时间不拍照2'
// that.setData({ let takephoto = 'succes'
// take_photo_1, that.setData({
// takephoto take_photo_1,
// }); takephoto
// } })
// // console.log('that.data.takephoto',that.data.takephoto) }
// if (fail_text !== '' && that.data.takephoto === 'succes' && that.data.all_state !== true) { // console.log('that.data.takephoto',that.data.takephoto)
// setTimeout(() => { if (
// // console.log('进行第二次拍照') fail_text !== '' &&
// that.takePhoto2() that.data.takephoto === 'succes' &&
// }, 3500) that.data.all_state !== true
// let take_state = true ) {
// that.setData({ setTimeout(() => {
// take_state, // console.log('进行第二次拍照')
// all_state: true that.takePhoto2()
// }); }, 3500)
// } let take_state = true
// } that.setData({
// if (that.data.snsMsgWait < 0) { take_state,
// clearInterval(inter) all_state: true
// that.setData({ })
// snsMsgWait: -5, }
// snsFlag: false }
// }) if (that.data.snsMsgWait < 0) {
// } clearInterval(inter)
// }, 1000);
// 转换临时文件
wx.canvasToTempFilePath({
canvasId: 'myCanvas',
x: 0,
y: (frame.height - frame.width) / 2,
width: frame.width, //288
height: frame.width, //352
fileType: 'jpg',
destWidth: frame.width,
destHeight: frame.width,
// 精度修改
quality: 'high',
success: (res) => {
// console.log('成功成功成功')
//进行编码
const base = wx.getFileSystemManager().readFileSync(res.tempFilePath, 'base64')
// console.log('base',base)
that.setData({ that.setData({
src: res.tempFilePath snsMsgWait: -5,
}); snsFlag: false
wx.request({ })
// url: 'https://ai.tj5.cc:35437/object/', }
url: 'https://www.7856.work:4433/clear_fuzzy_detect/', //目标检测+判断清晰模糊接口 }, 1000)
// url:'https://ai.china315net.com:35437/object/', // 转换临时文件
method: "POST", wx.canvasToTempFilePath(
data: { {
base canvasId: 'myCanvas',
}, x: 0,
success: (res) => { y: (frame.height - frame.width) / 2,
console.log('res.data', res.data) width: frame.width, //288
var result = res.data.result; height: frame.width, //352
var coord = res.data.coord[0][5] fileType: 'jpg',
console.log('coord', coord) destWidth: frame.width,
var minindex = -1; destHeight: frame.width,
var mindistance = 2; // 精度修改
console.log('length', result.length) quality: 'high',
for (var i = 0; i < result.length; i++) { success: (res) => {
var sublist = result[i]; // console.log('成功成功成功')
var distance = Math.abs(sublist[0] - 0.5) + Math.abs(sublist[1] - 0.5); //进行编码
if (distance < mindistance) { const base = wx
mindistance = distance; .getFileSystemManager()
minindex = i; .readFileSync(res.tempFilePath, 'base64')
// console.log('base',base)
that.setData({
src: res.tempFilePath
})
wx.request({
// url: 'https://ai.tj5.cc:35437/object/', //线上
url: 'https://www.7856.work:4433/clear_fuzzy_detect/', //目标检测+判断清晰模糊接口 测试地址
// url: 'https://tj5.cc:4433/object/',
// url:'https://ai.china315net.com:35437/object/',
method: 'POST',
data: {
base
},
success: (res) => {
var result = res.data.result
var coord = res.data.coord[0][5]
console.log('coord', coord)
var minindex = -1
var mindistance = 2
for (var i = 0; i < result.length; i++) {
var sublist = result[i]
var distance =
Math.abs(sublist[0] - 0.5) +
Math.abs(sublist[1] - 0.5)
if (distance < mindistance) {
mindistance = distance
minindex = i
}
} }
} 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 result_zoom = parseFloat((0.85 / result_w).toFixed(1))
var result_zoom = parseFloat((0.85 / result_w).toFixed(1))
that.setData({
result_zoom: result_zoom
})
let state = ''
let status = ''
let state_x = ''
if (result_zy > 0.588) { //0.568
state = 'left'
} else if (result_zy < 0.405) { //0.425
state = 'right'
} else if (result_sx > 0.577) { //0.547
state = 'on'
} else if (result_sx < 0.401) { //0.411
state = 'down'
} else {
let text = '大框参数已经完善'
var take_Count = 0;
// console.log('大框参数已经完善', text)
let singe_state = true
take_Count++,
wx.removeStorageSync('singe_state')
that.setData({ that.setData({
singe_state, result_zoom: result_zoom
small_finish: true
}) })
status = 'true' let state = ''
// console.log('that.data.takephoto', that.data.takephoto) let status = ''
if (coord != 0) { let state_x = ''
wx.showToast({ if (result_zy > 0.588) {
title: '当前位置模糊,请找合适的位置', //0.568
}) state = 'left'
} } else if (result_zy < 0.405) {
if (text == text && that.data.takephoto !== 'succes' && that.data.take_photo_1 === '' && coord === 0) { //0.425
// console.log('大框参数完成进行拍照') state = 'right'
that.takePhoto(); } else if (result_sx > 0.577) {
let takephoto = 'succes' //0.547
let d_takephoto = '大框拍照完成' state = 'on'
// console.log('d_takephoto', d_takephoto) } else if (result_sx < 0.401) {
//0.411
state = 'down'
} else {
let text = '大框参数已经完善'
var take_Count = 0
// console.log('大框参数已经完善', text)
let singe_state = true
take_Count++, wx.removeStorageSync('singe_state')
that.setData({ that.setData({
takephoto, singe_state,
text, small_finish: true
d_takephoto,
}) })
status = 'true'
if (coord != 0) {
wx.showToast({
title: '当前位置模糊,请找合适的位置'
})
}
// console.log('that.data.takephoto', that.data.takephoto) // console.log('that.data.takephoto', that.data.takephoto)
// console.log('that.data.all_state', that.data.all_state) if (
} text == text &&
//新修改 that.data.takephoto !== 'succes' &&
else if (that.data.takephoto === 'succes' && that.data.all_state === false) { that.data.take_photo_1 === '' &&
// console.log('进入小框判断') coord === 0
var result = res.data.result; ) {
var d_result_zy = result[minindex][0]; // console.log('大框参数完成进行拍照')
var d_result_sx = result[minindex][1]; that.takePhoto()
if (d_result_zy > 0.546) { //0.546 let takephoto = 'succes'
state_x = 'left' let d_takephoto = '大框拍照完成'
} else if (d_result_zy < 0.445) { //0.445 // console.log('d_takephoto', d_takephoto)
state_x = 'right'
} else if (d_result_sx > 0.571) { //0.531
state_x = 'on'
} else if (d_result_sx < 0.450) { //0.410
state_x = 'down'
} else {
// console.log('全部完成')
// console.log('this.data.all_state', this.data.all_state)
this.setData({
all_finish: true
});
that.takePhoto2()
that.setData({ that.setData({
all_state: true takephoto,
text,
d_takephoto
}) })
that.listener.stop() // console.log('that.data.takephoto', that.data.takephoto)
// console.log('that.data.all_state', that.data.all_state)
}
//新修改
else if (
that.data.takephoto === 'succes' &&
that.data.all_state === false
) {
// console.log('进入小框判断')
var result = res.data.result
var d_result_zy = result[minindex][0]
var d_result_sx = result[minindex][1]
if (d_result_zy > 0.546) {
//0.546
state_x = 'left'
} else if (d_result_zy < 0.445) {
//0.445
state_x = 'right'
} else if (d_result_sx > 0.571) {
//0.531
state_x = 'on'
} else if (d_result_sx < 0.45) {
//0.410
state_x = 'down'
} else {
// console.log('全部完成')
// console.log('this.data.all_state', this.data.all_state)
this.setData({
all_finish: true
})
that.takePhoto2()
that.setData({
all_state: true
})
that.listener.stop()
}
} else {
console.log('拍照失败')
// that.takePhoto2()
} }
} else {
console.log('拍照失败')
// that.takePhoto2()
} }
that.setData({
state: state,
status: status,
state_x: state_x
})
},
fail: (error) => {
console.log('目标检测失败', error)
} }
that.setData({ })
state: state, },
status: status, fail: (error) => {
state_x: state_x console.log('转换临时文件失败:', error)
}) }
},
fail: (error) => {
console.log('目标检测失败', error)
}
})
}, },
fail: (error) => { that
console.log('转换临时文件失败:', error); )
}
}, that)
}, },
fail: (error) => { fail: (error) => {
console.log('绘制图像数据失败', error) console.log('绘制图像数据失败', error)
...@@ -441,7 +463,7 @@ Page({ ...@@ -441,7 +463,7 @@ Page({
scope: 'scope.camera', scope: 'scope.camera',
success: function (res) { success: function (res) {
that.setData({ that.setData({
isShowCamera: true, isShowCamera: true
}) })
// console.log('走权限1') // console.log('走权限1')
let res_errMsg = res.errMsg let res_errMsg = res.errMsg
...@@ -449,48 +471,53 @@ Page({ ...@@ -449,48 +471,53 @@ Page({
res_errMsg: res_errMsg res_errMsg: res_errMsg
}) })
wx.removeStorageSync('res_errMsg') wx.removeStorageSync('res_errMsg')
//倒计时注释倒计时 //倒计时
// var inter = setInterval(function () { var inter = setInterval(
// that.setData({ function () {
// smsFlag: true, that.setData({
// sendTime: that.data.snsMsgWait_1, smsFlag: true,
// snsMsgWait_1: that.data.snsMsgWait_1 - 1 sendTime: that.data.snsMsgWait_1,
// }); snsMsgWait_1: that.data.snsMsgWait_1 - 1
// if (that.data.snsMsgWait_1 === -6 && res_errMsg != '') { })
// // console.log('长时间未响应') if (that.data.snsMsgWait_1 === -6 && res_errMsg != '') {
// setTimeout(() => { // console.log('长时间未响应')
// that.takePhoto2() setTimeout(() => {
// }, 2500) that.takePhoto2()
// that.setData({ }, 2500)
// longtime_state: true that.setData({
// }) longtime_state: true
// } })
// if (that.data.snsMsgWait_1 < 0) { }
// clearInterval(inter) if (that.data.snsMsgWait_1 < 0) {
// that.setData({ clearInterval(inter)
// snsMsgWait_1: -5, that.setData({
// snsFlag: false snsMsgWait_1: -5,
// }) snsFlag: false
// // console.log('that.data.snsMsgWait_2', that.data.snsMsgWait_1) })
// } // console.log('that.data.snsMsgWait_2', that.data.snsMsgWait_1)
// }.bind(that), 1000); }
// let camera_state = res.errMsg }.bind(that),
// that.setData({ 1000
// camera_state )
// }) let camera_state = res.errMsg
that.setData({
camera_state
})
}, },
fail: function (res) { fail: function (res) {
console.log("" + res); console.log('' + res)
// console.log('走权限2') // console.log('走权限2')
wx.showModal({ wx.showModal({
title: '请求授权您的摄像头', title: '请求授权您的摄像头',
content: '如需正常使用此小程序功能,请您按确定并在设置页面授权用户信息', content:
'如需正常使用此小程序功能,请您按确定并在设置页面授权用户信息',
confirmText: '确定', confirmText: '确定',
success: function (res) { success: function (res) {
if (res.confirm) { if (res.confirm) {
wx.openSetting({ wx.openSetting({
success: function (res) { success: function (res) {
if (res.authSetting['scope.camera']) { //设置允许获取摄像头 if (res.authSetting['scope.camera']) {
//设置允许获取摄像头
// console.log('设置允许获取摄像头') // console.log('设置允许获取摄像头')
wx.showToast({ wx.showToast({
title: '授权成功', title: '授权成功',
...@@ -501,7 +528,8 @@ Page({ ...@@ -501,7 +528,8 @@ Page({
isShowCamera: true, isShowCamera: true,
icon: icon icon: icon
}) })
} else { //不允许 } else {
//不允许
wx.showToast({ wx.showToast({
title: '授权失败', title: '授权失败',
icon: 'none', icon: 'none',
...@@ -513,7 +541,8 @@ Page({ ...@@ -513,7 +541,8 @@ Page({
} }
} }
}) })
} else { //取消 } else {
//取消
wx.showToast({ wx.showToast({
title: '授权失败', title: '授权失败',
icon: 'none', icon: 'none',
...@@ -528,7 +557,7 @@ Page({ ...@@ -528,7 +557,7 @@ Page({
}, },
fail: function (res) { fail: function (res) {
console.log('获取相机失败', res) console.log('获取相机失败', res)
onShow(); onShow()
} }
}) })
}, },
...@@ -540,11 +569,11 @@ Page({ ...@@ -540,11 +569,11 @@ Page({
// 设置拍照进度条 // 设置拍照进度条
this.setData({ this.setData({
progressNumber: 50, progressNumber: 50
}) })
var that = this var that = this
Counter++; Counter++
that.ctx.setZoom({ that.ctx.setZoom({
zoom: 1.0, zoom: 1.0,
success: (res) => { success: (res) => {
...@@ -556,10 +585,12 @@ Page({ ...@@ -556,10 +585,12 @@ Page({
/*储存 */ /*储存 */
wx.setStorage({ wx.setStorage({
key: 'res.tempImagePath', key: 'res.tempImagePath',
data: res.tempImagePath, data: res.tempImagePath
}) })
// console.log('res.tempImagePath', res.tempImagePath) // console.log('res.tempImagePath', res.tempImagePath)
const base = wx.getFileSystemManager().readFileSync(res.tempImagePath, 'base64') const base = wx
.getFileSystemManager()
.readFileSync(res.tempImagePath, 'base64')
// console.log('base', base) // console.log('base', base)
this.setData({ this.setData({
kongfileimage: res.tempImagePath kongfileimage: res.tempImagePath
...@@ -571,18 +602,19 @@ Page({ ...@@ -571,18 +602,19 @@ Page({
// url:'https://ai.china315net.com:35437/api/upload/', // url:'https://ai.china315net.com:35437/api/upload/',
// url: 'https://ai.tj5.cc:35437/api/upload/', // url: 'https://ai.tj5.cc:35437/api/upload/',
// url:'https://tj5.cc:4433/api/upload/', // url:'https://tj5.cc:4433/api/upload/',
url: 'https://ai.tj5.cc:35437/api/small_upload/', url: 'https://ai.tj5.cc:35437/api/small_upload/', //线上
// url:'https://www.7856.work:4433/clear_fuzzy_detect/', //测试地址
// url:'https://tj5.cc:4433/api/small_upload/', // url:'https://tj5.cc:4433/api/small_upload/',
method: 'POST', method: 'POST',
data: { data: {
base, base,
'labelCodejson': '123456789123' labelCodejson: this.data.labelInfo
}, },
success: (res) => { success: (res) => {
// console.log('base', base) // console.log('base', base)
// console.log('res.statusCode ', res.statusCode) // console.log('res.statusCode ', res.statusCode)
// console.log('接口访问') // console.log('接口访问')
var dtime = util.formatTime(new Date) var dtime = util.formatTime(new Date())
wx.setStorage({ wx.setStorage({
key: 'dtime', key: 'dtime',
data: dtime data: dtime
...@@ -592,7 +624,11 @@ Page({ ...@@ -592,7 +624,11 @@ Page({
// console.log('res_data', res_data) // console.log('res_data', res_data)
var succes_data = res_data.succes var succes_data = res_data.succes
// console.log('succes_data', succes_data) // console.log('succes_data', succes_data)
if (res_data === '码解析失败' || succes_data === 'loser' || res.statusCode !== 200) { if (
res_data === '码解析失败' ||
succes_data === 'loser' ||
res.statusCode !== 200
) {
// console.log('计算res_data长度',res_data.length) // console.log('计算res_data长度',res_data.length)
// console.log('网络请求值不等于200 ') // console.log('网络请求值不等于200 ')
const datajson = '码解析失败' const datajson = '码解析失败'
...@@ -620,7 +656,7 @@ Page({ ...@@ -620,7 +656,7 @@ Page({
key: 'points', key: 'points',
data: points data: points
}) })
var datajson = res_data.codeinfo; var datajson = res_data.codeinfo
console.log('原图解析内容datajson', datajson) console.log('原图解析内容datajson', datajson)
wx.setStorage({ wx.setStorage({
key: 'datajson', key: 'datajson',
...@@ -657,10 +693,10 @@ Page({ ...@@ -657,10 +693,10 @@ Page({
wx.request({ wx.request({
url: 'https://ai.tj5.cc:35437/classify16/', url: 'https://ai.tj5.cc:35437/classify16/',
// url: 'https://tj5.cc:4433/classify16/', // url: 'https://tj5.cc:4433/classify16/',
method: "POST", method: 'POST',
data: { data: {
'image_type': 50, image_type: 50,
'base': base, base: base
}, },
success: (res) => { success: (res) => {
let result_value = res.data.result let result_value = res.data.result
...@@ -693,18 +729,18 @@ Page({ ...@@ -693,18 +729,18 @@ Page({
// console.log('hint_phone', hint_phone) // console.log('hint_phone', hint_phone)
} }
}, },
fail: error => { fail: (error) => {
console.log('调用upload失败', error) console.log('调用upload失败', error)
} }
}); })
var dtime_2 = util.formatTime(new Date) var dtime_2 = util.formatTime(new Date())
wx.setStorage({ wx.setStorage({
key: 'dtime_2', key: 'dtime_2',
data: dtime_2 data: dtime_2
}) })
} }
}) })
}, 350); }, 350)
} }
}) })
let once_takephoto = 'true' let once_takephoto = 'true'
...@@ -763,10 +799,9 @@ Page({ ...@@ -763,10 +799,9 @@ Page({
// console.log('takePhoto2') // console.log('takePhoto2')
// 设置拍照进度条 // 设置拍照进度条
this.setData({ this.setData({
progressNumber: 100, progressNumber: 100
}) })
const that = this; const that = this
function isIOS() { function isIOS() {
let system = wx.getSystemInfoSync().system let system = wx.getSystemInfoSync().system
return system.indexOf('iOS') !== -1 return system.indexOf('iOS') !== -1
...@@ -782,46 +817,49 @@ Page({ ...@@ -782,46 +817,49 @@ Page({
// console.log('this.data.result_zoom', this.data.result_zoom) // console.log('this.data.result_zoom', this.data.result_zoom)
that.ctx.setZoom({ that.ctx.setZoom({
zoom: this.data.result_zoom, zoom: this.data.result_zoom,
success: res => { success: (res) => {
// console.log('setZoom成功', res); // console.log('setZoom成功', res);
const takephoto2_state = res.errMsg; const takephoto2_state = res.errMsg
this.setData({ this.setData({
takephoto2_state, takephoto2_state
}); })
// console.log('takephoto2_state', takephoto2_state); // console.log('takephoto2_state', takephoto2_state);
setTimeout(() => { setTimeout(() => {
that.ctx.takePhoto({ that.ctx.takePhoto({
quality: 'high', quality: 'high',
flash: 'on', flash: 'on',
success: res => { success: (res) => {
// console.log('到相机里面'); // console.log('到相机里面');
// console.log('res.data', res); // console.log('res.data', res);
// console.log('res.tempfile', res.tempImagePath); // console.log('res.tempfile', res.tempImagePath);
/*储存 */ /*储存 */
wx.setStorage({ wx.setStorage({
key: 'originalImagePath', key: 'originalImagePath',
data: res.tempImagePath, data: res.tempImagePath
}); })
this.setData({ this.setData({
bigfileimage: res.tempImagePath, bigfileimage: res.tempImagePath
}); })
wx.navigateTo({ wx.navigateTo({
url: '../upload/upload?path=' + that.data.bigfileimage + '&char=0' url:
}); '../upload/upload?path=' +
that.data.bigfileimage +
'&char=0'
})
}, },
fail: err => { fail: (err) => {
console.error('拍照失败', err); console.error('拍照失败', err)
that.takePhoto2() that.takePhoto2()
// console.log('拍照完成') // console.log('拍照完成')
} }
}); })
}) })
}, },
fail: err => { fail: (err) => {
console.error('设置缩放失败', err); console.error('设置缩放失败', err)
} }
}); })
} else { } else {
// console.log('当前设备是安卓') // console.log('当前设备是安卓')
// console.log('this.data.result_zoom', this.data.result_zoom) // console.log('this.data.result_zoom', this.data.result_zoom)
...@@ -831,36 +869,51 @@ Page({ ...@@ -831,36 +869,51 @@ Page({
}) })
} }
// const one_zoom = Math.floor(this.data.result_zoom * 0.85) // const one_zoom = Math.floor(this.data.result_zoom * 0.85)
const one_zoom = parseFloat((this.data.result_zoom * 0.82).toFixed(1)); const one_zoom = parseFloat((this.data.result_zoom * 0.82).toFixed(1))
// console.log('one_zoom', one_zoom) // console.log('one_zoom', one_zoom)
const benchmarkLevel = (wx.getStorageSync('benchmarkLevel') || 0) const benchmarkLevel = wx.getStorageSync('benchmarkLevel') || 0
const phone_model = (wx.getStorageSync('phone_model') || '') const phone_model = wx.getStorageSync('phone_model') || ''
// wx.removeStorageSync(String(benchmarkLevel)); // wx.removeStorageSync(String(benchmarkLevel));
// console.log('benchmarkLevel', benchmarkLevel) // console.log('benchmarkLevel', benchmarkLevel)
// console.log('phone_model', phone_model) // console.log('phone_model', phone_model)
let timeS; let timeS
// if(){ // if(){
// } // }
// console.log('手机型号',phone_model) // console.log('手机型号',phone_model)
let phone_list = ['NOH-AN00', 'NOH-AN01', 'OCE-AN10', 'JAD-AL00', 'LNA-AL00', 'NOP-AN00', 'NOH-AL10', 'ABR-AL80', 'MNA-AL00', 'JAD-AL50', 'ABR-AL00', 'ABR-AL90', 'ABR-AL60', 'ABR-AL60', 'NOH-AN50'] let phone_list = [
'NOH-AN00',
'NOH-AN01',
'OCE-AN10',
'JAD-AL00',
'LNA-AL00',
'NOP-AN00',
'NOH-AL10',
'ABR-AL80',
'MNA-AL00',
'JAD-AL50',
'ABR-AL00',
'ABR-AL90',
'ABR-AL60',
'ABR-AL60',
'NOH-AN50'
]
if (phone_list.includes(phone_model)) { if (phone_list.includes(phone_model)) {
// console.log('特殊手机型号') // console.log('特殊手机型号')
timeS = 850 timeS = 850
} else if (benchmarkLevel > 40) { } else if (benchmarkLevel > 40) {
timeS = 350; timeS = 350
} else if (benchmarkLevel > 30) { } else if (benchmarkLevel > 30) {
timeS = 380; timeS = 380
} else if (benchmarkLevel > 20) { } else if (benchmarkLevel > 20) {
timeS = 410 timeS = 410
} else if (benchmarkLevel > 10) { } else if (benchmarkLevel > 10) {
timeS = 450; timeS = 450
} else { } else {
timeS = 450; timeS = 450
} }
this.takePhotoZoom(one_zoom, timeS) this.takePhotoZoom(one_zoom, timeS)
} }
}, },
takePhotoZoom: function (one_zoom, timeS) { takePhotoZoom: function (one_zoom, timeS) {
console.log('one_zoom', one_zoom) console.log('one_zoom', one_zoom)
...@@ -879,36 +932,35 @@ Page({ ...@@ -879,36 +932,35 @@ Page({
/*储存 */ /*储存 */
wx.setStorage({ wx.setStorage({
key: 'originalImagePath', key: 'originalImagePath',
data: res.tempImagePath, data: res.tempImagePath
}) })
wx.setStorage({ wx.setStorage({
key: 'one_zoom', key: 'one_zoom',
data: one_zoom data: one_zoom
}); })
this.setData({ this.setData({
bigfileimage: res.tempImagePath, bigfileimage: res.tempImagePath,
result_zoom: this.data.result_zoom result_zoom: this.data.result_zoom
}) })
wx.navigateTo({ wx.navigateTo({
url: '../upload/upload?path=' + that.data.bigfileimage + '&char=0' url:
'../upload/upload?path=' + that.data.bigfileimage + '&char=0'
}) })
}, },
fail: (err) => { fail: (err) => {
console.error('拍照失败2', err); console.error('拍照失败2', err)
that.takePhoto2() that.takePhoto2()
} }
}) })
}, timeS); }, timeS)
}, },
fail: err => { fail: (err) => {
console.error('设置缩放失败', err); console.error('设置缩放失败', err)
} }
}) })
}, },
// getUserInfo: function () { // getUserInfo: function () {
// wx.getUserInfo({ // wx.getUserInfo({
// desc: '获取用户信息', // desc: '获取用户信息',
...@@ -930,110 +982,129 @@ Page({ ...@@ -930,110 +982,129 @@ Page({
console.log('播放结束') console.log('播放结束')
}) })
}, },
Countone_Time: function () {
//注释长时间不拍照,换种方式提示 console.log('1')
// Countone_Time: function () { var inter = setInterval(
// console.log('1') function () {
// var inter = setInterval(function () { this.setData({
// this.setData({ smsFlag: true,
// smsFlag: true, snsMsgWait_one: this.data.snsMsgWait_one - 1
// snsMsgWait_one: this.data.snsMsgWait_one - 1 })
// }); // console.log('this.data.snsMsgWait_one', this.data.snsMsgWait_one)
// // console.log('this.data.snsMsgWait_one', this.data.snsMsgWait_one) if (this.data.snsMsgWait_one == 0) {
// if (this.data.snsMsgWait_one == 0) { this.setData({
// this.setData({ longTimeOnce: true
// longTimeOnce: true })
// }) clearInterval(inter)
// clearInterval(inter) // console.log('this.data.all_state', this.data.all_state)
// // console.log('this.data.all_state', this.data.all_state) // console.log('this.data.singe_state', this.data.singe_state)
// // console.log('this.data.singe_state', this.data.singe_state) // console.log('longTimeOnce',this.data.longTimeOnce)
// // console.log('longTimeOnce',this.data.longTimeOnce) if (
// if (this.data.singe_state === true && this.data.all_state === false && this.data.longTimeOnce === true) { this.data.singe_state === true &&
// console.log('倒计时0拍照one') this.data.all_state === false &&
// setTimeout(() => { this.data.longTimeOnce === true
// this.takePhoto2(); ) {
// this.setData({ console.log('倒计时0拍照one')
// all_state: true setTimeout(() => {
// }) this.takePhoto2()
// // console.log('all_state', this.data.all_state) this.setData({
// }, 350); all_state: true
// } })
// } // console.log('all_state', this.data.all_state)
// }.bind(this), 1200); }, 350)
// }, }
// Counttwo_Time: function () { }
// console.log('2') }.bind(this),
// var inter = setInterval(function () { 1200
// this.setData({ )
// smsFlag: true, },
// snsMsgWait_twotime: this.data.snsMsgWait_twotime - 1 Counttwo_Time: function () {
// }); console.log('2')
// // console.log('this.data.snsMsgWait_twotime', this.data.snsMsgWait_twotime) var inter = setInterval(
// if (this.data.snsMsgWait_twotime == 0) { function () {
// clearInterval(inter) this.setData({
// // console.log('this.data.all_state', this.data.all_state) smsFlag: true,
// // console.log('this.data.singe_state', this.data.singe_state) snsMsgWait_twotime: this.data.snsMsgWait_twotime - 1
// this.setData({ })
// longTimeTwo: true // console.log('this.data.snsMsgWait_twotime', this.data.snsMsgWait_twotime)
// }) if (this.data.snsMsgWait_twotime == 0) {
// // console.log('this.data.singe_state',this.data.singe_state) clearInterval(inter)
// // console.log('this.data.all_state',this.data.all_state) // console.log('this.data.all_state', this.data.all_state)
// // console.log('this.data.longtimeTwo',this.data.longTimeTwo) // console.log('this.data.singe_state', this.data.singe_state)
// if (this.data.singe_state == true && this.data.all_state == false && this.data.longTimeTwo === true) { this.setData({
// console.log('倒计时0拍照two') longTimeTwo: true
// setTimeout(() => { })
// // console.log('this.data.take_state', this.data.take_state) // console.log('this.data.singe_state',this.data.singe_state)
// if (this.data.take_state == true) { // console.log('this.data.all_state',this.data.all_state)
// // console.log('不进行拍照') // console.log('this.data.longtimeTwo',this.data.longTimeTwo)
// } else { if (
// this.takePhoto2(); this.data.singe_state == true &&
// this.setData({ this.data.all_state == false &&
// all_state: true this.data.longTimeTwo === true
// }) ) {
// } console.log('倒计时0拍照two')
// // console.log('倒计时0拍照twoall_state', this.data.all_state) setTimeout(() => {
// }, 350); // console.log('this.data.take_state', this.data.take_state)
// } if (this.data.take_state == true) {
// } // console.log('不进行拍照')
// }.bind(this), 1200); } else {
// }, this.takePhoto2()
// Countthree_Time: function () { this.setData({
// console.log('3') all_state: true
// var inter = setInterval(function () { })
// this.setData({ }
// smsFlag: true, // console.log('倒计时0拍照twoall_state', this.data.all_state)
// snsMsgWait_three: this.data.snsMsgWait_three - 1 }, 350)
// }); }
// // console.log('this.data.snsMsgWait_three', this.data.snsMsgWait_three) }
// if (this.data.snsMsgWait_three == 0) { }.bind(this),
// clearInterval(inter) 1200
// this.setData({ )
// longTimeThree: true },
// }) Countthree_Time: function () {
// // console.log('this.data.singe_state',this.data.singe_state) console.log('3')
// // console.log('this.data.all_state',this.data.all_state) var inter = setInterval(
// // console.log('this.data.longtimeThree',this.data.longTimeThree) function () {
// if (this.data.singe_state == true && this.data.all_state == false && this.data.longTimeThree === true) { this.setData({
// console.log('倒计时0拍照three') smsFlag: true,
// setTimeout(() => { snsMsgWait_three: this.data.snsMsgWait_three - 1
// // console.log('this.data.take_state', this.data.take_state) })
// if (this.data.take_state == true) { // console.log('this.data.snsMsgWait_three', this.data.snsMsgWait_three)
// console.log('不进行拍照') if (this.data.snsMsgWait_three == 0) {
// } else { clearInterval(inter)
// this.takePhoto2(); this.setData({
// this.setData({ longTimeThree: true
// all_state: true })
// }) // console.log('this.data.singe_state',this.data.singe_state)
// } // console.log('this.data.all_state',this.data.all_state)
// // console.log('all_state', this.data.all_state) // console.log('this.data.longtimeThree',this.data.longTimeThree)
// }, 350); if (
// } this.data.singe_state == true &&
// } this.data.all_state == false &&
// }.bind(this), 1200); this.data.longTimeThree === true
// }, ) {
console.log('倒计时0拍照three')
setTimeout(() => {
// console.log('this.data.take_state', this.data.take_state)
if (this.data.take_state == true) {
console.log('不进行拍照')
} else {
this.takePhoto2()
this.setData({
all_state: true
})
}
// console.log('all_state', this.data.all_state)
}, 350)
}
}
}.bind(this),
1200
)
},
handleOpenVideo() { handleOpenVideo() {
wx.navigateTo({ wx.navigateTo({
url: '/pages/video/video', url: '/pages/video/video'
}) })
}, }
}) })
\ No newline at end of file
...@@ -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%;" />
......
// 获取全局应用程序实例对象 // 获取全局应用程序实例对象
var util = require('../../utils/util') var util = require('../../utils/util')
var Count = 0; var Count = 0
var fail_Count = 0 var fail_Count = 0
// 创建页面实例对象 // 创建页面实例对象
Page({ Page({
// 页面的初始数据 // 页面的初始数据
data: { data: {
notice: '', notice: '',
tempFilePath: "", tempFilePath: '',
width: 0, width: 0,
height: 0, height: 0,
score: '', score: '',
...@@ -25,7 +25,7 @@ Page({ ...@@ -25,7 +25,7 @@ Page({
openid: '', openid: '',
aiState: 0, aiState: 0,
sameCodeState: 0, sameCodeState: 0,
Labeldiff:0, Labeldiff: 0,
filePath: '', filePath: '',
datajson: '', datajson: '',
labelCodejson: '', labelCodejson: '',
...@@ -88,7 +88,7 @@ Page({ ...@@ -88,7 +88,7 @@ Page({
zoom_number: '' zoom_number: ''
}, },
onLoad: function (options) { onLoad: function (options) {
this.onHide(); this.onHide()
const openid = wx.getStorageSync('openid') const openid = wx.getStorageSync('openid')
const extraData = JSON.parse(wx.getStorageSync('extraData')) const extraData = JSON.parse(wx.getStorageSync('extraData'))
const param = wx.getStorageSync('fenggu') const param = wx.getStorageSync('fenggu')
...@@ -112,14 +112,16 @@ Page({ ...@@ -112,14 +112,16 @@ Page({
}) })
} else { } else {
this.setData({ this.setData({
'userid': userid, userid: userid,
'cpid': cpid cpid: cpid
}) })
} }
if (labelInfo.os === 'davis') { if (labelInfo.os === 'davis') {
console.log('云平台') console.log('云平台')
wx.request({ wx.request({
url: 'https://davis.china315net.com/wx/ajax/consumer/info?consumer_id=' + userid, url:
'https://davis.china315net.com/wx/ajax/consumer/info?consumer_id=' +
userid,
method: 'GET', method: 'GET',
success: (res) => { success: (res) => {
if (res.data.e !== '') { if (res.data.e !== '') {
...@@ -145,7 +147,9 @@ Page({ ...@@ -145,7 +147,9 @@ Page({
} else { } else {
console.log('不走云平台') console.log('不走云平台')
wx.request({ wx.request({
url: 'https://tjfnew.china315net.com/api/MiniProgram/requestUserData.ashx?uid=' + userid, url:
'https://tjfnew.china315net.com/api/MiniProgram/requestUserData.ashx?uid=' +
userid,
method: 'POST', method: 'POST',
success: (res) => { success: (res) => {
if (res.statusCode !== 200) { if (res.statusCode !== 200) {
...@@ -184,8 +188,8 @@ Page({ ...@@ -184,8 +188,8 @@ Page({
county: '获取失败' county: '获取失败'
}) })
} else { } else {
var locationinfo = res.data; var locationinfo = res.data
var address = locationinfo.address; var address = locationinfo.address
// console.log('address', address); // console.log('address', address);
var province = locationinfo.province var province = locationinfo.province
// console.log('province', province) // console.log('province', province)
...@@ -248,12 +252,11 @@ Page({ ...@@ -248,12 +252,11 @@ Page({
// }) // })
// } // }
let SCREEN_WIDTH = 750 let SCREEN_WIDTH = 750
let RATE = wx.getSystemInfoSync().screenHeight / wx.getSystemInfoSync().screenWidth let RATE =
wx.getSystemInfoSync().screenHeight / wx.getSystemInfoSync().screenWidth
let { let { windowWidth = SCREEN_WIDTH, windowHeight = SCREEN_WIDTH * RATE } =
windowWidth = SCREEN_WIDTH, wx.getSystemInfoSync()
windowHeight = SCREEN_WIDTH * RATE
} = wx.getSystemInfoSync()
this.setData({ this.setData({
windowWidth, windowWidth,
windowHeight windowHeight
...@@ -271,7 +274,7 @@ Page({ ...@@ -271,7 +274,7 @@ Page({
wx.removeStorageSync('yuan_file') wx.removeStorageSync('yuan_file')
// console.log('yuan_file', yuan_file) // console.log('yuan_file', yuan_file)
const phone_model = (wx.getStorageSync('phone_model') || []) const phone_model = wx.getStorageSync('phone_model') || []
wx.removeStorageSync(phone_model) wx.removeStorageSync(phone_model)
// console.log('phone_model', phone_model) // console.log('phone_model', phone_model)
const latitude = wx.getStorageSync('latitude') || '获取失败' const latitude = wx.getStorageSync('latitude') || '获取失败'
...@@ -280,7 +283,7 @@ Page({ ...@@ -280,7 +283,7 @@ Page({
const longitude = wx.getStorageSync('longitude') || '获取失败' const longitude = wx.getStorageSync('longitude') || '获取失败'
wx.removeStorageSync('longitude') wx.removeStorageSync('longitude')
// console.log('longitude',longitude) // console.log('longitude',longitude)
var timesc = new Date().getTime(); var timesc = new Date().getTime()
let all_info = wx.getStorageSync('all_info') || '获取失败' let all_info = wx.getStorageSync('all_info') || '获取失败'
// console.log('all_info',all_info) // console.log('all_info',all_info)
let zoom_number = wx.getStorageSync('one_zoom') || '获取失败' let zoom_number = wx.getStorageSync('one_zoom') || '获取失败'
...@@ -319,12 +322,13 @@ Page({ ...@@ -319,12 +322,13 @@ Page({
}, },
uploadImg() { uploadImg() {
console.log('this.data.filePath', this.data.filePath) console.log('this.data.filePath', this.data.filePath)
const base = wx.getFileSystemManager().readFileSync(this.data.filePath, 'base64') const base = wx
.getFileSystemManager()
.readFileSync(this.data.filePath, 'base64')
//增加不需要进行码判断 //增加不需要进行码判断
// this.checkAiResult(base); // this.checkAiResult(base);
// console.log('base', base) // console.log('base', base)
//判断标签序号
if (this.data.labelCode) { if (this.data.labelCode) {
// console.log('开始检查标签相似') // console.log('开始检查标签相似')
this.checkIsSameCode(base, (state) => { this.checkIsSameCode(base, (state) => {
...@@ -332,14 +336,14 @@ Page({ ...@@ -332,14 +336,14 @@ Page({
sameCodeState: state sameCodeState: state
}) })
if (state === 1) { if (state === 1) {
this.checkAiResult(base); this.checkAiResult(base)
} else { } else {
this.setData({ this.setData({
isLoading: false, isLoading: false
}) })
} }
}) })
console.log("sameCodeState", this.data.sameCodeState) console.log('sameCodeState', this.data.sameCodeState)
} else { } else {
console.log('进入不需要检查标签相似') console.log('进入不需要检查标签相似')
this.setData({ this.setData({
...@@ -347,7 +351,7 @@ Page({ ...@@ -347,7 +351,7 @@ Page({
userimage: false, userimage: false,
userinfo_name: false userinfo_name: false
}) })
this.checkAiResult(base); this.checkAiResult(base)
} }
}, },
//检查标签是否相同 //检查标签是否相同
...@@ -355,27 +359,27 @@ Page({ ...@@ -355,27 +359,27 @@ Page({
// console.log('this.data.labelCode', this.data.labelCode) // console.log('this.data.labelCode', this.data.labelCode)
// console.log('this.data.labelCode.length', this.data.labelCode.length) // console.log('this.data.labelCode.length', this.data.labelCode.length)
const requestData = { const requestData = {
'base': base, base: base,
'labelCodejson': this.data.labelCode labelCodejson: this.data.labelCode
}; }
wx.request({ wx.request({
// url: 'https://tj5.cc:4433/api/upload/', // url: 'https://tj5.cc:4433/api/upload/',
// url: 'https://ai.china315net.com:35437/api/upload/', // url: 'https://ai.china315net.com:35437/api/upload/',
// url:'https://www.7856.work:4433/api/upload/', // url:'https://www.7856.work:4433/api/upload/',
url: 'https://ai.tj5.cc:35437/api/upload/', url: 'https://ai.tj5.cc:35437/api/upload/',
method: "POST", method: 'POST',
data: requestData, data: requestData,
success: (res) => { success: (res) => {
const res_data = res.data; const res_data = res.data
// console.log("res_data", res_data); // console.log("res_data", res_data);
const recognize_LabelCode = res_data.codeinfo; const recognize_LabelCode = res_data.codeinfo
// console.log('recognizeLabelCode放大解析内容', recognize_LabelCode) // console.log('recognizeLabelCode放大解析内容', recognize_LabelCode)
const recognize_labelimage = res_data.image_file; const recognize_labelimage = res_data.image_file
const succes_data = res_data.succes; const succes_data = res_data.succes
const img_method = res_data.img_method; const img_method = res_data.img_method
const img_reader = res_data.img_reader; const img_reader = res_data.img_reader
const points = res_data.points; const points = res_data.points
var image_file_myapi = res_data.image_file; var image_file_myapi = res_data.image_file
this.setData({ this.setData({
image_file_myapi, image_file_myapi,
img_reader, img_reader,
...@@ -383,189 +387,208 @@ Page({ ...@@ -383,189 +387,208 @@ Page({
points, points,
recognize_labelimage, recognize_labelimage,
recognize_LabelCode recognize_LabelCode
}); })
const labelCode = this.data.labelCode; const labelCode = this.data.labelCode
const labelCodejson = labelCode.substring(-12); const labelCodejson = labelCode.substring(-12)
let recognizeLabelCode = ''; let recognizeLabelCode = ''
let datajson = ''; let datajson = ''
if (res_data === '码解析失败' || succes_data === 'loser' || res.statusCode !== 200) { if (
res_data === '码解析失败' ||
succes_data === 'loser' ||
res.statusCode !== 200
) {
// console.log('网络请求值不等于200') // console.log('网络请求值不等于200')
recognizeLabelCode = '码解析失败' recognizeLabelCode = '码解析失败'
} else { } else {
recognizeLabelCode = recognize_LabelCode; recognizeLabelCode = recognize_LabelCode
} }
if (!this.data.datajson || this.data.value === 'false') { if (!this.data.datajson || this.data.value === 'false') {
datajson = '码解析失败'; datajson = '码解析失败'
} else { } else {
datajson = this.data.datajson; datajson = this.data.datajson
} }
this.setData({ this.setData({
recognizeLabelCode, recognizeLabelCode,
datajson, datajson,
labelCodejson, labelCodejson,
labelCodejson_len: labelCodejson.length labelCodejson_len: labelCodejson.length
}); })
console.log('this.data.recognizeLabelCode放大解析内容', this.data.recognizeLabelCode) console.log(
'this.data.recognizeLabelCode放大解析内容',
this.data.recognizeLabelCode
)
console.log('this.data.datajson1111原图解析内容', this.data.datajson) console.log('this.data.datajson1111原图解析内容', this.data.datajson)
console.log('labelcodejson111标签号', labelCodejson) console.log('labelcodejson111标签号', labelCodejson)
//判断放大解析与原图解析内容是否与标签号一致 //判断放大解析与原图解析内容是否与标签号一致
if (this.data.recognizeLabelCode === labelCodejson || this.data.datajson === labelCodejson) { if (
this.data.recognizeLabelCode === labelCodejson ||
this.data.datajson === labelCodejson
) {
console.log('一致') console.log('一致')
cb(1); cb(1)
} else if (this.data.recognizeLabelCode === '码解析失败' && this.data.datajson === '码解析失败') { } else if (
this.data.recognizeLabelCode === '码解析失败' &&
this.data.datajson === '码解析失败'
) {
console.log('解析失败') console.log('解析失败')
cb(2); cb(2)
// this.setData({ // this.setData({
// aiState: 3 // aiState: 3
// }) // })
const dtime1 = util.formatTime(new Date()); const dtime1 = util.formatTime(new Date())
wx.request({ wx.request({
url: 'https://ai.tj5.cc:35437/api/all/', url: 'https://ai.tj5.cc:35437/api/all/',
// url: 'https://ai.china315net.com:35437/api/all/', // url: 'https://ai.china315net.com:35437/api/all/',
// url: 'https://tj5.cc:4433/api/all/', // url: 'https://tj5.cc:4433/api/all/',
// url:'https://www.7856.work:4433/api/all/', // url:'https://www.7856.work:4433/api/all/',
method: "POST", method: 'POST',
data: { data: {
'result': '码解析失败', result: '码解析失败',
'score': '0', score: '0',
'imagefile': recognize_labelimage, imagefile: recognize_labelimage,
'classs': this.data.hint_phone, classs: this.data.hint_phone,
'usetime': '0', usetime: '0',
'datetime': dtime1, datetime: dtime1,
'openid': this.data.openid, openid: this.data.openid,
'userip': '', userip: '',
'userlat': this.data.latitude, userlat: this.data.latitude,
'userlon': this.data.longitude, userlon: this.data.longitude,
'recognizelabelcode': this.data.recognizeLabelCode, recognizelabelcode: this.data.recognizeLabelCode,
'artwork': this.data.datajson, artwork: this.data.datajson,
'labelcode': this.data.labelCode, labelcode: this.data.labelCode,
'scorelist': '', scorelist: '',
'img_method': '', img_method: '',
'img_reader': '', img_reader: '',
'points': '', points: '',
'userid': this.data.userid || '', userid: this.data.userid || '',
'userimage': this.data.userimage, userimage: this.data.userimage,
'userinfo_name': this.data.userinfo_name, userinfo_name: this.data.userinfo_name,
'yuan_file': this.data.yuan_file, yuan_file: this.data.yuan_file,
'phone_model': this.data.phone_model, phone_model: this.data.phone_model,
'cpid': this.data.cpid || '', cpid: this.data.cpid || '',
'address': this.data.address || '', address: this.data.address || '',
'province': this.data.province || '', province: this.data.province || '',
'city': this.data.city || '', city: this.data.city || '',
'county': this.data.county || '', county: this.data.county || '',
'all_info': this.data.all_info || '', all_info: this.data.all_info || '',
'zoom_number': this.data.zoom_number || '' zoom_number: this.data.zoom_number || ''
}, },
success: (res) => { success: (res) => {
console.log('all入库成功', res); console.log('all入库成功', res)
wx.reLaunch({
url: `/pages/result/result?aiState=${0}`
})
}, },
fail: (error) => { fail: (error) => {
console.log('入库失败', error); console.log('入库失败', error)
} }
}); })
} else { } else {
console.log('码不同') console.log('码不同')
const Labeldiff = 1 const Labeldiff = 1
cb(0); cb(0)
// console.log('码不同', this.data.sameCodeState) // console.log('码不同', this.data.sameCodeState)
const dtime2 = util.formatTime(new Date()); const dtime2 = util.formatTime(new Date())
wx.request({ wx.request({
url: 'https://ai.tj5.cc:35437/api/all/', url: 'https://ai.tj5.cc:35437/api/all/',
// url: 'https://tj5.cc:4433/api/all/', // url: 'https://tj5.cc:4433/api/all/',
// url:'https://www.7856.work:4433/api/all/', // url:'https://www.7856.work:4433/api/all/',
// url: 'https://ai.china315net.com:35437/api/all/', // url: 'https://ai.china315net.com:35437/api/all/',
method: "POST", method: 'POST',
data: { data: {
'result': '码不同', result: '码不同',
'score': '0', score: '0',
'imagefile': recognize_labelimage, imagefile: recognize_labelimage,
'classs': '', classs: '',
'usetime': '0', usetime: '0',
'datetime': dtime2, datetime: dtime2 || '',
'openid': this.data.openid, openid: this.data.openid,
'userip': '', userip: '',
'userlat': this.data.latitude, userlat: this.data.latitude,
'userlon': this.data.longitude, userlon: this.data.longitude,
'recognizelabelcode': this.data.recognizeLabelCode, recognizelabelcode: this.data.recognizeLabelCode,
'artwork': this.data.datajson, artwork: this.data.datajson,
'labelcode': this.data.labelCode, labelcode: this.data.labelCode,
'scorelist': '', scorelist: '',
'img_method': '', img_method: '',
'img_reader': '', img_reader: '',
'points': '', points: '',
'userid': this.data.userid || '', userid: this.data.userid || '',
'userimage': this.data.userimage || '', userimage: this.data.userimage || '',
'userinfo_name': this.data.userinfo_name || '', userinfo_name: this.data.userinfo_name || '',
'yuan_file': this.data.yuan_file || '', yuan_file: this.data.yuan_file || '',
'phone_model': this.data.phone_model || '', phone_model: this.data.phone_model || '',
'cpid': this.data.cpid || '', cpid: this.data.cpid || '',
'address': this.data.address || '', address: this.data.address || '',
'province': this.data.province || '', province: this.data.province || '',
'city': this.data.city || '', city: this.data.city || '',
'county': this.data.county || '', county: this.data.county || '',
'all_info': this.data.all_info || '', all_info: this.data.all_info || '',
'zoom_number': this.data.zoom_number || '' zoom_number: this.data.zoom_number || ''
}, },
success: (res) => { success: (res) => {
console.log('all入库成功', res); console.log('all入库成功', res)
wx.reLaunch({ wx.reLaunch({
url: `/pages/result/result?Labeldiff=${Labeldiff}` url: `/pages/result/result?Labeldiff=${Labeldiff}`
}) })
return return
}, },
fail: (error) => { fail: (error) => {
console.log('入库失败', error); console.log('入库失败', error)
} }
}); })
} }
}, },
fail: (error) => { fail: (error) => {
console.log('调用upload接口超时', error) console.log('调用upload接口超时', error)
cb(2); cb(2)
console.log('222222222222')
wx.request({ wx.request({
url: 'https://ai.tj5.cc:35437/api/all/', url: 'https://ai.tj5.cc:35437/api/all/',
// url: 'https://tj5.cc:4433/api/all/', // url: 'https://tj5.cc:4433/api/all/',
// url:'https://www.7856.work:4433/api/all/', // url:'https://www.7856.work:4433/api/all/',
method: "POST", method: 'POST',
data: { data: {
'result': '调用upload接口超时', result: '调用upload接口超时',
'score': '0', score: '0',
'imagefile': '', imagefile: '',
'classs': this.data.hint_phone, classs: this.data.hint_phone,
'usetime': '0', usetime: '0',
'datetime': dtime2, datetime:'',
'openid': this.data.openid, openid: this.data.openid,
'userip': '', userip: '',
'userlat': this.data.latitude, userlat: this.data.latitude,
'userlon': this.data.longitude, userlon: this.data.longitude,
'recognizelabelcode': '码解析失败', recognizelabelcode: '码解析失败',
'artwork': this.data.datajson, artwork: this.data.datajson,
'labelcode': this.data.labelCode, labelcode: this.data.labelCode,
'scorelist': '', scorelist: '',
'img_method': '', img_method: '',
'img_reader': '', img_reader: '',
'points': '', points: '',
'userid': this.data.userid || '', userid: this.data.userid || '',
'userimage': this.data.userimage, userimage: this.data.userimage,
'userinfo_name': this.data.userinfo_name, userinfo_name: this.data.userinfo_name,
'yuan_file': this.data.yuan_file, yuan_file: this.data.yuan_file,
'phone_model': this.data.phone_model, phone_model: this.data.phone_model,
'cpid': this.data.cpid || '', cpid: this.data.cpid || '',
'address': this.data.address || '', address: this.data.address || '',
'province': this.data.province || '', province: this.data.province || '',
'city': this.data.city || '', city: this.data.city || '',
'county': this.data.county || '', county: this.data.county || '',
'all_info': this.data.all_info || '', all_info: this.data.all_info || '',
'zoom_number': this.data.zoom_number || '' zoom_number: this.data.zoom_number || ''
}, },
success: (res) => { success: (res) => {
console.log('success,调用upload接口超时', res) console.log('success,调用upload接口超时', res)
wx.reLaunch({
url: `/pages/result/result?aiState=${0}`
})
}, },
fail: (error) => { fail: (error) => {
console.log('fail,调用upload接口超时', error); console.log('fail,调用upload接口超时', error)
} }
}); })
//判断手机型号 开始注释 //判断手机型号 开始注释
// let timeoutIndex = -1; // let timeoutIndex = -1;
// if (wx.getSystemInfoSync().platform === 'ios') { // if (wx.getSystemInfoSync().platform === 'ios') {
...@@ -729,7 +752,7 @@ Page({ ...@@ -729,7 +752,7 @@ Page({
// } // }
//一直注释到这里 //一直注释到这里
}, },
timeout: 3000 timeout: 7000
}) })
}, },
//检查ai识别结果 //检查ai识别结果
...@@ -746,45 +769,45 @@ Page({ ...@@ -746,45 +769,45 @@ Page({
// url:'https://www.7856.work:4433/api/classify16/', // url:'https://www.7856.work:4433/api/classify16/',
method: 'POST', method: 'POST',
data: { data: {
'image_type': 50, image_type: 50,
'base': base, base: base
}, },
success: (res) => { success: (res) => {
console.log('base',base)
console.log('打印分类接口返回数据res.data', res.data) console.log('打印分类接口返回数据res.data', res.data)
let imagefile = res.data.image_path let imagefile = res.data.image_path
const classScore = res.data.result const classScore = res.data.result
const max_score = Math.max.apply(null, res.data.confidence) const max_score = Math.max.apply(null, res.data.confidence)
const max_score_value = max_score.toFixed(3) const max_score_value = max_score.toFixed(3)
const Score_list = res.data.confidence const Score_list = res.data.confidence
console.log('Score_list', Score_list) // console.log('Score_list', Score_list)
for (var i = 0; i < Score_list.length; i++) { for (var i = 0; i < Score_list.length; i++) {
Score_list[i] = Score_list[i].toFixed(3); Score_list[i] = Score_list[i].toFixed(3)
} }
var floatList = []; // 存放转换后的浮点型数据 var floatList = [] // 存放转换后的浮点型数据
for (var i = 0; i < Score_list.length; i++) { for (var i = 0; i < Score_list.length; i++) {
var num = parseFloat(Score_list[i]); var num = parseFloat(Score_list[i])
if (!isNaN(num)) { // 如果转换结果不是NaN,则表示转换成功 if (!isNaN(num)) {
floatList.push(num); // 将转换结果添加到列表中 // 如果转换结果不是NaN,则表示转换成功
floatList.push(num) // 将转换结果添加到列表中
} }
} }
const phone_score = res.data.confidence[4] const phone_score = res.data.confidence[4]
function mysort(a) { function mysort(a) {
var n = a.length; var n = a.length
var newa = []; var newa = []
var temp; var temp
for (var i = 0; i < n; i++) { for (var i = 0; i < n; i++) {
for (var j = i; j < n; j++) { for (var j = i; j < n; j++) {
if (a[i] > a[j]) { if (a[i] > a[j]) {
temp = a[i]; temp = a[i]
a[i] = a[j]; a[i] = a[j]
a[j] = temp; a[j] = temp
} }
} }
newa.push(a[i]); newa.push(a[i])
} }
return newa; return newa
} }
const class_score_sor = mysort(Score_list) const class_score_sor = mysort(Score_list)
// console.log('class_score_sor', class_score_sor) // console.log('class_score_sor', class_score_sor)
...@@ -798,11 +821,11 @@ Page({ ...@@ -798,11 +821,11 @@ Page({
let succ = '' let succ = ''
// ai通过状态 // ai通过状态
let aiState = 0; let aiState = 0
this.setData({ this.setData({
isLoading: true, isLoading: true,
imagefile: imagefile, imagefile: imagefile,
phone_score: phone_score, phone_score: phone_score
}) })
// console.log('classScore_11111', classScore) // console.log('classScore_11111', classScore)
if (this.data.hint_phone == 14) { if (this.data.hint_phone == 14) {
...@@ -932,34 +955,35 @@ Page({ ...@@ -932,34 +955,35 @@ Page({
phone_score: phone_score, phone_score: phone_score,
succ: succ, succ: succ,
notice: notice, notice: notice,
aiState: aiState, aiState: aiState
}); })
wx.setStorage({ wx.setStorage({
key: 'notice', key: 'notice',
data: notice data: notice
}) })
console.log('notice结果展示',notice) console.log('notice结果展示', notice)
if (notice != '手机边框') { if (notice != '手机边框') {
if (aiState !== 1) { if (aiState !== 1) {
Count++; Count++
} else { } else {
Count = 0; Count = 0
} }
if (Count >= 3) { if (Count >= 3) {
// console.log('Count', Count) // console.log('Count', Count)
console.log('三次未通过调用人工') console.log('三次未通过调用人工')
var people_time = util.formatTime(new Date) var people_time = util.formatTime(new Date())
var timessc = new Date().getTime(); var timessc = new Date().getTime()
this.setData({ this.setData({
isLoading: true, isLoading: true,
people_time people_time
}) })
Count = 0; Count = 0
console.log('三次请拍摄结构三维码调用人工') console.log('三次请拍摄结构三维码调用人工')
wx.request({ wx.request({
header: { header: {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' 'Content-Type':
'application/x-www-form-urlencoded;charset=utf-8'
}, },
// url: 'https://tj5.cc:4433/bg/swmrecognizeproject/apis/miniprogram/uploadimg.ashx', // url: 'https://tj5.cc:4433/bg/swmrecognizeproject/apis/miniprogram/uploadimg.ashx',
url: 'https://www.7856.work:4433/bg/swmrecognizeproject/apis/miniprogram/uploadimg.ashx', url: 'https://www.7856.work:4433/bg/swmrecognizeproject/apis/miniprogram/uploadimg.ashx',
...@@ -984,21 +1008,24 @@ Page({ ...@@ -984,21 +1008,24 @@ Page({
}) })
// console.log('this.data.sameCodeState', this.data.sameCodeState) // console.log('this.data.sameCodeState', this.data.sameCodeState)
} else { } else {
var inter = setInterval(function () { var inter = setInterval(
this.setData({ function () {
smsFlag: true,
sendTime: this.data.people_wait,
people_wait: this.data.people_wait - 1
});
// console.log('this.data.people_wait', this.data.people_wait)
if (this.data.people_wait < 0) {
this.setData({ this.setData({
zidong_fuzhi: true smsFlag: true,
}); sendTime: this.data.people_wait,
// console.log('this.data.zidong_fuzhi', this.data.zidong_fuzhi) people_wait: this.data.people_wait - 1
clearInterval(inter) })
} // console.log('this.data.people_wait', this.data.people_wait)
}.bind(this), 1000); if (this.data.people_wait < 0) {
this.setData({
zidong_fuzhi: true
})
// console.log('this.data.zidong_fuzhi', this.data.zidong_fuzhi)
clearInterval(inter)
}
}.bind(this),
1000
)
// let people_statu = res.data.success // let people_statu = res.data.success
let people_id = res.data.id let people_id = res.data.id
let people_image = res.data.image let people_image = res.data.image
...@@ -1029,12 +1056,12 @@ Page({ ...@@ -1029,12 +1056,12 @@ Page({
peo_state: peo_state, peo_state: peo_state,
true_state: true, true_state: true,
isLoading: false, isLoading: false,
aiState: 1, aiState: 1
}) })
// console.log('this.data.peo_state', this.data.peo_state) // console.log('this.data.peo_state', this.data.peo_state)
// console.log('this.data.aiState', this.data.aiState) // console.log('this.data.aiState', this.data.aiState)
clearInterval(this.data.setInter) clearInterval(this.data.setInter)
var timeec = new Date().getTime(); var timeec = new Date().getTime()
var people_replytime = timeec - timessc var people_replytime = timeec - timessc
// console.log('本次认证时间people_replytime', people_replytime / 1000) // console.log('本次认证时间people_replytime', people_replytime / 1000)
this.setData({ this.setData({
...@@ -1042,7 +1069,10 @@ Page({ ...@@ -1042,7 +1069,10 @@ Page({
}) })
// console.log('people_replytime', people_replytime) // console.log('people_replytime', people_replytime)
} }
if (peo_state !== 0 && peo_state !== 1 || this.data.zidong_fuzhi) { if (
(peo_state !== 0 && peo_state !== 1) ||
this.data.zidong_fuzhi
) {
console.log('人工回复不是真品') console.log('人工回复不是真品')
this.setData({ this.setData({
peo_state: peo_state, peo_state: peo_state,
...@@ -1054,7 +1084,7 @@ Page({ ...@@ -1054,7 +1084,7 @@ Page({
// console.log('this.data.fail_state', this.data.fail_state) // console.log('this.data.fail_state', this.data.fail_state)
// console.log('this.data.sameCodeState', this.data.sameCodeState) // console.log('this.data.sameCodeState', this.data.sameCodeState)
clearInterval(this.data.setInter) clearInterval(this.data.setInter)
var timeec = new Date().getTime(); var timeec = new Date().getTime()
var people_replytime = timeec - timessc var people_replytime = timeec - timessc
this.setData({ this.setData({
people_replytime people_replytime
...@@ -1062,7 +1092,7 @@ Page({ ...@@ -1062,7 +1092,7 @@ Page({
// console.log('people_replytime', people_replytime) // console.log('people_replytime', people_replytime)
} else { } else {
console.log('没有进行回复') console.log('没有进行回复')
var timeec = new Date().getTime(); var timeec = new Date().getTime()
var people_replytime = timeec - timessc var people_replytime = timeec - timessc
this.setData({ this.setData({
people_replytime people_replytime
...@@ -1070,7 +1100,7 @@ Page({ ...@@ -1070,7 +1100,7 @@ Page({
// console.log('people_replytime', people_replytime) // console.log('people_replytime', people_replytime)
} }
} }
}, }
}) })
}, 2500) }, 2500)
} }
...@@ -1096,23 +1126,23 @@ Page({ ...@@ -1096,23 +1126,23 @@ Page({
Count Count
}) })
} }
var timeec = new Date().getTime(); var timeec = new Date().getTime()
var datemill = timeec - this.data.timesc var datemill = timeec - this.data.timesc
// console.log('本次认证时间', datemill / 1000) // console.log('本次认证时间', datemill / 1000)
var dtime = util.formatTime(new Date) var dtime = util.formatTime(new Date())
this.setData({ this.setData({
notice, notice,
datemill, datemill,
dtime, dtime,
succ, succ,
aiState, aiState
}) })
if (this.data.recognizeLabelCode === '码解析失败') { if (this.data.recognizeLabelCode === '码解析失败') {
console.log('判断条件成功,使用原图的') console.log('判断条件成功,使用原图的')
const img_method = this.data.img_method_chuan; const img_method = this.data.img_method_chuan
const img_reader = this.data.img_reader_chuan; const img_reader = this.data.img_reader_chuan
const points = this.data.points_chuan; const points = this.data.points_chuan
this.setData({ this.setData({
img_method, img_method,
img_reader, img_reader,
...@@ -1120,9 +1150,9 @@ Page({ ...@@ -1120,9 +1150,9 @@ Page({
}) })
} else { } else {
console.log('使用放大的') console.log('使用放大的')
const img_method = this.data.img_method; const img_method = this.data.img_method
const img_reader = this.data.img_reader; const img_reader = this.data.img_reader
const points = this.data.points; const points = this.data.points
this.setData({ this.setData({
img_reader, img_reader,
img_method, img_method,
...@@ -1130,9 +1160,16 @@ Page({ ...@@ -1130,9 +1160,16 @@ Page({
}) })
} }
let state = 0; let state = 0
if (notice === '结构三维码' || notice === '烫金三维码' || notice === '多层纸结构三维码' || notice === '高分子三维码' || notice === '铆钉三维码' || notice === '护照烫金三维码') { if (
state = 1; notice === '结构三维码' ||
notice === '烫金三维码' ||
notice === '多层纸结构三维码' ||
notice === '高分子三维码' ||
notice === '铆钉三维码' ||
notice === '护照烫金三维码'
) {
state = 1
this.setData({ this.setData({
sameCodeState: 3 sameCodeState: 3
}) })
...@@ -1146,67 +1183,70 @@ Page({ ...@@ -1146,67 +1183,70 @@ Page({
// console.log('this.data.sameCodeState', this.data.sameCodeState) // console.log('this.data.sameCodeState', this.data.sameCodeState)
if (state == 1) { if (state == 1) {
console.log('倒计时') console.log('倒计时')
var inter = setInterval(function () { var inter = setInterval(
this.setData({ function () {
smsFlag: true,
sendTime: this.data.snsMsgWait_1,
snsMsgWait_1: this.data.snsMsgWait_1 - 1
});
// console.log('this.data.snsMsgWait_1', this.data.snsMsgWait_1)
if (this.data.snsMsgWait_1 === -1) {
this.popup()
}
if (this.data.snsMsgWait_1 < 0) {
clearInterval(inter)
this.setData({ this.setData({
snsMsgWait_1: 2, smsFlag: true,
smsFlag: false sendTime: this.data.snsMsgWait_1,
}); snsMsgWait_1: this.data.snsMsgWait_1 - 1
} })
}.bind(this), 1000); // console.log('this.data.snsMsgWait_1', this.data.snsMsgWait_1)
if (this.data.snsMsgWait_1 === -1) {
this.popup()
}
if (this.data.snsMsgWait_1 < 0) {
clearInterval(inter)
this.setData({
snsMsgWait_1: 2,
smsFlag: false
})
}
}.bind(this),
1000
)
} }
this.callBackAIStatus(state) this.callBackAIStatus(state)
const postdata = { const postdata = {
'result': notice, result: notice,
'score': max_score_value, score: max_score_value,
'imagefile': this.data.image_file_myapi || imagefile, imagefile: this.data.image_file_myapi || imagefile,
'classs': classScore, classs: classScore,
'usetime': datemill / 1000, usetime: datemill / 1000,
'datetime': dtime, datetime: dtime,
'openid': this.data.openid, openid: this.data.openid,
'userip': '', userip: '',
'userlat': this.data.latitude, userlat: this.data.latitude,
'userlon': this.data.longitude, userlon: this.data.longitude,
'recognizelabelcode': this.data.recognizeLabelCode, recognizelabelcode: this.data.recognizeLabelCode,
'artwork': this.data.datajson, artwork: this.data.datajson,
'labelcode': this.data.labelCode || '', labelcode: this.data.labelCode || '',
'scorelist': floatList, scorelist: floatList,
'img_method': this.data.img_method, img_method: this.data.img_method,
'img_reader': this.data.img_reader, img_reader: this.data.img_reader,
'points': this.data.points, points: this.data.points,
'userid': this.data.userid || '', userid: this.data.userid || '',
'userimage': this.data.userimage, userimage: this.data.userimage,
'userinfo_name': this.data.userinfo_name, userinfo_name: this.data.userinfo_name,
'yuan_file': this.data.yuan_file, yuan_file: this.data.yuan_file,
'phone_model': this.data.phone_model, phone_model: this.data.phone_model,
'cpid': this.data.cpid || '', cpid: this.data.cpid || '',
'address': this.data.address || '', address: this.data.address || '',
'province': this.data.province || '', province: this.data.province || '',
'city': this.data.city || '', city: this.data.city || '',
'county': this.data.county || '', county: this.data.county || '',
'all_info': this.data.all_info || '', all_info: this.data.all_info || '',
'zoom_number': this.data.zoom_number || '' zoom_number: this.data.zoom_number || ''
} }
console.log('this.data.image_file_myapi', ) console.log('this.data.image_file_myapi')
console.log('aistate',aiState) console.log('aistate', aiState)
wx.request({ wx.request({
// url: 'https://ai.china315net.com:35437/api/all/', // url: 'https://ai.china315net.com:35437/api/all/',
url: 'https://ai.tj5.cc:35437/api/all/', url: 'https://ai.tj5.cc:35437/api/all/',
// url: 'https://tj5.cc:4433/api/all/', // url: 'https://tj5.cc:4433/api/all/',
// url:'https://www.7856.work:4433/api/all/', // url:'https://www.7856.work:4433/api/all/',
method: "POST", method: 'POST',
data: { data: {
...postdata ...postdata
}, },
...@@ -1218,7 +1258,7 @@ Page({ ...@@ -1218,7 +1258,7 @@ Page({
complete: () => {} complete: () => {}
}) })
wx.removeStorage({ wx.removeStorage({
'artwork': this.data.datajson, artwork: this.data.datajson,
succes(res) { succes(res) {
console.log('resresres', res) console.log('resresres', res)
} }
...@@ -1228,10 +1268,12 @@ Page({ ...@@ -1228,10 +1268,12 @@ Page({
} catch (e) { } catch (e) {
console.log('eee', e) console.log('eee', e)
} }
// 跳转到结果页面 // 跳转到结果页面
wx.reLaunch({ wx.reLaunch({
url: `/pages/result/result?time1=${util.formatTime(new Date()) || this.data.people_time}&time2=${new Date().getTime()}&aiState=${aiState}&Labeldiff=${this.dataLabeldiff}` url: `/pages/result/result?time1=${
util.formatTime(new Date()) || this.data.people_time
}&time2=${new Date().getTime()}&aiState=${aiState}`
}) })
return return
}, },
...@@ -1242,7 +1284,7 @@ Page({ ...@@ -1242,7 +1284,7 @@ Page({
}, },
back() { back() {
wx.reLaunch({ wx.reLaunch({
url: '/pages/index/index', url: '/pages/index/index'
}) })
}, },
// old() { // old() {
...@@ -1397,22 +1439,22 @@ Page({ ...@@ -1397,22 +1439,22 @@ Page({
// }, // },
// 回调AI结果 // 回调AI结果
callBackAIStatus(state) { callBackAIStatus(state) {
const labelInfo = this.data.labelInfo; const labelInfo = this.data.labelInfo
console.log('labelInfo', labelInfo) console.log('labelInfo', labelInfo)
if (!labelInfo) { if (!labelInfo) {
return; return
} }
labelInfo.state = state labelInfo.state = state
//调用云平台接口 //调用云平台接口
if (labelInfo.os === 'davis') { if (labelInfo.os === 'davis') {
wx.request({ wx.request({
url: 'https://davis.china315net.com/wx/ajax/get_ai_status/', url: 'https://davis.china315net.com/wx/ajax/get_ai_status/',
method: 'GET', method: 'GET',
data: { data: {
"label_code": labelInfo.cpid, label_code: labelInfo.cpid,
"consumer_id": labelInfo.uid, consumer_id: labelInfo.uid,
"uuid": labelInfo.uuid, uuid: labelInfo.uuid,
"state": labelInfo.state, state: labelInfo.state
}, },
success: (res) => { success: (res) => {
console.log('回调成功davis') console.log('回调成功davis')
...@@ -1434,7 +1476,6 @@ Page({ ...@@ -1434,7 +1476,6 @@ Page({
} }
}, },
//点击按钮显示 //点击按钮显示
popup: function (e) { popup: function (e) {
this.setData({ this.setData({
...@@ -1442,24 +1483,27 @@ Page({ ...@@ -1442,24 +1483,27 @@ Page({
}) })
// console.log('popup_showModal', this.data.showModal); // console.log('popup_showModal', this.data.showModal);
//实现倒计时 //实现倒计时
var inter = setInterval(function () { var inter = setInterval(
this.setData({ function () {
smsFlag: true,
sendTime: this.data.snsMsgWait,
snsMsgWait: this.data.snsMsgWait - 1
});
// console.log('this.data.snsMsgWait', this.data.snsMsgWait)
if (this.data.snsMsgWait === -1) {
this.hidepopup()
}
if (this.data.snsMsgWait < 0) {
clearInterval(inter)
this.setData({ this.setData({
snsMsgWait: 3, smsFlag: true,
smsFlag: false sendTime: this.data.snsMsgWait,
}); snsMsgWait: this.data.snsMsgWait - 1
} })
}.bind(this), 1000); // console.log('this.data.snsMsgWait', this.data.snsMsgWait)
if (this.data.snsMsgWait === -1) {
this.hidepopup()
}
if (this.data.snsMsgWait < 0) {
clearInterval(inter)
this.setData({
snsMsgWait: 3,
smsFlag: false
})
}
}.bind(this),
1000
)
}, },
//点击隐藏图标 //点击隐藏图标
hidepopup: function () { hidepopup: function () {
...@@ -1480,8 +1524,8 @@ Page({ ...@@ -1480,8 +1524,8 @@ Page({
//修改 清除缓存 //修改 清除缓存
}, },
onHide: function () { onHide: function () {
const innerAudioContext = wx.createInnerAudioContext(); const innerAudioContext = wx.createInnerAudioContext()
innerAudioContext.stop(); innerAudioContext.stop()
innerAudioContext.destroy(); innerAudioContext.destroy()
}, }
}) })
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论