Преглед изворни кода

feat: 补货管理首页新增扫码浮钮 快速识别设备进入补货/盘点

- 右下角圆形黄色扫码按钮
- 支持二维码/条形码 自动提取deviceId参数
- 扫描后弹出选项: 设备补货/库存盘点
- 选择后跳转对应页面

Co-Authored-By: Claude <noreply@anthropic.com>
skyline пре 3 дана
родитељ
комит
d7517b6c73
1 измењених фајлова са 44 додато и 0 уклоњено
  1. 44 0
      haha-admin-mp/src/pages/replenish/home.vue

+ 44 - 0
haha-admin-mp/src/pages/replenish/home.vue

@@ -49,6 +49,11 @@
         <view class="card-audit" @click.stop="goToAudit(device)"><text>盘点</text></view>
       </view>
     </scroll-view>
+
+    <!-- 扫码浮钮 -->
+    <view class="scan-fab" @click="handleScan">
+      <view class="scan-icon"></view>
+    </view>
   </view>
 </template>
 
@@ -79,6 +84,37 @@ const goToAudit = (device: any) => {
   uni.navigateTo({ url: `/pages/replenish/audit?deviceId=${device.deviceId}` });
 };
 
+const handleScan = () => {
+  uni.scanCode({
+    onlyFromCamera: true,
+    scanType: ['qrCode', 'barCode'],
+    success: (res: any) => {
+      const result = (res.result || '').trim();
+      if (!result) {
+        uni.showToast({ title: '未识别到设备ID', icon: 'none' });
+        return;
+      }
+      // 提取设备ID(支持直接扫描设备SN或URL中的设备ID参数)
+      let deviceId = result;
+      if (result.includes('deviceId=')) {
+        const match = result.match(/deviceId=([^&\s]+)/);
+        if (match) deviceId = match[1];
+      }
+      uni.showActionSheet({
+        itemList: ['设备补货', '库存盘点'],
+        success: (sheetRes) => {
+          if (sheetRes.tapIndex === 0) {
+            uni.navigateTo({ url: `/pages/replenish/operation?deviceId=${deviceId}` });
+          } else if (sheetRes.tapIndex === 1) {
+            uni.navigateTo({ url: `/pages/replenish/audit?deviceId=${deviceId}` });
+          }
+        }
+      });
+    },
+    fail: () => { /* 用户取消扫码 */ }
+  });
+};
+
 const handleLogout = () => {
   uni.showModal({
     title: '退出登录',
@@ -150,4 +186,12 @@ onShow(async () => { await loadData(); });
 .card-audit { margin-left: 12rpx; padding: 8rpx 16rpx; border-radius: $radius-sm; background: $info-color-bg; font-size: 22rpx; color: $info-color; font-weight: 500; flex-shrink: 0;
   &:active { opacity: 0.7; }
 }
+
+.scan-fab { position: fixed; right: 48rpx; bottom: calc(80rpx + env(safe-area-inset-bottom)); width: 104rpx; height: 104rpx; border-radius: 50%; background: $primary-color; box-shadow: 0 8rpx 24rpx rgba(255,193,7,0.35); display: flex; align-items: center; justify-content: center; z-index: 100;
+  &:active { transform: scale(0.92); background: $primary-color-dark; }
+}
+.scan-icon { width: 48rpx; height: 48rpx; position: relative;
+  &::before { content: ''; position: absolute; top: 4rpx; left: 4rpx; width: 28rpx; height: 28rpx; border: 4rpx solid $text-color-primary; border-radius: 4rpx; }
+  &::after { content: ''; position: absolute; bottom: 4rpx; left: 50%; transform: translateX(-50%); width: 24rpx; height: 4rpx; background: $text-color-primary; border-radius: 2rpx; }
+}
 </style>