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

View File

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

View File

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