From 3f63164b824fd996273a2533e9d27b98f87c56c5 Mon Sep 17 00:00:00 2001
From: chen.llin <1442464845@qq.comm>
Date: 星期三, 14 一月 2026 19:47:12 +0800
Subject: [PATCH] rfid初版
---
pages/rfid/settings.vue | 800 ++++++++++
pages/stock/stockQuery.vue | 18
pages/home/home.vue | 33
pages/AGV/agv_empty.vue | 598 ++++++++
nativeplugins/iData-UHFPlugin/package.json | 26
pages/AGV/agv_start.vue | 39
pages.json | 25
common/rfid-input-helper.js | 354 ++++
common/rfid-scanner.js | 565 +++++++
pages/rfid/uhftest2.vue | 400 +++++
.hbuilderx/launch.json | 2
App.vue | 318 +++
common/idata-rfid.js | 501 ++++++
.idea/misc.xml | 1
nativeplugins/iData-UHFPlugin/license.md | 7
nativeplugins/iData-UHFPlugin/android/uhflib-release.aar | 0
pages/rfid/uhftest.vue | 509 ++++++
manifest.json | 14
pages/order/orderPakin2.vue | 18
pages/pakin/pakin.vue | 40
uni_modules/uni-popup/components/uni-popup/uni-popup.vue | 37
pages/AGV/agv_back.vue | 31
22 files changed, 4,277 insertions(+), 59 deletions(-)
diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json
index 8ae452a..1b8d0f6 100644
--- a/.hbuilderx/launch.json
+++ b/.hbuilderx/launch.json
@@ -2,7 +2,7 @@
"version" : "1.0",
"configurations" : [
{
- "playground" : "standard",
+ "playground" : "custom",
"type" : "uni-app:app-android"
}
]
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 07115cd..ef89d98 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,3 @@
-<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
diff --git a/App.vue b/App.vue
index 8147dc3..beab781 100644
--- a/App.vue
+++ b/App.vue
@@ -1,33 +1,264 @@
<script>
import Vue from 'vue'
+ // #ifdef APP-PLUS
+ import { startRFIDInputHelper, stopRFIDInputHelper } from '@/common/rfid-input-helper.js'
+ // #endif
export default {
onLaunch: function() {
console.log('App Launch')
+
+ // #ifdef APP-PLUS
+ // 鍏ㄥ眬鍒濆鍖朢FID妯″潡锛堝簲鐢ㄥ惎鍔ㄦ椂鍒濆鍖栵紝鍏抽棴app鏃跺叧闂級
+ console.log('[App] 鍒濆鍖朢FID妯″潡...');
+ const uhfModel = uni.requireNativePlugin("iData-UHFPlugin-UHFModule");
+ const globalEvent = uni.requireNativePlugin('globalEvent');
+ const modal = uni.requireNativePlugin('modal');
+
+ if (!uhfModel) {
+ console.error('[App] RFID鎻掍欢鏈壘鍒�');
+ } else {
+ // 鐩戝惉涓婄數浜嬩欢
+ let isPowerOn = false;
+ globalEvent.addEventListener('POWEREvent', function(e) {
+ console.log('[App] POWEREvent:', JSON.stringify(e));
+ if (e && e.status === 'connected') {
+ isPowerOn = true;
+ console.log('[App] 鉁撯湏鉁� RFID妯″潡宸蹭笂鐢垫垚鍔燂紒');
+ } else {
+ isPowerOn = false;
+ console.log('[App] 鉁� RFID妯″潡鏈笂鐢�');
+ }
+ });
+
+ // 鍒濆鍖朢FID妯″潡锛堜娇鐢⊿LR妯″潡锛屼笌娴嬭瘯椤甸潰涓�鑷达級
+ uhfModel.initUHF(1, (ret) => {
+ console.log('[App] initUHF result:', ret);
+ if (ret && typeof ret === 'string' && ret.includes('success')) {
+ console.log('[App] 鉁� RFID妯″潡鍒濆鍖栨垚鍔�');
+ } else {
+ console.warn('[App] 鈿� RFID妯″潡鍒濆鍖栧け璐�:', ret);
+ }
+ });
+
+ // 淇濆瓨寮曠敤锛岀敤浜巓nExit鏃跺叧闂�
+ this.uhfModel = uhfModel;
+ this.globalEvent = globalEvent;
+ }
+
+ // 鍚姩鍏ㄥ眬RFID杈撳叆鍔╂墜锛堢敤浜庤嚜鍔ㄥ~鍏ヨ緭鍏ユ锛�
+ startRFIDInputHelper();
+ // #endif
+
+ // 娉ㄦ剰锛氫互涓嬩唬鐮佸凡搴熷純锛屾敼涓轰笂闈㈢殑鍏ㄥ眬鍒濆鍖栨柟寮�
+ // #ifdef APP-PLUS
+ /*
+ console.log('[App] 鍒濆鍖朢FID妯″潡...');
+ const uhfModel = uni.requireNativePlugin("iData-UHFPlugin-UHFModule");
+ const globalEvent = uni.requireNativePlugin('globalEvent');
+ const modal = uni.requireNativePlugin('modal');
+
+ // 鐩戝惉涓婄數浜嬩欢
+ let isPowerOn = false;
+ let moduleTypeIndex = 0; // 褰撳墠灏濊瘯鐨勬ā鍧楃被鍨嬬储寮曪細0=UM, 1=SLR, 2=GX
+ const moduleTypes = [0, 1, 2]; // 妯″潡绫诲瀷鍒楄〃
+ const moduleTypeNames = ['UM妯″潡', 'SLR妯″潡', 'GX妯″潡'];
+ let initRetryCount = 0;
+ const maxRetryCount = 3; // 姣忕妯″潡绫诲瀷鏈�澶氬皾璇�3娆�
+
+ globalEvent.addEventListener('POWEREvent', function(e) {
+ console.log('[App] POWEREvent:', JSON.stringify(e));
+ if (e && e.status === 'connected') {
+ isPowerOn = true;
+ console.log('[App] 鉁撯湏鉁� 妯″潡宸蹭笂鐢垫垚鍔燂紒妯″潡绫诲瀷:', moduleTypeNames[moduleTypeIndex]);
+ } else {
+ isPowerOn = false;
+ console.log('[App] 鉁� 妯″潡鏈笂鐢�:', e ? e.msg : '鏈煡閿欒');
+
+ // 濡傛灉涓婄數澶辫触锛屽皾璇曚笅涓�涓ā鍧楃被鍨�
+ if (e && e.msg && e.msg.includes('涓婄數澶辫触')) {
+ setTimeout(() => {
+ tryNextModuleType();
+ }, 2000);
+ }
+ }
+ });
+
+ // 灏濊瘯涓嬩竴涓ā鍧楃被鍨�
+ const tryNextModuleType = () => {
+ initRetryCount++;
+ if (initRetryCount >= maxRetryCount) {
+ // 褰撳墠妯″潡绫诲瀷灏濊瘯娆℃暟鐢ㄥ畬锛屽垏鎹㈠埌涓嬩竴涓�
+ moduleTypeIndex++;
+ initRetryCount = 0;
+
+ if (moduleTypeIndex >= moduleTypes.length) {
+ // 鎵�鏈夋ā鍧楃被鍨嬮兘灏濊瘯杩囦簡
+ console.log('[App] 鈿� 鎵�鏈夋ā鍧楃被鍨嬮兘灏濊瘯澶辫触锛屽仠姝㈠垵濮嬪寲');
+ modal.toast({
+ message: 'RFID妯″潡鍒濆鍖栧け璐ワ紝璇锋鏌ヨ澶�',
+ duration: 2
+ });
+ return;
+ }
+ }
+
+ // 鍏堟竻闄ら厤缃俊鎭�
+ if (uhfModel.clearConfigInfo) {
+ console.log('[App] 娓呴櫎閰嶇疆淇℃伅...');
+ uhfModel.clearConfigInfo();
+ }
+
+ // 寤惰繜鍚庡皾璇曞垵濮嬪寲
+ setTimeout(() => {
+ const moduleType = moduleTypes[moduleTypeIndex];
+ console.log(`[App] 灏濊瘯鍒濆鍖� ${moduleTypeNames[moduleTypeIndex]} (绫诲瀷${moduleType})锛岀${initRetryCount + 1}娆�...`);
+ uhfModel.initUHF(moduleType, (ret) => {
+ console.log('[App] initUHF result:', ret);
+ if (ret && ret.code === 'success') {
+ // 鍒濆鍖栨垚鍔燂紝绛夊緟涓婄數浜嬩欢
+ console.log('[App] initUHF璋冪敤鎴愬姛锛岀瓑寰呬笂鐢典簨浠�...');
+ } else {
+ // 鍒濆鍖栧け璐ワ紝閲嶈瘯
+ setTimeout(() => {
+ tryNextModuleType();
+ }, 2000);
+ }
+ });
+ }, 100);
+ };
+
+ // 寮�濮嬪皾璇曞垵濮嬪寲
+ tryNextModuleType();
+
+ // 鍏ㄥ眬鐩戝惉鎵爜鎸夐敭锛�189銆�190銆�191锛夛紝瑙﹀彂RFID鎵弿
+ let scanKeyDebounceTimer = null; // 闃叉姈瀹氭椂鍣�
+ const handleScanKey = (e) => {
+ const keyCode = e.keyCode;
+ // 鎵爜鎸夐敭锛�189銆�190銆�191
+ if (keyCode === 189 || keyCode === 190 || keyCode === 191) {
+ // 闃叉姈澶勭悊锛岄伩鍏嶅揩閫熸寜閿�
+ if (scanKeyDebounceTimer) {
+ clearTimeout(scanKeyDebounceTimer);
+ }
+
+ scanKeyDebounceTimer = setTimeout(() => {
+ console.log('[App] 鎵爜鎸夐敭鎸変笅锛堥敭鍊�' + keyCode + '锛夛紝瑙﹀彂RFID鎵弿');
+ if (isPowerOn) {
+ // 瑙﹀彂鎵弿
+ uhfModel.startOrStopRFID((ret) => {
+ console.log('[App] startOrStopRFID result:', JSON.stringify(ret));
+ if (ret && ret.code === 'success') {
+ if (ret.msg === 'start') {
+ modal.toast({
+ message: 'RFID鎵弿宸插惎鍔�',
+ duration: 1.5
+ });
+ } else {
+ modal.toast({
+ message: 'RFID鎵弿宸插仠姝�',
+ duration: 1.5
+ });
+ }
+ }
+ });
+ } else {
+ modal.toast({
+ message: 'RFID姝e湪涓婄數锛岃绋嶅��...',
+ duration: 1.5
+ });
+ }
+ }, 300); // 300ms闃叉姈
+ }
+ };
+ // 纭繚plus瀵硅薄瀛樺湪鍚庡啀娣诲姞鎸夐敭鐩戝惉
+ if (typeof plus !== 'undefined' && plus.key) {
+ plus.key.addEventListener('keydown', handleScanKey);
+ // 淇濆瓨鎸夐敭鐩戝惉鍣ㄥ紩鐢紝鐢ㄤ簬娓呯悊
+ this.scanKeyHandler = handleScanKey;
+ this.scanKeyDebounceTimer = scanKeyDebounceTimer;
+ } else {
+ console.warn('[App] plus瀵硅薄鏈垵濮嬪寲锛屾棤娉曟坊鍔犳寜閿洃鍚�');
+ }
+ */
+ // 娉ㄦ剰锛歊FID鍒濆鍖栧凡娉ㄩ噴锛岀敱鍚勪釜椤甸潰鑷繁绠$悊锛堝弬鑰僫DataUHFDemo锛�
+ // #endif
+
+ // 鍏ㄥ眬鐩戝惉鎵爜鎸夐敭锛�189銆�190銆�191锛夛紝瑙﹀彂鍗曟爣绛捐鏃犺繃婊�
+ // #ifdef APP-PLUS
+ let scanKeyDebounceTimer = null; // 闃叉姈瀹氭椂鍣�
+ const handleScanKey = (e) => {
+ const keyCode = e.keyCode;
+ // 鎵爜鎸夐敭锛�189銆�190銆�191
+ if (keyCode === 189 || keyCode === 190 || keyCode === 191) {
+ // 闃叉姈澶勭悊锛岄伩鍏嶅揩閫熸寜閿�
+ if (scanKeyDebounceTimer) {
+ clearTimeout(scanKeyDebounceTimer);
+ }
+
+ scanKeyDebounceTimer = setTimeout(() => {
+ console.log('[App] 鎵爜鎸夐敭鎸変笅锛堥敭鍊�' + keyCode + '锛夛紝瑙﹀彂鍗曟爣绛捐鏃犺繃婊�');
+ // 璋冪敤鍗曟爣绛捐鏃犺繃婊ゅ姛鑳斤紝鑷姩濉叆褰撳墠鐒︾偣杈撳叆妗�
+ rfidScanner.readSingleTagWithoutFilter(null, (tagData) => {
+ if (tagData && tagData.epc) {
+ console.log('[App] 鍗曟爣绛捐鎴愬姛锛孍PC:', tagData.epc);
+ }
+ });
+ }, 300); // 300ms闃叉姈
+ }
+ };
+ // 纭繚plus瀵硅薄瀛樺湪鍚庡啀娣诲姞鎸夐敭鐩戝惉
+ if (typeof plus !== 'undefined' && plus.key) {
+ plus.key.addEventListener('keydown', handleScanKey);
+ console.log('[App] 宸叉坊鍔犳壂鐮佹寜閿洃鍚紙189銆�190銆�191锛�');
+ } else {
+ console.warn('[App] plus瀵硅薄鏈垵濮嬪寲锛屾棤娉曟坊鍔犳寜閿洃鍚�');
+ }
+ // #endif
+
uni.getSystemInfo({
success: function(e) {
+ // 瀹夊叏鍦板鐞嗙郴缁熶俊鎭紝閬垮厤璁块棶涓嶅瓨鍦ㄧ殑灞炴��
+ if (!e) {
+ console.warn('[App] getSystemInfo 杩斿洖绌烘暟鎹�');
+ return;
+ }
+
// #ifndef MP
- Vue.prototype.StatusBar = e.statusBarHeight;
- if (e.platform == 'android') {
- Vue.prototype.CustomBar = e.statusBarHeight + 50;
- } else {
- Vue.prototype.CustomBar = e.statusBarHeight + 45;
- };
+ if (e.statusBarHeight !== undefined) {
+ Vue.prototype.StatusBar = e.statusBarHeight;
+ if (e.platform == 'android') {
+ Vue.prototype.CustomBar = e.statusBarHeight + 50;
+ } else {
+ Vue.prototype.CustomBar = e.statusBarHeight + 45;
+ }
+ }
// #endif
-
+
// #ifdef MP-WEIXIN
- Vue.prototype.StatusBar = e.statusBarHeight;
- let custom = wx.getMenuButtonBoundingClientRect();
- Vue.prototype.Custom = custom;
- Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
+ if (e.statusBarHeight !== undefined) {
+ Vue.prototype.StatusBar = e.statusBarHeight;
+ if (typeof wx !== 'undefined' && wx.getMenuButtonBoundingClientRect) {
+ let custom = wx.getMenuButtonBoundingClientRect();
+ if (custom) {
+ Vue.prototype.Custom = custom;
+ Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
+ }
+ }
+ }
// #endif
-
+
// #ifdef MP-ALIPAY
- Vue.prototype.StatusBar = e.statusBarHeight;
- Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
+ if (e.statusBarHeight !== undefined && e.titleBarHeight !== undefined) {
+ Vue.prototype.StatusBar = e.statusBarHeight;
+ Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
+ }
// #endif
+ },
+ fail: function(err) {
+ console.warn('[App] getSystemInfo 澶辫触:', err);
}
})
-
+
Vue.prototype.ColorList = [{
title: '瀚g孩',
name: 'red',
@@ -110,18 +341,39 @@
},
onHide: function() {
console.log('App Hide')
+ },
+ onError: function(err) {
+ console.log('App Error:', err)
+ },
+ onExit: function() {
+ console.log('App Exit')
+ // #ifdef APP-PLUS
+ // 鍋滄鍏ㄥ眬RFID杈撳叆鍔╂墜
+ stopRFIDInputHelper();
+
+ // 鍏抽棴RFID妯″潡
+ if (this.uhfModel && this.uhfModel.closeUHF) {
+ this.uhfModel.closeUHF();
+ console.log('[App] 鉁� RFID妯″潡宸插叧闂�');
+ }
+ if (this.globalEvent) {
+ this.globalEvent.removeEventListener('POWEREvent');
+ }
+ // #endif
}
}
</script>
<style>
@import "static/css/colorUi/icon.css";
+
/*姣忎釜椤甸潰鍏叡css */
body {
background-color: #f1f1f1;
color: #606266;
font-family: Helvetica Neue, Helvetica, sans-serif;
}
+
.nav-list {
display: flex;
flex-wrap: wrap;
@@ -129,7 +381,7 @@
justify-content: space-between;
margin-top: 20px;
}
-
+
.nav-li {
padding: 30upx;
border-radius: 12upx;
@@ -141,7 +393,7 @@
position: relative;
z-index: 1;
}
-
+
.nav-li::after {
content: "";
position: absolute;
@@ -155,30 +407,30 @@
opacity: 0.2;
transform: scale(0.9, 0.9);
}
-
+
.nav-li.cur {
color: #fff;
background: rgb(94, 185, 94);
box-shadow: 4upx 4upx 6upx rgba(94, 185, 94, 0.4);
}
-
+
.nav-title {
font-size: 32upx;
font-weight: 300;
}
-
+
.nav-title::first-letter {
font-size: 40upx;
margin-right: 4upx;
}
-
+
.nav-name {
font-size: 28upx;
text-transform: Capitalize;
margin-top: 20upx;
position: relative;
}
-
+
.nav-name::before {
content: "";
position: absolute;
@@ -190,7 +442,7 @@
right: 0;
opacity: 0.5;
}
-
+
.nav-name::after {
content: "";
position: absolute;
@@ -202,13 +454,13 @@
right: 40upx;
opacity: 0.3;
}
-
+
.nav-name::first-letter {
font-weight: bold;
font-size: 36upx;
margin-right: 1px;
}
-
+
.nav-li text {
position: absolute;
right: 30upx;
@@ -219,36 +471,36 @@
text-align: center;
line-height: 60upx;
}
-
+
.text-light {
font-weight: 300;
}
-
+
@keyframes show {
0% {
transform: translateY(-50px);
}
-
+
60% {
transform: translateY(40upx);
}
-
+
100% {
transform: translateY(0px);
}
}
-
+
@-webkit-keyframes show {
0% {
transform: translateY(-50px);
}
-
+
60% {
transform: translateY(40upx);
}
-
+
100% {
transform: translateY(0px);
}
}
-</style>
+</style>
\ No newline at end of file
diff --git a/common/idata-rfid.js b/common/idata-rfid.js
new file mode 100644
index 0000000..4e1fe7f
--- /dev/null
+++ b/common/idata-rfid.js
@@ -0,0 +1,501 @@
+/**
+ * iData UHF RFID 宸ュ叿绫�
+ * 灏佽 iData-UHFPlugin 鎻掍欢鐨勬墍鏈夊姛鑳�
+ */
+
+// #ifdef APP-PLUS
+const uhfModel = uni.requireNativePlugin("iData-UHFPlugin-UHFModule");
+const globalEvent = uni.requireNativePlugin('globalEvent');
+const modal = uni.requireNativePlugin('modal');
+// #endif
+
+class iDataRFID {
+ constructor() {
+ this.isInitialized = false;
+ this.isScanning = false;
+ this.powerStatus = 'disconnected'; // connected/disconnected
+ this.scanCallback = null;
+ this.powerCallback = null;
+ }
+
+ /**
+ * 娓呴櫎閰嶇疆淇℃伅锛堝湪鍒濆鍖栧墠璋冪敤锛岄伩鍏�"Please use the 'clearConfigInfo' function to clear the current instance first"閿欒锛�
+ */
+ clearConfigInfo() {
+ // #ifdef APP-PLUS
+ if (!uhfModel) {
+ console.error('[iDataRFID] 鎻掍欢鏈壘鍒�');
+ return;
+ }
+ console.log('[iDataRFID] 娓呴櫎閰嶇疆淇℃伅...');
+ if (uhfModel.clearConfigInfo) {
+ uhfModel.clearConfigInfo();
+ }
+ // #endif
+ }
+
+ /**
+ * 鍒濆鍖朥HF妯″潡
+ * @param {Number} mode - 1涓篠LR妯″潡锛�0涓篣M妯″潡锛�2涓篏X妯″潡
+ * @param {Function} callback - 鍥炶皟鍑芥暟
+ */
+ initUHF(mode, callback) {
+ // #ifdef APP-PLUS
+ if (!uhfModel) {
+ console.error('[iDataRFID] 鎻掍欢鏈壘鍒�');
+ if (callback) callback({ code: 'error', msg: '鎻掍欢鏈壘鍒�' });
+ return;
+ }
+
+ // 鍏堟竻闄ら厤缃俊鎭紝閬垮厤"Please use the 'clearConfigInfo' function to clear the current instance first"閿欒
+ this.clearConfigInfo();
+
+ // 寤惰繜涓�涓嬪啀鍒濆鍖栵紝纭繚娓呴櫎鎿嶄綔瀹屾垚
+ setTimeout(() => {
+ console.log('[iDataRFID] initUHF mode:', mode);
+ uhfModel.initUHF(mode, (ret) => {
+ console.log('[iDataRFID] initUHF result:', ret);
+ if (typeof ret === 'string' && ret.includes('success')) {
+ this.isInitialized = true;
+ }
+ if (callback) callback(ret);
+ });
+ }, 100);
+ // #endif
+ // #ifndef APP-PLUS
+ if (callback) callback({ code: 'error', msg: '浠呮敮鎸丄PP鐜' });
+ // #endif
+ }
+
+ /**
+ * 鐩戝惉妯″潡涓婄數缁撴灉
+ * @param {Function} callback - 鍥炶皟鍑芥暟 (e) => {}
+ */
+ onPowerEvent(callback) {
+ // #ifdef APP-PLUS
+ if (!globalEvent) {
+ console.error('[iDataRFID] globalEvent鏈壘鍒�');
+ return;
+ }
+ this.powerCallback = callback;
+ globalEvent.addEventListener('POWEREvent', (e) => {
+ console.log('[iDataRFID] POWEREvent:', JSON.stringify(e));
+ if (e && e.status === 'connected') {
+ this.powerStatus = 'connected';
+ } else {
+ this.powerStatus = 'disconnected';
+ }
+ if (callback) callback(e);
+ });
+ // #endif
+ }
+
+ /**
+ * 鐩戝惉UHF鐩樼偣鎵弿缁撴灉
+ * @param {Function} callback - 鍥炶皟鍑芥暟 (e) => {}
+ */
+ onScanEvent(callback) {
+ // #ifdef APP-PLUS
+ if (!globalEvent) {
+ console.error('[iDataRFID] globalEvent鏈壘鍒�');
+ return;
+ }
+ this.scanCallback = callback;
+ globalEvent.addEventListener('iDataUHFEvent', (e) => {
+ console.log('[iDataRFID] ========== 鎵弿鍒版爣绛� ==========');
+ console.log('[iDataRFID] iDataUHFEvent:', JSON.stringify(e));
+ console.log('[iDataRFID] EPC:', e ? e.epc : 'undefined');
+ console.log('[iDataRFID] TID:', e ? e.tid : 'undefined');
+ console.log('[iDataRFID] ====================================');
+ if (callback) callback(e);
+ });
+ // #endif
+ }
+
+ /**
+ * 寮�濮�/缁撴潫鎵弿
+ * @param {Function} callback - 鍥炶皟鍑芥暟
+ */
+ startOrStopRFID(callback) {
+ // #ifdef APP-PLUS
+ if (!uhfModel) {
+ if (callback) callback({ code: 'error', msg: '鎻掍欢鏈壘鍒�' });
+ return;
+ }
+
+ console.log('[iDataRFID] ========== 寮�濮�/鍋滄鎵弿 ==========');
+ console.log('[iDataRFID] 褰撳墠鎵弿鐘舵��:', this.isScanning);
+ console.log('[iDataRFID] 褰撳墠涓婄數鐘舵��:', this.powerStatus);
+ uhfModel.startOrStopRFID((ret) => {
+ console.log('[iDataRFID] startOrStopRFID result:', JSON.stringify(ret));
+ if (ret && ret.code === 'success') {
+ if (ret.msg === 'start') {
+ this.isScanning = true;
+ console.log('[iDataRFID] 鉁� 鎵弿宸插惎鍔�');
+ console.log('[iDataRFID] 銆愭彁绀恒�戣灏嗘爣绛炬斁鍦ㄨ鍙栬寖鍥村唴锛堝缓璁�5-10cm锛�');
+ console.log('[iDataRFID] 銆愭彁绀恒�戝鏋滄壂鎻忎笉鍒版爣绛撅紝璇锋鏌ワ細');
+ console.log('[iDataRFID] 1. 鍔熺巼璁剧疆鏄惁瓒冲锛堝缓璁�20-30锛�');
+ console.log('[iDataRFID] 2. 鏍囩鏄惁鍦ㄨ鍙栬寖鍥村唴');
+ console.log('[iDataRFID] 3. 棰戠巼璁剧疆鏄惁姝g‘');
+ } else {
+ this.isScanning = false;
+ console.log('[iDataRFID] 鉁� 鎵弿宸插仠姝�');
+ }
+ } else {
+ console.error('[iDataRFID] 鉁� 鎵弿鎿嶄綔澶辫触:', ret ? ret.msg : '鏈煡閿欒');
+ }
+ console.log('[iDataRFID] ====================================');
+ if (callback) callback(ret);
+ });
+ // #endif
+ // #ifndef APP-PLUS
+ if (callback) callback({ code: 'error', msg: '浠呮敮鎸丄PP鐜' });
+ // #endif
+ }
+
+ /**
+ * 璁剧疆鐩樼偣鏍囩杩斿洖鐨勬暟鎹唴瀹规ā寮�
+ * @param {Number} mode - 0鍙鍙朎PC, 1璇诲彇EPC鍜孴ID
+ * @param {Function} callback - 鍥炶皟鍑芥暟
+ */
+ readTagModeSet(mode, callback) {
+ // #ifdef APP-PLUS
+ if (!uhfModel) {
+ if (callback) callback('鎻掍欢鏈壘鍒�');
+ return;
+ }
+ uhfModel.readTagModeSet(mode, (ret) => {
+ console.log('[iDataRFID] readTagModeSet result:', ret);
+ if (callback) callback(ret);
+ });
+ // #endif
+ }
+
+ /**
+ * 鑾峰彇鐩樼偣鏍囩杩斿洖鐨勬暟鎹唴瀹规ā寮�
+ * @param {Function} callback - 鍥炶皟鍑芥暟
+ */
+ readTagModeGet(callback) {
+ // #ifdef APP-PLUS
+ if (!uhfModel) {
+ if (callback) callback('鎻掍欢鏈壘鍒�');
+ return;
+ }
+ uhfModel.readTagModeGet((ret) => {
+ console.log('[iDataRFID] readTagModeGet result:', ret);
+ if (callback) callback(ret);
+ });
+ // #endif
+ }
+
+ /**
+ * 绉婚櫎浜嬩欢鐩戝惉鍣紙鍙傝�冪ず渚嬮」鐩級
+ */
+ removeEventListeners() {
+ // #ifdef APP-PLUS
+ if (globalEvent) {
+ globalEvent.removeEventListener('POWEREvent');
+ globalEvent.removeEventListener('iDataUHFEvent');
+ console.log('[iDataRFID] 浜嬩欢鐩戝惉鍣ㄥ凡绉婚櫎');
+ }
+ this.powerCallback = null;
+ this.scanCallback = null;
+ // #endif
+ }
+
+ /**
+ * 妯″潡涓嬬數
+ */
+ closeUHF() {
+ // #ifdef APP-PLUS
+ if (!uhfModel) {
+ console.error('[iDataRFID] 鎻掍欢鏈壘鍒�');
+ return;
+ }
+ uhfModel.closeUHF();
+ this.isInitialized = false;
+ this.isScanning = false;
+ this.powerStatus = 'disconnected';
+
+ // 绉婚櫎浜嬩欢鐩戝惉
+ this.removeEventListeners();
+ // #endif
+ }
+
+ /**
+ * 鍗曟爣绛捐鍙栵紝鏃犺繃婊ゆ潯浠�
+ * @param {Number} readBank - 0->RESERVED,1->EPC,2->TID,3->USR
+ * @param {Number} startBlock - 璧峰鍦板潃(Word绫诲瀷)
+ * @param {Number} len - 鏁版嵁闀垮害(Word绫诲瀷)
+ * @param {String} pwd - 璁块棶瀵嗙爜锛岄粯璁�00000000
+ * @param {Function} callback - 鍥炶皟鍑芥暟
+ */
+ readTagWithoutFilter(readBank, startBlock, len, pwd, callback) {
+ // #ifdef APP-PLUS
+ if (!uhfModel) {
+ console.error('[iDataRFID] readTagWithoutFilter: 鎻掍欢鏈壘鍒�');
+ if (callback) callback({ code: 'error', msg: '鎻掍欢鏈壘鍒�' });
+ return;
+ }
+ console.log('[iDataRFID] readTagWithoutFilter 璋冪敤鍙傛暟:');
+ console.log('[iDataRFID] readBank:', readBank, '(' + ['RESERVED', 'EPC', 'TID', 'USR'][readBank] + ')');
+ console.log('[iDataRFID] startBlock:', startBlock);
+ console.log('[iDataRFID] len:', len);
+ console.log('[iDataRFID] pwd:', pwd || '00000000');
+ uhfModel.readTagWithoutFilter(readBank, startBlock, len, pwd || '00000000', (ret) => {
+ console.log('[iDataRFID] readTagWithoutFilter 杩斿洖缁撴灉:');
+ console.log('[iDataRFID] 瀹屾暣缁撴灉:', JSON.stringify(ret));
+ console.log('[iDataRFID] code:', ret ? ret.code : 'undefined');
+ console.log('[iDataRFID] msg:', ret ? ret.msg : 'undefined');
+ console.log('[iDataRFID] data:', ret ? ret.data : 'undefined');
+ if (ret && ret.code === 'fail') {
+ console.error('[iDataRFID] 璇诲彇鏍囩澶辫触!');
+ console.error('[iDataRFID] 澶辫触鍘熷洜:', ret.msg || '鏈煡閿欒');
+ console.error('[iDataRFID] 閿欒璇︽儏:', JSON.stringify(ret));
+ }
+ if (callback) callback(ret);
+ });
+ // #endif
+ }
+
+ /**
+ * 鍗曟爣绛惧啓鍏ワ紝鏃犺繃婊ゆ潯浠�
+ * @param {Number} writeBank - 0->RESERVED,1->EPC,2->TID,3->USR
+ * @param {Number} startBlock - 璧峰鍦板潃(Word绫诲瀷)
+ * @param {String} writeData - 鍐欏叆鐨勬暟鎹�
+ * @param {String} pwd - 璁块棶瀵嗙爜锛岄粯璁�00000000
+ * @param {Function} callback - 鍥炶皟鍑芥暟
+ */
+ writeTagWithoutFilter(writeBank, startBlock, writeData, pwd, callback) {
+ // #ifdef APP-PLUS
+ if (!uhfModel) {
+ if (callback) callback({ code: 'error', msg: '鎻掍欢鏈壘鍒�' });
+ return;
+ }
+ uhfModel.writeTagWithoutFilter(writeBank, startBlock, writeData, pwd || '00000000', (ret) => {
+ console.log('[iDataRFID] writeTagWithoutFilter result:', JSON.stringify(ret));
+ if (callback) callback(ret);
+ });
+ // #endif
+ }
+
+ /**
+ * 鍗曟爣绛捐鍙栵紝鏈夎繃婊ゆ潯浠�
+ * @param {Object} options - 鍙傛暟瀵硅薄
+ * @param {Function} callback - 鍥炶皟鍑芥暟
+ */
+ readTagWithFilter(options, callback) {
+ // #ifdef APP-PLUS
+ if (!uhfModel) {
+ if (callback) callback({ code: 'error', msg: '鎻掍欢鏈壘鍒�' });
+ return;
+ }
+ const {
+ fBank, fStartBlock, fLen, fData,
+ readBank, startBlock, len, pwd
+ } = options;
+ uhfModel.readTagWithFilter(fBank, fStartBlock, fLen, fData, readBank, startBlock, len, pwd || '00000000', (ret) => {
+ console.log('[iDataRFID] readTagWithFilter result:', JSON.stringify(ret));
+ if (callback) callback(ret);
+ });
+ // #endif
+ }
+
+ /**
+ * 鍗曟爣绛惧啓鍏ワ紝鏈夎繃婊ゆ潯浠�
+ * @param {Object} options - 鍙傛暟瀵硅薄
+ * @param {Function} callback - 鍥炶皟鍑芥暟
+ */
+ writeTagWithFilter(options, callback) {
+ // #ifdef APP-PLUS
+ if (!uhfModel) {
+ if (callback) callback({ code: 'error', msg: '鎻掍欢鏈壘鍒�' });
+ return;
+ }
+ const {
+ fBank, fStartBlock, fLen, fData,
+ writeBank, startBlock, writeData, pwd
+ } = options;
+ uhfModel.writeTagWithFilter(fBank, fStartBlock, fLen, fData, writeBank, startBlock, writeData, pwd || '00000000', (ret) => {
+ console.log('[iDataRFID] writeTagWithFilter result:', JSON.stringify(ret));
+ if (callback) callback(ret);
+ });
+ // #endif
+ }
+
+ /**
+ * 鐩樼偣妯″紡璁剧疆
+ * @param {Number} mode - UM:0澶氭爣绛炬ā寮�,1蹇洏妯″紡,2浣庡姛鑰楁ā寮� | SLR:0寮傛妯″紡,2鏅鸿兘鎺ф俯,3鏂板揩閫熸ā寮�,4鏅�氭ā寮�
+ * @param {Function} callback - 鍥炶皟鍑芥暟
+ */
+ inventoryModeSet(mode, callback) {
+ // #ifdef APP-PLUS
+ if (!uhfModel) {
+ if (callback) callback('鎻掍欢鏈壘鍒�');
+ return;
+ }
+ uhfModel.inventoryModeSet(mode, (ret) => {
+ console.log('[iDataRFID] inventoryModeSet result:', ret);
+ if (callback) callback(ret);
+ });
+ // #endif
+ }
+
+ /**
+ * 鐩樼偣妯″紡鑾峰彇
+ * @param {Function} callback - 鍥炶皟鍑芥暟
+ */
+ inventoryModeGet(callback) {
+ // #ifdef APP-PLUS
+ if (!uhfModel) {
+ if (callback) callback('鎻掍欢鏈壘鍒�');
+ return;
+ }
+ uhfModel.inventoryModeGet((ret) => {
+ console.log('[iDataRFID] inventoryModeGet result:', ret);
+ if (callback) callback(ret);
+ });
+ // #endif
+ }
+
+ /**
+ * 鍗犵┖姣斿弬鏁拌缃�
+ * @param {Number} scanTime - 鐩樼偣鏃堕棿
+ * @param {Number} waitTime - 浼戠湢鏃堕棿
+ * @param {Boolean} save - 鏄惁鏂數淇濆瓨閰嶇疆
+ * @param {Function} callback - 鍥炶皟鍑芥暟
+ */
+ inventoryWaitTimeSet(scanTime, waitTime, save, callback) {
+ // #ifdef APP-PLUS
+ if (!uhfModel) {
+ if (callback) callback('鎻掍欢鏈壘鍒�');
+ return;
+ }
+ uhfModel.inventoryWaitTimeSet(scanTime, waitTime, save, (ret) => {
+ console.log('[iDataRFID] inventoryWaitTimeSet result:', ret);
+ if (callback) callback(ret);
+ });
+ // #endif
+ }
+
+ /**
+ * 鍗犵┖姣斿弬鏁拌幏鍙�
+ * @param {Function} callback - 鍥炶皟鍑芥暟
+ */
+ inventoryWaitTimeGet(callback) {
+ // #ifdef APP-PLUS
+ if (!uhfModel) {
+ if (callback) callback('鎻掍欢鏈壘鍒�');
+ return;
+ }
+ uhfModel.inventoryWaitTimeGet((ret) => {
+ console.log('[iDataRFID] inventoryWaitTimeGet result:', ret);
+ if (callback) callback(ret);
+ });
+ // #endif
+ }
+
+ /**
+ * 澶╃嚎鍔熺巼鍙傛暟璁剧疆
+ * @param {Number} power - 0-33
+ * @param {Function} callback - 鍥炶皟鍑芥暟
+ */
+ setPower(power, callback) {
+ // #ifdef APP-PLUS
+ if (!uhfModel) {
+ if (callback) callback('鎻掍欢鏈壘鍒�');
+ return;
+ }
+ uhfModel.setPower(power, (ret) => {
+ console.log('[iDataRFID] setPower result:', ret);
+ if (callback) callback(ret);
+ });
+ // #endif
+ }
+
+ /**
+ * 澶╃嚎鍔熺巼鍙傛暟鑾峰彇
+ * @param {Function} callback - 鍥炶皟鍑芥暟
+ */
+ getPower(callback) {
+ // #ifdef APP-PLUS
+ if (!uhfModel) {
+ if (callback) callback('鎻掍欢鏈壘鍒�');
+ return;
+ }
+ uhfModel.getPower((ret) => {
+ console.log('[iDataRFID] getPower result:', ret);
+ if (callback) callback(ret);
+ });
+ // #endif
+ }
+
+ /**
+ * 棰戠巼璁剧疆
+ * @param {Number} mode - 0:涓浗(840-845MHz),1:涓浗(920-925MHz),2:娆ф床(865-868MHz),3:缇庡浗(902-928MHz)
+ * @param {Function} callback - 鍥炶皟鍑芥暟
+ */
+ setFrequencyMode(mode, callback) {
+ // #ifdef APP-PLUS
+ if (!uhfModel) {
+ if (callback) callback('鎻掍欢鏈壘鍒�');
+ return;
+ }
+ uhfModel.setFrequencyMode(mode, (ret) => {
+ console.log('[iDataRFID] setFrequencyMode result:', ret);
+ if (callback) callback(ret);
+ });
+ // #endif
+ }
+
+ /**
+ * 棰戠巼鑾峰彇
+ * @param {Function} callback - 鍥炶皟鍑芥暟
+ */
+ getFrequencyMode(callback) {
+ // #ifdef APP-PLUS
+ if (!uhfModel) {
+ if (callback) callback('鎻掍欢鏈壘鍒�');
+ return;
+ }
+ uhfModel.getFrequencyMode((ret) => {
+ console.log('[iDataRFID] getFrequencyMode result:', ret);
+ if (callback) callback(ret);
+ });
+ // #endif
+ }
+
+ /**
+ * 鏄剧ずToast娑堟伅
+ * @param {String} message - 娑堟伅鍐呭
+ * @param {Number} duration - 鎸佺画鏃堕棿锛堢锛�
+ */
+ showToast(message, duration = 1.5) {
+ // #ifdef APP-PLUS
+ if (modal) {
+ modal.toast({
+ message: message,
+ duration: duration
+ });
+ } else {
+ uni.showToast({
+ title: message,
+ icon: 'none',
+ duration: duration * 1000
+ });
+ }
+ // #endif
+ // #ifndef APP-PLUS
+ uni.showToast({
+ title: message,
+ icon: 'none',
+ duration: duration * 1000
+ });
+ // #endif
+ }
+}
+
+// 鍒涘缓鍗曚緥瀹炰緥
+const idataRFID = new iDataRFID();
+
+export default idataRFID;
diff --git a/common/rfid-input-helper.js b/common/rfid-input-helper.js
new file mode 100644
index 0000000..1262093
--- /dev/null
+++ b/common/rfid-input-helper.js
@@ -0,0 +1,354 @@
+/**
+ * RFID杈撳叆妗嗚嚜鍔ㄥ~鍏ュ姪鎵�
+ * 鍏ㄥ眬鐩戝惉RFID鎵弿鎸夐敭锛�189銆�190銆�191锛夛紝鑷姩璇诲彇鏍囩骞跺~鍏ュ綋鍓嶇劍鐐硅緭鍏ユ
+ */
+
+// #ifdef APP-PLUS
+let uhfModel = null;
+let globalEvent = null;
+let modal = null;
+let isPowerOn = false;
+let isScanning = false; // 鏄惁姝e湪鎵弿涓�
+let scanKeyHandler = null; // 鎸夐敭鐩戝惉鍣ㄥ紩鐢�
+
+/**
+ * 鍒濆鍖朢FID鍔╂墜锛堝彧鍒濆鍖栨彃浠跺紩鐢ㄥ拰浜嬩欢鐩戝惉锛屼笉鍒濆鍖朢FID妯″潡锛�
+ * RFID妯″潡鐢盇pp.vue鍏ㄥ眬鍒濆鍖栵紝杩欓噷鍙礋璐g洃鍚寜閿拰璇诲彇鏍囩
+ */
+function initRFIDForInput() {
+ try {
+ uhfModel = uni.requireNativePlugin("iData-UHFPlugin-UHFModule");
+ globalEvent = uni.requireNativePlugin('globalEvent');
+ modal = uni.requireNativePlugin('modal');
+
+ if (!uhfModel) {
+ console.warn('[RFIDInputHelper] RFID鎻掍欢鏈壘鍒�');
+ return false;
+ }
+
+ // 鐩戝惉涓婄數浜嬩欢锛堢洃鍚叏灞�涓婄數鐘舵�侊紝RFID妯″潡鐢盇pp.vue鍒濆鍖栵級
+ globalEvent.addEventListener('POWEREvent', function(e) {
+ console.log('[RFIDInputHelper] POWEREvent:', JSON.stringify(e));
+ if (e && e.status === 'connected') {
+ isPowerOn = true;
+ console.log('[RFIDInputHelper] 鉁� RFID妯″潡宸蹭笂鐢�');
+ } else {
+ isPowerOn = false;
+ console.log('[RFIDInputHelper] 鉁� RFID妯″潡鏈笂鐢�');
+ }
+ });
+
+ // 娉ㄦ剰锛歊FID妯″潡鐢盇pp.vue鍦╫nLaunch鏃跺叏灞�鍒濆鍖�
+ // 杩欓噷鍙礋璐g洃鍚寜閿拰璇诲彇鏍囩锛屼笉鍒濆鍖朢FID妯″潡
+
+ return true;
+ } catch (error) {
+ console.error('[RFIDInputHelper] 鍒濆鍖栧け璐�:', error);
+ return false;
+ }
+}
+
+/**
+ * 妫�鏌ュ綋鍓嶉〉闈㈡槸鍚︽槸娴嬭瘯椤甸潰
+ */
+function isTestPage() {
+ try {
+ const pages = getCurrentPages();
+ if (pages.length > 0) {
+ const currentPage = pages[pages.length - 1];
+ const route = currentPage.route || '';
+ // 濡傛灉鏄祴璇曢〉闈紝涓嶅惎鐢ㄥ叏灞�RFID鎵弿
+ return route.includes('rfid/uhftest') || route.includes('rfid/uhftest2');
+ }
+ return false;
+ } catch (error) {
+ console.error('[RFIDInputHelper] 妫�鏌ラ〉闈㈠け璐�:', error);
+ return false;
+ }
+}
+
+/**
+ * 璇诲彇RFID鏍囩锛堝崟鏍囩璇伙紝鏃犺繃婊わ級
+ */
+function readRFIDTag() {
+ if (!uhfModel) {
+ // 濡傛灉妯″潡鏈垵濮嬪寲锛屽皾璇曞垵濮嬪寲
+ uhfModel = uni.requireNativePlugin("iData-UHFPlugin-UHFModule");
+ if (!uhfModel) {
+ console.warn('[RFIDInputHelper] RFID妯″潡鏈壘鍒�');
+ modal.toast({
+ message: 'RFID妯″潡鏈壘鍒�',
+ duration: 1.5
+ });
+ return;
+ }
+ }
+
+ // 妫�鏌FID鏄惁宸蹭笂鐢碉紙RFID妯″潡鐢盇pp.vue鍏ㄥ眬鍒濆鍖栵級
+ if (!isPowerOn) {
+ modal.toast({
+ message: 'RFID姝e湪涓婄數锛岃绋嶅��...',
+ duration: 1.5
+ });
+ return;
+ }
+
+ if (isScanning) {
+ console.log('[RFIDInputHelper] 姝e湪鎵弿涓紝璺宠繃');
+ return;
+ }
+
+ isScanning = true;
+ console.log('[RFIDInputHelper] 寮�濮嬭鍙朢FID鏍囩...');
+
+ /**
+ * readBank:0->RESERVED,1->EPC,2->TID,3->USR
+ * startBlock:璇诲彇鐨勮捣濮嬪湴鍧�(Word绫诲瀷)
+ * len:璇诲彇鐨勬暟鎹暱搴�(Word绫诲瀷锛屽ぇ浜�0)
+ * pwd:璁块棶瀵嗙爜锛岄粯璁ゅ瘑鐮佷负锛�00000000
+ * 娉ㄦ剰锛歐ord绫诲瀷锛屼竴涓暱搴﹁〃绀烘爣绛惧瓨鍌�4浣嶅瓧绗�
+ */
+ uhfModel.readTagWithoutFilter(1, 2, 6, "00000000", (ret) => {
+ isScanning = false;
+ console.log('[RFIDInputHelper] readTagWithoutFilter result:', ret);
+
+ if (ret && typeof ret === 'string') {
+ // 瑙f瀽杩斿洖缁撴灉锛屾彁鍙朎PC
+ // 杩斿洖鏍煎紡鍙兘鏄細success EPC:XXXXXXXX 鎴栫被浼兼牸寮�
+ let epc = '';
+ if (ret.includes('success') || ret.includes('EPC')) {
+ // 灏濊瘯鎻愬彇EPC鍊�
+ const epcMatch = ret.match(/EPC[:\s]+([A-F0-9]+)/i);
+ if (epcMatch && epcMatch[1]) {
+ epc = epcMatch[1];
+ } else {
+ // 濡傛灉娌℃湁鍖归厤鍒帮紝灏濊瘯鎻愬彇16杩涘埗瀛楃涓�
+ const hexMatch = ret.match(/([A-F0-9]{16,})/i);
+ if (hexMatch && hexMatch[1]) {
+ epc = hexMatch[1];
+ }
+ }
+ }
+
+ if (epc) {
+ console.log('[RFIDInputHelper] 鉁� 璇诲彇鍒版爣绛綞PC:', epc);
+ // 鑷姩濉叆褰撳墠鐒︾偣杈撳叆妗�
+ fillCurrentInput(epc);
+ modal.toast({
+ message: '宸茶鍙栨爣绛�',
+ duration: 1.5
+ });
+ } else {
+ console.warn('[RFIDInputHelper] 鏃犳硶瑙f瀽EPC锛岃繑鍥炵粨鏋�:', ret);
+ // 濡傛灉杩斿洖鐨勬槸澶辫触娑堟伅锛岀洿鎺ユ樉绀�
+ if (ret.includes('fail') || ret.includes('澶辫触')) {
+ modal.toast({
+ message: '璇诲彇澶辫触锛岃閲嶈瘯',
+ duration: 1.5
+ });
+ } else {
+ // 灏濊瘯鐩存帴浣跨敤杩斿洖鐨勫瓧绗︿覆浣滀负EPC
+ const cleanRet = ret.trim();
+ if (cleanRet.length >= 8) {
+ fillCurrentInput(cleanRet);
+ modal.toast({
+ message: '宸茶鍙栨爣绛�',
+ duration: 1.5
+ });
+ } else {
+ modal.toast({
+ message: '璇诲彇澶辫触锛岃閲嶈瘯',
+ duration: 1.5
+ });
+ }
+ }
+ }
+ } else if (ret && typeof ret === 'object') {
+ // 濡傛灉杩斿洖鐨勬槸瀵硅薄鏍煎紡
+ if (ret.code === 'success' && ret.data) {
+ const epc = ret.data.epc || ret.data;
+ if (epc) {
+ fillCurrentInput(epc);
+ modal.toast({
+ message: '宸茶鍙栨爣绛�',
+ duration: 1.5
+ });
+ } else {
+ modal.toast({
+ message: '璇诲彇澶辫触锛岃閲嶈瘯',
+ duration: 1.5
+ });
+ }
+ } else {
+ modal.toast({
+ message: '璇诲彇澶辫触锛岃閲嶈瘯',
+ duration: 1.5
+ });
+ }
+ } else {
+ console.warn('[RFIDInputHelper] 璇诲彇澶辫触:', ret);
+ modal.toast({
+ message: '璇诲彇澶辫触锛岃閲嶈瘯',
+ duration: 1.5
+ });
+ }
+ });
+}
+
+/**
+ * 鑷姩濉叆褰撳墠鐒︾偣杈撳叆妗�
+ */
+function fillCurrentInput(epc) {
+ try {
+ console.log('[RFIDInputHelper] 灏濊瘯濉叆EPC鍒拌緭鍏ユ:', epc);
+
+ // 鑾峰彇褰撳墠椤甸潰瀹炰緥
+ const pages = getCurrentPages();
+ if (pages.length === 0) {
+ console.warn('[RFIDInputHelper] 娌℃湁椤甸潰瀹炰緥');
+ return;
+ }
+
+ const currentPage = pages[pages.length - 1];
+ if (!currentPage || !currentPage.$vm) {
+ console.warn('[RFIDInputHelper] 椤甸潰瀹炰緥鏃犳晥');
+ return;
+ }
+
+ const vm = currentPage.$vm;
+ console.log('[RFIDInputHelper] 褰撳墠椤甸潰:', currentPage.route);
+
+ // 瀹氫箟杈撳叆妗嗗瓧娈靛拰瀵瑰簲鐨勭劍鐐圭姸鎬佸瓧娈�
+ // 鏍煎紡锛歿 瀛楁鍚�: 鐒︾偣鐘舵�佸瓧娈靛悕 }
+ const inputFieldMap = [
+ { field: 'barcode', focusField: 'barcodeFocus' },
+ { field: 'matnr', focusField: 'matFocus' },
+ { field: 'sourceSite', focusField: 'sourceSiteFocus' },
+ { field: 'orderNo', focusField: 'orderNoFocus' },
+ { field: 'targetSite', focusField: 'targetSiteFocus' },
+ { field: 'locNo', focusField: 'locNoFocus' }
+ ];
+
+ // 鍙煡鎵炬湁鐒︾偣鐨勮緭鍏ユ锛堝厜鏍囨墍鍦ㄧ殑杈撳叆妗嗭級
+ let focusedField = null;
+ for (let item of inputFieldMap) {
+ if (vm[item.field] !== undefined) {
+ // 妫�鏌ユ槸鍚︽湁鐒︾偣鐘舵�佸瓧娈碉紝骞朵笖鐒︾偣涓簍rue
+ if (vm[item.focusField] === true) {
+ focusedField = item.field;
+ console.log(`[RFIDInputHelper] 鉁� 鎵惧埌鏈夌劍鐐圭殑杈撳叆妗�: ${item.field}`);
+ break;
+ }
+ }
+ }
+
+ // 鍙~鍏ユ湁鐒︾偣鐨勮緭鍏ユ锛屽鏋滄病鏈夌劍鐐瑰垯涓嶅~鍏�
+ if (focusedField) {
+ console.log(`[RFIDInputHelper] 濉叆鏈夌劍鐐圭殑杈撳叆妗� ${focusedField}:`, epc);
+ vm[focusedField] = epc;
+ // 瑙﹀彂input浜嬩欢锛岀‘淇濋〉闈㈤�昏緫鑳藉搷搴�
+ if (vm.$nextTick) {
+ vm.$nextTick(() => {
+ // 濡傛灉椤甸潰鏈夊搴旂殑input澶勭悊鏂规硶锛屽彲浠ユ墜鍔ㄨЕ鍙�
+ if (focusedField === 'barcode' && typeof vm.barcodeInput === 'function') {
+ vm.barcodeInput();
+ } else if (focusedField === 'matnr' && typeof vm.findMat === 'function') {
+ vm.findMat();
+ }
+ });
+ }
+ } else {
+ console.warn('[RFIDInputHelper] 鏈壘鍒版湁鐒︾偣鐨勮緭鍏ユ锛屼笉濉叆浠讳綍杈撳叆妗�');
+ modal.toast({
+ message: '璇峰厛鐐瑰嚮杈撳叆妗嗚幏寰楃劍鐐�',
+ duration: 1.5
+ });
+ }
+ } catch (error) {
+ console.error('[RFIDInputHelper] 鑷姩濉叆澶辫触:', error);
+ }
+}
+
+/**
+ * 鐩戝惉鎵爜鎸夐敭
+ */
+function setupScanKeyListener() {
+ if (scanKeyHandler) {
+ console.log('[RFIDInputHelper] 鎸夐敭鐩戝惉鍣ㄥ凡瀛樺湪');
+ return;
+ }
+
+ if (typeof plus === 'undefined' || !plus.key) {
+ console.warn('[RFIDInputHelper] plus瀵硅薄鏈垵濮嬪寲锛屾棤娉曟坊鍔犳寜閿洃鍚�');
+ return;
+ }
+
+ scanKeyHandler = function(e) {
+ const keyCode = e.keyCode;
+
+ // 鎵爜鎸夐敭锛�189銆�190銆�191
+ if (keyCode === 189 || keyCode === 190 || keyCode === 191) {
+ // 濡傛灉鏄祴璇曢〉闈紝涓嶅鐞嗭紙璁╂祴璇曢〉闈㈣嚜宸卞鐞嗭級
+ if (isTestPage()) {
+ console.log('[RFIDInputHelper] 娴嬭瘯椤甸潰锛岃烦杩囧叏灞�RFID鎵弿');
+ return;
+ }
+
+ console.log('[RFIDInputHelper] 鎵爜鎸夐敭鎸変笅锛堥敭鍊�' + keyCode + '锛夛紝瑙﹀彂RFID鎵弿');
+ readRFIDTag();
+ }
+ };
+
+ plus.key.addEventListener('keydown', scanKeyHandler);
+ console.log('[RFIDInputHelper] 鉁� 鎸夐敭鐩戝惉鍣ㄥ凡娣诲姞');
+}
+
+/**
+ * 绉婚櫎鎸夐敭鐩戝惉
+ */
+function removeScanKeyListener() {
+ if (scanKeyHandler && typeof plus !== 'undefined' && plus.key) {
+ plus.key.removeEventListener('keydown', scanKeyHandler);
+ scanKeyHandler = null;
+ console.log('[RFIDInputHelper] 鉁� 鎸夐敭鐩戝惉鍣ㄥ凡绉婚櫎');
+ }
+}
+
+/**
+ * 鍏抽棴RFID妯″潡锛堟敞鎰忥細RFID妯″潡鐢盇pp.vue绠$悊锛岃繖閲屼笉鍏抽棴锛�
+ */
+function closeRFID() {
+ // RFID妯″潡鐢盇pp.vue鍦╫nExit鏃跺叧闂紝杩欓噷涓嶉渶瑕佸叧闂�
+ console.log('[RFIDInputHelper] RFID妯″潡鐢盇pp.vue绠$悊锛屼笉鍦ㄦ澶勫叧闂�');
+}
+
+/**
+ * 鍚姩鍏ㄥ眬RFID杈撳叆鍔╂墜
+ */
+export function startRFIDInputHelper() {
+ // #ifdef APP-PLUS
+ console.log('[RFIDInputHelper] 鍚姩RFID杈撳叆鍔╂墜...');
+
+ // 鍒濆鍖朢FID妯″潡
+ if (initRFIDForInput()) {
+ // 寤惰繜娣诲姞鎸夐敭鐩戝惉锛岀‘淇濆垵濮嬪寲瀹屾垚
+ setTimeout(() => {
+ setupScanKeyListener();
+ }, 500);
+ }
+ // #endif
+}
+
+/**
+ * 鍋滄鍏ㄥ眬RFID杈撳叆鍔╂墜
+ */
+export function stopRFIDInputHelper() {
+ // #ifdef APP-PLUS
+ console.log('[RFIDInputHelper] 鍋滄RFID杈撳叆鍔╂墜...');
+ removeScanKeyListener();
+ // 娉ㄦ剰锛氫笉鍏抽棴RFID妯″潡锛屽洜涓烘祴璇曢〉闈㈠彲鑳藉湪浣跨敤
+ // closeRFID();
+ // #endif
+}
+
+// #endif
diff --git a/common/rfid-scanner.js b/common/rfid-scanner.js
new file mode 100644
index 0000000..377e5b9
--- /dev/null
+++ b/common/rfid-scanner.js
@@ -0,0 +1,565 @@
+/**
+ * RFID鎵弿绠$悊鍣�
+ * 鐢ㄤ簬鍦ㄦ壂鐮佹椂鑷姩鍚姩RFID鎵弿
+ * 鍏ㄥ眬鍗曚緥锛屽簲鐢ㄥ惎鍔ㄦ椂鑷姩鍒濆鍖栵紝搴旂敤閫�鍑烘椂鎵嶆竻鐞�
+ */
+import idataRFID from '@/common/idata-rfid.js';
+
+class RFIDScanner {
+ constructor() {
+ this.isInitialized = false;
+ this.isInitializing = false; // 姝e湪鍒濆鍖栨爣蹇�
+ this.isScanning = false;
+ this.powerStatus = 'disconnected';
+ this.scanCallback = null;
+ this.currentInputRef = null; // 褰撳墠杈撳叆妗嗙殑寮曠敤锛堢敤浜庤嚜鍔ㄥ~鍏ワ級
+ this.moduleTypeIndex = 0; // 褰撳墠灏濊瘯鐨勬ā鍧楃被鍨嬬储寮曪細0=UM, 1=SLR, 2=GX
+ this.moduleTypes = [0, 1, 2]; // 妯″潡绫诲瀷鍒楄〃
+ this.moduleTypeNames = ['UM妯″潡', 'SLR妯″潡', 'GX妯″潡'];
+ this.initRetryCount = 0;
+ this.maxRetryCount = 3; // 姣忕妯″潡绫诲瀷鏈�澶氬皾璇�3娆�
+ this.autoStopTimer = null; // 鑷姩鍋滄瀹氭椂鍣�
+ this.autoStopDelay = 30000; // 30绉掑悗鑷姩鍋滄鎵弿锛堝欢闀匡紝閬垮厤棰戠箒鍋滄锛�
+ this.powerCheckTimer = null; // 涓婄數妫�鏌ュ畾鏃跺櫒
+ this.currentPageInstance = null; // 褰撳墠椤甸潰瀹炰緥锛堢敤浜庤嚜鍔ㄥ~鍏ワ級
+ this.globalScanMode = false; // 鍏ㄥ眬鎵弿妯″紡锛堜笉渚濊禆杈撳叆妗嗙劍鐐癸級
+ this.scanDebounceTimer = null; // 闃叉姈瀹氭椂鍣�
+ this.scanDebounceDelay = 300; // 闃叉姈寤惰繜300ms
+ }
+
+ /**
+ * 鍒濆鍖朢FID妯″潡锛堝簲鐢ㄥ惎鍔ㄦ椂璋冪敤锛屽叏灞�鍙垵濮嬪寲涓�娆★級
+ */
+ init() {
+ if (this.isInitialized) {
+ console.log('[RFIDScanner] 妯″潡宸插垵濮嬪寲锛岃烦杩�');
+ return;
+ }
+
+ if (this.isInitializing) {
+ console.log('[RFIDScanner] 姝e湪鍒濆鍖栦腑锛岃烦杩�');
+ return;
+ }
+
+ this.isInitializing = true;
+ console.log('[RFIDScanner] ========== 寮�濮嬪垵濮嬪寲RFID妯″潡 ==========');
+
+ // 鐩戝惉涓婄數浜嬩欢
+ idataRFID.onPowerEvent((e) => {
+ console.log('[RFIDScanner] POWEREvent:', JSON.stringify(e));
+ if (e && e.status === 'connected') {
+ this.powerStatus = 'connected';
+ this.isInitialized = true;
+ this.isInitializing = false;
+ console.log('[RFIDScanner] 鉁撯湏鉁� 妯″潡宸蹭笂鐢垫垚鍔燂紒');
+ // 娓呴櫎閲嶈瘯瀹氭椂鍣�
+ if (this.powerCheckTimer) {
+ clearTimeout(this.powerCheckTimer);
+ this.powerCheckTimer = null;
+ }
+ } else {
+ this.powerStatus = 'disconnected';
+ console.log('[RFIDScanner] 鉁� 妯″潡鏈笂鐢�:', e ? e.msg : '鏈煡閿欒');
+ }
+ });
+
+ // 鐩戝惉鎵弿浜嬩欢
+ idataRFID.onScanEvent((e) => {
+ console.log('[RFIDScanner] ========== 鎵弿鍒版爣绛� ==========');
+ console.log('[RFIDScanner] EPC:', e ? e.epc : 'undefined');
+ console.log('[RFIDScanner] TID:', e ? e.tid : 'undefined');
+
+ // 璋冪敤鍥炶皟鍑芥暟锛堝洖璋冨嚱鏁颁腑浼氭洿鏂拌緭鍏ユ锛�
+ if (this.scanCallback) {
+ this.scanCallback(e);
+ }
+
+ // 鍏ㄥ眬鎵弿妯″紡锛氳嚜鍔ㄥ~鍏ュ綋鍓嶇劍鐐硅緭鍏ユ
+ if (this.globalScanMode && e && e.epc) {
+ this.fillCurrentInput(e.epc);
+ }
+ });
+
+ // 寮�濮嬪皾璇曞垵濮嬪寲
+ this.tryInitModule();
+ }
+
+ /**
+ * 灏濊瘯鍒濆鍖栨ā鍧楋紙鑷姩灏濊瘯涓嶅悓妯″潡绫诲瀷锛�
+ */
+ tryInitModule() {
+ if (this.isInitialized) {
+ return;
+ }
+
+ const moduleType = this.moduleTypes[this.moduleTypeIndex];
+ console.log(`[RFIDScanner] 灏濊瘯鍒濆鍖� ${this.moduleTypeNames[this.moduleTypeIndex]} (绫诲瀷${moduleType})...`);
+
+ idataRFID.initUHF(moduleType, (ret) => {
+ console.log(`[RFIDScanner] initUHF(${moduleType}) result:`, ret);
+
+ // 绛夊緟涓婄數缁撴灉锛堟渶澶氱瓑寰�3绉掞級
+ this.powerCheckTimer = setTimeout(() => {
+ if (!this.isInitialized && this.powerStatus !== 'connected') {
+ console.log(`[RFIDScanner] ${this.moduleTypeNames[this.moduleTypeIndex]} 鍒濆鍖栬秴鏃讹紝灏濊瘯涓嬩竴涓ā鍧楃被鍨媊);
+ this.initRetryCount++;
+
+ if (this.initRetryCount >= this.maxRetryCount) {
+ // 褰撳墠妯″潡绫诲瀷灏濊瘯娆℃暟鐢ㄥ畬锛屽垏鎹㈠埌涓嬩竴涓�
+ this.moduleTypeIndex = (this.moduleTypeIndex + 1) % this.moduleTypes.length;
+ this.initRetryCount = 0;
+ console.log(`[RFIDScanner] 鍒囨崲鍒� ${this.moduleTypeNames[this.moduleTypeIndex]}`);
+ }
+
+ // 寤惰繜鍚庨噸璇�
+ setTimeout(() => {
+ if (!this.isInitialized) {
+ this.tryInitModule();
+ }
+ }, 2000);
+ }
+ }, 3000);
+ });
+ }
+
+ /**
+ * 寮�濮嬫壂鎻忥紙鍦ㄦ壂鐮佽緭鍏ユ鑾峰緱鐒︾偣鏃惰皟鐢紝鎴栨壂鐮佹寜閿Е鍙戯級
+ * @param {Object} inputRef - 杈撳叆妗嗗紩鐢ㄥ璞★紝鐢ㄤ簬鑷姩濉叆鎵弿缁撴灉 {epc: ''}
+ * @param {Function} callback - 鎵弿鍒版爣绛炬椂鐨勫洖璋冨嚱鏁帮紙鍙�夛級
+ */
+ startScan(inputRef = null, callback = null) {
+ // 闃叉姈澶勭悊锛岄伩鍏嶅揩閫熺偣鍑�
+ if (this.scanDebounceTimer) {
+ clearTimeout(this.scanDebounceTimer);
+ }
+
+ this.scanDebounceTimer = setTimeout(() => {
+ this._doStartScan(inputRef, callback);
+ }, this.scanDebounceDelay);
+ }
+
+ /**
+ * 瀹為檯鎵ц寮�濮嬫壂鎻�
+ */
+ _doStartScan(inputRef = null, callback = null) {
+ console.log('[RFIDScanner] ========== 寮�濮嬫壂鎻� ==========');
+ console.log('[RFIDScanner] 褰撳墠鐘舵�� - isScanning:', this.isScanning, 'powerStatus:', this.powerStatus);
+
+ // 濡傛灉鏈垵濮嬪寲锛屽厛鍒濆鍖栵紙纭繚妯″潡宸蹭笂鐢碉級
+ if (!this.isInitialized && !this.isInitializing) {
+ console.log('[RFIDScanner] 妯″潡鏈垵濮嬪寲锛屽紑濮嬪垵濮嬪寲...');
+ this.init();
+ }
+
+ // 濡傛灉宸茬粡鍦ㄦ壂鎻忥紝鐩存帴杩斿洖
+ if (this.isScanning) {
+ console.log('[RFIDScanner] 宸插湪鎵弿涓紝璺宠繃');
+ return;
+ }
+
+ // 璁剧疆鎵弿鍥炶皟鍜岃緭鍏ユ寮曠敤
+ this.scanCallback = callback;
+ this.currentInputRef = inputRef;
+
+ // 濡傛灉涓嶆槸鍏ㄥ眬鎵弿妯″紡锛岃缃綋鍓嶉〉闈㈠疄渚�
+ if (!this.globalScanMode && typeof getCurrentPages === 'function') {
+ const pages = getCurrentPages();
+ if (pages.length > 0) {
+ this.currentPageInstance = pages[pages.length - 1].$vm;
+ }
+ }
+
+ // 妫�鏌ヤ笂鐢电姸鎬�
+ if (this.powerStatus !== 'connected') {
+ console.log('[RFIDScanner] 鈿� RFID姝e湪涓婄數锛岃绋嶅��...');
+ idataRFID.showToast('RFID姝e湪涓婄數锛岃绋嶅��...', 1);
+ // 绛夊緟涓婄數瀹屾垚鍚庡啀寮�濮嬫壂鎻�
+ const checkPowerAndStart = () => {
+ if (this.powerStatus === 'connected' && !this.isScanning) {
+ console.log('[RFIDScanner] 妯″潡宸蹭笂鐢碉紝寮�濮嬫壂鎻�...');
+ this.doStartScan();
+ } else if (!this.isScanning) {
+ console.log('[RFIDScanner] 绛夊緟妯″潡涓婄數...');
+ // 濡傛灉鏈笂鐢碉紝绛夊緟1绉掑悗閲嶈瘯锛堟渶澶氱瓑寰�10绉掞級
+ setTimeout(() => {
+ if (!this.isScanning && this.powerStatus !== 'connected') {
+ checkPowerAndStart();
+ }
+ }, 1000);
+ }
+ };
+ setTimeout(() => {
+ checkPowerAndStart();
+ }, 500);
+ return;
+ }
+
+ // 濡傛灉宸蹭笂鐢碉紝鐩存帴寮�濮嬫壂鎻�
+ this.doStartScan();
+ }
+
+ /**
+ * 鎵ц寮�濮嬫壂鎻忔搷浣�
+ */
+ doStartScan() {
+ // 濡傛灉宸茬粡鍦ㄦ壂鎻忥紝涓嶉噸澶嶈皟鐢�
+ if (this.isScanning) {
+ console.log('[RFIDScanner] 宸插湪鎵弿涓紝璺宠繃');
+ return;
+ }
+
+ console.log('[RFIDScanner] 妯″潡宸蹭笂鐢碉紝寮�濮嬫壂鎻�...');
+ idataRFID.startOrStopRFID((ret) => {
+ console.log('[RFIDScanner] startOrStopRFID result:', JSON.stringify(ret));
+ if (ret && ret.code === 'success') {
+ if (ret.msg === 'start') {
+ // 鎴愬姛鍚姩
+ this.isScanning = true;
+ console.log('[RFIDScanner] 鉁� RFID鎵弿宸插惎鍔�');
+ idataRFID.showToast('RFID鎵弿宸插惎鍔�', 1);
+
+ // 璁剧疆鑷姩鍋滄瀹氭椂鍣紙30绉掑悗鑷姩鍋滄锛岄伩鍏嶉绻佸仠姝級
+ if (this.autoStopTimer) {
+ clearTimeout(this.autoStopTimer);
+ }
+ this.autoStopTimer = setTimeout(() => {
+ console.log('[RFIDScanner] 鑷姩鍋滄鎵弿锛堣秴鏃讹級');
+ this.stopScan();
+ }, this.autoStopDelay);
+ } else if (ret.msg === 'stop') {
+ // 濡傛灉杩斿洖stop锛岃鏄庡綋鍓嶇姸鎬佹槸鍚姩鐨勶紝璋冪敤鍚庡彉鎴愪簡鍋滄
+ // 杩欑鎯呭喌涓嶅簲璇ュ彂鐢燂紝浣嗛渶瑕佸鐞�
+ console.log('[RFIDScanner] 鈿� 鎵弿鐘舵�佸紓甯革紝鏀跺埌stop娑堟伅');
+ this.isScanning = false;
+ } else {
+ console.log('[RFIDScanner] 鈿� 鏈煡鐨勬壂鎻忕姸鎬�:', ret.msg);
+ }
+ } else {
+ console.log('[RFIDScanner] 鈿� 鍚姩鎵弿澶辫触:', ret ? ret.msg : '鏈煡閿欒');
+ idataRFID.showToast('鍚姩鎵弿澶辫触', 1);
+ }
+ });
+ }
+
+ /**
+ * 鍋滄鎵弿锛堝湪鎵爜杈撳叆妗嗗け鍘荤劍鐐规垨杈撳叆瀹屾垚鏃惰皟鐢級
+ * 娉ㄦ剰锛氬彧鍋滄鎵弿锛屼笉涓嬬數锛屼繚鎸佹ā鍧椾笂鐢电姸鎬�
+ */
+ stopScan() {
+ // 闃叉姈澶勭悊
+ if (this.scanDebounceTimer) {
+ clearTimeout(this.scanDebounceTimer);
+ this.scanDebounceTimer = null;
+ }
+
+ if (!this.isScanning) {
+ console.log('[RFIDScanner] 褰撳墠鏈湪鎵弿锛岃烦杩囧仠姝㈡搷浣�');
+ return;
+ }
+
+ console.log('[RFIDScanner] ========== 鍋滄鎵弿 ==========');
+
+ // 娓呴櫎鑷姩鍋滄瀹氭椂鍣�
+ if (this.autoStopTimer) {
+ clearTimeout(this.autoStopTimer);
+ this.autoStopTimer = null;
+ }
+
+ // 鍏堣缃姸鎬佷负false锛岄伩鍏嶉噸澶嶈皟鐢�
+ this.isScanning = false;
+
+ idataRFID.startOrStopRFID((ret) => {
+ console.log('[RFIDScanner] stop scan result:', JSON.stringify(ret));
+ if (ret && ret.code === 'success') {
+ if (ret.msg === 'stop') {
+ console.log('[RFIDScanner] 鉁� RFID鎵弿宸插仠姝紙妯″潡淇濇寔涓婄數鐘舵�侊級');
+ } else if (ret.msg === 'start') {
+ // 濡傛灉杩斿洖start锛岃鏄庡綋鍓嶇姸鎬佹槸鍋滄鐨勶紝璋冪敤鍚庡彉鎴愪簡鍚姩
+ // 杩欑鎯呭喌涓嶅簲璇ュ彂鐢燂紝浣嗛渶瑕佸鐞�
+ console.log('[RFIDScanner] 鈿� 鎵弿鐘舵�佸紓甯革紝鏀跺埌start娑堟伅锛岄噸鏂拌缃负鍋滄');
+ this.isScanning = true;
+ // 绔嬪嵆鍐嶆鍋滄
+ setTimeout(() => {
+ this.stopScan();
+ }, 100);
+ }
+ }
+ });
+
+ // 娓呴櫎鍥炶皟鍜岃緭鍏ユ寮曠敤锛堜絾涓嶆竻闄lobalScanMode锛屽洜涓哄彲鑳借繕闇�瑕佺户缁壂鎻忥級
+ this.scanCallback = null;
+ this.currentInputRef = null;
+ }
+
+ /**
+ * 鑾峰彇涓婄數鐘舵��
+ */
+ getPowerStatus() {
+ return this.powerStatus;
+ }
+
+ /**
+ * 鑾峰彇鎵弿鐘舵��
+ */
+ getScanningStatus() {
+ return this.isScanning;
+ }
+
+ /**
+ * 鍏ㄥ眬鎵弿妯″紡锛氫负褰撳墠鐒︾偣杈撳叆妗嗗惎鍔ㄦ壂鎻忥紙鎵爜鎸夐敭瑙﹀彂锛�
+ */
+ startScanForCurrentInput() {
+ console.log('[RFIDScanner] ========== 鍏ㄥ眬鎵弿妯″紡鍚姩 ==========');
+
+ // 濡傛灉姝e湪鎵弿锛屽厛鍋滄
+ if (this.isScanning) {
+ console.log('[RFIDScanner] 褰撳墠姝e湪鎵弿锛屽厛鍋滄');
+ this.stopScan();
+ // 绛夊緟鍋滄瀹屾垚鍚庡啀鍚姩
+ setTimeout(() => {
+ this._startScanForCurrentInput();
+ }, 500);
+ return;
+ }
+
+ this._startScanForCurrentInput();
+ }
+
+ /**
+ * 瀹為檯鎵ц鍏ㄥ眬鎵弿
+ */
+ _startScanForCurrentInput() {
+ // 纭繚璁剧疆浜嗗綋鍓嶉〉闈㈠疄渚�
+ if (typeof getCurrentPages === 'function') {
+ const pages = getCurrentPages();
+ if (pages.length > 0) {
+ this.currentPageInstance = pages[pages.length - 1].$vm;
+ console.log('[RFIDScanner] 宸茶缃綋鍓嶉〉闈㈠疄渚�:', pages[pages.length - 1].route);
+ }
+ }
+
+ this.globalScanMode = true;
+ this.startScan(null, (tagData) => {
+ if (tagData && tagData.epc) {
+ console.log('[RFIDScanner] 鎵弿鍒版爣绛撅紝鑷姩濉叆褰撳墠杈撳叆妗�:', tagData.epc);
+ this.fillCurrentInput(tagData.epc);
+ // 鎵弿鎴愬姛鍚庡仠姝紙寤惰繜涓�涓嬶紝纭繚濉叆瀹屾垚锛�
+ setTimeout(() => {
+ this.stopScan();
+ }, 500);
+ }
+ });
+ }
+
+ /**
+ * 鑷姩濉叆褰撳墠鐒︾偣杈撳叆妗�
+ */
+ fillCurrentInput(epc) {
+ try {
+ console.log('[RFIDScanner] ========== 灏濊瘯鑷姩濉叆EPC:', epc);
+
+ // 浼樺厛浣跨敤淇濆瓨鐨勯〉闈㈠疄渚�
+ let vm = null;
+ if (this.currentPageInstance) {
+ vm = this.currentPageInstance;
+ console.log('[RFIDScanner] 浣跨敤淇濆瓨鐨勯〉闈㈠疄渚�');
+ } else if (typeof getCurrentPages === 'function') {
+ // 濡傛灉淇濆瓨鐨勫疄渚嬫病鏈夋壘鍒帮紝灏濊瘯浠巊etCurrentPages鑾峰彇
+ const pages = getCurrentPages();
+ if (pages.length > 0) {
+ const currentPage = pages[pages.length - 1];
+ console.log('[RFIDScanner] 褰撳墠椤甸潰:', currentPage.route);
+ if (currentPage && currentPage.$vm) {
+ vm = currentPage.$vm;
+ // 鏇存柊淇濆瓨鐨勫疄渚�
+ this.currentPageInstance = vm;
+ }
+ }
+ }
+
+ if (!vm) {
+ console.log('[RFIDScanner] 鏈壘鍒伴〉闈㈠疄渚嬶紝鏃犳硶鑷姩濉叆');
+ return;
+ }
+
+ // 妫�鏌ュ父瑙佺殑杈撳叆妗嗗彉閲忓悕锛堟寜浼樺厛绾э級
+ // 浼樺厛鏌ユ壘鍙兘鏈夌劍鐐圭殑杈撳叆妗�
+ const inputFields = ['barcode', 'matnr', 'locNo', 'orderNo', 'sourceSite', 'targetSite'];
+ let filled = false;
+
+ for (let field of inputFields) {
+ if (vm[field] !== undefined) {
+ console.log(`[RFIDScanner] 鎵惧埌杈撳叆妗嗗彉閲� ${field}锛屽綋鍓嶅��:`, vm[field]);
+ vm[field] = epc;
+ console.log(`[RFIDScanner] 鉁撯湏鉁� 宸茶嚜鍔ㄥ~鍏PC鍒� ${field}:`, epc);
+ idataRFID.showToast('宸茶嚜鍔ㄥ~鍏�', 1);
+ filled = true;
+ break; // 鍙~鍏ョ涓�涓壘鍒扮殑
+ }
+ }
+
+ if (!filled) {
+ console.log('[RFIDScanner] 鏈壘鍒拌緭鍏ユ鍙橀噺锛屾棤娉曡嚜鍔ㄥ~鍏�');
+ console.log('[RFIDScanner] 椤甸潰瀹炰緥data:', Object.keys(vm.$data || {}));
+ }
+ } catch (error) {
+ console.error('[RFIDScanner] 鑷姩濉叆澶辫触:', error);
+ }
+ }
+
+ /**
+ * 鍗曟爣绛捐鏃犺繃婊わ紙鍦ㄨ緭鍏ユ鑾峰緱鐒︾偣鏃惰皟鐢級
+ * @param {String} fieldName - 瑕佸~鍏ョ殑瀛楁鍚嶏紙濡� 'barcode', 'matnr' 绛夛級
+ * @param {Function} callback - 璇诲彇鎴愬姛鍚庣殑鍥炶皟鍑芥暟锛堝彲閫夛級
+ */
+ readSingleTagWithoutFilter(fieldName = null, callback = null) {
+ console.log('[RFIDScanner] ========== 鍗曟爣绛捐鏃犺繃婊� ==========');
+ console.log('[RFIDScanner] 瀛楁鍚�:', fieldName);
+
+ // 濡傛灉鏈垵濮嬪寲锛屽厛鍒濆鍖栵紙纭繚妯″潡宸蹭笂鐢碉級
+ if (!this.isInitialized && !this.isInitializing) {
+ console.log('[RFIDScanner] 妯″潡鏈垵濮嬪寲锛屽紑濮嬪垵濮嬪寲...');
+ this.init();
+ }
+
+ // 妫�鏌ヤ笂鐢电姸鎬�
+ if (this.powerStatus !== 'connected') {
+ console.log('[RFIDScanner] 鈿� RFID姝e湪涓婄數锛岃绋嶅��...');
+ idataRFID.showToast('RFID姝e湪涓婄數锛岃绋嶅��...', 1);
+ // 绛夊緟涓婄數瀹屾垚鍚庡啀璇诲彇
+ const checkPowerAndRead = () => {
+ if (this.powerStatus === 'connected') {
+ console.log('[RFIDScanner] 妯″潡宸蹭笂鐢碉紝寮�濮嬪崟鏍囩璇诲彇...');
+ this._doReadSingleTag(fieldName, callback);
+ } else {
+ console.log('[RFIDScanner] 绛夊緟妯″潡涓婄數...');
+ setTimeout(() => {
+ if (this.powerStatus !== 'connected') {
+ checkPowerAndRead();
+ }
+ }, 1000);
+ }
+ };
+ setTimeout(() => {
+ checkPowerAndRead();
+ }, 500);
+ return;
+ }
+
+ // 濡傛灉宸蹭笂鐢碉紝鐩存帴璇诲彇
+ this._doReadSingleTag(fieldName, callback);
+ }
+
+ /**
+ * 鎵ц鍗曟爣绛捐鍙栨搷浣�
+ */
+ _doReadSingleTag(fieldName = null, callback = null) {
+ // 纭繚璁剧疆浜嗗綋鍓嶉〉闈㈠疄渚�
+ if (typeof getCurrentPages === 'function') {
+ const pages = getCurrentPages();
+ if (pages.length > 0) {
+ this.currentPageInstance = pages[pages.length - 1].$vm;
+ }
+ }
+
+ // 璋冪敤鍗曟爣绛捐鏃犺繃婊�
+ // readBank: 1->EPC, startBlock: 2, len: 6, pwd: "00000000"
+ idataRFID.readTagWithoutFilter(1, 2, 6, "00000000", (ret) => {
+ console.log('[RFIDScanner] readTagWithoutFilter result:', JSON.stringify(ret));
+
+ if (ret && ret.code === 'success' && ret.data) {
+ const epc = ret.data.trim();
+ console.log('[RFIDScanner] 鉁撯湏鉁� 鎴愬姛璇诲彇鍒版爣绛� EPC:', epc);
+
+ // 濡傛灉鏈夊洖璋冨嚱鏁帮紝鍏堣皟鐢ㄥ洖璋�
+ if (callback && typeof callback === 'function') {
+ callback({ epc: epc, tid: '' });
+ }
+
+ // 濡傛灉鎸囧畾浜嗗瓧娈靛悕锛岃嚜鍔ㄥ~鍏�
+ if (fieldName) {
+ this.fillFieldByName(fieldName, epc);
+ } else {
+ // 濡傛灉娌℃湁鎸囧畾瀛楁鍚嶏紝鑷姩濉叆褰撳墠鐒︾偣杈撳叆妗�
+ this.fillCurrentInput(epc);
+ }
+
+ idataRFID.showToast('璇诲彇鎴愬姛', 1);
+ } else {
+ console.log('[RFIDScanner] 鉁� 璇诲彇澶辫触:', ret ? ret.msg : '鏈煡閿欒');
+ if (ret && ret.code === 'fail') {
+ idataRFID.showToast('璇诲彇澶辫触: ' + (ret.msg || '鏈煡閿欒'), 1);
+ }
+ }
+ });
+ }
+
+ /**
+ * 鏍规嵁瀛楁鍚嶅~鍏ュ��
+ */
+ fillFieldByName(fieldName, value) {
+ try {
+ console.log(`[RFIDScanner] 灏濊瘯濉叆瀛楁 ${fieldName}:`, value);
+
+ // 浼樺厛浣跨敤淇濆瓨鐨勯〉闈㈠疄渚�
+ let vm = null;
+ if (this.currentPageInstance) {
+ vm = this.currentPageInstance;
+ } else if (typeof getCurrentPages === 'function') {
+ const pages = getCurrentPages();
+ if (pages.length > 0 && pages[pages.length - 1].$vm) {
+ vm = pages[pages.length - 1].$vm;
+ this.currentPageInstance = vm;
+ }
+ }
+
+ if (!vm) {
+ console.log('[RFIDScanner] 鏈壘鍒伴〉闈㈠疄渚嬶紝鏃犳硶濉叆');
+ return;
+ }
+
+ if (vm[fieldName] !== undefined) {
+ vm[fieldName] = value;
+ console.log(`[RFIDScanner] 鉁撯湏鉁� 宸插~鍏ュ瓧娈� ${fieldName}:`, value);
+ idataRFID.showToast('宸茶嚜鍔ㄥ~鍏�', 1);
+ } else {
+ console.log(`[RFIDScanner] 瀛楁 ${fieldName} 涓嶅瓨鍦╜);
+ }
+ } catch (error) {
+ console.error('[RFIDScanner] 濉叆瀛楁澶辫触:', error);
+ }
+ }
+
+ /**
+ * 璁剧疆褰撳墠椤甸潰瀹炰緥锛堥〉闈nShow鏃惰皟鐢級
+ */
+ setCurrentPageInstance(pageInstance) {
+ this.currentPageInstance = pageInstance;
+ }
+
+ /**
+ * 娓呯悊璧勬簮锛堝簲鐢ㄩ��鍑烘椂璋冪敤锛屽叏灞�鍙皟鐢ㄤ竴娆★級
+ */
+ cleanup() {
+ console.log('[RFIDScanner] ========== 娓呯悊RFID璧勬簮锛堝簲鐢ㄩ��鍑猴級 ==========');
+ this.stopScan();
+ idataRFID.closeUHF();
+ idataRFID.removeEventListeners();
+ this.isInitialized = false;
+ this.isInitializing = false;
+ this.isScanning = false;
+ this.powerStatus = 'disconnected';
+ this.scanCallback = null;
+ this.currentInputRef = null;
+ if (this.powerCheckTimer) {
+ clearTimeout(this.powerCheckTimer);
+ this.powerCheckTimer = null;
+ }
+ console.log('[RFIDScanner] 鉁� RFID璧勬簮宸叉竻鐞�');
+ }
+}
+
+// 鍒涘缓鍗曚緥瀹炰緥
+const rfidScanner = new RFIDScanner();
+
+export default rfidScanner;
diff --git a/manifest.json b/manifest.json
index 8d74284..b423a12 100644
--- a/manifest.json
+++ b/manifest.json
@@ -3,7 +3,7 @@
"appid" : "__UNI__DA5854D",
"description" : "",
"versionName" : "20240420",
- "versionCode" : "100",
+ "versionCode" : 100,
"transformPx" : false,
/* 5+App鐗规湁鐩稿叧 */
"app-plus" : {
@@ -24,6 +24,7 @@
"distribute" : {
/* android鎵撳寘閰嶇疆 */
"android" : {
+ "packageName" : "uni.UNIDA5854D",
"permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
@@ -97,6 +98,17 @@
"pid" : "2731",
"parameters" : {}
}
+ },
+ "iData-UHFPlugin" : {
+ "__plugin_info__" : {
+ "name" : "iData UHF鎵弿鎻掍欢",
+ "description" : "瀹炵幇浜咥PP鎺ユ敹iData鍝佺墝鎵弿鐨刄HF鏍囩鏁版嵁锛岄�傞厤iData鍝佺墝鎵�鏈夊畨鍗揚DA璁惧",
+ "platforms" : "Android",
+ "android_package_name" : "uni.UNIDA5854D",
+ "ios_bundle_id" : "",
+ "isCloud" : false,
+ "parameters" : {}
+ }
}
}
},
diff --git a/nativeplugins/iData-UHFPlugin/android/uhflib-release.aar b/nativeplugins/iData-UHFPlugin/android/uhflib-release.aar
new file mode 100644
index 0000000..3470268
--- /dev/null
+++ b/nativeplugins/iData-UHFPlugin/android/uhflib-release.aar
Binary files differ
diff --git a/nativeplugins/iData-UHFPlugin/license.md b/nativeplugins/iData-UHFPlugin/license.md
new file mode 100644
index 0000000..a440133
--- /dev/null
+++ b/nativeplugins/iData-UHFPlugin/license.md
@@ -0,0 +1,7 @@
+#iData Copyright (c) 2021 Lzy
+
+###Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+###The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+###THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/nativeplugins/iData-UHFPlugin/package.json b/nativeplugins/iData-UHFPlugin/package.json
new file mode 100644
index 0000000..78b8685
--- /dev/null
+++ b/nativeplugins/iData-UHFPlugin/package.json
@@ -0,0 +1,26 @@
+{
+ "name": "iData UHF鎻掍欢",
+ "id": "iData-UHFPlugin",
+ "version": "1.7",
+ "description": "瀹炵幇浜咥PP鎺ユ敹iData鍝佺墝UHF鏍囩璇诲彇銆�",
+ "_dp_type": "nativeplugin",
+ "_dp_nativeplugin": {
+ "android": {
+ "minSdkVersion": 23,
+ "plugins": [{
+ "type": "module",
+ "name": "iData-UHFPlugin-UHFModule",
+ "class": "com.idata.uhflib.UHFModule"
+ }],
+ "integrateType": "aar",
+ "abis": [
+ "arm64-v8a", "armeabi-v7a"
+ ],
+ "compileOptions": {
+ "sourceCompatibility": "1.8",
+ "targetCompatibility": "1.8"
+ },
+ "useAndroidX": true
+ }
+ }
+}
\ No newline at end of file
diff --git a/pages.json b/pages.json
index 8f048c9..3cf9195 100644
--- a/pages.json
+++ b/pages.json
@@ -65,12 +65,37 @@
}
},
{
+ "path": "pages/AGV/agv_empty",
+ "style": {
+ "navigationBarTitleText": "AGV绌烘墭鍏ュ簱",
+ "enablePullDownRefresh": false
+ }
+ },
+ {
"path": "pages/stock/stockQuery",
"style": {
"navigationBarTitleText": "搴撳瓨鏌ヨ"
}
},
{
+ "path": "pages/rfid/settings",
+ "style": {
+ "navigationBarTitleText": "RFID璁剧疆"
+ }
+ },
+ {
+ "path": "pages/rfid/uhftest",
+ "style": {
+ "navigationBarTitleText": "UHF娴嬭瘯"
+ }
+ },
+ {
+ "path": "pages/rfid/uhftest2",
+ "style": {
+ "navigationBarTitleText": "UHF娴嬭瘯2"
+ }
+ },
+ {
"path": "pages/login/logOut",
"style": {
"navigationBarTitleText": "閫�鍑虹櫥褰�"
diff --git a/pages/AGV/agv_back.vue b/pages/AGV/agv_back.vue
index 9b3744f..18d06cf 100644
--- a/pages/AGV/agv_back.vue
+++ b/pages/AGV/agv_back.vue
@@ -9,7 +9,7 @@
</view>
<view class="form-input-wrap">
<input class="form-input" type="text" placeholder="鎵爜 / 杈撳叆鎵樼洏鐮�" v-model="barcode"
- :focus="barcodeFocus" @input="barcodeInput()" />
+ :focus="barcodeFocus" @input="barcodeInput()" @focus="onBarcodeFocus()" />
<uni-icons v-if="barcode" type="clear" size="18" color="#c0c4cc" @click="clearBarcode"></uni-icons>
</view>
</view>
@@ -19,7 +19,7 @@
<text class="label-text">鏆傚瓨浣�</text>
</view>
<view class="form-input-wrap">
- <input class="form-input" type="text" placeholder="鎵爜 / 杈撳叆鏆傚瓨浣�" v-model="sourceSite" />
+ <input class="form-input" type="text" placeholder="鎵爜 / 杈撳叆鏆傚瓨浣�" v-model="sourceSite" @focus="onSourceSiteFocus()" />
<uni-icons v-if="sourceSite" type="clear" size="18" color="#c0c4cc" @click="sourceSite=''"></uni-icons>
</view>
</view>
@@ -181,6 +181,7 @@
</template>
<script>
+ import rfidScanner from '@/common/rfid-scanner.js';
export default {
data() {
return {
@@ -202,6 +203,7 @@
content: '',
barcodeFocus: true,
matFocus: false,
+ sourceSiteFocus: false,
matData: '',
removeNum: 0,
ck1: true,
@@ -223,8 +225,33 @@
onShow() {
this.baseUrl = uni.getStorageSync('baseUrl');
this.token = uni.getStorageSync('token');
+ // RFID宸插湪App.vue涓叏灞�鍒濆鍖栵紝杩欓噷涓嶉渶瑕佸啀鍒濆鍖�
+ // 璁剧疆褰撳墠椤甸潰瀹炰緥锛岀敤浜庡叏灞�鎵弿鏃惰嚜鍔ㄥ~鍏�
+ rfidScanner.setCurrentPageInstance(this);
},
methods: {
+ // 鎵樼洏鐮佽緭鍏ユ鑾峰緱鐒︾偣锛堜繚鐣欐柟娉曪紝浣嗕笉鑷姩瑙﹀彂鎵弿锛�
+ onBarcodeFocus() {
+ console.log('[agv_back] 鎵樼洏鐮佽緭鍏ユ鑾峰緱鐒︾偣');
+ // 璁剧疆鎵樼洏鐮佽緭鍏ユ涓虹劍鐐癸紝鍏朵粬杈撳叆妗嗗け鍘荤劍鐐�
+ this.barcodeFocus = true;
+ this.matFocus = false;
+ if (this.sourceSiteFocus !== undefined) {
+ this.sourceSiteFocus = false;
+ }
+ // 娉ㄦ剰锛氬崟鏍囩璇绘棤杩囨护鍔熻兘宸叉敼涓烘寜閿Е鍙戯紙191銆�189銆�190锛夛紝涓嶅啀鍦ㄧ劍鐐规椂鑷姩瑙﹀彂
+ },
+ // 鏆傚瓨浣嶈緭鍏ユ鑾峰緱鐒︾偣锛堜繚鐣欐柟娉曪紝浣嗕笉鑷姩瑙﹀彂鎵弿锛�
+ onSourceSiteFocus() {
+ console.log('[agv_back] 鏆傚瓨浣嶈緭鍏ユ鑾峰緱鐒︾偣');
+ // 璁剧疆鏆傚瓨浣嶈緭鍏ユ涓虹劍鐐癸紝鍏朵粬杈撳叆妗嗗け鍘荤劍鐐�
+ if (this.sourceSiteFocus !== undefined) {
+ this.sourceSiteFocus = true;
+ }
+ this.barcodeFocus = false;
+ this.matFocus = false;
+ // 娉ㄦ剰锛氬崟鏍囩璇绘棤杩囨护鍔熻兘宸叉敼涓烘寜閿Е鍙戯紙191銆�189銆�190锛夛紝涓嶅啀鍦ㄧ劍鐐规椂鑷姩瑙﹀彂
+ },
onTargetSiteChange(e) {
const index = e.detail.value;
this.selectedTargetSite = this.targetSiteList[index];
diff --git a/pages/AGV/agv_empty.vue b/pages/AGV/agv_empty.vue
new file mode 100644
index 0000000..8f041a3
--- /dev/null
+++ b/pages/AGV/agv_empty.vue
@@ -0,0 +1,598 @@
+<template>
+ <view class="page-container">
+ <!-- 琛ㄥ崟鍖哄煙 -->
+ <view class="form-section">
+ <view class="form-item">
+ <view class="form-label">
+ <uni-icons type="scan" size="18" color="#667eea"></uni-icons>
+ <text class="label-text">鎵樼洏鐮�</text>
+ </view>
+ <view class="form-input-wrap">
+ <input class="form-input" type="text" placeholder="鎵爜 / 杈撳叆鎵樼洏鐮�" v-model="barcode"
+ :focus="barcodeFocus" @input="barcodeInput()" @focus="onBarcodeFocus()" @blur="onBarcodeBlur()" />
+ <uni-icons v-if="barcode" type="clear" size="18" color="#c0c4cc" @click="clearBarcode"></uni-icons>
+ </view>
+ </view>
+ <view class="form-item">
+ <view class="form-label">
+ <uni-icons type="location" size="18" color="#667eea"></uni-icons>
+ <text class="label-text">鏆傚瓨浣�</text>
+ </view>
+ <view class="form-input-wrap">
+ <input class="form-input" type="text" placeholder="鎵爜 / 杈撳叆鏆傚瓨浣�" v-model="sourceSite" @focus="onSourceSiteFocus()" />
+ <uni-icons v-if="sourceSite" type="clear" size="18" color="#c0c4cc" @click="sourceSite=''"></uni-icons>
+ </view>
+ </view>
+ </view>
+
+ <!-- 鍒楄〃澶撮儴 -->
+ <view class="list-header" v-if="showDetl">
+ <view class="header-left">
+ <text class="header-title">鍟嗗搧鍒楄〃</text>
+ <view class="count-badge" v-if="dataList.length > 0">
+ <text class="count-text">{{dataList.length}}</text>
+ </view>
+ </view>
+ </view>
+
+ <!-- 鍟嗗搧鍒楄〃 -->
+ <view class="list-container" v-if="showDetl">
+ <view class="mat-card" v-for="(item, i) in dataList" :key="i">
+ <!-- 鍗$墖澶撮儴 -->
+ <view class="card-top">
+ <view class="card-index">{{i + 1}}</view>
+ <view class="mat-code-wrap">
+ <text class="mat-code">{{item.matnr}}</text>
+ </view>
+ </view>
+
+ <!-- 鍗$墖鍐呭 -->
+ <view class="card-content">
+ <view class="info-row">
+ <view class="info-col">
+ <text class="info-label">鍝佸悕</text>
+ <text class="info-value">{{item.maktx || '-'}}</text>
+ </view>
+ </view>
+ <view class="info-row">
+ <view class="info-col half">
+ <text class="info-label">瑙勬牸</text>
+ <text class="info-value">{{item.specs || '-'}}</text>
+ </view>
+ <view class="info-col half">
+ <text class="info-label">鎵瑰彿</text>
+ <text class="info-value highlight">{{item.batch || '-'}}</text>
+ </view>
+ </view>
+ <view class="info-row">
+ <view class="info-col half">
+ <text class="info-label">鏁伴噺</text>
+ <text class="info-value qty">{{item.anfme}}</text>
+ </view>
+ </view>
+ </view>
+
+ <!-- 鍗$墖鎿嶄綔 -->
+ <view class="card-actions">
+ <view class="action-btn edit-btn" @click="revise(item, i)">
+ <uni-icons type="compose" size="18" color="#667eea"></uni-icons>
+ <text class="action-text">淇敼</text>
+ </view>
+ <view class="action-btn delete-btn" @click="remove(item, i, 'warn')">
+ <uni-icons type="trash" size="18" color="#f56c6c"></uni-icons>
+ <text class="action-text delete-text">绉婚櫎</text>
+ </view>
+ </view>
+ </view>
+
+ <!-- 绌虹姸鎬� -->
+ <view class="empty-state" v-if="dataList.length === 0">
+ <uni-icons type="cart" size="60" color="#CCCCCC"></uni-icons>
+ <text class="empty-text">鏆傛棤鍟嗗搧</text>
+ <text class="empty-hint">璇锋壂鎻忕墿鏂欑爜娣诲姞鍟嗗搧</text>
+ </view>
+
+ <!-- 搴曢儴鍗犱綅 -->
+ <view class="bottom-placeholder"></view>
+ </view>
+
+ <!-- 搴曢儴鎿嶄綔鎸夐挳 -->
+ <view class="bottom-bar">
+ <view class="btn-reset" @click="reset('warn')">
+ <uni-icons type="refresh" size="18" color="#909399"></uni-icons>
+ <text class="btn-text">閲嶇疆</text>
+ </view>
+ <view class="btn-submit" :class="{'btn-disabled': isSubmitting || barcode === ''}" @click="combConfirm('warn')">
+ <uni-icons type="checkbox" size="18" color="#ffffff"></uni-icons>
+ <text class="btn-text">纭鍛煎彨</text>
+ </view>
+ </view>
+
+ <!-- 寮圭獥鍖哄煙 -->
+ <!-- 淇敼鏁伴噺 -->
+ <uni-popup ref="revise" type="dialog">
+ <view class="popup-card">
+ <view class="popup-header">
+ <text class="popup-title">淇敼淇℃伅</text>
+ </view>
+ <view class="popup-body">
+ <view class="popup-row">
+ <text class="popup-label">缂栫爜</text>
+ <view class="popup-value disabled">{{editMatnr}}</view>
+ </view>
+ <view class="popup-row">
+ <text class="popup-label">鎵瑰彿</text>
+ <input class="popup-value input" type="text" v-model="batch" placeholder="杈撳叆鎵瑰彿" />
+ </view>
+ <view class="popup-row">
+ <text class="popup-label">鏁伴噺</text>
+ <view class="popup-value number">
+ <uni-number-box :value="count" :step='0.01' :max="9999999" color="#747474" @change="changeValue" />
+ </view>
+ </view>
+ </view>
+ <view class="popup-footer">
+ <view class="popup-btn cancel" @click="reviseClose">鍙栨秷</view>
+ <view class="popup-btn confirm" @click="reviseConfirm()">纭</view>
+ </view>
+ </view>
+ </uni-popup>
+
+ <!-- 绉婚櫎纭 -->
+ <uni-popup ref="alertDialog" type="dialog">
+ <uni-popup-dialog :type="msgType" confirmText="绉婚櫎" :title="title" :content="content"
+ @confirm="removeConfirm()" @close="removeClose"></uni-popup-dialog>
+ </uni-popup>
+
+ <!-- 鎻愮ず淇℃伅寮圭獥 -->
+ <uni-popup ref="message" type="message">
+ <uni-popup-message :type="msgType1" :message="messageText" :duration="2000"></uni-popup-message>
+ </uni-popup>
+
+ <!-- 纭缁勬墭 -->
+ <uni-popup ref="combConfirm" type="dialog">
+ <uni-popup-dialog :type="msgType" cancelText="鍙栨秷" confirmText="纭" :title="title" :content="content"
+ @confirm="comb" @close="combClose"></uni-popup-dialog>
+ </uni-popup>
+
+ <!-- 纭閲嶇疆 -->
+ <uni-popup ref="resetConfirm" type="dialog">
+ <uni-popup-dialog :type="msgType" cancelText="鍙栨秷" confirmText="纭" :title="title" :content="content"
+ @confirm="resetConfirm" @close="resetClose"></uni-popup-dialog>
+ </uni-popup>
+ </view>
+</template>
+
+<script>
+ // #ifdef APP-PLUS
+ import rfidScanner from '@/common/rfid-scanner.js';
+ // #endif
+ export default {
+ data() {
+ return {
+ showDetl:false,
+ baseUrl: '',
+ token: '',
+ barcode: '',
+ dataList: [],
+ count: 0,
+ rowNum: '',
+ matnr: '',
+ editMatnr: '',
+ batch: '',
+ weight: '',
+ msgType1: 'success',
+ msgType: 'success',
+ messageText: '',
+ title: '',
+ content: '',
+ barcodeFocus: true,
+ matFocus: false,
+ sourceSiteFocus: false,
+ matData: '',
+ removeNum: 0,
+ ck1: true,
+ ck2: false,
+ isFull: true,
+ isSubmitting: false,
+ sourceSite:'',
+ targetSiteList: [
+ { label: '101', value: '101' },
+ { label: '102', value: '102' }
+ ],
+ selectedTargetSite: { label: '101', value: '101' },
+ type : 3
+ }
+ },
+ onLoad() {
+
+ },
+ onShow() {
+ this.baseUrl = uni.getStorageSync('baseUrl');
+ this.token = uni.getStorageSync('token');
+ // #ifdef APP-PLUS
+ // RFID宸插湪App.vue涓叏灞�鍒濆鍖栵紝杩欓噷涓嶉渶瑕佸啀鍒濆鍖�
+ // 璁剧疆褰撳墠椤甸潰瀹炰緥锛岀敤浜庡叏灞�鎵弿鏃惰嚜鍔ㄥ~鍏�
+ try {
+ if (typeof rfidScanner !== 'undefined' && rfidScanner && typeof rfidScanner.setCurrentPageInstance === 'function') {
+ rfidScanner.setCurrentPageInstance(this);
+ }
+ } catch (e) {
+ console.warn('[agv_empty] RFID妯″潡鍒濆鍖栧け璐�:', e);
+ }
+ // #endif
+ },
+ onHide() {
+ // #ifdef APP-PLUS
+ // 椤甸潰闅愯棌鏃跺仠姝FID鎵弿锛堜絾涓嶄笅鐢碉級
+ // 娉ㄦ剰锛氫笉鍐嶈嚜鍔ㄥ仠姝㈡壂鎻忥紝鍥犱负鍏ㄥ眬鎵弿妯″紡鏀寔璺ㄩ〉闈㈡壂鎻�
+ // 濡傛灉闇�瑕侀〉闈㈤殣钘忔椂鍋滄鎵弿锛屽彲浠ュ彇娑堜笅闈㈢殑娉ㄩ噴
+ // try {
+ // if (typeof rfidScanner !== 'undefined' && rfidScanner && typeof rfidScanner.stopScan === 'function') {
+ // rfidScanner.stopScan();
+ // }
+ // } catch (e) {
+ // console.warn('[agv_empty] RFID妯″潡鍋滄澶辫触:', e);
+ // }
+ // #endif
+ },
+ methods: {
+ // 鎵樼洏鐮佽緭鍏ユ鑾峰緱鐒︾偣锛堜繚鐣欐柟娉曪紝浣嗕笉鑷姩瑙﹀彂鎵弿锛�
+ onBarcodeFocus() {
+ console.log('[agv_empty] 鎵樼洏鐮佽緭鍏ユ鑾峰緱鐒︾偣');
+ // 璁剧疆鎵樼洏鐮佽緭鍏ユ涓虹劍鐐癸紝鍏朵粬杈撳叆妗嗗け鍘荤劍鐐�
+ this.barcodeFocus = true;
+ this.matFocus = false;
+ if (this.sourceSiteFocus !== undefined) {
+ this.sourceSiteFocus = false;
+ }
+ // #ifdef APP-PLUS
+ // 娉ㄦ剰锛氬崟鏍囩璇绘棤杩囨护鍔熻兘宸叉敼涓烘寜閿Е鍙戯紙191銆�189銆�190锛夛紝涓嶅啀鍦ㄧ劍鐐规椂鑷姩瑙﹀彂
+ // #endif
+ },
+ // 鎵樼洏鐮佽緭鍏ユ澶卞幓鐒︾偣鏃跺仠姝FID鎵弿锛堝彲閫夛級
+ onBarcodeBlur() {
+ console.log('[agv_empty] 鎵樼洏鐮佽緭鍏ユ澶卞幓鐒︾偣');
+ // #ifdef APP-PLUS
+ // 娉ㄦ剰锛氫笉鍐嶈嚜鍔ㄥ仠姝㈡壂鎻忥紝鍥犱负鍏ㄥ眬鎵弿妯″紡鏀寔鎸佺画鎵弿
+ // 濡傛灉闇�瑕佸け鍘荤劍鐐规椂鍋滄鎵弿锛屽彲浠ュ彇娑堜笅闈㈢殑娉ㄩ噴
+ // setTimeout(() => {
+ // try {
+ // if (typeof rfidScanner !== 'undefined' && rfidScanner && typeof rfidScanner.stopScan === 'function') {
+ // rfidScanner.stopScan();
+ // }
+ // } catch (e) {
+ // console.warn('[agv_empty] RFID妯″潡鍋滄澶辫触:', e);
+ // }
+ // }, 1000);
+ // #endif
+ },
+ // 鏆傚瓨浣嶈緭鍏ユ鑾峰緱鐒︾偣锛堜繚鐣欐柟娉曪紝浣嗕笉鑷姩瑙﹀彂鎵弿锛�
+ onSourceSiteFocus() {
+ console.log('[agv_empty] 鏆傚瓨浣嶈緭鍏ユ鑾峰緱鐒︾偣');
+ // 璁剧疆鏆傚瓨浣嶈緭鍏ユ涓虹劍鐐癸紝鍏朵粬杈撳叆妗嗗け鍘荤劍鐐�
+ if (this.sourceSiteFocus !== undefined) {
+ this.sourceSiteFocus = true;
+ }
+ this.barcodeFocus = false;
+ this.matFocus = false;
+ // #ifdef APP-PLUS
+ // 娉ㄦ剰锛氬崟鏍囩璇绘棤杩囨护鍔熻兘宸叉敼涓烘寜閿Е鍙戯紙191銆�189銆�190锛夛紝涓嶅啀鍦ㄧ劍鐐规椂鑷姩瑙﹀彂
+ // #endif
+ },
+ onTargetSiteChange(e) {
+ const index = e.detail.value;
+ this.selectedTargetSite = this.targetSiteList[index];
+ },
+ clearBarcode() {
+ this.barcode = '';
+ this.barcodeFocus = false;
+ setTimeout(() => {
+ this.barcodeFocus = true;
+ }, 100);
+ },
+ clearMatnr() {
+ this.matnr = '';
+ this.matFocus = false;
+ setTimeout(() => {
+ this.matFocus = true;
+ }, 100);
+ },
+ isFrozen() {
+ this.isFull = !this.isFull
+ console.log(this.isFull);
+ },
+ messageToggle(type) {
+ this.msgType1 = type
+ this.$refs.message.open()
+ },
+ // barcode input 浜嬩欢
+ barcodeInput() {
+ // #ifdef APP-PLUS
+ // 娉ㄦ剰锛氫笉鍐嶈嚜鍔ㄥ仠姝㈡壂鎻忥紝鍥犱负鍏ㄥ眬鎵弿妯″紡鏀寔鎸佺画鎵弿
+ // 濡傛灉闇�瑕佽緭鍏ュ畬鎴愬悗鍋滄鎵弿锛屽彲浠ュ彇娑堜笅闈㈢殑娉ㄩ噴
+ // setTimeout(() => {
+ // try {
+ // if (typeof rfidScanner !== 'undefined' && rfidScanner && typeof rfidScanner.stopScan === 'function') {
+ // rfidScanner.stopScan();
+ // }
+ // } catch (e) {
+ // console.warn('[agv_empty] RFID妯″潡鍋滄澶辫触:', e);
+ // }
+ // }, 500);
+ // #endif
+
+ // 涓嶈缃畾鏃跺櫒 浼氬嚭鐜版壂鍏ョ殑瀛楃涓蹭笉鍏�
+ setTimeout(() => {
+ var len = this.barcode.length
+ if (len >= 9 && len <=8) {
+ uni.showToast({
+ title: '鎵樼洏鐮佹湁璇閲嶈瘯',
+ icon: "none",
+ position: 'top'
+ });
+ this.barcodeFocuss()
+ return;
+ }
+ this.focuss()
+ }, 200)
+ },
+ // 鎵樼洏鐮佹湁璇噸缃�
+ barcodeFocuss() {
+ let that = this;
+ that.barcodeFocus = false;
+ setTimeout(() => {
+ that.barcode = '';
+ that.barcodeFocus = true;
+ }, 100);
+ },
+ // 鍟嗗搧鍏夋爣娓呯┖閲嶇疆
+ focuss() {
+ this.focus = false;
+ setTimeout(() => {
+ this.matnr = '';
+ this.matFocus = true;
+ }, 100);
+ },
+ // 鎼滅储鐗╂枡
+ findMat() {
+ let that = this
+
+ uni.request({
+ url: that.baseUrl + '/mat/auth',
+ data: {
+ matnr: that.matnr
+ },
+ header: {
+ 'token': uni.getStorageSync('token')
+ },
+ success(result) {
+ result = result.data
+ if (result.code === 200 && result.data) {
+ that.matData = result.data
+ that.matnr = ''
+ that.matData['batch'] = ''
+ uni.navigateTo({
+ url: "../mat/matSelected",
+ // 閫氳繃eventChannel鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹�
+ success: function(res) {
+ res.eventChannel.emit('mat', {
+ data: result.data
+ })
+ },
+ // 涓烘寚瀹氫簨浠舵坊鍔犱竴涓洃鍚櫒锛岃幏鍙栬鎵撳紑椤甸潰浼犻�佸埌褰撳墠椤甸潰鐨勬暟鎹�
+ events: {
+ matList: function(data) {
+ that.checkMat(data.data)
+ that.focuss()
+ },
+ },
+ });
+ } else if (result.code == 403) {
+ uni.showToast({
+ title: result.msg,
+ icon: "none",
+ position: 'top'
+ })
+ setTimeout(() => {
+ uni.reLaunch({
+ url: '../login/login'
+ });
+ }, 1000);
+ } else {
+ uni.showToast({
+ title: result.msg,
+ icon: "none",
+ position: 'top'
+ })
+ }
+
+ }
+ });
+
+ },
+ selectMat() {
+ let that = this
+ uni.navigateTo({
+ url: "../mat/matQuery",
+ success: function(res) {
+ // 閫氳繃eventChannel鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹� 鍚戝彟澶栦竴涓〉闈紶閫掑�肩殑
+ res.eventChannel.emit('commonUrl', {
+ commonUrl: ''
+ })
+ },
+ events: {
+ // 涓烘寚瀹氫簨浠舵坊鍔犱竴涓洃鍚櫒锛岃幏鍙栬鎵撳紑椤甸潰浼犻�佸埌褰撳墠椤甸潰鐨勬暟鎹� 鍙﹀涓�涓〉闈紶杩囨潵鐨�
+ acceptDataFromOpenedPage: function(data) {
+ that.matnr = data.data
+ that.findMat(that.matnr)
+ },
+ },
+
+
+ });
+ that.matnr = ''
+ },
+ checkMat(mat) {
+ var len = this.dataList.length
+ var add = true ,sameItem = false
+ for (var i = 0; i < len; i++) {
+ if (mat.matnr == this.dataList[i].matnr) {
+ for (var j = 0; j < len; j++) {
+ if (mat.batch == this.dataList[j].batch) {
+ sameItem = true
+ }
+ }
+ // 鐩稿悓鐗╂枡 涓嶅悓鎵瑰彿 鏂板姞鍒楄〃
+ if (mat.batch != this.dataList[i].batch) {
+ this.$forceUpdate() // 寮哄埗鍒锋柊
+ if (sameItem) {
+ add = false
+ } else {
+ add = true
+ }
+
+ } else {
+ // 鐩稿悓鐗╂枡鐩稿悓鎵瑰彿 鏁伴噺绱姞
+ this.dataList[i].anfme += mat.anfme
+ this.$forceUpdate() // 寮哄埗鍒锋柊
+ add = false
+ }
+ }
+ }
+ if (add) {
+ this.dataList.unshift(mat)
+ }
+ },
+ // 淇敼鎵瑰彿
+ revise(item, i) {
+ this.editMatnr = this.dataList[i].matnr
+ this.count = this.dataList[i].anfme
+ this.batch = this.dataList[i].batch
+ this.weight = this.dataList[i].weight
+ this.rowNum = i
+ this.eject()
+ },
+ eject(type) {
+ this.type = type
+ this.$refs.revise.open(type)
+ },
+ // 鍒楄〃绉婚櫎鎸夐挳
+ remove(item, i, type) {
+ this.removeNum = i
+ this.msgType = type
+ this.title = '纭绉婚櫎'
+ this.content = '鏄惁绉婚櫎璇ュ晢鍝侊紵'
+ this.$refs.alertDialog.open(i)
+ },
+ // 纭绉婚櫎
+ removeConfirm() {
+ this.messageText = "绉婚櫎鎴愬姛"
+ this.messageToggle('success')
+ this.dataList.splice(this.removeNum, 1)
+ },
+ // 鍙栨秷绉婚櫎
+ removeClose() {
+ this.$refs.alertDialog.close()
+ },
+ reviseConfirm() {
+ this.dataList[this.rowNum].anfme = this.count
+ this.dataList[this.rowNum].batch = this.batch
+ this.dataList[this.rowNum].weight = this.weight
+ this.editMatnr = ''
+ this.messageText = "淇敼鎴愬姛"
+ this.messageToggle('success')
+ this.$refs.revise.close()
+ },
+ reviseClose() {
+ this.$refs.revise.close()
+ },
+ changeValue(value) {
+ this.count = value
+ },
+ combConfirm(type) {
+ if (this.isSubmitting || this.barcode === '' || this.sourceSite === '') return;
+ this.msgType = type
+ this.title = '纭鍛煎彨'
+ this.content = '纭鍛煎彨锛�'
+ this.$refs.combConfirm.open()
+ },
+ combClose() {
+ this.$refs.combConfirm.close()
+ },
+ comb() {
+ uni.vibrateShort();
+ let that = this;
+ that.isSubmitting = true;
+ uni.request({
+ url: that.baseUrl + '/mobile/agv/start',
+ data: JSON.stringify({
+ type : that.type,
+ barcode: that.barcode,
+ sourceSite:that.sourceSite
+ }),
+ method: 'POST',
+ header: {
+ 'token': uni.getStorageSync('token')
+ },
+ success(result) {
+ var res = result.data
+ if (res.code === 200) {
+ that.resst();
+ that.messageText = "鍛煎彨鎴愬姛"
+ that.messageToggle('success')
+ } else if (res.code == 403) {
+ that.messageText = res.msg
+ that.messageToggle('error')
+ setTimeout(() => {
+ uni.reLaunch({
+ url: '../login/login'
+ });
+ }, 1000);
+ } else {
+ that.messageText = res.msg
+ that.messageToggle('error')
+ }
+ },
+ fail: () => {
+ that.messageText = "缃戠粶璇锋眰瓒呮椂"
+ that.messageToggle('error')
+ },
+ complete: () => {
+ that.isSubmitting = false;
+ }
+ });
+ },
+ reset(type) {
+ this.msgType = type
+ this.title = '纭閲嶇疆'
+ this.content = '鏄惁娓呯┖鎵�鏈夋暟鎹紵'
+ this.$refs.resetConfirm.open()
+ },
+ // 纭閲嶇疆
+ resetConfirm() {
+ this.dataList = []
+ this.barcode = ''
+ this.messageText = "閲嶇疆瀹屾垚"
+ this.messageToggle('success')
+ },
+ // 鍙栨秷閲嶇疆
+ resetClose() {
+
+ },
+ // 娓呯┖
+ resst() {
+ // this.dataList = []
+ this.barcode = ''
+ this.sourceSite = ''
+ this.barcodeFocuss()
+ },
+ }
+ }
+</script>
+
+<style>
+ /* 寮曞叆鍏叡鏍峰紡 */
+ @import url('../../static/css/common.css');
+ /* @import url('../../static/css/wms.css/wms.css'); */
+</style>
diff --git a/pages/AGV/agv_start.vue b/pages/AGV/agv_start.vue
index b4b190c..8dc0c4d 100644
--- a/pages/AGV/agv_start.vue
+++ b/pages/AGV/agv_start.vue
@@ -9,7 +9,7 @@
</view>
<view class="form-input-wrap">
<input class="form-input" type="text" placeholder="鎵爜 / 杈撳叆鎵樼洏鐮�" v-model="barcode"
- :focus="barcodeFocus" @input="barcodeInput()" />
+ :focus="barcodeFocus" @input="barcodeInput()" @focus="onBarcodeFocus()" @blur="onBarcodeBlur()" />
<uni-icons v-if="barcode" type="clear" size="18" color="#c0c4cc" @click="clearBarcode"></uni-icons>
</view>
</view>
@@ -19,7 +19,7 @@
<text class="label-text">鏆傚瓨浣�</text>
</view>
<view class="form-input-wrap">
- <input class="form-input" type="text" placeholder="鎵爜 / 杈撳叆鏆傚瓨浣�" v-model="sourceSite" />
+ <input class="form-input" type="text" placeholder="鎵爜 / 杈撳叆鏆傚瓨浣�" v-model="sourceSite" @focus="onSourceSiteFocus()" />
<uni-icons v-if="sourceSite" type="clear" size="18" color="#c0c4cc" @click="sourceSite=''"></uni-icons>
</view>
</view>
@@ -181,6 +181,7 @@
</template>
<script>
+ import rfidScanner from '@/common/rfid-scanner.js';
export default {
data() {
return {
@@ -223,8 +224,36 @@
onShow() {
this.baseUrl = uni.getStorageSync('baseUrl');
this.token = uni.getStorageSync('token');
+ // RFID宸插湪App.vue涓叏灞�鍒濆鍖栵紝杩欓噷涓嶉渶瑕佸啀鍒濆鍖�
+ // 璁剧疆褰撳墠椤甸潰瀹炰緥锛岀敤浜庡叏灞�鎵弿鏃惰嚜鍔ㄥ~鍏�
+ rfidScanner.setCurrentPageInstance(this);
+ },
+ onHide() {
+ // 椤甸潰闅愯棌鏃跺仠姝FID鎵弿锛堜絾涓嶄笅鐢碉級
+ // 娉ㄦ剰锛氫笉鍐嶈嚜鍔ㄥ仠姝㈡壂鎻忥紝鍥犱负鍏ㄥ眬鎵弿妯″紡鏀寔璺ㄩ〉闈㈡壂鎻�
+ // 濡傛灉闇�瑕侀〉闈㈤殣钘忔椂鍋滄鎵弿锛屽彲浠ュ彇娑堜笅闈㈢殑娉ㄩ噴
+ // rfidScanner.stopScan();
},
methods: {
+ // 鎵樼洏鐮佽緭鍏ユ鑾峰緱鐒︾偣锛堜繚鐣欐柟娉曪紝浣嗕笉鑷姩瑙﹀彂鎵弿锛�
+ onBarcodeFocus() {
+ console.log('[agv_start] 鎵樼洏鐮佽緭鍏ユ鑾峰緱鐒︾偣');
+ // 娉ㄦ剰锛氬崟鏍囩璇绘棤杩囨护鍔熻兘宸叉敼涓烘寜閿Е鍙戯紙191銆�189銆�190锛夛紝涓嶅啀鍦ㄧ劍鐐规椂鑷姩瑙﹀彂
+ },
+ // 鎵樼洏鐮佽緭鍏ユ澶卞幓鐒︾偣鏃跺仠姝FID鎵弿锛堝彲閫夛級
+ onBarcodeBlur() {
+ console.log('[agv_start] 鎵樼洏鐮佽緭鍏ユ澶卞幓鐒︾偣');
+ // 娉ㄦ剰锛氫笉鍐嶈嚜鍔ㄥ仠姝㈡壂鎻忥紝鍥犱负鍏ㄥ眬鎵弿妯″紡鏀寔鎸佺画鎵弿
+ // 濡傛灉闇�瑕佸け鍘荤劍鐐规椂鍋滄鎵弿锛屽彲浠ュ彇娑堜笅闈㈢殑娉ㄩ噴
+ // setTimeout(() => {
+ // rfidScanner.stopScan();
+ // }, 1000);
+ },
+ // 鏆傚瓨浣嶈緭鍏ユ鑾峰緱鐒︾偣锛堜繚鐣欐柟娉曪紝浣嗕笉鑷姩瑙﹀彂鎵弿锛�
+ onSourceSiteFocus() {
+ console.log('[agv_start] 鏆傚瓨浣嶈緭鍏ユ鑾峰緱鐒︾偣');
+ // 娉ㄦ剰锛氬崟鏍囩璇绘棤杩囨护鍔熻兘宸叉敼涓烘寜閿Е鍙戯紙191銆�189銆�190锛夛紝涓嶅啀鍦ㄧ劍鐐规椂鑷姩瑙﹀彂
+ },
onTargetSiteChange(e) {
const index = e.detail.value;
this.selectedTargetSite = this.targetSiteList[index];
@@ -253,6 +282,12 @@
},
// barcode input 浜嬩欢
barcodeInput() {
+ // 娉ㄦ剰锛氫笉鍐嶈嚜鍔ㄥ仠姝㈡壂鎻忥紝鍥犱负鍏ㄥ眬鎵弿妯″紡鏀寔鎸佺画鎵弿
+ // 濡傛灉闇�瑕佽緭鍏ュ畬鎴愬悗鍋滄鎵弿锛屽彲浠ュ彇娑堜笅闈㈢殑娉ㄩ噴
+ // setTimeout(() => {
+ // rfidScanner.stopScan();
+ // }, 500);
+
// 涓嶈缃畾鏃跺櫒 浼氬嚭鐜版壂鍏ョ殑瀛楃涓蹭笉鍏�
setTimeout(() => {
var len = this.barcode.length
diff --git a/pages/home/home.vue b/pages/home/home.vue
index 4c62735..ac33832 100644
--- a/pages/home/home.vue
+++ b/pages/home/home.vue
@@ -151,11 +151,32 @@
url: '/AGV/agv_back'
},
{
+ title: 'AGV绌烘墭鍏ュ簱',
+ name: 'agv_empty',
+ color: 'pink',
+ cuIcon: '',
+ url: '/AGV/agv_empty'
+ },
+ {
title: '搴撳瓨鏌ヨ',
name: 'stockQuery',
color: 'green',
cuIcon: '',
url: '/stock/stockQuery'
+ },
+ {
+ title: 'RFID璁剧疆',
+ name: 'rfidSettings',
+ color: 'mauve',
+ cuIcon: 'scan',
+ url: '/rfid/settings'
+ },
+ {
+ title: 'UHF娴嬭瘯',
+ name: 'uhftest',
+ color: 'red',
+ cuIcon: 'scan',
+ url: '/rfid/uhftest'
},
{
title: '閫�鍑虹櫥褰�',
@@ -178,6 +199,9 @@
'stockCheck': 'checkbox',
'agv_start': 'navigate',
'agv_back': 'refresh',
+ 'agv_empty': 'upload',
+ 'rfidSettings': 'scan',
+ 'uhftest': 'scan',
},
// 鑿滃崟鍒嗙被閰嶇疆锛堜粎鍒嗙被妯″紡浣跨敤锛�
// key: 鍒嗙被鍞竴鏍囪瘑
@@ -198,7 +222,7 @@
name: 'AGV绠$悊',
color: 'blue',
icon: 'navigate',
- menuNames: ['agv_start', 'agv_back']
+ menuNames: ['agv_start', 'agv_back', 'agv_empty']
},
{
key: 'stock_category',
@@ -206,6 +230,13 @@
color: 'green',
icon: 'search',
menuNames: ['stockQuery']
+ },
+ {
+ key: 'device_category',
+ name: '璁惧璁剧疆',
+ color: 'mauve',
+ icon: 'settings',
+ menuNames: ['rfidSettings', 'uhftest']
}
],
// 涓嶅弬涓庡垎绫荤殑鑿滃崟椤癸紙濡傞��鍑虹櫥褰曪紝濮嬬粓鍗曠嫭鏄剧ず锛�
diff --git a/pages/order/orderPakin2.vue b/pages/order/orderPakin2.vue
index a3b0af5..2905059 100644
--- a/pages/order/orderPakin2.vue
+++ b/pages/order/orderPakin2.vue
@@ -22,7 +22,7 @@
</view>
<view class="form-input-wrap">
<input class="form-input" type="text" placeholder="鎵爜 / 杈撳叆鎵樼洏鐮�" v-model="barcode"
- :focus="barcodeFocus" @input="barcodeInput()" />
+ :focus="barcodeFocus" @input="barcodeInput()" @focus="onBarcodeFocus()" />
<uni-icons v-if="barcode" type="clear" size="20" color="#c0c4cc" @click="clearBarcode"></uni-icons>
</view>
</view>
@@ -35,7 +35,7 @@
</view>
<view class="form-input-wrap">
<input class="form-input" type="text" placeholder="鎵爜澶嶆牳鐗╂枡" v-model="matnr"
- :focus="matFocus" @input="findMat()" />
+ :focus="matFocus" @input="findMat()" @focus="onMatnrFocus()" />
</view>
</view>
</view>
@@ -186,6 +186,7 @@
</template>
<script>
+ import rfidScanner from '@/common/rfid-scanner.js';
export default {
data() {
return {
@@ -231,8 +232,21 @@
onShow() {
this.baseUrl = uni.getStorageSync('baseUrl');
this.token = uni.getStorageSync('token');
+ // RFID宸插湪App.vue涓叏灞�鍒濆鍖栵紝杩欓噷涓嶉渶瑕佸啀鍒濆鍖�
+ // 璁剧疆褰撳墠椤甸潰瀹炰緥锛岀敤浜庡叏灞�鎵弿鏃惰嚜鍔ㄥ~鍏�
+ rfidScanner.setCurrentPageInstance(this);
},
methods: {
+ // 鎵樼洏鐮佽緭鍏ユ鑾峰緱鐒︾偣锛堜繚鐣欐柟娉曪紝浣嗕笉鑷姩瑙﹀彂鎵弿锛�
+ onBarcodeFocus() {
+ console.log('[orderPakin2] 鎵樼洏鐮佽緭鍏ユ鑾峰緱鐒︾偣');
+ // 娉ㄦ剰锛氬崟鏍囩璇绘棤杩囨护鍔熻兘宸叉敼涓烘寜閿Е鍙戯紙191銆�189銆�190锛夛紝涓嶅啀鍦ㄧ劍鐐规椂鑷姩瑙﹀彂
+ },
+ // 鐗╂枡鐮佽緭鍏ユ鑾峰緱鐒︾偣锛堜繚鐣欐柟娉曪紝浣嗕笉鑷姩瑙﹀彂鎵弿锛�
+ onMatnrFocus() {
+ console.log('[orderPakin2] 鐗╂枡鐮佽緭鍏ユ鑾峰緱鐒︾偣');
+ // 娉ㄦ剰锛氬崟鏍囩璇绘棤杩囨护鍔熻兘宸叉敼涓烘寜閿Е鍙戯紙191銆�189銆�190锛夛紝涓嶅啀鍦ㄧ劍鐐规椂鑷姩瑙﹀彂
+ },
messageToggle(type) {
this.msgType1 = type;
this.$refs.message.open();
diff --git a/pages/pakin/pakin.vue b/pages/pakin/pakin.vue
index 76b2afd..edd6646 100644
--- a/pages/pakin/pakin.vue
+++ b/pages/pakin/pakin.vue
@@ -9,7 +9,7 @@
</view>
<view class="form-input-wrap">
<input class="form-input" type="text" placeholder="鎵爜 / 杈撳叆鎵樼洏鐮�" v-model="barcode"
- :focus="barcodeFocus" @input="barcodeInput()" />
+ :focus="barcodeFocus" @input="barcodeInput()" @focus="onBarcodeFocus()" @blur="onBarcodeBlur()" />
<uni-icons v-if="barcode" type="clear" size="18" color="#c0c4cc" @click="clearBarcode"></uni-icons>
</view>
</view>
@@ -20,7 +20,7 @@
</view>
<view class="form-input-wrap">
<input class="form-input" type="text" placeholder="鎵爜 / 杈撳叆鐗╂枡鐮�" v-model="matnr"
- :focus="matFocus" @input="findMat()" />
+ :focus="matFocus" @input="findMat()" @focus="onMatnrFocus()" />
<uni-icons v-if="matnr" type="clear" size="18" color="#c0c4cc" @click="clearMatnr"></uni-icons>
</view>
</view>
@@ -168,6 +168,8 @@
</template>
<script>
+ import rfidScanner from '@/common/rfid-scanner.js';
+
export default {
data() {
return {
@@ -202,8 +204,36 @@
onShow() {
this.baseUrl = uni.getStorageSync('baseUrl');
this.token = uni.getStorageSync('token');
+ // RFID宸插湪App.vue涓叏灞�鍒濆鍖栵紝杩欓噷涓嶉渶瑕佸啀鍒濆鍖�
+ // 璁剧疆褰撳墠椤甸潰瀹炰緥锛岀敤浜庡叏灞�鎵弿鏃惰嚜鍔ㄥ~鍏�
+ rfidScanner.setCurrentPageInstance(this);
+ },
+ onHide() {
+ // 椤甸潰闅愯棌鏃跺仠姝FID鎵弿锛堜絾涓嶄笅鐢碉級
+ // 娉ㄦ剰锛氫笉鍐嶈嚜鍔ㄥ仠姝㈡壂鎻忥紝鍥犱负鍏ㄥ眬鎵弿妯″紡鏀寔璺ㄩ〉闈㈡壂鎻�
+ // 濡傛灉闇�瑕侀〉闈㈤殣钘忔椂鍋滄鎵弿锛屽彲浠ュ彇娑堜笅闈㈢殑娉ㄩ噴
+ // rfidScanner.stopScan();
},
methods: {
+ // 鎵樼洏鐮佽緭鍏ユ鑾峰緱鐒︾偣锛堜繚鐣欐柟娉曪紝浣嗕笉鑷姩瑙﹀彂鎵弿锛�
+ onBarcodeFocus() {
+ console.log('[pakin] 鎵樼洏鐮佽緭鍏ユ鑾峰緱鐒︾偣');
+ // 娉ㄦ剰锛氬崟鏍囩璇绘棤杩囨护鍔熻兘宸叉敼涓烘寜閿Е鍙戯紙191銆�189銆�190锛夛紝涓嶅啀鍦ㄧ劍鐐规椂鑷姩瑙﹀彂
+ },
+ // 鎵樼洏鐮佽緭鍏ユ澶卞幓鐒︾偣鏃跺仠姝FID鎵弿锛堝彲閫夛級
+ onBarcodeBlur() {
+ console.log('[pakin] 鎵樼洏鐮佽緭鍏ユ澶卞幓鐒︾偣');
+ // 娉ㄦ剰锛氫笉鍐嶈嚜鍔ㄥ仠姝㈡壂鎻忥紝鍥犱负鍏ㄥ眬鎵弿妯″紡鏀寔鎸佺画鎵弿
+ // 濡傛灉闇�瑕佸け鍘荤劍鐐规椂鍋滄鎵弿锛屽彲浠ュ彇娑堜笅闈㈢殑娉ㄩ噴
+ // setTimeout(() => {
+ // rfidScanner.stopScan();
+ // }, 1000);
+ },
+ // 鐗╂枡鐮佽緭鍏ユ鑾峰緱鐒︾偣锛堜繚鐣欐柟娉曪紝浣嗕笉鑷姩瑙﹀彂鎵弿锛�
+ onMatnrFocus() {
+ console.log('[pakin] 鐗╂枡鐮佽緭鍏ユ鑾峰緱鐒︾偣');
+ // 娉ㄦ剰锛氬崟鏍囩璇绘棤杩囨护鍔熻兘宸叉敼涓烘寜閿Е鍙戯紙191銆�189銆�190锛夛紝涓嶅啀鍦ㄧ劍鐐规椂鑷姩瑙﹀彂
+ },
clearBarcode() {
this.barcode = '';
this.barcodeFocus = false;
@@ -228,6 +258,12 @@
},
// barcode input 浜嬩欢
barcodeInput() {
+ // 娉ㄦ剰锛氫笉鍐嶈嚜鍔ㄥ仠姝㈡壂鎻忥紝鍥犱负鍏ㄥ眬鎵弿妯″紡鏀寔鎸佺画鎵弿
+ // 濡傛灉闇�瑕佽緭鍏ュ畬鎴愬悗鍋滄鎵弿锛屽彲浠ュ彇娑堜笅闈㈢殑娉ㄩ噴
+ // setTimeout(() => {
+ // rfidScanner.stopScan();
+ // }, 500);
+
// 涓嶈缃畾鏃跺櫒 浼氬嚭鐜版壂鍏ョ殑瀛楃涓蹭笉鍏�
setTimeout(() => {
var len = this.barcode.length
diff --git a/pages/rfid/settings.vue b/pages/rfid/settings.vue
new file mode 100644
index 0000000..a3cef24
--- /dev/null
+++ b/pages/rfid/settings.vue
@@ -0,0 +1,800 @@
+<template>
+ <view class="page-container">
+ <!-- 鐘舵�佹爮 -->
+ <view class="status-section">
+ <view class="status-card">
+ <view class="status-item">
+ <text class="status-label">涓婄數鐘舵��</text>
+ <text class="status-value" :class="{'success': powerStatus === 'connected', 'error': powerStatus !== 'connected'}">
+ {{ powerStatus === 'connected' ? '宸茶繛鎺�' : '鏈繛鎺�' }}
+ </text>
+ </view>
+ <view class="status-item">
+ <text class="status-label">鎵弿鐘舵��</text>
+ <text class="status-value" :class="{'success': isScanning, 'error': !isScanning}">
+ {{ isScanning ? '鎵弿涓�' : '鏈壂鎻�' }}
+ </text>
+ </view>
+ </view>
+ </view>
+
+ <!-- 鎵弿缁撴灉鏄剧ず -->
+ <view class="scan-result-section">
+ <view class="section-header">
+ <text class="section-title">鎵弿缁撴灉 ({{ scanResults.length }})</text>
+ <view class="btn-clear" @click="clearResults">
+ <uni-icons type="trash" size="16" color="#f56c6c"></uni-icons>
+ <text class="btn-clear-text">娓呯┖</text>
+ </view>
+ </view>
+ <scroll-view class="result-list" scroll-y>
+ <view class="result-item" v-for="(item, index) in scanResults" :key="index">
+ <view class="result-header">
+ <text class="result-index">#{{ index + 1 }}</text>
+ <text class="result-time">{{ item.time }}</text>
+ </view>
+ <view class="result-content">
+ <view class="result-row" v-if="item.epc">
+ <text class="result-label">EPC:</text>
+ <text class="result-value">{{ item.epc }}</text>
+ </view>
+ <view class="result-row" v-if="item.tid">
+ <text class="result-label">TID:</text>
+ <text class="result-value">{{ item.tid }}</text>
+ </view>
+ </view>
+ </view>
+ <view class="empty-result" v-if="scanResults.length === 0">
+ <text class="empty-text">鏆傛棤鎵弿缁撴灉</text>
+ <text class="empty-hint">璇峰皢鏍囩鏀惧湪璇诲彇鑼冨洿鍐�</text>
+ </view>
+ </scroll-view>
+ </view>
+
+ <!-- 鎺у埗鎸夐挳 -->
+ <view class="control-section">
+ <button class="btn-control" :class="{'btn-scanning': isScanning}" @click.stop="handleStartStopScan" @tap.stop="handleStartStopScan">
+ {{ isScanning ? '鍋滄鎵弿' : '寮�濮嬫壂鎻�' }}
+ </button>
+ </view>
+ </view>
+</template>
+
+<script>
+ import idataRFID from '@/common/idata-rfid.js';
+
+ export default {
+ data() {
+ return {
+ isScanning: false,
+ powerStatus: 'disconnected',
+ scanResults: [],
+ moduleTypeIndex: 0, // 0=UM妯″潡, 1=SLR妯″潡, 2=GX妯″潡
+ initRetryCount: 0,
+ maxRetryCount: 3,
+ readTagTimer: null, // 鍗曟爣绛捐鍙栧畾鏃跺櫒
+ readTagInterval: 300, // 璇诲彇闂撮殧锛堟绉掞級- 缂╃煭鍒�300ms锛屾洿蹇疆鎹�
+ currentMethod: 0, // 褰撳墠浣跨敤鐨勬柟娉曠储寮�
+ methodNames: ['杩炵画鎵弿', '鍗曟爣绛捐鍙朎PC', '鍗曟爣绛捐鍙朤ID', '鍗曟爣绛捐鍙朎PC(鍦板潃0)', '鍗曟爣绛捐鍙朎PC(鍦板潃1)'],
+ methodCounter: 0, // 鏂规硶璋冪敤璁℃暟鍣�
+ methodMaxRetries: 5, // 姣忕鏂规硶鏈�澶氬皾璇�5娆★紙绾�1.5绉掞級灏卞垏鎹㈠埌涓嬩竴涓�
+ methodSwitchTimer: null // 鏂规硶鍒囨崲瀹氭椂鍣�
+ }
+ },
+ onShow() {
+ // 鍙傝�冪ず渚嬮」鐩細鍦� onShow() 涓垵濮嬪寲
+ console.log('[RFID] ========== onShow() 椤甸潰鏄剧ず ==========');
+
+ // 鐩戝惉涓婄數浜嬩欢锛堝弬鑰冪ず渚嬮」鐩細鍦� onShow() 涓洃鍚級
+ idataRFID.onPowerEvent((e) => {
+ console.log('[RFID] POWEREvent:', JSON.stringify(e));
+ if (e && e.status === 'connected') {
+ this.powerStatus = 'connected';
+ console.log('[RFID] 鉁� 妯″潡宸蹭笂鐢�');
+ // 涓婄數鎴愬姛鍚庯紝鍏堣缃弬鏁帮紝鍐嶅紑鍚壂鎻�
+ this.setupAndStartScan();
+ } else {
+ this.powerStatus = 'disconnected';
+ console.log('[RFID] 鉁� 妯″潡鏈笂鐢�');
+ }
+ });
+
+ // 鐩戝惉鎵弿浜嬩欢锛堣繛缁壂鎻忔ā寮� - 鏂规硶1浣跨敤锛�
+ idataRFID.onScanEvent((e) => {
+ console.log('[RFID] ========== 銆愭柟娉�1銆慽DataUHFEvent 浜嬩欢瑙﹀彂 ==========');
+ console.log('[RFID] 銆愭柟娉�1銆戜簨浠舵暟鎹�:', JSON.stringify(e));
+ if (e) {
+ const result = {
+ epc: e.epc || '',
+ tid: e.tid || '',
+ time: new Date().toLocaleTimeString()
+ };
+ console.log('[RFID] 銆愭柟娉�1銆戔湏鉁撯湏鉁撯湏 鎴愬姛鎵弿鍒版爣绛撅紝EPC:', result.epc, 'TID:', result.tid);
+
+ // 濡傛灉鏂规硶1鎴愬姛锛屾竻闄ゅ垏鎹㈠畾鏃跺櫒锛屽仠姝㈣疆鎹�
+ if (this.methodSwitchTimer) {
+ clearTimeout(this.methodSwitchTimer);
+ this.methodSwitchTimer = null;
+ console.log('[RFID] 銆愭柟娉�1銆戞垚鍔燂紒鍋滄杞崲锛岀户缁娇鐢ㄨ繛缁壂鎻忔ā寮�');
+ }
+
+ // 妫�鏌ユ槸鍚﹀凡瀛樺湪锛堥伩鍏嶉噸澶嶏級
+ const exists = this.scanResults.some(item =>
+ (item.epc && item.epc === result.epc) ||
+ (item.tid && item.tid === result.tid)
+ );
+
+ if (!exists) {
+ this.scanResults.unshift(result);
+ // 闄愬埗鏈�澶氫繚瀛�100鏉�
+ if (this.scanResults.length > 100) {
+ this.scanResults = this.scanResults.slice(0, 100);
+ }
+ idataRFID.showToast('鎵弿鍒版爣绛�');
+ }
+ } else {
+ console.warn('[RFID] 銆愭柟娉�1銆戞壂鎻忎簨浠舵暟鎹负绌�');
+ }
+ console.log('[RFID] ====================================');
+ });
+
+ // 鑷姩鍒濆鍖栵紙鍙傝�冪ず渚嬮」鐩細鍦� onShow() 涓垵濮嬪寲锛�
+ this.autoInit();
+ },
+ onHide() {
+ // 鍙傝�冪ず渚嬮」鐩細鍦� onHide() 涓竻鐞�
+ console.log('[RFID] ========== onHide() 椤甸潰闅愯棌 ==========');
+ this.stopReadTag();
+ idataRFID.closeUHF();
+ idataRFID.removeEventListeners();
+ },
+ onLoad() {
+ // 椤甸潰鍔犺浇鏃朵笉鍋氫换浣曟搷浣滐紝绛夊緟 onShow() 瑙﹀彂
+ console.log('[RFID] ========== onLoad() 椤甸潰鍔犺浇 ==========');
+ },
+ onUnload() {
+ // 鍙傝�冪ず渚嬮」鐩細鍦� onUnload() 涓竻鐞�
+ console.log('[RFID] ========== onUnload() 椤甸潰鍗歌浇 ==========');
+ this.stopReadTag();
+ idataRFID.closeUHF();
+ idataRFID.removeEventListeners();
+ },
+ methods: {
+ // 鑷姩鍒濆鍖�
+ autoInit() {
+ console.log('[RFID] ========== 鑷姩鍒濆鍖栨ā鍧� ==========');
+ console.log('[RFID] 妯″潡绫诲瀷:', ['UM妯″潡', 'SLR妯″潡', 'GX妯″潡'][this.moduleTypeIndex]);
+ idataRFID.initUHF(this.moduleTypeIndex, (ret) => {
+ console.log('[RFID] initUHF result:', JSON.stringify(ret));
+ if (ret && (ret.code === 'success' || (typeof ret === 'string' && ret.includes('success')))) {
+ console.log('[RFID] 鉁� 鍒濆鍖栨垚鍔燂紝绛夊緟涓婄數...');
+ } else {
+ // 濡傛灉澶辫触锛屽皾璇曞叾浠栨ā鍧楃被鍨�
+ this.initRetryCount++;
+ if (this.initRetryCount < this.maxRetryCount) {
+ console.log('[RFID] 鍒濆鍖栧け璐ワ紝灏濊瘯鍏朵粬妯″潡绫诲瀷...');
+ this.moduleTypeIndex = (this.moduleTypeIndex + 1) % 3;
+ setTimeout(() => {
+ this.autoInit();
+ }, 2000);
+ } else {
+ console.error('[RFID] 鉁� 鍒濆鍖栧け璐ワ紝宸插皾璇曟墍鏈夋ā鍧楃被鍨�');
+ console.error('[RFID] 璇锋墜鍔ㄩ�夋嫨姝g‘鐨勬ā鍧楃被鍨�');
+ }
+ }
+ });
+ },
+
+ // 璁剧疆鍙傛暟骞跺紑鍚壂鎻�
+ setupAndStartScan() {
+ if (this.powerStatus !== 'connected') {
+ console.log('[RFID] 妯″潡鏈笂鐢碉紝鏃犳硶璁剧疆鍙傛暟');
+ return;
+ }
+
+ console.log('[RFID] ========== 璁剧疆鍙傛暟骞跺紑鍚壂鎻� ==========');
+
+ // 姝ラ1锛氳缃姛鐜囷紙25锛屽鏋滃け璐ヤ篃涓嶅奖鍝嶏級
+ console.log('[RFID] 姝ラ1: 璁剧疆鍔熺巼涓�25...');
+ idataRFID.setPower(25, (ret) => {
+ console.log('[RFID] setPower result:', JSON.stringify(ret));
+ if (ret && ret.code === 'success') {
+ console.log('[RFID] 鉁� 鍔熺巼璁剧疆鎴愬姛');
+ } else {
+ console.log('[RFID] 鈿� 鍔熺巼璁剧疆澶辫触锛堝彲鑳戒笉鏀寔鎴栧凡璁剧疆锛�:', ret ? ret.msg : '鏈煡閿欒');
+ }
+
+ // 姝ラ2锛氳缃鐜囷紙1=涓浗920-925MHz锛�
+ setTimeout(() => {
+ console.log('[RFID] 姝ラ2: 璁剧疆棰戠巼涓轰腑鍥�(920-925MHz)...');
+ idataRFID.setFrequencyMode(1, (ret) => {
+ console.log('[RFID] setFrequencyMode result:', JSON.stringify(ret));
+ if (ret && ret.code === 'success') {
+ console.log('[RFID] 鉁� 棰戠巼璁剧疆鎴愬姛');
+ } else {
+ console.log('[RFID] 鈿� 棰戠巼璁剧疆澶辫触锛堝彲鑳戒笉鏀寔鎴栧凡璁剧疆锛�:', ret ? ret.msg : '鏈煡閿欒');
+ }
+
+ // 姝ラ3锛氳缃鍙栨ā寮忥紙鍙傝�僓HFDemo锛氬厛璁剧疆璇诲彇妯″紡锛屽啀寮�鍚壂鎻忥級
+ setTimeout(() => {
+ console.log('[RFID] 姝ラ3: 璁剧疆璇诲彇妯″紡涓篍PC锛堝弬鑰僓HFDemo娴佺▼锛�...');
+ idataRFID.readTagModeSet(0, (ret) => {
+ console.log('[RFID] readTagModeSet result:', JSON.stringify(ret));
+ if (ret && (ret.code === 'success' || (typeof ret === 'string' && ret.includes('success')))) {
+ console.log('[RFID] 鉁� 璇诲彇妯″紡璁剧疆鎴愬姛');
+ } else {
+ console.log('[RFID] 鈿� 璇诲彇妯″紡璁剧疆澶辫触锛堝彲鑳戒笉鏀寔锛�:', ret);
+ }
+
+ // 姝ラ4锛氬欢杩�1绉掑悗寮�鍚繛缁壂鎻忥紙鍙傝�僓HFDemo锛歴tartInventoryTag鍚庣珛鍗冲紑濮嬭鍙栵級
+ setTimeout(() => {
+ console.log('[RFID] ========== 鍙傝�僓HFDemo娴佺▼寮�鍚壂鎻� ==========');
+ console.log('[RFID] UHFDemo娴佺▼: powerOn() 鈫� startInventoryTag() 鈫� readTagFromBuffer()寰幆');
+ console.log('[RFID] iData娴佺▼: initUHF() 鈫� POWEREvent 鈫� readTagModeSet() 鈫� startOrStopRFID() 鈫� iDataUHFEvent');
+ this.startReadTagLoop();
+ }, 1000);
+ });
+ }, 500);
+ });
+ }, 500);
+ });
+ },
+
+ // 寮�鍚鍙栵紙杞崲灏濊瘯涓嶅悓鏂规硶锛�
+ startReadTagLoop() {
+ if (this.powerStatus !== 'connected') {
+ console.log('[RFID] 妯″潡鏈笂鐢碉紝鏃犳硶寮�鍚鍙�');
+ idataRFID.showToast('妯″潡鏈笂鐢�');
+ return;
+ }
+
+ if (this.isScanning) {
+ console.log('[RFID] 璇诲彇宸插湪杩涜涓�');
+ return;
+ }
+
+ console.log('[RFID] ========== 寮�濮嬭疆鎹㈠皾璇曚笉鍚屾柟娉� ==========');
+ console.log('[RFID] 褰撳墠鏂规硶:', this.methodNames[this.currentMethod]);
+ console.log('[RFID] 銆愭彁绀恒�戣灏嗘爣绛炬斁鍦ㄨ鍙栬寖鍥村唴锛�5-10cm锛�');
+
+ this.isScanning = true;
+ this.methodCounter = 0;
+
+ // 鏍规嵁褰撳墠鏂规硶绱㈠紩閫夋嫨涓嶅悓鐨勮鍙栨柟寮�
+ this.tryCurrentMethod();
+ },
+
+ // 灏濊瘯褰撳墠鏂规硶
+ tryCurrentMethod() {
+ if (!this.isScanning || this.powerStatus !== 'connected') {
+ console.log('[RFID] tryCurrentMethod: 宸插仠姝㈡垨鏈笂鐢碉紝閫�鍑�');
+ return;
+ }
+
+ // 鏂规硶1鐗规畩澶勭悊锛氬彧鎵ц涓�娆★紝绛夊緟浜嬩欢
+ if (this.currentMethod === 0) {
+ if (this.methodCounter === 0) {
+ this.methodCounter = 1;
+ console.log(`[RFID] ========== 鏂规硶1: 杩炵画鎵弿 (寮�濮嬶紝绛夊緟3绉�) ==========`);
+ this.methodContinuousScan();
+ // 璁剧疆瓒呮椂锛�3绉掑悗鍒囨崲鍒颁笅涓�涓柟娉�
+ this.methodSwitchTimer = setTimeout(() => {
+ if (this.isScanning && this.scanResults.length === 0) {
+ console.log(`[RFID] 銆愭柟娉�1銆�3绉掓湭鎵弿鍒版爣绛撅紝鍒囨崲鍒颁笅涓�涓柟娉昤);
+ this.switchToNextMethod();
+ }
+ }, 3000);
+ }
+ return; // 鏂规硶1鍙墽琛屼竴娆★紝鐩存帴杩斿洖
+ }
+
+ // 鏂规硶2-5锛氬惊鐜皾璇�
+ this.methodCounter++;
+ const elapsedTime = (this.methodCounter * this.readTagInterval / 1000).toFixed(1);
+ console.log(`[RFID] ========== 鏂规硶${this.currentMethod + 1}: ${this.methodNames[this.currentMethod]} (绗�${this.methodCounter}娆★紝宸茬敤鏃�${elapsedTime}绉�) ==========`);
+
+ switch(this.currentMethod) {
+ case 1:
+ // 鏂规硶2: 鍗曟爣绛捐鍙朎PC锛堝湴鍧�2锛�
+ this.methodReadEPC(2);
+ break;
+ case 2:
+ // 鏂规硶3: 鍗曟爣绛捐鍙朤ID锛堝湴鍧�0锛�
+ this.methodReadTID(0);
+ break;
+ case 3:
+ // 鏂规硶4: 鍗曟爣绛捐鍙朎PC锛堝湴鍧�0锛�
+ this.methodReadEPC(0);
+ break;
+ case 4:
+ // 鏂规硶5: 鍗曟爣绛捐鍙朎PC锛堝湴鍧�1锛�
+ this.methodReadEPC(1);
+ break;
+ }
+
+ // 濡傛灉褰撳墠鏂规硶灏濊瘯娆℃暟杈惧埌涓婇檺锛屽垏鎹㈠埌涓嬩竴涓柟娉�
+ if (this.methodCounter >= this.methodMaxRetries) {
+ console.log(`[RFID] 銆愭柟娉�${this.currentMethod + 1}銆戝凡灏濊瘯${this.methodCounter}娆★紝鍒囨崲鍒颁笅涓�涓柟娉昤);
+ this.switchToNextMethod();
+ } else {
+ // 缁х画灏濊瘯褰撳墠鏂规硶
+ setTimeout(() => {
+ if (this.isScanning && this.powerStatus === 'connected' && this.currentMethod !== 0) {
+ this.tryCurrentMethod();
+ }
+ }, this.readTagInterval);
+ }
+ },
+
+ // 鏂规硶1: 杩炵画鎵弿妯″紡锛堝弬鑰僓HFDemo锛歴tartInventoryTag + readTagFromBuffer寰幆锛�
+ methodContinuousScan() {
+ console.log('[RFID] 銆愭柟娉�1銆戣繛缁壂鎻忔ā寮� - startOrStopRFID锛堝搴擴HFDemo鐨剆tartInventoryTag锛�');
+ console.log('[RFID] 銆愭柟娉�1銆戝弬鑰僓HFDemo: startInventoryTag() 鈫� readTagFromBuffer()寰幆');
+ console.log('[RFID] 銆愭柟娉�1銆慽Data瀵瑰簲: startOrStopRFID() 鈫� iDataUHFEvent浜嬩欢');
+ console.log('[RFID] 銆愭柟娉�1銆戝皢绛夊緟3绉掞紝濡傛灉鏈塱DataUHFEvent浜嬩欢鍒欐垚鍔燂紝鍚﹀垯鍒囨崲鍒颁笅涓�涓柟娉�');
+
+ idataRFID.startOrStopRFID((ret) => {
+ console.log('[RFID] 銆愭柟娉�1銆憇tartOrStopRFID result:', JSON.stringify(ret));
+ if (ret && ret.code === 'success' && ret.msg === 'start') {
+ console.log('[RFID] 銆愭柟娉�1銆戔湏 杩炵画鎵弿宸插惎鍔紙鐩稿綋浜嶶HFDemo鐨剆tartInventoryTag鎴愬姛锛�');
+ console.log('[RFID] 銆愭柟娉�1銆戠瓑寰� iDataUHFEvent 浜嬩欢锛堢浉褰撲簬UHFDemo鐨剅eadTagFromBuffer杩斿洖鏁版嵁锛�...');
+ console.log('[RFID] 銆愭柟娉�1銆戝鏋�3绉掑唴娌℃湁浜嬩欢锛屽皢鑷姩鍒囨崲鍒颁笅涓�涓柟娉�');
+ } else {
+ console.error('[RFID] 銆愭柟娉�1銆戔湕 寮�鍚壂鎻忓け璐�:', ret ? ret.msg : '鏈煡閿欒');
+ // 濡傛灉鍚姩澶辫触锛岀珛鍗冲垏鎹㈠埌涓嬩竴涓柟娉�
+ setTimeout(() => {
+ this.switchToNextMethod();
+ }, 500);
+ }
+ });
+ },
+
+ // 鏂规硶2-5: 鍗曟爣绛捐鍙朎PC
+ methodReadEPC(startBlock) {
+ // 纭繚褰撳墠鏂规硶涓嶆槸鏂规硶1
+ if (this.currentMethod === 0) {
+ console.error('[RFID] 閿欒锛氭柟娉�1涓嶅簲璇ヨ皟鐢� methodReadEPC');
+ return;
+ }
+
+ console.log(`[RFID] 銆愭柟娉�${this.currentMethod + 1}銆戝崟鏍囩璇诲彇EPC锛岃捣濮嬪湴鍧�: ${startBlock}`);
+ console.log(`[RFID] 銆愭柟娉�${this.currentMethod + 1}銆戝綋鍓嶇姸鎬� - isScanning: ${this.isScanning}, powerStatus: ${this.powerStatus}, currentMethod: ${this.currentMethod}`);
+
+ idataRFID.readTagWithoutFilter(
+ 1, // EPC鍖哄煙
+ startBlock, // 璧峰鍦板潃
+ 6, // 鏁版嵁闀垮害
+ '00000000',
+ (ret) => {
+ // 妫�鏌ユ槸鍚﹁繕鍦ㄤ娇鐢ㄥ綋鍓嶆柟娉曪紙鍙兘宸茬粡鍒囨崲浜嗭級
+ if (this.currentMethod === 0) {
+ console.log(`[RFID] 銆愭柟娉�${this.currentMethod + 1}銆戝洖璋冩椂鏂规硶宸插垏鎹紝蹇界暐缁撴灉`);
+ return;
+ }
+
+ console.log(`[RFID] 銆愭柟娉�${this.currentMethod + 1}銆憆eadTagWithoutFilter result:`, JSON.stringify(ret));
+ if (ret && ret.code === 'success' && ret.data) {
+ const epc = ret.data.trim();
+ console.log(`[RFID] 銆愭柟娉�${this.currentMethod + 1}銆戔湏鉁撯湏鉁撯湏 鎴愬姛璇诲彇鍒版爣绛� EPC:`, epc);
+ this.addScanResult({ epc: epc, tid: '' });
+ idataRFID.showToast('璇诲彇鎴愬姛: ' + epc.substring(0, 16));
+ // 鎴愬姛璇诲彇鍚庯紝鍋滄杞崲锛岀户缁娇鐢ㄥ綋鍓嶆柟娉�
+ console.log(`[RFID] 銆愭柟娉�${this.currentMethod + 1}銆戞垚鍔燂紒鍋滄杞崲锛岀户缁娇鐢ㄦ鏂规硶`);
+ // 缁х画寰幆璇诲彇
+ setTimeout(() => {
+ if (this.isScanning && this.powerStatus === 'connected' && this.currentMethod !== 0) {
+ this.methodReadEPC(startBlock);
+ }
+ }, this.readTagInterval);
+ } else {
+ // 澶辫触鏃剁户缁皾璇曪紙鐢眛ryCurrentMethod鎺у埗锛�
+ console.log(`[RFID] 銆愭柟娉�${this.currentMethod + 1}銆戣鍙栧け璐� (code: ${ret ? ret.code : 'undefined'}, msg: ${ret ? ret.msg : 'undefined'})`);
+ }
+ }
+ );
+ },
+
+ // 鏂规硶3: 鍗曟爣绛捐鍙朤ID
+ methodReadTID(startBlock) {
+ // 纭繚褰撳墠鏂规硶涓嶆槸鏂规硶1
+ if (this.currentMethod === 0) {
+ console.error('[RFID] 閿欒锛氭柟娉�1涓嶅簲璇ヨ皟鐢� methodReadTID');
+ return;
+ }
+
+ console.log(`[RFID] 銆愭柟娉�${this.currentMethod + 1}銆戝崟鏍囩璇诲彇TID锛岃捣濮嬪湴鍧�: ${startBlock}`);
+ console.log(`[RFID] 銆愭柟娉�${this.currentMethod + 1}銆戝綋鍓嶇姸鎬� - isScanning: ${this.isScanning}, powerStatus: ${this.powerStatus}, currentMethod: ${this.currentMethod}`);
+
+ idataRFID.readTagWithoutFilter(
+ 2, // TID鍖哄煙
+ startBlock, // 璧峰鍦板潃
+ 6, // 鏁版嵁闀垮害
+ '00000000',
+ (ret) => {
+ // 妫�鏌ユ槸鍚﹁繕鍦ㄤ娇鐢ㄥ綋鍓嶆柟娉曪紙鍙兘宸茬粡鍒囨崲浜嗭級
+ if (this.currentMethod === 0) {
+ console.log(`[RFID] 銆愭柟娉�${this.currentMethod + 1}銆戝洖璋冩椂鏂规硶宸插垏鎹紝蹇界暐缁撴灉`);
+ return;
+ }
+
+ console.log(`[RFID] 銆愭柟娉�${this.currentMethod + 1}銆憆eadTagWithoutFilter result:`, JSON.stringify(ret));
+ if (ret && ret.code === 'success' && ret.data) {
+ const tid = ret.data.trim();
+ console.log(`[RFID] 銆愭柟娉�${this.currentMethod + 1}銆戔湏鉁撯湏鉁撯湏 鎴愬姛璇诲彇鍒版爣绛� TID:`, tid);
+ this.addScanResult({ epc: '', tid: tid });
+ idataRFID.showToast('璇诲彇鎴愬姛: ' + tid.substring(0, 16));
+ // 鎴愬姛璇诲彇鍚庯紝鍋滄杞崲锛岀户缁娇鐢ㄥ綋鍓嶆柟娉�
+ console.log(`[RFID] 銆愭柟娉�${this.currentMethod + 1}銆戞垚鍔燂紒鍋滄杞崲锛岀户缁娇鐢ㄦ鏂规硶`);
+ // 缁х画寰幆璇诲彇
+ setTimeout(() => {
+ if (this.isScanning && this.powerStatus === 'connected' && this.currentMethod !== 0) {
+ this.methodReadTID(startBlock);
+ }
+ }, this.readTagInterval);
+ } else {
+ // 澶辫触鏃剁户缁皾璇曪紙鐢眛ryCurrentMethod鎺у埗锛�
+ console.log(`[RFID] 銆愭柟娉�${this.currentMethod + 1}銆戣鍙栧け璐� (code: ${ret ? ret.code : 'undefined'}, msg: ${ret ? ret.msg : 'undefined'})`);
+ }
+ }
+ );
+ },
+
+ // 鍒囨崲鍒颁笅涓�涓柟娉�
+ switchToNextMethod() {
+ // 娓呴櫎鏂规硶1鐨勮秴鏃跺畾鏃跺櫒
+ if (this.methodSwitchTimer) {
+ clearTimeout(this.methodSwitchTimer);
+ this.methodSwitchTimer = null;
+ }
+
+ // 濡傛灉鏂规硶1姝e湪杩愯锛屽厛鍋滄瀹�
+ if (this.currentMethod === 0 && this.isScanning) {
+ idataRFID.startOrStopRFID((ret) => {
+ console.log('[RFID] 鍋滄鏂规硶1鐨勬壂鎻�:', JSON.stringify(ret));
+ this.doSwitchToNextMethod();
+ });
+ } else {
+ this.doSwitchToNextMethod();
+ }
+ },
+
+ // 鎵ц鍒囨崲鍒颁笅涓�涓柟娉�
+ doSwitchToNextMethod() {
+ this.currentMethod = (this.currentMethod + 1) % this.methodNames.length;
+ this.methodCounter = 0;
+ console.log(`[RFID] ========== 鍒囨崲鍒版柟娉�${this.currentMethod + 1}: ${this.methodNames[this.currentMethod]} ==========`);
+ console.log(`[RFID] 姣忕鏂规硶灏嗗皾璇�${this.methodMaxRetries}娆★紙绾�${(this.methodMaxRetries * this.readTagInterval / 1000).toFixed(1)}绉掞級`);
+ setTimeout(() => {
+ if (this.isScanning && this.powerStatus === 'connected') {
+ this.tryCurrentMethod();
+ }
+ }, 300);
+ },
+
+ // 娣诲姞鎵弿缁撴灉
+ addScanResult(result) {
+ const exists = this.scanResults.some(item =>
+ (item.epc && item.epc === result.epc) ||
+ (item.tid && item.tid === result.tid)
+ );
+
+ if (!exists) {
+ result.time = new Date().toLocaleTimeString();
+ this.scanResults.unshift(result);
+ if (this.scanResults.length > 100) {
+ this.scanResults = this.scanResults.slice(0, 100);
+ }
+ }
+ },
+
+ // 璇诲彇鍗曚釜鏍囩
+ readSingleTag() {
+ if (this.powerStatus !== 'connected') {
+ return;
+ }
+
+ // 灏濊瘯澶氱璇诲彇鏂瑰紡
+ // 鏂瑰紡1锛氳鍙朎PC鍖哄煙锛堣捣濮嬪湴鍧�2锛岄暱搴�6锛�
+ idataRFID.readTagWithoutFilter(
+ 1, // EPC鍖哄煙
+ 2, // 璧峰鍦板潃锛圵ord锛�
+ 6, // 鏁版嵁闀垮害锛圵ord锛�
+ '00000000', // 璁块棶瀵嗙爜
+ (ret) => {
+ if (ret && ret.code === 'success' && ret.data) {
+ // 妫�鏌ユ槸鍚﹀凡瀛樺湪锛堥伩鍏嶉噸澶嶏級
+ const epc = ret.data.trim();
+ const exists = this.scanResults.some(item => item.epc === epc);
+
+ if (!exists) {
+ const result = {
+ epc: epc,
+ tid: '',
+ time: new Date().toLocaleTimeString()
+ };
+ this.scanResults.unshift(result);
+ // 闄愬埗鏈�澶氫繚瀛�100鏉�
+ if (this.scanResults.length > 100) {
+ this.scanResults = this.scanResults.slice(0, 100);
+ }
+ console.log('[RFID] 鉁� 璇诲彇鍒版爣绛� EPC:', epc);
+ idataRFID.showToast('璇诲彇鎴愬姛: ' + epc.substring(0, 16));
+ }
+ } else if (ret && ret.code === 'fail') {
+ // 濡傛灉EPC璇诲彇澶辫触锛屽皾璇曡鍙朤ID
+ this.readSingleTagTID();
+ }
+ }
+ );
+ },
+
+ // 璇诲彇TID鍖哄煙锛堝鐢ㄦ柟妗堬級
+ readSingleTagTID() {
+ if (this.powerStatus !== 'connected') {
+ return;
+ }
+
+ // 璇诲彇TID鍖哄煙锛堣捣濮嬪湴鍧�0锛岄暱搴�6锛�
+ idataRFID.readTagWithoutFilter(
+ 2, // TID鍖哄煙
+ 0, // 璧峰鍦板潃锛圵ord锛�
+ 6, // 鏁版嵁闀垮害锛圵ord锛�
+ '00000000', // 璁块棶瀵嗙爜
+ (ret) => {
+ if (ret && ret.code === 'success' && ret.data) {
+ const tid = ret.data.trim();
+ const exists = this.scanResults.some(item => item.tid === tid);
+
+ if (!exists) {
+ const result = {
+ epc: '',
+ tid: tid,
+ time: new Date().toLocaleTimeString()
+ };
+ this.scanResults.unshift(result);
+ if (this.scanResults.length > 100) {
+ this.scanResults = this.scanResults.slice(0, 100);
+ }
+ console.log('[RFID] 鉁� 璇诲彇鍒版爣绛� TID:', tid);
+ idataRFID.showToast('璇诲彇鎴愬姛: ' + tid.substring(0, 16));
+ }
+ }
+ }
+ );
+ },
+
+ // 鍋滄璇诲彇
+ stopReadTag() {
+ console.log('[RFID] stopReadTag 琚皟鐢�');
+
+ if (this.readTagTimer) {
+ clearInterval(this.readTagTimer);
+ this.readTagTimer = null;
+ console.log('[RFID] 瀹氭椂鍣ㄥ凡娓呴櫎');
+ }
+
+ if (this.methodSwitchTimer) {
+ clearTimeout(this.methodSwitchTimer);
+ this.methodSwitchTimer = null;
+ console.log('[RFID] 鏂规硶鍒囨崲瀹氭椂鍣ㄥ凡娓呴櫎');
+ }
+
+ this.isScanning = false;
+
+ // 鍋滄杩炵画鎵弿锛堝鏋滄鍦ㄤ娇鐢ㄦ柟娉�1锛�
+ if (this.currentMethod === 0) {
+ idataRFID.startOrStopRFID((ret) => {
+ console.log('[RFID] stop scan result:', JSON.stringify(ret));
+ console.log('[RFID] 杩炵画鎵弿宸插仠姝�');
+ });
+ }
+
+ console.log('[RFID] 鎵�鏈夎鍙栨柟娉曞凡鍋滄');
+ },
+
+ // 寮�濮�/鍋滄璇诲彇
+ handleStartStopScan() {
+ console.log('[RFID] ========== 鎸夐挳鐐瑰嚮 ==========');
+ console.log('[RFID] 褰撳墠鐘舵�� - isScanning:', this.isScanning, 'powerStatus:', this.powerStatus);
+
+ if (this.powerStatus !== 'connected') {
+ console.log('[RFID] 妯″潡鏈笂鐢碉紝鏃犳硶鎿嶄綔');
+ idataRFID.showToast('璇峰厛绛夊緟妯″潡涓婄數鎴愬姛');
+ return;
+ }
+
+ if (this.isScanning) {
+ console.log('[RFID] 鍋滄璇诲彇...');
+ this.stopReadTag();
+ idataRFID.showToast('宸插仠姝㈣鍙�');
+ } else {
+ console.log('[RFID] 寮�濮嬭鍙�...');
+ this.startReadTagLoop();
+ idataRFID.showToast('宸插紑濮嬭鍙�');
+ }
+ },
+
+ // 娓呯┖缁撴灉
+ clearResults() {
+ this.scanResults = [];
+ }
+ }
+ }
+</script>
+
+<style>
+ .page-container {
+ min-height: 100vh;
+ background: #f5f5f5;
+ padding-bottom: 20px;
+ }
+
+ .status-section {
+ padding: 15px;
+ background: #fff;
+ margin-bottom: 10px;
+ }
+
+ .status-card {
+ display: flex;
+ justify-content: space-around;
+ padding: 15px 0;
+ }
+
+ .status-item {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ }
+
+ .status-label {
+ font-size: 12px;
+ color: #909399;
+ margin-bottom: 5px;
+ }
+
+ .status-value {
+ font-size: 14px;
+ font-weight: 500;
+ }
+
+ .status-value.success {
+ color: #67c23a;
+ }
+
+ .status-value.error {
+ color: #f56c6c;
+ }
+
+ .scan-result-section {
+ background: #fff;
+ margin-bottom: 10px;
+ padding: 15px;
+ flex: 1;
+ }
+
+ .section-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 10px;
+ }
+
+ .section-title {
+ font-size: 16px;
+ font-weight: 500;
+ color: #303133;
+ }
+
+ .btn-clear {
+ display: flex;
+ align-items: center;
+ padding: 5px 10px;
+ }
+
+ .btn-clear-text {
+ font-size: 12px;
+ color: #f56c6c;
+ margin-left: 3px;
+ }
+
+ .result-list {
+ max-height: calc(100vh - 300px);
+ min-height: 200px;
+ }
+
+ .result-item {
+ padding: 10px;
+ border-bottom: 1px solid #ebeef5;
+ }
+
+ .result-header {
+ display: flex;
+ justify-content: space-between;
+ margin-bottom: 5px;
+ }
+
+ .result-index {
+ font-size: 12px;
+ color: #909399;
+ }
+
+ .result-time {
+ font-size: 12px;
+ color: #909399;
+ }
+
+ .result-content {
+ margin-top: 5px;
+ }
+
+ .result-row {
+ display: flex;
+ margin-top: 3px;
+ }
+
+ .result-label {
+ font-size: 13px;
+ color: #606266;
+ margin-right: 8px;
+ min-width: 40px;
+ }
+
+ .result-value {
+ font-size: 13px;
+ color: #303133;
+ font-family: monospace;
+ word-break: break-all;
+ }
+
+ .empty-result {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ padding: 40px 0;
+ }
+
+ .empty-text {
+ font-size: 14px;
+ color: #909399;
+ margin-bottom: 5px;
+ }
+
+ .empty-hint {
+ font-size: 12px;
+ color: #c0c4cc;
+ }
+
+ .control-section {
+ padding: 15px;
+ position: fixed;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ background: #fff;
+ border-top: 1px solid #ebeef5;
+ z-index: 999;
+ }
+
+ .btn-control {
+ width: 100%;
+ padding: 15px;
+ background: #667eea;
+ color: #fff;
+ border-radius: 8px;
+ font-size: 16px;
+ font-weight: 500;
+ border: none;
+ position: relative;
+ z-index: 1000;
+ }
+
+ .btn-control.btn-scanning {
+ background: #f56c6c;
+ }
+
+ .btn-control:active {
+ opacity: 0.8;
+ }
+</style>
diff --git a/pages/rfid/uhftest.vue b/pages/rfid/uhftest.vue
new file mode 100644
index 0000000..6ac08c0
--- /dev/null
+++ b/pages/rfid/uhftest.vue
@@ -0,0 +1,509 @@
+<template>
+ <div>
+ <button type="primary" @click="scanStartOrStopFunc()">寮�鍚�/鍏抽棴鐩樼偣</button>
+ <br />
+ <button type="primary" @click="readTagWithoutFilterFunc()">鍗曟爣绛捐锛屾棤杩囨护</button>
+ <br />
+ <button type="primary" @click="writeTagWithoutFilterFunc()">鍗曟爣绛惧啓锛屾棤杩囨护</button>
+ <br />
+ <button type="primary" @click="readTagWithFilterFunc()">鍗曟爣绛捐锛屾湁杩囨护</button>
+ <br />
+ <button type="primary" @click="writeTagWithFilterFunc()">鍗曟爣绛惧啓锛屾湁杩囨护</button>
+ <br />
+ <button type="primary" @click="inventoryModeSetFunc()">鐩樼偣妯″紡璁剧疆</button>
+ <br />
+ <button type="primary" @click="inventoryModeGetFunc()">鐩樼偣妯″紡鑾峰彇</button>
+ <br />
+ <button type="primary" @click="inventoryWaitTimeSetFunc()">鍗犵┖姣旇缃紙50锛�50锛�</button>
+ <br />
+ <button type="primary" @click="inventoryWaitTimeGetFunc()">鍗犵┖姣旇幏鍙�</button>
+ <br />
+ <button type="primary" @click="readTagModeSetFunc()">鐩樼偣鏍囩鏁版嵁杩斿洖妯″紡璁剧疆</button>
+ <br />
+ <button type="primary" @click="readTagModeGetFunc()">鐩樼偣鏍囩鏁版嵁杩斿洖妯″紡鑾峰彇</button>
+ <br />
+ <button type="primary" @click="setPowerFunc()">璁剧疆澶╃嚎鍔熺巼20</button>
+ <br />
+ <button type="primary" @click="getPowerFunc()">鑾峰彇澶╃嚎鍔熺巼</button>
+ <br />
+ <button type="primary" @click="getFrequencyMode()">鑾峰彇棰戠巼</button>
+ <br />
+ <button type="primary" @click="openSound()">鎵撳紑澹伴煶</button>
+ <br />
+ <button type="primary" @click="closeSound()">鍏抽棴澹伴煶</button>
+ <br />
+ <button type="primary" @click="startOrStop6BAnd6CFunc()">鐩樼偣/鍋滄鐩樼偣6B鍜�6C鏍囩</button>
+ <br />
+ <button type="primary" @click="read6BFunc()">璇�6B鏍囩</button>
+ <br />
+ <button type="primary" @click="FilterFunc()">杩囨护鏍囩</button>
+ <br />
+ <button type="primary" @click="goTestFunc()">璺宠浆</button>
+ <br />
+
+
+ </div>
+</template>
+
+<script>
+ //鑾峰彇module
+ var uhfModel = uni.requireNativePlugin("iData-UHFPlugin-UHFModule")
+ const modal = uni.requireNativePlugin('modal');
+
+ var globalEvent = uni.requireNativePlugin('globalEvent');
+
+ var globalEvent2 = uni.requireNativePlugin('globalEvent');
+
+ var isPowerOn = false;
+
+ const handleKeydown = (e) => {
+ const keyCode = e.keyCode;
+ console.log(keyCode);
+ switch (keyCode) {
+ case 181:
+ console.log('閿�间负181鐨勬寜閿鎸変笅');
+ break;
+ case 191:
+ console.log('鍏朵粬閿�肩殑鎸夐敭琚寜涓�');
+ break;
+ }
+ };
+
+ const that = this;
+
+ export default {
+ data() {
+ return {
+
+ }
+ },
+ onShow() {
+ globalEvent.addEventListener('POWEREvent', function(e) {
+ console.log(JSON.stringify(e));
+
+ if (e["status"] == "connected") {
+ isPowerOn = true;
+ }else{
+ isPowerOn = false;
+ }
+
+ console.log("isPowerOn=" + isPowerOn);
+ });
+
+ //globalEvent2.addEventListener('iDataUHFEvent', function(e) {
+ //console.log(JSON.stringify(e));
+ // modal.toast({
+ // message: JSON.stringify(e),
+ // duration: 1
+ // });
+ //});
+
+ // 娉ㄦ剰锛歊FID妯″潡宸茬敱App.vue鍏ㄥ眬鍒濆鍖栵紝娴嬭瘯椤甸潰涓嶅啀鍒濆鍖栵紝閬垮厤鍐茬獊
+ // 鏁翠釜app鍙娇鐢ㄤ竴涓猂FID鍒濆鍖栵紙App.vue鐨刼nLaunch锛�
+ // 濡傛灉闇�瑕佸湪娴嬭瘯椤甸潰鐙珛鍒濆鍖栵紝鍙互鍙栨秷涓嬮潰鐨勬敞閲�
+ /*
+ uhfModel.initUHF(1, (ret) => {
+ console.log(ret);
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ */
+ plus.key.addEventListener('keydown', handleKeydown);
+ },
+ onHide() {
+ //椤甸潰杩涘叆鍚庡彴鏃惰皟鐢紝閫氬父鍦ㄥ睆骞曢攣灞忔垨鑰呰烦杞埌鍏朵粬椤甸潰鏃�
+ // 娉ㄦ剰锛歊FID妯″潡鐢盇pp.vue鍏ㄥ眬绠$悊锛屾祴璇曢〉闈笉鍏抽棴RFID妯″潡锛岄伩鍏嶅奖鍝嶅叾浠栭〉闈�
+ // 濡傛灉闇�瑕佸湪娴嬭瘯椤甸潰鐙珛绠$悊RFID锛屽彲浠ュ彇娑堜笅闈㈢殑娉ㄩ噴
+ // uhfModel.closeUHF();
+ globalEvent.removeEventListener('POWEREvent');
+ globalEvent.removeEventListener('iDataUHFEvent');
+ plus.key.removeEventListener('keydown', handleKeydown);
+ },
+ onUnload() {
+ //杩斿洖涓婁竴涓〉闈㈡椂璋冪敤
+ // 娉ㄦ剰锛歊FID妯″潡鐢盇pp.vue鍏ㄥ眬绠$悊锛屾祴璇曢〉闈笉鍏抽棴RFID妯″潡锛岄伩鍏嶅奖鍝嶅叾浠栭〉闈�
+ // 濡傛灉闇�瑕佸湪娴嬭瘯椤甸潰鐙珛绠$悊RFID锛屽彲浠ュ彇娑堜笅闈㈢殑娉ㄩ噴
+ // uhfModel.closeUHF();
+ globalEvent.removeEventListener('POWEREvent');
+ globalEvent.removeEventListener('iDataUHFEvent');
+ plus.key.removeEventListener('keydown', handleKeydown);
+ },
+ onLoad() {},
+ methods: {
+ openSound() {
+ uhfModel.setRFIDSound(true,(ret) => {
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+
+ });
+ },
+ closeSound() {
+ uhfModel.setRFIDSound(false,(ret) => {
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+
+ });
+ },
+ FilterFunc(){
+ console.log("FilterFunc");
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+
+ uhfModel.filterSet(1,0,16,'0000',(ret) => {
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+
+ });
+ },
+ read6BFunc(){
+ console.log("read6BFunc");
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+
+ uhfModel.read6BTag(0,0,6,null,(ret) => {
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+
+ });
+ },
+ startOrStop6BAnd6CFunc(){
+ console.log("startOrStop6BAnd6CFunc");
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+
+ uhfModel.startOrStop6BAnd6CRFID(true,0,10,(ret) => {
+ console.log(JSON.stringify(ret));
+
+ });
+ },
+ scanStartOrStopFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+
+ uhfModel.startOrStopRFID((ret) => {
+ console.log(JSON.stringify(ret));
+
+ });
+ },
+ readTagWithoutFilterFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ /**
+ * readBank:0->RESERVED,1->EPC,2->TID,3->USR
+ * startBlock:璇诲彇鐨勮捣濮嬪湴鍧�(Word绫诲瀷)
+ * len:璇诲彇鐨勬暟鎹暱搴�(Word绫诲瀷锛屽ぇ浜�0)
+ * pwd:璁块棶瀵嗙爜锛岄粯璁ゅ瘑鐮佷负锛�00000000
+ * 娉ㄦ剰锛歐ord绫诲瀷锛屼竴涓暱搴﹁〃绀烘爣绛惧瓨鍌�4浣嶅瓧绗�
+ */
+ uhfModel.readTagWithoutFilter(1, 2, 6, "00000000", (ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ writeTagWithoutFilterFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ /**
+ * writeBank:0->RESERVED,1->EPC,2->TID,3->USR
+ * startBlock:璇诲彇鐨勮捣濮嬪湴鍧�(Word绫诲瀷)
+ * writeData:鍐欏叆鐨勬暟鎹�
+ * pwd:璁块棶瀵嗙爜锛岄粯璁ゅ瘑鐮佷负锛�00000000
+ * 娉ㄦ剰锛歐ord绫诲瀷锛屼竴涓暱搴﹁〃绀烘爣绛惧瓨鍌�4浣嶅瓧绗�
+ */
+ uhfModel.writeTagWithoutFilter(1, 2, "1234567890ABCDEF", "00000000", (ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ readTagWithFilterFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ /**
+ * 杩囨护鏉′欢
+ * fBank:鎿嶄綔鍖哄煙 0->RESERVED,1->EPC,2->TID,3->USR
+ * fStartBlock:璧峰鍦板潃
+ * fLen:鏁版嵁闀垮害
+ * fData:杩囨护鏁版嵁
+ * 璇绘爣绛炬潯浠�
+ * readBank:0->RESERVED,1->EPC,2->TID,3->USR
+ * startBlock:璇诲彇鐨勮捣濮嬪湴鍧�(Word绫诲瀷)
+ * len:璇诲彇闀垮害
+ * pwd:璁块棶瀵嗙爜锛岄粯璁ゅ瘑鐮佷负锛�00000000
+ * 娉ㄦ剰锛歐ord绫诲瀷锛屼竴涓暱搴﹁〃绀烘爣绛惧瓨鍌�4浣嶅瓧绗�
+ */
+ uhfModel.readTagWithFilter(1, 32, 32, "12345678", 1, 2, 6, "00000000", (ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ writeTagWithFilterFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ /**
+ * 杩囨护鏉′欢
+ * fBank:鎿嶄綔鍖哄煙 0->RESERVED,1->EPC,2->TID,3->USR
+ * fStartBlock:璧峰鍦板潃
+ * fLen:鏁版嵁闀垮害
+ * fData:杩囨护鏁版嵁
+ * 鍐欐爣绛炬潯浠�
+ * writeBank:0->RESERVED,1->EPC,2->TID,3->USR
+ * startBlock:璇诲彇鐨勮捣濮嬪湴鍧�(Word绫诲瀷)
+ * writeData:鍐欏叆鐨勬暟鎹�
+ * pwd:璁块棶瀵嗙爜锛岄粯璁ゅ瘑鐮佷负锛�00000000
+ * 娉ㄦ剰锛歐ord绫诲瀷锛屼竴涓暱搴﹁〃绀烘爣绛惧瓨鍌�4浣嶅瓧绗�
+ */
+ uhfModel.writeTagWithFilter(1, 32, 32, "12345678", 1, 2, "1234567890ABCDE1", "00000000", (
+ ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ inventoryModeSetFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ /**
+ * 0:澶氭爣绛炬ā寮�,渚ч噸璇诲叏鏍囩 锛�1:蹇洏妯″紡锛屼晶閲嶅揩閫熻鍙栨爣绛� 锛�2.浣庡姛鑰楁ā寮�
+ */
+ uhfModel.inventoryModeSet(0, (ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ inventoryModeGetFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ /**
+ * 0:澶氭爣绛炬ā寮�,渚ч噸璇诲叏鏍囩 锛�1:蹇洏妯″紡锛屼晶閲嶅揩閫熻鍙栨爣绛� 锛�2.浣庡姛鑰楁ā寮�
+ */
+ uhfModel.inventoryModeGet((ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ inventoryWaitTimeSetFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ /**
+ * 鍗犵┖姣旀帴鍙o紝鐢ㄤ簬瑙e喅闀挎椂闂寸洏鐐规爣绛撅紝瀵艰嚧妯″潡鍙戠儹骞堕檷浣庢�ц兘
+ * scanTime:鐩樼偣鏃堕棿
+ * waitTime:浼戠湢鏃堕棿
+ * save:鏄惁鏂數淇濆瓨閰嶇疆
+ */
+ uhfModel.inventoryWaitTimeSet(50, 50, false, (ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ inventoryWaitTimeGetFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ /**
+ * 鍗犵┖姣旀帴鍙o紝鐢ㄤ簬瑙e喅闀挎椂闂寸洏鐐规爣绛撅紝瀵艰嚧妯″潡鍙戠儹骞堕檷浣庢�ц兘
+ * scanTime:鐩樼偣鏃堕棿
+ * waitTime:浼戠湢鏃堕棿
+ * save:鏄惁鏂數淇濆瓨閰嶇疆
+ */
+ uhfModel.inventoryWaitTimeGet((ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ readTagModeSetFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ /**
+ * mode - 璁剧疆0鍙鍙栨爣绛綞PC,1璇诲彇鏍囩EPC鍜孴ID
+ */
+ uhfModel.readTagModeSet(1, (ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ readTagModeGetFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+
+ uhfModel.readTagModeGet((ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ setPowerFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+
+ /**
+ * power:0-33
+ * 涓嶅悓妯″潡鏀寔鐨勫姛鐜囧�间笉鍚岋紝濡傛灉杩斿洖澶辫触閫氬父鏄笉鏀寔
+ */
+ uhfModel.setPower(20, (ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ getPowerFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+
+ uhfModel.getPower((ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ getFrequencyMode() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ uhfModel.getFrequencyMode((ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ goTestFunc(){
+ console.log("goTestFunc");
+ globalEvent.removeEventListener('iDataUHFEvent');
+ globalEvent.removeEventListener('POWEREvent');
+ uni.navigateTo({
+ url: './uhftest2'
+ });
+ },
+ }
+ }
+</script>
+
+<style>
+
+</style>
diff --git a/pages/rfid/uhftest2.vue b/pages/rfid/uhftest2.vue
new file mode 100644
index 0000000..785ba8a
--- /dev/null
+++ b/pages/rfid/uhftest2.vue
@@ -0,0 +1,400 @@
+<template>
+ <div>
+ <button type="primary" @click="scanStartOrStopFunc()">寮�鍚�/鍏抽棴鐩樼偣</button>
+ <br />
+ <button type="primary" @click="readTagWithoutFilterFunc()">鍗曟爣绛捐锛屾棤杩囨护</button>
+ <br />
+ <button type="primary" @click="writeTagWithoutFilterFunc()">鍗曟爣绛惧啓锛屾棤杩囨护</button>
+ <br />
+ <button type="primary" @click="readTagWithFilterFunc()">鍗曟爣绛捐锛屾湁杩囨护</button>
+ <br />
+ <button type="primary" @click="writeTagWithFilterFunc()">鍗曟爣绛惧啓锛屾湁杩囨护</button>
+ <br />
+ <button type="primary" @click="inventoryModeSetFunc()">鐩樼偣妯″紡璁剧疆</button>
+ <br />
+ <button type="primary" @click="inventoryModeGetFunc()">鐩樼偣妯″紡鑾峰彇</button>
+ <br />
+ <button type="primary" @click="inventoryWaitTimeSetFunc()">鍗犵┖姣旇缃紙50锛�50锛�</button>
+ <br />
+ <button type="primary" @click="inventoryWaitTimeGetFunc()">鍗犵┖姣旇幏鍙�</button>
+ <br />
+ <button type="primary" @click="readTagModeSetFunc()">鐩樼偣鏍囩鏁版嵁杩斿洖妯″紡璁剧疆</button>
+ <br />
+ <button type="primary" @click="readTagModeGetFunc()">鐩樼偣鏍囩鏁版嵁杩斿洖妯″紡鑾峰彇</button>
+ <br />
+ <button type="primary" @click="setPowerFunc()">璁剧疆澶╃嚎鍔熺巼20</button>
+ <br />
+ <button type="primary" @click="getPowerFunc()">鑾峰彇澶╃嚎鍔熺巼</button>
+ <button type="primary" @click="getFrequencyMode()">鑾峰彇棰戠巼</button>
+ <button type="primary" @click="goTestFunc()">鎵撳紑鏂伴〉闈�</button>
+
+ </div>
+</template>
+
+<script>
+ //鑾峰彇module
+ var uhfModel = uni.requireNativePlugin("iData-UHFPlugin-UHFModule")
+ const modal = uni.requireNativePlugin('modal');
+
+ var globalEvent = uni.requireNativePlugin('globalEvent');
+
+ var globalEvent2 = uni.requireNativePlugin('globalEvent');
+
+ var isPowerOn = true;
+
+ export default {
+ onShow() {
+ globalEvent.addEventListener('POWEREvent', function(e) {
+ console.log(JSON.stringify(e));
+
+ if (e["status"] == "connected") {
+ isPowerOn = true;
+ }else{
+ isPowerOn = false;
+ }
+
+ console.log("isPowerOn=" + isPowerOn);
+ });
+
+ globalEvent2.addEventListener('iDataUHFEvent', function(e) {
+ console.log(JSON.stringify(e));
+ });
+
+ uhfModel.initUHF(1, (ret) => {
+ console.log(ret);
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ // uhfModel.setRFIDListener((ret) => {
+ // console.log(ret);
+ // modal.toast({
+ // message: ret,
+ // duration: 1.5
+ // });
+ // });
+ },
+ onHide() {
+ //椤甸潰杩涘叆鍚庡彴鏃惰皟鐢紝閫氬父鍦ㄥ睆骞曢攣灞忔垨鑰呰烦杞埌鍏朵粬椤甸潰鏃�
+ uhfModel.closeUHF();
+ globalEvent.removeEventListener('POWEREvent');
+ globalEvent.removeEventListener('iDataUHFEvent');
+ },
+ onUnload() {
+ //杩斿洖涓婁竴涓〉闈㈡椂璋冪敤
+ uhfModel.closeUHF();
+ globalEvent.removeEventListener('POWEREvent');
+ globalEvent.removeEventListener('iDataUHFEvent');
+ },
+ data() {
+ return {}
+ },
+ onLoad() {},
+ methods: {
+ goTestFunc(){
+ console.log("goTestFunc");
+ globalEvent.removeEventListener('iDataUHFEvent');
+ globalEvent.removeEventListener('POWEREvent');
+ uni.navigateTo({
+ url: './uhftest'
+ });
+ },
+ scanStartOrStopFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+
+ uhfModel.startOrStopRFID((ret) => {
+ console.log(JSON.stringify(ret));
+
+ });
+ },
+ readTagWithoutFilterFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ /**
+ * readBank:0->RESERVED,1->EPC,2->TID,3->USR
+ * startBlock:璇诲彇鐨勮捣濮嬪湴鍧�(Word绫诲瀷)
+ * len:璇诲彇鐨勬暟鎹暱搴�(Word绫诲瀷锛屽ぇ浜�0)
+ * pwd:璁块棶瀵嗙爜锛岄粯璁ゅ瘑鐮佷负锛�00000000
+ * 娉ㄦ剰锛歐ord绫诲瀷锛屼竴涓暱搴﹁〃绀烘爣绛惧瓨鍌�4浣嶅瓧绗�
+ */
+ uhfModel.readTagWithoutFilter(1, 2, 6, "00000000", (ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ writeTagWithoutFilterFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ /**
+ * writeBank:0->RESERVED,1->EPC,2->TID,3->USR
+ * startBlock:璇诲彇鐨勮捣濮嬪湴鍧�(Word绫诲瀷)
+ * writeData:鍐欏叆鐨勬暟鎹�
+ * pwd:璁块棶瀵嗙爜锛岄粯璁ゅ瘑鐮佷负锛�00000000
+ * 娉ㄦ剰锛歐ord绫诲瀷锛屼竴涓暱搴﹁〃绀烘爣绛惧瓨鍌�4浣嶅瓧绗�
+ */
+ uhfModel.writeTagWithoutFilter(1, 2, "1234567890ABCDEF", "00000000", (ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ readTagWithFilterFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ /**
+ * 杩囨护鏉′欢
+ * fBank:鎿嶄綔鍖哄煙 0->RESERVED,1->EPC,2->TID,3->USR
+ * fStartBlock:璧峰鍦板潃
+ * fLen:鏁版嵁闀垮害
+ * fData:杩囨护鏁版嵁
+ * 璇绘爣绛炬潯浠�
+ * readBank:0->RESERVED,1->EPC,2->TID,3->USR
+ * startBlock:璇诲彇鐨勮捣濮嬪湴鍧�(Word绫诲瀷)
+ * len:璇诲彇闀垮害
+ * pwd:璁块棶瀵嗙爜锛岄粯璁ゅ瘑鐮佷负锛�00000000
+ * 娉ㄦ剰锛歐ord绫诲瀷锛屼竴涓暱搴﹁〃绀烘爣绛惧瓨鍌�4浣嶅瓧绗�
+ */
+ uhfModel.readTagWithFilter(1, 32, 32, "12345678", 1, 2, 6, "00000000", (ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ writeTagWithFilterFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ /**
+ * 杩囨护鏉′欢
+ * fBank:鎿嶄綔鍖哄煙 0->RESERVED,1->EPC,2->TID,3->USR
+ * fStartBlock:璧峰鍦板潃
+ * fLen:鏁版嵁闀垮害
+ * fData:杩囨护鏁版嵁
+ * 鍐欐爣绛炬潯浠�
+ * writeBank:0->RESERVED,1->EPC,2->TID,3->USR
+ * startBlock:璇诲彇鐨勮捣濮嬪湴鍧�(Word绫诲瀷)
+ * writeData:鍐欏叆鐨勬暟鎹�
+ * pwd:璁块棶瀵嗙爜锛岄粯璁ゅ瘑鐮佷负锛�00000000
+ * 娉ㄦ剰锛歐ord绫诲瀷锛屼竴涓暱搴﹁〃绀烘爣绛惧瓨鍌�4浣嶅瓧绗�
+ */
+ uhfModel.writeTagWithFilter(1, 32, 32, "12345678", 1, 2, "1234567890ABCDE1", "00000000", (
+ ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ inventoryModeSetFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ /**
+ * 0:澶氭爣绛炬ā寮�,渚ч噸璇诲叏鏍囩 锛�1:蹇洏妯″紡锛屼晶閲嶅揩閫熻鍙栨爣绛� 锛�2.浣庡姛鑰楁ā寮�
+ */
+ uhfModel.inventoryModeSet(0, (ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ inventoryModeGetFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ /**
+ * 0:澶氭爣绛炬ā寮�,渚ч噸璇诲叏鏍囩 锛�1:蹇洏妯″紡锛屼晶閲嶅揩閫熻鍙栨爣绛� 锛�2.浣庡姛鑰楁ā寮�
+ */
+ uhfModel.inventoryModeGet((ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ inventoryWaitTimeSetFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ /**
+ * 鍗犵┖姣旀帴鍙o紝鐢ㄤ簬瑙e喅闀挎椂闂寸洏鐐规爣绛撅紝瀵艰嚧妯″潡鍙戠儹骞堕檷浣庢�ц兘
+ * scanTime:鐩樼偣鏃堕棿
+ * waitTime:浼戠湢鏃堕棿
+ * save:鏄惁鏂數淇濆瓨閰嶇疆
+ */
+ uhfModel.inventoryWaitTimeSet(50, 50, false, (ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ inventoryWaitTimeGetFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ /**
+ * 鍗犵┖姣旀帴鍙o紝鐢ㄤ簬瑙e喅闀挎椂闂寸洏鐐规爣绛撅紝瀵艰嚧妯″潡鍙戠儹骞堕檷浣庢�ц兘
+ * scanTime:鐩樼偣鏃堕棿
+ * waitTime:浼戠湢鏃堕棿
+ * save:鏄惁鏂數淇濆瓨閰嶇疆
+ */
+ uhfModel.inventoryWaitTimeGet((ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ readTagModeSetFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ /**
+ * mode - 璁剧疆0鍙鍙栨爣绛綞PC,1璇诲彇鏍囩EPC鍜孴ID
+ */
+ uhfModel.readTagModeSet(1, (ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ readTagModeGetFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+
+ uhfModel.readTagModeGet((ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ setPowerFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+
+ /**
+ * power:0-33
+ * 涓嶅悓妯″潡鏀寔鐨勫姛鐜囧�间笉鍚岋紝濡傛灉杩斿洖澶辫触閫氬父鏄笉鏀寔
+ */
+ uhfModel.setPower(20, (ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ getPowerFunc() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+
+ uhfModel.getPower((ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ getFrequencyMode() {
+ if (!isPowerOn) {
+ modal.toast({
+ message: "姝e湪涓婄數 锛岃绋嶅悗閲嶈瘯锛�",
+ duration: 1.5
+ });
+ return;
+ }
+ uhfModel.getFrequencyMode((ret) => {
+ //
+ modal.toast({
+ message: ret,
+ duration: 1.5
+ });
+ });
+ },
+ }
+ }
+</script>
+
+<style>
+
+</style>
diff --git a/pages/stock/stockQuery.vue b/pages/stock/stockQuery.vue
index b7abae3..51d6575 100644
--- a/pages/stock/stockQuery.vue
+++ b/pages/stock/stockQuery.vue
@@ -8,7 +8,7 @@
<text class="label-text">搴撲綅鍙�</text>
</view>
<view class="form-input-wrap">
- <input class="form-input" type="text" placeholder="鎵爜 / 杈撳叆搴撲綅鍙�" v-model="locNo" />
+ <input class="form-input" type="text" placeholder="鎵爜 / 杈撳叆搴撲綅鍙�" v-model="locNo" @focus="onLocNoFocus()" />
<uni-icons v-if="locNo" type="clear" size="18" color="#c0c4cc" @click="locNo=''"></uni-icons>
</view>
</view>
@@ -18,7 +18,7 @@
<text class="label-text">鐗╂枡鍙�</text>
</view>
<view class="form-input-wrap">
- <input class="form-input" type="text" placeholder="鎵爜 / 杈撳叆鐗╂枡鍙�" v-model="matnr" @input="findMat()" />
+ <input class="form-input" type="text" placeholder="鎵爜 / 杈撳叆鐗╂枡鍙�" v-model="matnr" @input="findMat()" @focus="onMatnrFocus()" />
<uni-icons v-if="matnr" type="clear" size="18" color="#c0c4cc" @click="matnr=''"></uni-icons>
</view>
</view>
@@ -114,6 +114,7 @@
</template>
<script>
+ import rfidScanner from '@/common/rfid-scanner.js';
export default {
data() {
return {
@@ -133,8 +134,21 @@
onShow() {
this.baseUrl = uni.getStorageSync('baseUrl');
this.token = uni.getStorageSync('token');
+ // RFID宸插湪App.vue涓叏灞�鍒濆鍖栵紝杩欓噷涓嶉渶瑕佸啀鍒濆鍖�
+ // 璁剧疆褰撳墠椤甸潰瀹炰緥锛岀敤浜庡叏灞�鎵弿鏃惰嚜鍔ㄥ~鍏�
+ rfidScanner.setCurrentPageInstance(this);
},
methods: {
+ // 搴撲綅鍙疯緭鍏ユ鑾峰緱鐒︾偣锛堜繚鐣欐柟娉曪紝浣嗕笉鑷姩瑙﹀彂鎵弿锛�
+ onLocNoFocus() {
+ console.log('[stockQuery] 搴撲綅鍙疯緭鍏ユ鑾峰緱鐒︾偣');
+ // 娉ㄦ剰锛氬崟鏍囩璇绘棤杩囨护鍔熻兘宸叉敼涓烘寜閿Е鍙戯紙191銆�189銆�190锛夛紝涓嶅啀鍦ㄧ劍鐐规椂鑷姩瑙﹀彂
+ },
+ // 鐗╂枡鍙疯緭鍏ユ鑾峰緱鐒︾偣锛堜繚鐣欐柟娉曪紝浣嗕笉鑷姩瑙﹀彂鎵弿锛�
+ onMatnrFocus() {
+ console.log('[stockQuery] 鐗╂枡鍙疯緭鍏ユ鑾峰緱鐒︾偣');
+ // 娉ㄦ剰锛氬崟鏍囩璇绘棤杩囨护鍔熻兘宸叉敼涓烘寜閿Е鍙戯紙191銆�189銆�190锛夛紝涓嶅啀鍦ㄧ劍鐐规椂鑷姩瑙﹀彂
+ },
// 鎼滅储鐗╂枡
findMat() {
let that = this;
diff --git a/uni_modules/uni-popup/components/uni-popup/uni-popup.vue b/uni_modules/uni-popup/components/uni-popup/uni-popup.vue
index bd12076..4b026c1 100644
--- a/uni_modules/uni-popup/components/uni-popup/uni-popup.vue
+++ b/uni_modules/uni-popup/components/uni-popup/uni-popup.vue
@@ -175,18 +175,31 @@
},
mounted() {
const fixSize = () => {
- const { windowWidth, windowHeight, windowTop, safeArea,screenHeight ,safeAreaInsets } = uni.getSystemInfoSync()
- this.popupWidth = windowWidth
- this.popupHeight = windowHeight + windowTop
- // TODO fix by mehaotian 鏄惁閫傞厤搴曢儴瀹夊叏鍖� ,鐩墠寰俊ios 銆佸拰 app ios 璁$畻鏈夊樊寮傦紝闇�瑕佹鏋朵慨澶�
- if(safeArea){
- // #ifdef MP-WEIXIN
- this.safeAreaInsets = screenHeight - safeArea.bottom
- // #endif
- // #ifndef MP-WEIXIN
- this.safeAreaInsets = safeAreaInsets.bottom
- // #endif
- }else{
+ try {
+ const systemInfo = uni.getSystemInfoSync()
+ if (!systemInfo) {
+ console.warn('[uni-popup] getSystemInfoSync 杩斿洖绌烘暟鎹�')
+ return
+ }
+ const { windowWidth = 0, windowHeight = 0, windowTop = 0, safeArea, screenHeight = 0, safeAreaInsets } = systemInfo
+ this.popupWidth = windowWidth || 0
+ this.popupHeight = (windowHeight || 0) + (windowTop || 0)
+ // TODO fix by mehaotian 鏄惁閫傞厤搴曢儴瀹夊叏鍖� ,鐩墠寰俊ios 銆佸拰 app ios 璁$畻鏈夊樊寮傦紝闇�瑕佹鏋朵慨澶�
+ if(safeArea){
+ // #ifdef MP-WEIXIN
+ this.safeAreaInsets = screenHeight - (safeArea && safeArea.bottom ? safeArea.bottom : 0)
+ // #endif
+ // #ifndef MP-WEIXIN
+ this.safeAreaInsets = safeAreaInsets && safeAreaInsets.bottom ? safeAreaInsets.bottom : 0
+ // #endif
+ }else{
+ this.safeAreaInsets = 0
+ }
+ } catch (error) {
+ console.error('[uni-popup] fixSize 閿欒:', error)
+ // 璁剧疆榛樿鍊�
+ this.popupWidth = 0
+ this.popupHeight = 0
this.safeAreaInsets = 0
}
}
--
Gitblit v1.9.1