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

最新代码

上级 313080e6
......@@ -7,7 +7,7 @@ App({
extraData: null
},
// 根据不同产品展示不同的页面背景
page_bg:'',
page_bg: '',
onLaunch() {
// 展示本地存储能力
const logs = wx.getStorageSync('logs') || []
......@@ -58,6 +58,8 @@ App({
}
// console.log('到这里extraData',extraData)
wx.setStorageSync('extraData', strData)
wx.setStorageSync('labeljson', JSON.parse(strData)?.cpid_jm || JSON.parse(strData)?.cpid || '')
// wx.setStorageSync('fenggu', JSON.parse(strData)?.company || '')
// 启动摄像头预览
......
......@@ -11,6 +11,7 @@ Page({
* 页面的初始数据
*/
data: {
src:'https://res.wx.qq.com/wxdoc/dist/assets/img/0.4cb08bb4.jpg',
height: 0,
width: 0,
showPage: '' // '' 为拍照 ,'error'为不通过,'success' 为通过
......@@ -34,15 +35,20 @@ Page({
let flag = true
const that = this
const listener = this.cameraContext.onCameraFrame(async (frame) => {
console.log(frame.width,frame.height);
if (flag) {
flag = false
// 文件系统
const fileSystem = wx.getFileSystemManager()
that.setData({
height: frame.height,
width: frame.width
})
// 实时帧渲染到canvas
await wx.canvasPutImageData({
canvasId: 'myCanvas',
x:0,
y:-frame.height/5,
x:-frame.width / 4,
y:-frame.height / 3,
width: frame.width,
height: frame.height,
data: new Uint8ClampedArray(frame.data),
......@@ -66,22 +72,28 @@ Page({
// console.log('qe_result',qr_result)
// console.log('qr_result.data.codeinfo',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)
// 放大图(四倍)
// await new Promise((resovle) => {
// setTimeout(() => {
// resovle()
// },300)
// })
console.log('5555');
const photo2 = await that.handleTakePoto(that.cameraContext, 4,{flash:'on'})
console.log(photo2.tempImagePath,'photo1');
// this.setData({
// src:photo2.tempImagePath
// })
// 原图base64
const base64_1 = fileSystem.readFileSync(photo1.tempImagePath, 'base64')
// 放大四倍图 base64
const base64_2 = fileSystem.readFileSync(photo2.tempImagePath, 'base64')
// 请求接口
Promise.all([that.handleApiCheck(base64_1), that.handleApiCheck(base64_2)])
Promise.all([that.handleApiCheck(base64_1,'small'), that.handleApiCheck(base64_2,'big')])
.then(value => {
let pageType = 'error'
const result1 = value[0],
......@@ -131,22 +143,33 @@ Page({
await context.setZoom({
zoom
})
if (zoom == 4) {
await new Promise((resovle) => {
setTimeout(() => {
resovle()
},300)
})
}
return await context.takePhoto({
flash:param?.flash || 'off',
quality: param?.quality || 'high',
quality:'high',
selfieMirror: param?.selfieMirror || false,
// success(res) {
// console.log(res,zoom,222222);
// }
})
},
// 接口请求
handleApiCheck(base64) {
handleApiCheck(base64,type) {
return new Promise((resolve, reject) => {
wx.request({
url: 'https://www.7856.work:4433/api/Bym_classfily_post/',
method: 'POST',
data: {
device_id: '50',
base: base64
base: base64,
type
},
success(res) {
resolve(res)
......
<!--pages/beiyinmei/beiyinmei.wxml-->
<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">
<image src="/assets/imgs/拍照框.png" style="width: 25%;" mode="widthFix" />
<text>请把二维码放置拍照框内</text>
......@@ -24,5 +24,5 @@
</view>
<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>
// 获取全局应用程序实例对象
// const app = getApp();
var util = require('../../utils/util')
var Counter = 0;
var take_Count = 0;
var Counter = 0
var take_Count = 0
// 创建页面实例对象
Page({
// 页面的初始数据
......@@ -16,7 +16,7 @@ Page({
userInfo: {},
hasUserInfo: false,
mybase64: '',
temfilePath: "",
temfilePath: '',
tag: false,
datajson: '',
labelCode: '',
......@@ -59,59 +59,55 @@ Page({
longTimeThree: false,
longTimeTakephoto: false,
all_finish: false,
small_finish: false,
small_finish: false
// status_zhi:''
},
onLoad: function (options) {
const param = options.param;
const param = options.param
console.log('param1', param)
wx.setStorage({
key: 'param',
data: param
})
var that = this
this.Sounds();
this.Sounds()
const dongtaishuju_chuan = wx.getStorageSync('dongtaishuju')
//注释长时间不拍照
// switch (dongtaishuju_chuan) {
// case 1:
// this.Countone_Time();
// break;
// case 2:
// this.Counttwo_Time();
// break;
// case 3:
// this.Countthree_Time();
// break;
// default:
// console.log('不等于1,2,3次')
// this.setData({
// longtime_state: true
// })
// }
switch (dongtaishuju_chuan) {
case 1:
this.Countone_Time()
break
case 2:
this.Counttwo_Time()
break
case 3:
this.Countthree_Time()
break
default:
console.log('不等于1,2,3次')
this.setData({
longtime_state: true
})
}
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) {
const labelCode = labelInfo.cpid_jm || labelInfo.cpid
const labelCode = labelInfo
this.setData({
labelCode,
dongtaishuju_chuan,
param,
param
})
// console.log('labelCode', labelCode)
}
var that = this
const {
screenWidth,
screenHeight
} = wx.getSystemInfoSync()
const { screenWidth, screenHeight } = wx.getSystemInfoSync()
const windowWidth = 750
const windowHeight = screenHeight / screenWidth * windowWidth
const windowHeight = (screenHeight / screenWidth) * windowWidth
this.setData({
windowWidth,
windowHeight,
windowHeight
})
// console.log('wind', windowWidth, 'height', windowHeight)
this.ctx = wx.createCameraContext()
......@@ -124,11 +120,11 @@ Page({
}, 1000)
this.setData({
['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)
var clamped = new Uint8ClampedArray(data);
var clamped = new Uint8ClampedArray(data)
// console.log('clamped', clamped)
// 实时帧数据添加到Canvas上
// console.log('===========')
......@@ -140,55 +136,61 @@ Page({
height: frame.height, //512 381
data: clamped,
success: (res) => {
// var inter = setInterval(function () {
// that.setData({
// smsFlag: true,
// sendTime: that.data.snsMsgWait,
// snsMsgWait: that.data.snsMsgWait - 1
// });
// console.log('that.data.snsMsgWait', that.data.snsMsgWait)
// console.log('that.data.take_state', that.data.take_state)
// console.log('that.data.longtime_state', that.data.longtime_state)
// if (that.data.snsMsgWait === -6 && !that.data.take_state && that.data.longtime_state === true) {
// let fail_text = '长时间不拍照1'
// // console.log('fail_text', fail_text)
// that.setData({
// longTimeTakephoto: true
// })
// // console.log('that.data.takephoto',that.data.takephoto)
// if (fail_text !== '' && that.data.takephoto !== 'succes') {
// // console.log('进行第一次拍照')
// that.takePhoto()
// let take_photo_1 = '长时间不拍照2'
// let takephoto = 'succes'
// that.setData({
// take_photo_1,
// takephoto
// });
// }
// // console.log('that.data.takephoto',that.data.takephoto)
// if (fail_text !== '' && that.data.takephoto === 'succes' && that.data.all_state !== true) {
// setTimeout(() => {
// // console.log('进行第二次拍照')
// that.takePhoto2()
// }, 3500)
// let take_state = true
// that.setData({
// take_state,
// all_state: true
// });
// }
// }
// if (that.data.snsMsgWait < 0) {
// clearInterval(inter)
// that.setData({
// snsMsgWait: -5,
// snsFlag: false
// })
// }
// }, 1000);
var inter = setInterval(function () {
that.setData({
smsFlag: true,
sendTime: that.data.snsMsgWait,
snsMsgWait: that.data.snsMsgWait - 1
})
if (
that.data.snsMsgWait === -6 &&
!that.data.take_state &&
that.data.longtime_state === true
) {
let fail_text = '长时间不拍照1'
// console.log('fail_text', fail_text)
that.setData({
longTimeTakephoto: true
})
// console.log('that.data.takephoto',that.data.takephoto)
if (fail_text !== '' && that.data.takephoto !== 'succes') {
// console.log('进行第一次拍照')
that.takePhoto()
let take_photo_1 = '长时间不拍照2'
let takephoto = 'succes'
that.setData({
take_photo_1,
takephoto
})
}
// console.log('that.data.takephoto',that.data.takephoto)
if (
fail_text !== '' &&
that.data.takephoto === 'succes' &&
that.data.all_state !== true
) {
setTimeout(() => {
// console.log('进行第二次拍照')
that.takePhoto2()
}, 3500)
let take_state = true
that.setData({
take_state,
all_state: true
})
}
}
if (that.data.snsMsgWait < 0) {
clearInterval(inter)
that.setData({
snsMsgWait: -5,
snsFlag: false
})
}
}, 1000)
// 转换临时文件
wx.canvasToTempFilePath({
wx.canvasToTempFilePath(
{
canvasId: 'myCanvas',
x: 0,
y: (frame.height - frame.width) / 2,
......@@ -202,33 +204,36 @@ Page({
success: (res) => {
// console.log('成功成功成功')
//进行编码
const base = wx.getFileSystemManager().readFileSync(res.tempFilePath, 'base64')
const base = wx
.getFileSystemManager()
.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://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",
method: 'POST',
data: {
base
},
success: (res) => {
console.log('res.data', res.data)
var result = res.data.result;
var result = res.data.result
var coord = res.data.coord[0][5]
console.log('coord', coord)
var minindex = -1;
var mindistance = 2;
console.log('length', result.length)
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);
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;
mindistance = distance
minindex = i
}
}
var result_zy = result[minindex][0]
......@@ -241,66 +246,81 @@ Page({
let state = ''
let status = ''
let state_x = ''
if (result_zy > 0.588) { //0.568
if (result_zy > 0.588) {
//0.568
state = 'left'
} else if (result_zy < 0.405) { //0.425
} else if (result_zy < 0.405) {
//0.425
state = 'right'
} else if (result_sx > 0.577) { //0.547
} else if (result_sx > 0.577) {
//0.547
state = 'on'
} else if (result_sx < 0.401) { //0.411
} else if (result_sx < 0.401) {
//0.411
state = 'down'
} else {
let text = '大框参数已经完善'
var take_Count = 0;
var take_Count = 0
// console.log('大框参数已经完善', text)
let singe_state = true
take_Count++,
wx.removeStorageSync('singe_state')
take_Count++, wx.removeStorageSync('singe_state')
that.setData({
singe_state,
small_finish: true
})
status = 'true'
// console.log('that.data.takephoto', that.data.takephoto)
if (coord != 0) {
wx.showToast({
title: '当前位置模糊,请找合适的位置',
title: '当前位置模糊,请找合适的位置'
})
}
if (text == text && that.data.takephoto !== 'succes' && that.data.take_photo_1 === '' && coord === 0) {
// console.log('that.data.takephoto', that.data.takephoto)
if (
text == text &&
that.data.takephoto !== 'succes' &&
that.data.take_photo_1 === '' &&
coord === 0
) {
// console.log('大框参数完成进行拍照')
that.takePhoto();
that.takePhoto()
let takephoto = 'succes'
let d_takephoto = '大框拍照完成'
// console.log('d_takephoto', d_takephoto)
that.setData({
takephoto,
text,
d_takephoto,
d_takephoto
})
// 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) {
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
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
} else if (d_result_zy < 0.445) {
//0.445
state_x = 'right'
} else if (d_result_sx > 0.571) { //0.531
} else if (d_result_sx > 0.571) {
//0.531
state_x = 'on'
} else if (d_result_sx < 0.450) { //0.410
} 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
......@@ -324,9 +344,11 @@ Page({
})
},
fail: (error) => {
console.log('转换临时文件失败:', error);
console.log('转换临时文件失败:', error)
}
}, that)
},
that
)
},
fail: (error) => {
console.log('绘制图像数据失败', error)
......@@ -441,7 +463,7 @@ Page({
scope: 'scope.camera',
success: function (res) {
that.setData({
isShowCamera: true,
isShowCamera: true
})
// console.log('走权限1')
let res_errMsg = res.errMsg
......@@ -449,48 +471,53 @@ Page({
res_errMsg: res_errMsg
})
wx.removeStorageSync('res_errMsg')
//倒计时注释倒计时
// var inter = setInterval(function () {
// that.setData({
// smsFlag: true,
// sendTime: that.data.snsMsgWait_1,
// snsMsgWait_1: that.data.snsMsgWait_1 - 1
// });
// if (that.data.snsMsgWait_1 === -6 && res_errMsg != '') {
// // console.log('长时间未响应')
// setTimeout(() => {
// that.takePhoto2()
// }, 2500)
// that.setData({
// longtime_state: true
// })
// }
// if (that.data.snsMsgWait_1 < 0) {
// clearInterval(inter)
// that.setData({
// snsMsgWait_1: -5,
// snsFlag: false
// })
// // console.log('that.data.snsMsgWait_2', that.data.snsMsgWait_1)
// }
// }.bind(that), 1000);
// let camera_state = res.errMsg
// that.setData({
// camera_state
// })
//倒计时
var inter = setInterval(
function () {
that.setData({
smsFlag: true,
sendTime: that.data.snsMsgWait_1,
snsMsgWait_1: that.data.snsMsgWait_1 - 1
})
if (that.data.snsMsgWait_1 === -6 && res_errMsg != '') {
// console.log('长时间未响应')
setTimeout(() => {
that.takePhoto2()
}, 2500)
that.setData({
longtime_state: true
})
}
if (that.data.snsMsgWait_1 < 0) {
clearInterval(inter)
that.setData({
snsMsgWait_1: -5,
snsFlag: false
})
// console.log('that.data.snsMsgWait_2', that.data.snsMsgWait_1)
}
}.bind(that),
1000
)
let camera_state = res.errMsg
that.setData({
camera_state
})
},
fail: function (res) {
console.log("" + res);
console.log('' + res)
// console.log('走权限2')
wx.showModal({
title: '请求授权您的摄像头',
content: '如需正常使用此小程序功能,请您按确定并在设置页面授权用户信息',
content:
'如需正常使用此小程序功能,请您按确定并在设置页面授权用户信息',
confirmText: '确定',
success: function (res) {
if (res.confirm) {
wx.openSetting({
success: function (res) {
if (res.authSetting['scope.camera']) { //设置允许获取摄像头
if (res.authSetting['scope.camera']) {
//设置允许获取摄像头
// console.log('设置允许获取摄像头')
wx.showToast({
title: '授权成功',
......@@ -501,7 +528,8 @@ Page({
isShowCamera: true,
icon: icon
})
} else { //不允许
} else {
//不允许
wx.showToast({
title: '授权失败',
icon: 'none',
......@@ -513,7 +541,8 @@ Page({
}
}
})
} else { //取消
} else {
//取消
wx.showToast({
title: '授权失败',
icon: 'none',
......@@ -528,7 +557,7 @@ Page({
},
fail: function (res) {
console.log('获取相机失败', res)
onShow();
onShow()
}
})
},
......@@ -540,11 +569,11 @@ Page({
// 设置拍照进度条
this.setData({
progressNumber: 50,
progressNumber: 50
})
var that = this
Counter++;
Counter++
that.ctx.setZoom({
zoom: 1.0,
success: (res) => {
......@@ -556,10 +585,12 @@ Page({
/*储存 */
wx.setStorage({
key: 'res.tempImagePath',
data: res.tempImagePath,
data: 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)
this.setData({
kongfileimage: res.tempImagePath
......@@ -571,18 +602,19 @@ Page({
// url:'https://ai.china315net.com:35437/api/upload/',
// url: 'https://ai.tj5.cc:35437/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/',
method: 'POST',
data: {
base,
'labelCodejson': '123456789123'
labelCodejson: this.data.labelInfo
},
success: (res) => {
// console.log('base', base)
// console.log('res.statusCode ', res.statusCode)
// console.log('接口访问')
var dtime = util.formatTime(new Date)
var dtime = util.formatTime(new Date())
wx.setStorage({
key: 'dtime',
data: dtime
......@@ -592,7 +624,11 @@ Page({
// console.log('res_data', res_data)
var succes_data = res_data.succes
// 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('网络请求值不等于200 ')
const datajson = '码解析失败'
......@@ -620,7 +656,7 @@ Page({
key: 'points',
data: points
})
var datajson = res_data.codeinfo;
var datajson = res_data.codeinfo
console.log('原图解析内容datajson', datajson)
wx.setStorage({
key: 'datajson',
......@@ -657,10 +693,10 @@ Page({
wx.request({
url: 'https://ai.tj5.cc:35437/classify16/',
// url: 'https://tj5.cc:4433/classify16/',
method: "POST",
method: 'POST',
data: {
'image_type': 50,
'base': base,
image_type: 50,
base: base
},
success: (res) => {
let result_value = res.data.result
......@@ -693,18 +729,18 @@ Page({
// console.log('hint_phone', hint_phone)
}
},
fail: error => {
fail: (error) => {
console.log('调用upload失败', error)
}
});
var dtime_2 = util.formatTime(new Date)
})
var dtime_2 = util.formatTime(new Date())
wx.setStorage({
key: 'dtime_2',
data: dtime_2
})
}
})
}, 350);
}, 350)
}
})
let once_takephoto = 'true'
......@@ -763,10 +799,9 @@ Page({
// console.log('takePhoto2')
// 设置拍照进度条
this.setData({
progressNumber: 100,
progressNumber: 100
})
const that = this;
const that = this
function isIOS() {
let system = wx.getSystemInfoSync().system
return system.indexOf('iOS') !== -1
......@@ -782,46 +817,49 @@ Page({
// console.log('this.data.result_zoom', this.data.result_zoom)
that.ctx.setZoom({
zoom: this.data.result_zoom,
success: res => {
success: (res) => {
// console.log('setZoom成功', res);
const takephoto2_state = res.errMsg;
const takephoto2_state = res.errMsg
this.setData({
takephoto2_state,
});
takephoto2_state
})
// console.log('takephoto2_state', takephoto2_state);
setTimeout(() => {
that.ctx.takePhoto({
quality: 'high',
flash: 'on',
success: res => {
success: (res) => {
// console.log('到相机里面');
// console.log('res.data', res);
// console.log('res.tempfile', res.tempImagePath);
/*储存 */
wx.setStorage({
key: 'originalImagePath',
data: res.tempImagePath,
});
data: res.tempImagePath
})
this.setData({
bigfileimage: res.tempImagePath,
});
bigfileimage: res.tempImagePath
})
wx.navigateTo({
url: '../upload/upload?path=' + that.data.bigfileimage + '&char=0'
});
url:
'../upload/upload?path=' +
that.data.bigfileimage +
'&char=0'
})
},
fail: err => {
console.error('拍照失败', err);
fail: (err) => {
console.error('拍照失败', err)
that.takePhoto2()
// console.log('拍照完成')
}
});
})
})
},
fail: err => {
console.error('设置缩放失败', err);
fail: (err) => {
console.error('设置缩放失败', err)
}
});
})
} else {
// console.log('当前设备是安卓')
// console.log('this.data.result_zoom', this.data.result_zoom)
......@@ -831,36 +869,51 @@ Page({
})
}
// 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)
const benchmarkLevel = (wx.getStorageSync('benchmarkLevel') || 0)
const phone_model = (wx.getStorageSync('phone_model') || '')
const benchmarkLevel = wx.getStorageSync('benchmarkLevel') || 0
const phone_model = wx.getStorageSync('phone_model') || ''
// wx.removeStorageSync(String(benchmarkLevel));
// console.log('benchmarkLevel', benchmarkLevel)
// console.log('phone_model', phone_model)
let timeS;
let timeS
// if(){
// }
// 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)) {
// console.log('特殊手机型号')
timeS = 850
} else if (benchmarkLevel > 40) {
timeS = 350;
timeS = 350
} else if (benchmarkLevel > 30) {
timeS = 380;
timeS = 380
} else if (benchmarkLevel > 20) {
timeS = 410
} else if (benchmarkLevel > 10) {
timeS = 450;
timeS = 450
} else {
timeS = 450;
timeS = 450
}
this.takePhotoZoom(one_zoom, timeS)
}
},
takePhotoZoom: function (one_zoom, timeS) {
console.log('one_zoom', one_zoom)
......@@ -879,36 +932,35 @@ Page({
/*储存 */
wx.setStorage({
key: 'originalImagePath',
data: res.tempImagePath,
data: res.tempImagePath
})
wx.setStorage({
key: 'one_zoom',
data: one_zoom
});
})
this.setData({
bigfileimage: res.tempImagePath,
result_zoom: this.data.result_zoom
})
wx.navigateTo({
url: '../upload/upload?path=' + that.data.bigfileimage + '&char=0'
url:
'../upload/upload?path=' + that.data.bigfileimage + '&char=0'
})
},
fail: (err) => {
console.error('拍照失败2', err);
console.error('拍照失败2', err)
that.takePhoto2()
}
})
}, timeS);
}, timeS)
},
fail: err => {
console.error('设置缩放失败', err);
fail: (err) => {
console.error('设置缩放失败', err)
}
})
},
// getUserInfo: function () {
// wx.getUserInfo({
// desc: '获取用户信息',
......@@ -930,110 +982,129 @@ Page({
console.log('播放结束')
})
},
//注释长时间不拍照,换种方式提示
// Countone_Time: function () {
// console.log('1')
// var inter = setInterval(function () {
// this.setData({
// smsFlag: true,
// snsMsgWait_one: this.data.snsMsgWait_one - 1
// });
// // console.log('this.data.snsMsgWait_one', this.data.snsMsgWait_one)
// if (this.data.snsMsgWait_one == 0) {
// this.setData({
// longTimeOnce: true
// })
// clearInterval(inter)
// // console.log('this.data.all_state', this.data.all_state)
// // console.log('this.data.singe_state', this.data.singe_state)
// // console.log('longTimeOnce',this.data.longTimeOnce)
// if (this.data.singe_state === true && this.data.all_state === false && this.data.longTimeOnce === true) {
// console.log('倒计时0拍照one')
// setTimeout(() => {
// this.takePhoto2();
// this.setData({
// all_state: true
// })
// // console.log('all_state', this.data.all_state)
// }, 350);
// }
// }
// }.bind(this), 1200);
// },
// Counttwo_Time: function () {
// console.log('2')
// var inter = setInterval(function () {
// this.setData({
// smsFlag: true,
// snsMsgWait_twotime: this.data.snsMsgWait_twotime - 1
// });
// // console.log('this.data.snsMsgWait_twotime', this.data.snsMsgWait_twotime)
// if (this.data.snsMsgWait_twotime == 0) {
// clearInterval(inter)
// // console.log('this.data.all_state', this.data.all_state)
// // console.log('this.data.singe_state', this.data.singe_state)
// this.setData({
// longTimeTwo: true
// })
// // console.log('this.data.singe_state',this.data.singe_state)
// // console.log('this.data.all_state',this.data.all_state)
// // console.log('this.data.longtimeTwo',this.data.longTimeTwo)
// if (this.data.singe_state == true && this.data.all_state == false && this.data.longTimeTwo === true) {
// console.log('倒计时0拍照two')
// 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('倒计时0拍照twoall_state', this.data.all_state)
// }, 350);
// }
// }
// }.bind(this), 1200);
// },
// Countthree_Time: function () {
// console.log('3')
// var inter = setInterval(function () {
// this.setData({
// smsFlag: true,
// snsMsgWait_three: this.data.snsMsgWait_three - 1
// });
// // console.log('this.data.snsMsgWait_three', this.data.snsMsgWait_three)
// if (this.data.snsMsgWait_three == 0) {
// clearInterval(inter)
// this.setData({
// longTimeThree: true
// })
// // console.log('this.data.singe_state',this.data.singe_state)
// // console.log('this.data.all_state',this.data.all_state)
// // console.log('this.data.longtimeThree',this.data.longTimeThree)
// if (this.data.singe_state == true && this.data.all_state == false && 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) {
Countone_Time: function () {
console.log('1')
var inter = setInterval(
function () {
this.setData({
smsFlag: true,
snsMsgWait_one: this.data.snsMsgWait_one - 1
})
// console.log('this.data.snsMsgWait_one', this.data.snsMsgWait_one)
if (this.data.snsMsgWait_one == 0) {
this.setData({
longTimeOnce: true
})
clearInterval(inter)
// console.log('this.data.all_state', this.data.all_state)
// console.log('this.data.singe_state', this.data.singe_state)
// console.log('longTimeOnce',this.data.longTimeOnce)
if (
this.data.singe_state === true &&
this.data.all_state === false &&
this.data.longTimeOnce === true
) {
console.log('倒计时0拍照one')
setTimeout(() => {
this.takePhoto2()
this.setData({
all_state: true
})
// console.log('all_state', this.data.all_state)
}, 350)
}
}
}.bind(this),
1200
)
},
Counttwo_Time: function () {
console.log('2')
var inter = setInterval(
function () {
this.setData({
smsFlag: true,
snsMsgWait_twotime: this.data.snsMsgWait_twotime - 1
})
// console.log('this.data.snsMsgWait_twotime', this.data.snsMsgWait_twotime)
if (this.data.snsMsgWait_twotime == 0) {
clearInterval(inter)
// console.log('this.data.all_state', this.data.all_state)
// console.log('this.data.singe_state', this.data.singe_state)
this.setData({
longTimeTwo: true
})
// console.log('this.data.singe_state',this.data.singe_state)
// console.log('this.data.all_state',this.data.all_state)
// console.log('this.data.longtimeTwo',this.data.longTimeTwo)
if (
this.data.singe_state == true &&
this.data.all_state == false &&
this.data.longTimeTwo === true
) {
console.log('倒计时0拍照two')
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);
// },
} else {
this.takePhoto2()
this.setData({
all_state: true
})
}
// console.log('倒计时0拍照twoall_state', this.data.all_state)
}, 350)
}
}
}.bind(this),
1200
)
},
Countthree_Time: function () {
console.log('3')
var inter = setInterval(
function () {
this.setData({
smsFlag: true,
snsMsgWait_three: this.data.snsMsgWait_three - 1
})
// console.log('this.data.snsMsgWait_three', this.data.snsMsgWait_three)
if (this.data.snsMsgWait_three == 0) {
clearInterval(inter)
this.setData({
longTimeThree: true
})
// console.log('this.data.singe_state',this.data.singe_state)
// console.log('this.data.all_state',this.data.all_state)
// console.log('this.data.longtimeThree',this.data.longTimeThree)
if (
this.data.singe_state == true &&
this.data.all_state == false &&
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() {
wx.navigateTo({
url: '/pages/video/video',
url: '/pages/video/video'
})
},
}
})
......@@ -41,14 +41,13 @@
<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>
</view> -->
<view class="ai-check-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>
<view class="content">
<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">
<text >请保持结构三维码在识别框内等待进度条完成</text>
<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({
dongtaishuju: 0,
phone_model: '',
benchmarkLevel: 0,
showModal:false,
content: "1.识别时请将整个结构三维码放到识别框中,保持画面清晰稳定直到显示认证结果\r\n2.确保标签与背景保持在同一平面内,便于手机相机聚焦\r\n3.AI验证的标签需要与扫描进入主页的这枚标签一致(否则会提示码不同)",
showCover: true,
status_zhi: '',
......@@ -112,22 +113,31 @@ Page({
// console.log('status_zhi',status_zhi)
}
if (this.data.showmodel === true) {
wx.showModal({
title: '注意事项:',
content: this.data.content,
showCancel: false, // 是否显示取消按钮,默认值 true
// cancelText: '非常自信', // 取消按钮的文字,默认值 '取消'
confirmText: '我已知晓', // 确定按钮的文字,默认值 '确定'
success: function (res) {
if (res.confirm) {
console.log('用户点击确定')
this.setData({
showModal:true
})
// 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)
// }
// })
}
},
fail: function (res) {
console.log(res)
}
handleColseModal(){
this.setData({
showModal:false
})
}
},
/**ss
* 跳转到拍照界面
......
......@@ -12,7 +12,7 @@
<!-- 内容盒子 -->
<view class="index-content full">
<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">
......@@ -23,5 +23,18 @@
<!-- 底部文字 -->
<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 style="margin: 20rpx 0;font-weight: 700;font-size: 38rpx;color: #1666cfb4;" bind:tap="handleColseModal">我已知晓</view>
</view>
</view>
</view>
</view>
\ No newline at end of file
......@@ -48,3 +48,40 @@ page {
color: #fff;
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
Page({
/**
* 页面的初始数据
*/
......@@ -8,25 +7,20 @@ Page({
aiState: 0, //展示成功或失败页面,
time1: '', //本次认证时间
time2: '', //认证耗时
bg_color:'',
Labeldiff:0 //展示码不同页面
bg_color: '',
Labeldiff: 0,//展示码不同页面
},
onLoad(options) {
const {
aiState,
time1,
time2,
Labeldiff
} = options
// console.log(options,time1);
console.log('options.Labeldiff',options.Labeldiff)
const { aiState, time1, time2, Labeldiff } = options
console.log(options, time1)
console.log('options.Labeldiff', options.Labeldiff)
this.setData({
aiState: aiState || 0,
time1: time1 || '',
time2: time2 && (new Date().getTime() - time2) / 1000 || '',
time2: (time2 && (new Date().getTime() - time2) / 100) || '',
bg_color: getApp().page_bg,
Labeldiff:Labeldiff || 0
Labeldiff: Labeldiff || 0
})
},
// 返回首页
......@@ -36,21 +30,16 @@ Page({
})
},
// 重新拍照
handleGoTakePhoto(){
handleGoTakePhoto() {
wx.reLaunch({
url: `/pages/cameraTakePhoto/cameraTakePhoto`
})
},
handleOpenVideo() {
wx.navigateTo({
url: '/pages/video/video',
url: '/pages/video/video'
})
},
onReady() {
},
onShow() {
},
onReady() {},
onShow() {}
})
// 获取全局应用程序实例对象
var util = require('../../utils/util')
var Count = 0;
var Count = 0
var fail_Count = 0
// 创建页面实例对象
Page({
// 页面的初始数据
data: {
notice: '',
tempFilePath: "",
tempFilePath: '',
width: 0,
height: 0,
score: '',
......@@ -25,7 +25,7 @@ Page({
openid: '',
aiState: 0,
sameCodeState: 0,
Labeldiff:0,
Labeldiff: 0,
filePath: '',
datajson: '',
labelCodejson: '',
......@@ -88,7 +88,7 @@ Page({
zoom_number: ''
},
onLoad: function (options) {
this.onHide();
this.onHide()
const openid = wx.getStorageSync('openid')
const extraData = JSON.parse(wx.getStorageSync('extraData'))
const param = wx.getStorageSync('fenggu')
......@@ -112,14 +112,16 @@ Page({
})
} else {
this.setData({
'userid': userid,
'cpid': cpid
userid: userid,
cpid: cpid
})
}
if (labelInfo.os === 'davis') {
console.log('云平台')
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',
success: (res) => {
if (res.data.e !== '') {
......@@ -145,7 +147,9 @@ Page({
} else {
console.log('不走云平台')
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',
success: (res) => {
if (res.statusCode !== 200) {
......@@ -184,8 +188,8 @@ Page({
county: '获取失败'
})
} else {
var locationinfo = res.data;
var address = locationinfo.address;
var locationinfo = res.data
var address = locationinfo.address
// console.log('address', address);
var province = locationinfo.province
// console.log('province', province)
......@@ -248,12 +252,11 @@ Page({
// })
// }
let SCREEN_WIDTH = 750
let RATE = wx.getSystemInfoSync().screenHeight / wx.getSystemInfoSync().screenWidth
let RATE =
wx.getSystemInfoSync().screenHeight / wx.getSystemInfoSync().screenWidth
let {
windowWidth = SCREEN_WIDTH,
windowHeight = SCREEN_WIDTH * RATE
} = wx.getSystemInfoSync()
let { windowWidth = SCREEN_WIDTH, windowHeight = SCREEN_WIDTH * RATE } =
wx.getSystemInfoSync()
this.setData({
windowWidth,
windowHeight
......@@ -271,7 +274,7 @@ Page({
wx.removeStorageSync('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)
// console.log('phone_model', phone_model)
const latitude = wx.getStorageSync('latitude') || '获取失败'
......@@ -280,7 +283,7 @@ Page({
const longitude = wx.getStorageSync('longitude') || '获取失败'
wx.removeStorageSync('longitude')
// console.log('longitude',longitude)
var timesc = new Date().getTime();
var timesc = new Date().getTime()
let all_info = wx.getStorageSync('all_info') || '获取失败'
// console.log('all_info',all_info)
let zoom_number = wx.getStorageSync('one_zoom') || '获取失败'
......@@ -319,12 +322,13 @@ Page({
},
uploadImg() {
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);
// console.log('base', base)
//判断标签序号
if (this.data.labelCode) {
// console.log('开始检查标签相似')
this.checkIsSameCode(base, (state) => {
......@@ -332,14 +336,14 @@ Page({
sameCodeState: state
})
if (state === 1) {
this.checkAiResult(base);
this.checkAiResult(base)
} else {
this.setData({
isLoading: false,
isLoading: false
})
}
})
console.log("sameCodeState", this.data.sameCodeState)
console.log('sameCodeState', this.data.sameCodeState)
} else {
console.log('进入不需要检查标签相似')
this.setData({
......@@ -347,7 +351,7 @@ Page({
userimage: false,
userinfo_name: false
})
this.checkAiResult(base);
this.checkAiResult(base)
}
},
//检查标签是否相同
......@@ -355,27 +359,27 @@ Page({
// console.log('this.data.labelCode', this.data.labelCode)
// console.log('this.data.labelCode.length', this.data.labelCode.length)
const requestData = {
'base': base,
'labelCodejson': this.data.labelCode
};
base: base,
labelCodejson: this.data.labelCode
}
wx.request({
// url: 'https://tj5.cc:4433/api/upload/',
// url: 'https://ai.china315net.com:35437/api/upload/',
// url:'https://www.7856.work:4433/api/upload/',
url: 'https://ai.tj5.cc:35437/api/upload/',
method: "POST",
method: 'POST',
data: requestData,
success: (res) => {
const res_data = res.data;
const 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)
const recognize_labelimage = res_data.image_file;
const succes_data = res_data.succes;
const img_method = res_data.img_method;
const img_reader = res_data.img_reader;
const points = res_data.points;
var image_file_myapi = res_data.image_file;
const recognize_labelimage = res_data.image_file
const succes_data = res_data.succes
const img_method = res_data.img_method
const img_reader = res_data.img_reader
const points = res_data.points
var image_file_myapi = res_data.image_file
this.setData({
image_file_myapi,
img_reader,
......@@ -383,189 +387,208 @@ Page({
points,
recognize_labelimage,
recognize_LabelCode
});
const labelCode = this.data.labelCode;
const labelCodejson = labelCode.substring(-12);
let recognizeLabelCode = '';
let datajson = '';
if (res_data === '码解析失败' || succes_data === 'loser' || res.statusCode !== 200) {
})
const labelCode = this.data.labelCode
const labelCodejson = labelCode.substring(-12)
let recognizeLabelCode = ''
let datajson = ''
if (
res_data === '码解析失败' ||
succes_data === 'loser' ||
res.statusCode !== 200
) {
// console.log('网络请求值不等于200')
recognizeLabelCode = '码解析失败'
} else {
recognizeLabelCode = recognize_LabelCode;
recognizeLabelCode = recognize_LabelCode
}
if (!this.data.datajson || this.data.value === 'false') {
datajson = '码解析失败';
datajson = '码解析失败'
} else {
datajson = this.data.datajson;
datajson = this.data.datajson
}
this.setData({
recognizeLabelCode,
datajson,
labelCodejson,
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('labelcodejson111标签号', labelCodejson)
//判断放大解析与原图解析内容是否与标签号一致
if (this.data.recognizeLabelCode === labelCodejson || this.data.datajson === labelCodejson) {
if (
this.data.recognizeLabelCode === labelCodejson ||
this.data.datajson === labelCodejson
) {
console.log('一致')
cb(1);
} else if (this.data.recognizeLabelCode === '码解析失败' && this.data.datajson === '码解析失败') {
cb(1)
} else if (
this.data.recognizeLabelCode === '码解析失败' &&
this.data.datajson === '码解析失败'
) {
console.log('解析失败')
cb(2);
cb(2)
// this.setData({
// aiState: 3
// })
const dtime1 = util.formatTime(new Date());
const dtime1 = util.formatTime(new Date())
wx.request({
url: 'https://ai.tj5.cc:35437/api/all/',
// url: 'https://ai.china315net.com:35437/api/all/',
// url: 'https://tj5.cc:4433/api/all/',
// url:'https://www.7856.work:4433/api/all/',
method: "POST",
method: 'POST',
data: {
'result': '码解析失败',
'score': '0',
'imagefile': recognize_labelimage,
'classs': this.data.hint_phone,
'usetime': '0',
'datetime': dtime1,
'openid': this.data.openid,
'userip': '',
'userlat': this.data.latitude,
'userlon': this.data.longitude,
'recognizelabelcode': this.data.recognizeLabelCode,
'artwork': this.data.datajson,
'labelcode': this.data.labelCode,
'scorelist': '',
'img_method': '',
'img_reader': '',
'points': '',
'userid': this.data.userid || '',
'userimage': this.data.userimage,
'userinfo_name': this.data.userinfo_name,
'yuan_file': this.data.yuan_file,
'phone_model': this.data.phone_model,
'cpid': this.data.cpid || '',
'address': this.data.address || '',
'province': this.data.province || '',
'city': this.data.city || '',
'county': this.data.county || '',
'all_info': this.data.all_info || '',
'zoom_number': this.data.zoom_number || ''
result: '码解析失败',
score: '0',
imagefile: recognize_labelimage,
classs: this.data.hint_phone,
usetime: '0',
datetime: dtime1,
openid: this.data.openid,
userip: '',
userlat: this.data.latitude,
userlon: this.data.longitude,
recognizelabelcode: this.data.recognizeLabelCode,
artwork: this.data.datajson,
labelcode: this.data.labelCode,
scorelist: '',
img_method: '',
img_reader: '',
points: '',
userid: this.data.userid || '',
userimage: this.data.userimage,
userinfo_name: this.data.userinfo_name,
yuan_file: this.data.yuan_file,
phone_model: this.data.phone_model,
cpid: this.data.cpid || '',
address: this.data.address || '',
province: this.data.province || '',
city: this.data.city || '',
county: this.data.county || '',
all_info: this.data.all_info || '',
zoom_number: this.data.zoom_number || ''
},
success: (res) => {
console.log('all入库成功', res);
console.log('all入库成功', res)
wx.reLaunch({
url: `/pages/result/result?aiState=${0}`
})
},
fail: (error) => {
console.log('入库失败', error);
console.log('入库失败', error)
}
});
})
} else {
console.log('码不同')
const Labeldiff = 1
cb(0);
cb(0)
// console.log('码不同', this.data.sameCodeState)
const dtime2 = util.formatTime(new Date());
const dtime2 = util.formatTime(new Date())
wx.request({
url: 'https://ai.tj5.cc:35437/api/all/',
// url: 'https://tj5.cc:4433/api/all/',
// url:'https://www.7856.work:4433/api/all/',
// url: 'https://ai.china315net.com:35437/api/all/',
method: "POST",
method: 'POST',
data: {
'result': '码不同',
'score': '0',
'imagefile': recognize_labelimage,
'classs': '',
'usetime': '0',
'datetime': dtime2,
'openid': this.data.openid,
'userip': '',
'userlat': this.data.latitude,
'userlon': this.data.longitude,
'recognizelabelcode': this.data.recognizeLabelCode,
'artwork': this.data.datajson,
'labelcode': this.data.labelCode,
'scorelist': '',
'img_method': '',
'img_reader': '',
'points': '',
'userid': this.data.userid || '',
'userimage': this.data.userimage || '',
'userinfo_name': this.data.userinfo_name || '',
'yuan_file': this.data.yuan_file || '',
'phone_model': this.data.phone_model || '',
'cpid': this.data.cpid || '',
'address': this.data.address || '',
'province': this.data.province || '',
'city': this.data.city || '',
'county': this.data.county || '',
'all_info': this.data.all_info || '',
'zoom_number': this.data.zoom_number || ''
result: '码不同',
score: '0',
imagefile: recognize_labelimage,
classs: '',
usetime: '0',
datetime: dtime2 || '',
openid: this.data.openid,
userip: '',
userlat: this.data.latitude,
userlon: this.data.longitude,
recognizelabelcode: this.data.recognizeLabelCode,
artwork: this.data.datajson,
labelcode: this.data.labelCode,
scorelist: '',
img_method: '',
img_reader: '',
points: '',
userid: this.data.userid || '',
userimage: this.data.userimage || '',
userinfo_name: this.data.userinfo_name || '',
yuan_file: this.data.yuan_file || '',
phone_model: this.data.phone_model || '',
cpid: this.data.cpid || '',
address: this.data.address || '',
province: this.data.province || '',
city: this.data.city || '',
county: this.data.county || '',
all_info: this.data.all_info || '',
zoom_number: this.data.zoom_number || ''
},
success: (res) => {
console.log('all入库成功', res);
console.log('all入库成功', res)
wx.reLaunch({
url: `/pages/result/result?Labeldiff=${Labeldiff}`
})
return
},
fail: (error) => {
console.log('入库失败', error);
console.log('入库失败', error)
}
});
})
}
},
fail: (error) => {
console.log('调用upload接口超时', error)
cb(2);
cb(2)
console.log('222222222222')
wx.request({
url: 'https://ai.tj5.cc:35437/api/all/',
// url: 'https://tj5.cc:4433/api/all/',
// url:'https://www.7856.work:4433/api/all/',
method: "POST",
method: 'POST',
data: {
'result': '调用upload接口超时',
'score': '0',
'imagefile': '',
'classs': this.data.hint_phone,
'usetime': '0',
'datetime': dtime2,
'openid': this.data.openid,
'userip': '',
'userlat': this.data.latitude,
'userlon': this.data.longitude,
'recognizelabelcode': '码解析失败',
'artwork': this.data.datajson,
'labelcode': this.data.labelCode,
'scorelist': '',
'img_method': '',
'img_reader': '',
'points': '',
'userid': this.data.userid || '',
'userimage': this.data.userimage,
'userinfo_name': this.data.userinfo_name,
'yuan_file': this.data.yuan_file,
'phone_model': this.data.phone_model,
'cpid': this.data.cpid || '',
'address': this.data.address || '',
'province': this.data.province || '',
'city': this.data.city || '',
'county': this.data.county || '',
'all_info': this.data.all_info || '',
'zoom_number': this.data.zoom_number || ''
result: '调用upload接口超时',
score: '0',
imagefile: '',
classs: this.data.hint_phone,
usetime: '0',
datetime:'',
openid: this.data.openid,
userip: '',
userlat: this.data.latitude,
userlon: this.data.longitude,
recognizelabelcode: '码解析失败',
artwork: this.data.datajson,
labelcode: this.data.labelCode,
scorelist: '',
img_method: '',
img_reader: '',
points: '',
userid: this.data.userid || '',
userimage: this.data.userimage,
userinfo_name: this.data.userinfo_name,
yuan_file: this.data.yuan_file,
phone_model: this.data.phone_model,
cpid: this.data.cpid || '',
address: this.data.address || '',
province: this.data.province || '',
city: this.data.city || '',
county: this.data.county || '',
all_info: this.data.all_info || '',
zoom_number: this.data.zoom_number || ''
},
success: (res) => {
console.log('success,调用upload接口超时', res)
wx.reLaunch({
url: `/pages/result/result?aiState=${0}`
})
},
fail: (error) => {
console.log('fail,调用upload接口超时', error);
console.log('fail,调用upload接口超时', error)
}
});
})
//判断手机型号 开始注释
// let timeoutIndex = -1;
// if (wx.getSystemInfoSync().platform === 'ios') {
......@@ -729,7 +752,7 @@ Page({
// }
//一直注释到这里
},
timeout: 3000
timeout: 7000
})
},
//检查ai识别结果
......@@ -746,45 +769,45 @@ Page({
// url:'https://www.7856.work:4433/api/classify16/',
method: 'POST',
data: {
'image_type': 50,
'base': base,
image_type: 50,
base: base
},
success: (res) => {
console.log('base',base)
console.log('打印分类接口返回数据res.data', res.data)
let imagefile = res.data.image_path
const classScore = res.data.result
const max_score = Math.max.apply(null, res.data.confidence)
const max_score_value = max_score.toFixed(3)
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++) {
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++) {
var num = parseFloat(Score_list[i]);
if (!isNaN(num)) { // 如果转换结果不是NaN,则表示转换成功
floatList.push(num); // 将转换结果添加到列表中
var num = parseFloat(Score_list[i])
if (!isNaN(num)) {
// 如果转换结果不是NaN,则表示转换成功
floatList.push(num) // 将转换结果添加到列表中
}
}
const phone_score = res.data.confidence[4]
function mysort(a) {
var n = a.length;
var newa = [];
var temp;
var n = a.length
var newa = []
var temp
for (var i = 0; i < n; i++) {
for (var j = i; j < n; j++) {
if (a[i] > a[j]) {
temp = a[i];
a[i] = a[j];
a[j] = temp;
temp = a[i]
a[i] = a[j]
a[j] = temp
}
}
newa.push(a[i]);
newa.push(a[i])
}
return newa;
return newa
}
const class_score_sor = mysort(Score_list)
// console.log('class_score_sor', class_score_sor)
......@@ -798,11 +821,11 @@ Page({
let succ = ''
// ai通过状态
let aiState = 0;
let aiState = 0
this.setData({
isLoading: true,
imagefile: imagefile,
phone_score: phone_score,
phone_score: phone_score
})
// console.log('classScore_11111', classScore)
if (this.data.hint_phone == 14) {
......@@ -932,34 +955,35 @@ Page({
phone_score: phone_score,
succ: succ,
notice: notice,
aiState: aiState,
});
aiState: aiState
})
wx.setStorage({
key: 'notice',
data: notice
})
console.log('notice结果展示',notice)
console.log('notice结果展示', notice)
if (notice != '手机边框') {
if (aiState !== 1) {
Count++;
Count++
} else {
Count = 0;
Count = 0
}
if (Count >= 3) {
// console.log('Count', Count)
console.log('三次未通过调用人工')
var people_time = util.formatTime(new Date)
var timessc = new Date().getTime();
var people_time = util.formatTime(new Date())
var timessc = new Date().getTime()
this.setData({
isLoading: true,
people_time
})
Count = 0;
Count = 0
console.log('三次请拍摄结构三维码调用人工')
wx.request({
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://www.7856.work:4433/bg/swmrecognizeproject/apis/miniprogram/uploadimg.ashx',
......@@ -984,21 +1008,24 @@ Page({
})
// console.log('this.data.sameCodeState', this.data.sameCodeState)
} else {
var inter = setInterval(function () {
var inter = setInterval(
function () {
this.setData({
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({
zidong_fuzhi: true
});
})
// console.log('this.data.zidong_fuzhi', this.data.zidong_fuzhi)
clearInterval(inter)
}
}.bind(this), 1000);
}.bind(this),
1000
)
// let people_statu = res.data.success
let people_id = res.data.id
let people_image = res.data.image
......@@ -1029,12 +1056,12 @@ Page({
peo_state: peo_state,
true_state: true,
isLoading: false,
aiState: 1,
aiState: 1
})
// console.log('this.data.peo_state', this.data.peo_state)
// console.log('this.data.aiState', this.data.aiState)
clearInterval(this.data.setInter)
var timeec = new Date().getTime();
var timeec = new Date().getTime()
var people_replytime = timeec - timessc
// console.log('本次认证时间people_replytime', people_replytime / 1000)
this.setData({
......@@ -1042,7 +1069,10 @@ Page({
})
// 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('人工回复不是真品')
this.setData({
peo_state: peo_state,
......@@ -1054,7 +1084,7 @@ Page({
// console.log('this.data.fail_state', this.data.fail_state)
// console.log('this.data.sameCodeState', this.data.sameCodeState)
clearInterval(this.data.setInter)
var timeec = new Date().getTime();
var timeec = new Date().getTime()
var people_replytime = timeec - timessc
this.setData({
people_replytime
......@@ -1062,7 +1092,7 @@ Page({
// console.log('people_replytime', people_replytime)
} else {
console.log('没有进行回复')
var timeec = new Date().getTime();
var timeec = new Date().getTime()
var people_replytime = timeec - timessc
this.setData({
people_replytime
......@@ -1070,7 +1100,7 @@ Page({
// console.log('people_replytime', people_replytime)
}
}
},
}
})
}, 2500)
}
......@@ -1096,23 +1126,23 @@ Page({
Count
})
}
var timeec = new Date().getTime();
var timeec = new Date().getTime()
var datemill = timeec - this.data.timesc
// console.log('本次认证时间', datemill / 1000)
var dtime = util.formatTime(new Date)
var dtime = util.formatTime(new Date())
this.setData({
notice,
datemill,
dtime,
succ,
aiState,
aiState
})
if (this.data.recognizeLabelCode === '码解析失败') {
console.log('判断条件成功,使用原图的')
const img_method = this.data.img_method_chuan;
const img_reader = this.data.img_reader_chuan;
const points = this.data.points_chuan;
const img_method = this.data.img_method_chuan
const img_reader = this.data.img_reader_chuan
const points = this.data.points_chuan
this.setData({
img_method,
img_reader,
......@@ -1120,9 +1150,9 @@ Page({
})
} else {
console.log('使用放大的')
const img_method = this.data.img_method;
const img_reader = this.data.img_reader;
const points = this.data.points;
const img_method = this.data.img_method
const img_reader = this.data.img_reader
const points = this.data.points
this.setData({
img_reader,
img_method,
......@@ -1130,9 +1160,16 @@ Page({
})
}
let state = 0;
if (notice === '结构三维码' || notice === '烫金三维码' || notice === '多层纸结构三维码' || notice === '高分子三维码' || notice === '铆钉三维码' || notice === '护照烫金三维码') {
state = 1;
let state = 0
if (
notice === '结构三维码' ||
notice === '烫金三维码' ||
notice === '多层纸结构三维码' ||
notice === '高分子三维码' ||
notice === '铆钉三维码' ||
notice === '护照烫金三维码'
) {
state = 1
this.setData({
sameCodeState: 3
})
......@@ -1146,12 +1183,13 @@ Page({
// console.log('this.data.sameCodeState', this.data.sameCodeState)
if (state == 1) {
console.log('倒计时')
var inter = setInterval(function () {
var inter = setInterval(
function () {
this.setData({
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()
......@@ -1161,52 +1199,54 @@ Page({
this.setData({
snsMsgWait_1: 2,
smsFlag: false
});
})
}
}.bind(this), 1000);
}.bind(this),
1000
)
}
this.callBackAIStatus(state)
const postdata = {
'result': notice,
'score': max_score_value,
'imagefile': this.data.image_file_myapi || imagefile,
'classs': classScore,
'usetime': datemill / 1000,
'datetime': dtime,
'openid': this.data.openid,
'userip': '',
'userlat': this.data.latitude,
'userlon': this.data.longitude,
'recognizelabelcode': this.data.recognizeLabelCode,
'artwork': this.data.datajson,
'labelcode': this.data.labelCode || '',
'scorelist': floatList,
'img_method': this.data.img_method,
'img_reader': this.data.img_reader,
'points': this.data.points,
'userid': this.data.userid || '',
'userimage': this.data.userimage,
'userinfo_name': this.data.userinfo_name,
'yuan_file': this.data.yuan_file,
'phone_model': this.data.phone_model,
'cpid': this.data.cpid || '',
'address': this.data.address || '',
'province': this.data.province || '',
'city': this.data.city || '',
'county': this.data.county || '',
'all_info': this.data.all_info || '',
'zoom_number': this.data.zoom_number || ''
result: notice,
score: max_score_value,
imagefile: this.data.image_file_myapi || imagefile,
classs: classScore,
usetime: datemill / 1000,
datetime: dtime,
openid: this.data.openid,
userip: '',
userlat: this.data.latitude,
userlon: this.data.longitude,
recognizelabelcode: this.data.recognizeLabelCode,
artwork: this.data.datajson,
labelcode: this.data.labelCode || '',
scorelist: floatList,
img_method: this.data.img_method,
img_reader: this.data.img_reader,
points: this.data.points,
userid: this.data.userid || '',
userimage: this.data.userimage,
userinfo_name: this.data.userinfo_name,
yuan_file: this.data.yuan_file,
phone_model: this.data.phone_model,
cpid: this.data.cpid || '',
address: this.data.address || '',
province: this.data.province || '',
city: this.data.city || '',
county: this.data.county || '',
all_info: this.data.all_info || '',
zoom_number: this.data.zoom_number || ''
}
console.log('this.data.image_file_myapi', )
console.log('aistate',aiState)
console.log('this.data.image_file_myapi')
console.log('aistate', aiState)
wx.request({
// url: 'https://ai.china315net.com:35437/api/all/',
url: 'https://ai.tj5.cc:35437/api/all/',
// url: 'https://tj5.cc:4433/api/all/',
// url:'https://www.7856.work:4433/api/all/',
method: "POST",
method: 'POST',
data: {
...postdata
},
......@@ -1218,7 +1258,7 @@ Page({
complete: () => {}
})
wx.removeStorage({
'artwork': this.data.datajson,
artwork: this.data.datajson,
succes(res) {
console.log('resresres', res)
}
......@@ -1231,7 +1271,9 @@ Page({
// 跳转到结果页面
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
},
......@@ -1242,7 +1284,7 @@ Page({
},
back() {
wx.reLaunch({
url: '/pages/index/index',
url: '/pages/index/index'
})
},
// old() {
......@@ -1397,10 +1439,10 @@ Page({
// },
// 回调AI结果
callBackAIStatus(state) {
const labelInfo = this.data.labelInfo;
const labelInfo = this.data.labelInfo
console.log('labelInfo', labelInfo)
if (!labelInfo) {
return;
return
}
labelInfo.state = state
//调用云平台接口
......@@ -1409,10 +1451,10 @@ Page({
url: 'https://davis.china315net.com/wx/ajax/get_ai_status/',
method: 'GET',
data: {
"label_code": labelInfo.cpid,
"consumer_id": labelInfo.uid,
"uuid": labelInfo.uuid,
"state": labelInfo.state,
label_code: labelInfo.cpid,
consumer_id: labelInfo.uid,
uuid: labelInfo.uuid,
state: labelInfo.state
},
success: (res) => {
console.log('回调成功davis')
......@@ -1434,7 +1476,6 @@ Page({
}
},
//点击按钮显示
popup: function (e) {
this.setData({
......@@ -1442,12 +1483,13 @@ Page({
})
// console.log('popup_showModal', this.data.showModal);
//实现倒计时
var inter = setInterval(function () {
var inter = setInterval(
function () {
this.setData({
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()
......@@ -1457,9 +1499,11 @@ Page({
this.setData({
snsMsgWait: 3,
smsFlag: false
});
})
}
}.bind(this), 1000);
}.bind(this),
1000
)
},
//点击隐藏图标
hidepopup: function () {
......@@ -1480,8 +1524,8 @@ Page({
//修改 清除缓存
},
onHide: function () {
const innerAudioContext = wx.createInnerAudioContext();
innerAudioContext.stop();
innerAudioContext.destroy();
},
const innerAudioContext = wx.createInnerAudioContext()
innerAudioContext.stop()
innerAudioContext.destroy()
}
})
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论