点击这里,查看扫码入库系统演示的网址
一、界面样式
主要功能:
- 扫码入库,无线,有线扫码枪均可。
- 断点后自动续存编号,比如之前1号服务站入库了2单,换成8号服务站入库,当切换回1号服务站继续入库时,快递编号自动从第3单开始向后续。
- 能够把入库数据转换成EXCEL表格,以供下载使用。
- 手动输入,倒计时12秒后自动检测单号是否合规,并需要用户确认后存入浏览器本地存储
- 本地存储的几个主要用途。 ①计算时间,当第一次打开网站会存入一个毫秒时间,每次刷新或者重新打开页面都会比对当前时间与存储时间的差值,大于13小时,即弹出对话框让用户选择是否清理页面缓存信息。同时存入当前毫秒时间。 ②断点续号,将服务站编号与他的入库数,作为key:value保存于本地存储中,当点击切换服务站时,保存旧服务站的信息,调出新服务站的信息,以达到序号不乱的目的。 ③显示列表信息和下载EXCEL信息都来源于本地存储

二、扫码入库和手动入库
2.1 扫码入库,扫码枪获取单号的时间一般不超过20毫秒,为了保险起见,设置了300毫秒后,开始验证数据。
- 2.1.1 methods的首个函数,主要功能一些开关和计时
`this.flag 为 ture 时把毫秒时间存放于数组中,单号有15位就会存放15次毫秒时间`
`this.istrue 为 ture 时立即锁定并执行 this.timerSet() 函数`
`this.isFalse 用于切换提示信息与手动输入提示信息有关`
scanWrite() {
if (this.flag) {
let time = Date.now();
this.timeArr.push(time);
}
if (this.istrue) {
this.istrue = false;
this.isFalse = false;
this.timerSet();
}
}
`this.isShow 为 ture 时,是扫码入库,反之是手动入库`
timerSet() {
if (this.isShow) {
this.checkNumA();
} else {
this.checkNumB();
}
}
` this.istrue 为 false 时 300毫秒后执行数据检测 `
`第一步计算了时间,展示在网页顶部右侧的提示信息框内`
`第二步检测单号是否已经存在,并展示提示信息,开启或关闭某些开关`
`第三部检测单号属于哪个快递公司`
`第四步统计保存数据`
`重复或者错误都将执行清除函数 this.remove()`
checkNumA() {
if (!this.istrue) {
setTimeout(async () => {
this.timeArr.push(Date.now());
this.timess = '用时:' + (this.timeArr[this.timeArr.length - 1] - this.timeArr[0]) + '毫秒';
let myforArr = await this.forArr(this.numA);
if (!myforArr) {
this.remove();
this.countdown = `${
this.numA}号码重复`;
return;
}
let checkLength = await this.checkLength(this.numA);
if (!checkLength) {
this.remove();
this.countdown = `单号长度有误,应当在11~19位之间`;
return;
} else {
this.totalCount(this.numA);
}
}, 300);
}
}
2.2 手动入库,当点击输入框,倒计时启动,然后验证单号有效性。
`倒计时开启后运行倒计时音乐`
`倒计时结束后运行 this.timerSet()`
`this.right用于锁定,当前只能运行一个timer()函数`
timer() {
if(this.isRight){
this.isRight =false;
this.isHandleShow = true;
this.timer_audio = new Audio('../../static/yx/10s.mp3');
this.timer_audio.play();
let num = 12;
this.countdown = `将在${
num}秒后自动入库`;
this.myTimerNum = setInterval(() => {
num -= 1;
if (num <= 1) {
clearInterval(this.myTimerNum);
this.isShow = false;
this.timerSet();
} else {
this.countdown = `将在${
num}秒后自动入库`;
}
}, 1000);
}else{
return
}
}
- 2.2.2 自动分通道检测单号,同上
this.timerSet()
- 2.2.3 手动输入单号检测验证区
`第一步验证单号是否重复`
`第二步匹配对应的快递公司`
`第三步统计并保存数据`
`重复或者错误都将执行清除函数 this.remove()`
async checkNumB() {
let myforArr = await this.forArr(this.numB);
if (!myforArr) {
this.remove(this.numB);
this.isHandleShow = false;
return;
}
let checkLength = await this.checkLength(this.numB);
if (!checkLength) {
this.isRight = true;
this.remove(this.numB);
return;
} else {
if (this.timer_audio) {
this.timer_audio.pause();
}
const that = this;
uni.showModal({
title: '无法匹配快递公司',
content: '确定要保存当前单号吗?',
success: function(res) {
if (res.confirm) {
that.isRight = true;
that.totalCount(that.numB);
that.remove(that.numB);
return
} else if (res.cancel) {
that.countdown = '单号有误,已经删除';
that.isRight = true;