Commit 0f69b4fe by 姜雷

修改洗浴连接逻辑

parent 696da627
......@@ -28,6 +28,7 @@ import { PayOrderState } from '@/store/rootReducers/orderState';
enum BlueToothError {
BlueToothNotOpen = 'BlueToothNotOpen',
DeviceNotFound = 'DeviceNotFound',
}
type DeviceInfo = {
......@@ -364,16 +365,14 @@ class Shower extends Component {
.then(() => {
const { code, isOnlyBluetooth } = this.props.bluetoothDevice;
let timer: NodeJS.Timeout | null = null;
return new Promise(resolve => {
return new Promise((resolve, reject) => {
if (isOnlyBluetooth) {
timer = setTimeout(() => {
Taro.stopBluetoothDevicesDiscovery();
this.sendStartShower();
reject({ msg: BlueToothError.DeviceNotFound });
}, 10000);
} else {
timer = setTimeout(() => {
Taro.stopBluetoothDevicesDiscovery();
this.sendStartShower();
reject({ msg: BlueToothError.DeviceNotFound });
}, 5000);
}
Taro.onBluetoothDeviceFound(res => {
......@@ -394,9 +393,18 @@ class Shower extends Component {
})
.catch(err => {
// Taro.stopBluetoothDevicesDiscovery();
if (timer) {
clearInterval(timer);
}
Taro.hideLoading();
console.error('startBluetoothDevicesDiscovery: ', err);
this.warnBluetoothOpen();
// if (err.msg === BlueToothError.DeviceNotFound) {
Taro.stopBluetoothDevicesDiscovery();
this.sendStartShower();
throw err;
// } else {
// return this.warnBluetoothOpen();
// }
});
} else {
Taro.hideLoading();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment