diff --git a/apps/miniprogram/native/pkg-veepoo/index.js b/apps/miniprogram/native/pkg-veepoo/index.js index ccd257c..e77b548 100644 --- a/apps/miniprogram/native/pkg-veepoo/index.js +++ b/apps/miniprogram/native/pkg-veepoo/index.js @@ -88,6 +88,14 @@ Page({ // eslint-disable-next-line no-undef wx.setNavigationBarTitle({ title: 'M2 手环测量' }); this._updateSelectedDisplay('heart_rate'); + // 诊断:确认 SDK 加载状态 + // eslint-disable-next-line no-undef + console.log('[veepoo-native] SDK 加载状态:', { + veepooBle: typeof veepooBle, + veepooFeature: typeof veepooFeature, + veepooLogger: typeof veepooLogger, + scanFn: typeof veepooBle.veepooWeiXinSDKStartScanDeviceAndReceiveScanningDevice, + }); }, onUnload: function () { @@ -139,9 +147,11 @@ Page({ var device = Array.isArray(res) ? res[0] : res; if (!device) return; var name = (device.localName || device.name || '').toUpperCase(); + var deviceId = device.deviceId || device.mac || ''; // eslint-disable-next-line no-undef - console.log('[veepoo-native] 扫描到:', name, device.deviceId || device.mac); - if (name.indexOf('M2') !== -1 && !self._scanFound) { + console.log('[veepoo-native] 扫描到:', name, deviceId, JSON.stringify(device).substring(0, 200)); + // 放宽匹配:包含 M2 / VPM / VEEPOO 均视为目标设备 + if (!self._scanFound && (name.indexOf('M2') !== -1 || name.indexOf('VPM') !== -1 || name.indexOf('VEEPOO') !== -1)) { self._scanFound = device; veepooBle.veepooWeiXinSDKStopSearchBleManager(function () { self._doConnect(device); @@ -153,9 +163,9 @@ Page({ if (!self._scanFound) { veepooBle.veepooWeiXinSDKStopSearchBleManager(function () {}); self._connecting = false; - self.setData({ phase: 'error', error: '未找到 M2 设备,请确保手环已开机' }); + self.setData({ phase: 'error', error: '未找到 M2 设备,请确保手环已开机且蓝牙已开启' }); } - }, 10000); + }, 15000); }, _doConnect: function (device) { diff --git a/apps/miniprogram/src/utils/elder-toast.ts b/apps/miniprogram/src/utils/elder-toast.ts index 1ec71d9..fdfff57 100644 --- a/apps/miniprogram/src/utils/elder-toast.ts +++ b/apps/miniprogram/src/utils/elder-toast.ts @@ -16,7 +16,7 @@ export function showToast(options: { const duration = options.duration ?? (mode === 'elder' ? 3000 : 1500); if (mode === 'elder') { - try { Taro.vibrateShort({ type: 'light' }); } catch { /* 不支持时静默 */ } + Taro.vibrateShort({ type: 'light' }).catch(() => {}); } Taro.showToast({ ...options, duration, icon: options.icon ?? 'none' }); diff --git a/apps/miniprogram/src/utils/haptic.ts b/apps/miniprogram/src/utils/haptic.ts index 2e179d5..339f675 100644 --- a/apps/miniprogram/src/utils/haptic.ts +++ b/apps/miniprogram/src/utils/haptic.ts @@ -2,21 +2,15 @@ import Taro from '@tarojs/taro'; /** 轻触反馈(按钮点击) */ export function hapticLight(): void { - try { - Taro.vibrateShort({ type: 'light' }); - } catch { /* 部分设备不支持 */ } + Taro.vibrateShort({ type: 'light' }).catch(() => { /* DevTools 不支持 type 参数,真机正常 */ }); } /** 中等反馈(成功操作) */ export function hapticMedium(): void { - try { - Taro.vibrateShort({ type: 'medium' }); - } catch { /* ignore */ } + Taro.vibrateShort({ type: 'medium' }).catch(() => { /* ignore */ }); } /** 重度反馈(错误/警告) */ export function hapticHeavy(): void { - try { - Taro.vibrateShort({ type: 'heavy' }); - } catch { /* ignore */ } + Taro.vibrateShort({ type: 'heavy' }).catch(() => { /* ignore */ }); }