rfid扫描管理-lSun

This commit is contained in:
lSun 2024-11-09 21:08:18 +08:00
parent 232331df54
commit 9952d688d4
3 changed files with 131 additions and 45 deletions

View File

@ -2,8 +2,8 @@
<view class="hole-page">
<view class="upper-bgd">
<h4 style="font-size: 16px; font-weight: normal;">RFID标签绑定</h4>
<uni-data-select v-model="powerVal" :localdata="powerRange" placeholder="请选择功率" @change="powerChange"
:clear="false"></uni-data-select>
<!-- <uni-data-select v-model="powerVal" :localdata="powerRange" placeholder="请选择功率" @change="powerChange"
:clear="false"></uni-data-select> -->
</view>
<view class="lower-rfid" v-show="showStats">
<view class="stat-cont">
@ -96,7 +96,8 @@
</template>
<script>
const rfidMod = uni.requireNativePlugin('BNS-RfidRed')
// const rfidMod = uni.requireNativePlugin('BNS-RfidRed')
var rfidModule = uni.requireNativePlugin("DeviceModule_RFID");
export default {
data() {
return {
@ -152,21 +153,27 @@
let that = this
that.showPrompt = true;
that.promptMessage = '识别中,请稍候...';
// Toast
setTimeout(() => {
let goVeri = rfidMod.redTag()
console.log(goVeri);
if (goVeri.code == 1001) {
let jsonData = {
"bank": 1,
"ptr": 2,
"cnt": 6,
"accessPwd": "00000000"
}
let goVeri = rfidModule.readData(jsonData)
// let goVeri = rfidMod.redTag()
// console.log(goVeri);
if (goVeri.code == 0) {
that.showPrompt = false; //
that.rfidCode = goVeri.res
that.rfidCode = goVeri.data
uni.showToast({
icon: 'none',
title: '识别成功',
success: () => {
//
that.$api.fetchMaterialOutStore.searchRfid({
rfidCode: goVeri.res
rfidCode: goVeri.data
}).then(res => {
console.log(res);
console.log(res.data.data[0]);
@ -250,15 +257,15 @@
that.maId = ''
that.showStats = false
},
powerChange(e) {
console.log(e);
const ctrlPower = rfidMod.setPower(e)
console.log(ctrlPower);
uni.showToast({
icon: 'none',
title: ctrlPower.res
})
},
// powerChange(e) {
// console.log(e);
// const ctrlPower = rfidMod.setPower(e)
// console.log(ctrlPower);
// uni.showToast({
// icon: 'none',
// title: ctrlPower.res
// })
// },
//
typeChange(e) {
let that = this
@ -302,7 +309,7 @@
let that = this
this.showPrompt = true;
this.promptMessage = '识别中,请稍候...';
this.promptMessage = '正在绑定,请稍候...';
// Toast
setTimeout(() => {
that.$refs.qrForm.validate().then(formData => {
@ -336,15 +343,35 @@
this.showPrompt = false; //
console.log(err);
})
})
}).catch(validationError => {
//
this.showPrompt = false;
uni.showToast({
icon: 'none',
title: '表单验证失败,请检查输入'
});
console.error('Validation error:', validationError);
});
}, 1000)
}
},
onLoad() {
// 使RDIF
let res = rfidModule.init();
console.log(res)
// log(JSON.stringify(res));
if (res.code == 0) {
// this.isLoading = false;
} else if (res.code == -1) {
uni.showToast({
title: 'RFID模块加载失败'
})
}
// rfid
const obj = rfidMod.initUHF()
console.log(obj);
// const obj = rfidMod.initUHF()
// console.log(obj);
//
for (let i = 5; i <= 30; i++) {
this.powerRange.push({
@ -370,7 +397,30 @@
}).catch(err => {
console.log(err);
})
}
},
// mounted() {
// setTimeout(() => {
// // 使RDIF
// let res = rfidModule.init();
// // log(JSON.stringify(res));
// if (res.code == 0) {
// this.isLoading = false;
// } else if (res.code == -1) {
// uni.showToast({
// title: 'RFID'
// })
// }
// }, 400);
// },
// beforeDestroy() {
// //
// plus.key.removeEventListener('keydown', this.keyListener)
// // 使RDIF
// let res = rfidModule.free();
// console.log("使RDIF",res)
// // log("free: " + JSON.stringify(res))
// },
}
</script>

View File

@ -67,7 +67,8 @@
</template>
<script>
const rfidMod = uni.requireNativePlugin('BNS-RfidRed')
// const rfidMod = uni.requireNativePlugin('BNS-RfidRed');
var rfidModule = uni.requireNativePlugin("DeviceModule_RFID");
export default {
data() {
return {
@ -268,11 +269,21 @@
that.promptMessage = '识别中,请稍候...';
// Toast
setTimeout(() => {
let b = rfidMod.initUHF()
// let b = rfidMod.initUHF()
let b = rfidModule.init();
console.log(b);
let goVeri = rfidMod.redTag()
// let goVeri = rfidMod.redTag()
let jsonData = {
"bank": 1,
"ptr": 2,
"cnt": 6,
"accessPwd": "00000000"
}
let goVeri = rfidModule.readData(jsonData)
console.log(goVeri);
if (goVeri.code == 1001) {
if (goVeri.code == 0) {
that.showLoading = true
that.showPrompt = false; //
uni.showToast({
@ -281,7 +292,7 @@
success: () => {
//
that.$api.fetchMaterialOutStore.searchRfid({
rfidCode: goVeri.res
rfidCode: goVeri.data
}).then(res => {
console.log(res);
if (res.data.code == 200) {
@ -317,17 +328,19 @@
}, 1000)
},
stopVeri() {
let endVeri = rfidMod.closeRfid()
// let endVeri = rfidMod.closeRfid()
let endVeri = rfidModule.free();
console.log(endVeri);
if (endVeri.code == 1001) {
if (endVeri.code == 0) {
uni.showToast({
icon: 'none',
title: endVeri.res
title: "停止成功"
})
} else {
uni.showToast({
icon: 'none',
title: endVeri.res
title: "停止失败"
})
}
},
@ -344,8 +357,20 @@
this.parentId = params.parentId
this.taskId = params.taskId
// rfid
const obj = rfidMod.initUHF()
console.log(obj);
// const obj = rfidMod.initUHF()
// console.log(obj);
// 使RDIF
let res = rfidModule.init();
console.log(res)
// log(JSON.stringify(res));
if (res.code == 0) {
} else if (res.code == -1) {
uni.showToast({
title: 'RFID模块加载失败'
})
}
}
}
</script>

View File

@ -66,7 +66,8 @@
</template>
<script>
const rfidMod = uni.requireNativePlugin('BNS-RfidRed')
// const rfidMod = uni.requireNativePlugin('BNS-RfidRed')
var rfidModule = uni.requireNativePlugin("DeviceModule_RFID");
export default {
data() {
return {
@ -246,11 +247,19 @@
that.promptMessage = '识别中,请稍候...';
// Toast
setTimeout(() => {
let b = rfidMod.initUHF()
// let b = rfidMod.initUHF()
let b = rfidModule.init();
console.log(b);
let goVeri = rfidMod.redTag()
// let goVeri = rfidMod.redTag()
let jsonData = {
"bank": 1,
"ptr": 2,
"cnt": 6,
"accessPwd": "00000000"
}
let goVeri = rfidModule.readData(jsonData)
console.log(goVeri);
if (goVeri.code == 1001) {
if (goVeri.code == 0) {
that.showLoading = true
that.showPrompt = false; //
uni.showToast({
@ -259,7 +268,7 @@
success: () => {
//
that.$api.backMaterialReceive.searchRfid({
rfidCode: goVeri.res
rfidCode: goVeri.data
}).then(res => {
console.log(res);
if (res.data.code == 200) {
@ -294,17 +303,18 @@
}, 1000)
},
stopVeri() {
let endVeri = rfidMod.closeRfid()
// let endVeri = rfidMod.closeRfid()
let endVeri = rfidModule.free();
console.log(endVeri);
if (endVeri.code == 1001) {
if (endVeri.code == 0) {
uni.showToast({
icon: 'none',
title: endVeri.res
title: "停止成功"
})
} else {
uni.showToast({
icon: 'none',
title: endVeri.res
title: "停止失败"
})
}
},
@ -321,8 +331,9 @@
this.parentId = params.parentId
this.taskId = params.taskId
// rfid
const obj = rfidMod.initUHF()
console.log(obj);
// const obj = rfidMod.initUHF()
let res = rfidModule.init();
console.log(res);
}
}
</script>