diff --git a/src/common/scanMixin.js b/src/common/scanMixin.js index 1dc2597..80fb18a 100644 --- a/src/common/scanMixin.js +++ b/src/common/scanMixin.js @@ -72,20 +72,63 @@ export default { return configs.length ? configs[0] : null; }, + /** 停止手机连续扫码(含 Ba-Scanner) */ + stopPhoneScanContinuous() { + this._phoneScanContinuousActive = false; + // #ifdef APP-PLUS + try { + const scanner = uni.requireNativePlugin('Ba-Scanner'); + if (scanner && typeof scanner.onClose === 'function') { + scanner.onClose(); + } + } catch (e) { + // 未购买/未打包原生插件时忽略 + } + // #endif + }, + + /** + * 打开手机扫码 + * @param {{ continuous?: boolean, callback?: Function, fail?: Function, scanType?: string[], hintText?: string, scanTimeSpace?: number }} options + * continuous=true 时优先用 Ba-Scanner 连续扫;无插件则扫完自动再开相机 + */ openPhoneScan(options = {}) { const callback = options.callback || this._scanCallback; + const continuous = !!options.continuous; + this._phoneScanContinuousActive = continuous; + + // #ifdef APP-PLUS + if (continuous && this.openBaScannerContinuous(options, callback)) { + return; + } + // #endif + // #ifdef APP-PLUS || MP-WEIXIN uni.scanCode({ scanType: options.scanType || ['qrCode', 'barCode'], success: (res) => { - this.handleScanResult(res.result, callback); + const result = this.handleScanResult(res.result, callback); + if (!continuous || !this._phoneScanContinuousActive) return; + Promise.resolve(result) + .catch(() => null) + .then(() => { + if (!this._phoneScanContinuousActive || !this.isPageActive) return; + setTimeout(() => { + if (!this._phoneScanContinuousActive || !this.isPageActive) return; + this.openPhoneScan(options); + }, Number(options.scanTimeSpace) > 0 ? Number(options.scanTimeSpace) : 400); + }); }, fail: (err) => { console.error('手机扫码失败:', err); + this._phoneScanContinuousActive = false; if (options.fail) { options.fail(err); return; } + // 用户取消不打扰 + const msg = (err && (err.errMsg || err.message)) || ''; + if (/cancel|取消/i.test(msg)) return; uni.showToast({ title: '扫码失败', icon: 'none', @@ -103,6 +146,41 @@ export default { // #endif }, + /** + * Ba-Scanner 连续扫码(插件市场 id=9669) + * @returns {boolean} 是否已成功唤起原生连续扫 + */ + openBaScannerContinuous(options = {}, callback) { + // #ifdef APP-PLUS + try { + const scanner = uni.requireNativePlugin('Ba-Scanner'); + if (!scanner || typeof scanner.onScan !== 'function') return false; + scanner.onScan( + { + isContinuous: true, + scanTimeSpace: Number(options.scanTimeSpace) > 0 ? Number(options.scanTimeSpace) : 1500, + isShowVibrate: options.isShowVibrate !== false, + isShowBeep: !!options.isShowBeep, + isShowToast: false, + isShowPhotoAlbum: options.isShowPhotoAlbum !== false, + hintText: options.hintText || '扫二维码/条形码,可连续扫', + barcodeFormats: options.barcodeFormats || ['QR Code', 'Code 128', 'Code 39', 'EAN-13', 'EAN-8'], + }, + (ret) => { + if (!ret || !ret.result) return; + if (!this._phoneScanContinuousActive) return; + this.handleScanResult(ret.result, callback); + }, + ); + return true; + } catch (e) { + console.warn('Ba-Scanner 不可用,回退 uni.scanCode', e); + return false; + } + // #endif + return false; + }, + triggerScan() { if (this.usePhoneScanFallback) { this.openPhoneScan(); @@ -261,11 +339,12 @@ export default { console.log("扫码结果:", cleanCode); if (scanCallback) { - scanCallback(cleanCode); + return scanCallback(cleanCode); } } catch (error) { console.error("处理扫码结果时出错:", error); } + return undefined; }, unregisterScanBroadcast() { @@ -317,10 +396,13 @@ export default { onHide() { this.isPageActive = false; + // 不在 onHide 里关 Ba-Scanner:打开原生扫码页也会触发 hide,误关会打断连续扫 + // 无插件回退模式靠 isPageActive 控制是否自动再开相机 }, onUnload() { this.isPageActive = false; + this.stopPhoneScanContinuous(); this.unregisterScanBroadcast(); } } diff --git a/src/components/storefabric/FabricOutSummaryTable.vue b/src/components/storefabric/FabricOutSummaryTable.vue index 25a4d3e..945d02e 100644 --- a/src/components/storefabric/FabricOutSummaryTable.vue +++ b/src/components/storefabric/FabricOutSummaryTable.vue @@ -1,29 +1,52 @@ diff --git a/src/components/t-table/t-table.vue b/src/components/t-table/t-table.vue new file mode 100644 index 0000000..15f4949 --- /dev/null +++ b/src/components/t-table/t-table.vue @@ -0,0 +1,86 @@ + + + + + diff --git a/src/components/t-table/t-td.vue b/src/components/t-table/t-td.vue new file mode 100644 index 0000000..1e5c81d --- /dev/null +++ b/src/components/t-table/t-td.vue @@ -0,0 +1,71 @@ + + + + + diff --git a/src/components/t-table/t-th.vue b/src/components/t-table/t-th.vue new file mode 100644 index 0000000..e6cf4d9 --- /dev/null +++ b/src/components/t-table/t-th.vue @@ -0,0 +1,71 @@ + + + + + diff --git a/src/components/t-table/t-tr.vue b/src/components/t-table/t-tr.vue new file mode 100644 index 0000000..9dc5d88 --- /dev/null +++ b/src/components/t-table/t-tr.vue @@ -0,0 +1,81 @@ + + + + + diff --git a/src/manifest.json b/src/manifest.json index 91ee273..17e8e6d 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,8 +2,8 @@ "name" : "浩拓织厂", "appid" : "__UNI__F79F300", "description" : "周尚-浩拓织厂", - "versionName" : "1.1.23", - "versionCode" : 123, + "versionName" : "1.1.24", + "versionCode" : 124, "transformPx" : false, "app-plus" : { "optimization" : { diff --git a/src/pages/storefabric/storeFabricBusinessOutMixin.js b/src/pages/storefabric/storeFabricBusinessOutMixin.js index 4ba888e..f0f9a9a 100644 --- a/src/pages/storefabric/storeFabricBusinessOutMixin.js +++ b/src/pages/storefabric/storeFabricBusinessOutMixin.js @@ -120,7 +120,16 @@ export default { }, methods: { handlePhoneScan() { - this.openPhoneScan(); + // 手机连续扫:优先 Ba-Scanner;无插件时扫完自动再开相机 + this.openPhoneScan({ + continuous: true, + hintText: '连续扫码出仓,扫完可继续下一条', + scanTimeSpace: 1200, + callback: (scanResult) => { + this.QRBarCode = String(scanResult || '').trim().replace(/[\r\n]/g, ''); + return this.handleScan(); + }, + }); }, registerOrderScanBroadcast() { this.registerScanBroadcast((scanResult) => { @@ -314,14 +323,14 @@ export default { if (!this.canScan || !this.orderId) { this.showError('请先提交保存后再扫码'); this.QRBarCode = ''; - return; + return Promise.resolve(); } if (!code) { this.QRBarCode = ''; - return; + return Promise.resolve(); } const scanType = this.BarCodeDelStatus ? 2 : 1; - this.doScanUpdate(code, scanType); + return this.doScanUpdate(code, scanType); }, BarCodeDelChange(e) { this.BarCodeDelStatus = (e.detail.value || []).length > 0;