Commit 0f69b4fe by 姜雷

修改洗浴连接逻辑

parent 696da627
...@@ -28,6 +28,7 @@ import { PayOrderState } from '@/store/rootReducers/orderState'; ...@@ -28,6 +28,7 @@ import { PayOrderState } from '@/store/rootReducers/orderState';
enum BlueToothError { enum BlueToothError {
BlueToothNotOpen = 'BlueToothNotOpen', BlueToothNotOpen = 'BlueToothNotOpen',
DeviceNotFound = 'DeviceNotFound',
} }
type DeviceInfo = { type DeviceInfo = {
...@@ -364,16 +365,14 @@ class Shower extends Component { ...@@ -364,16 +365,14 @@ class Shower extends Component {
.then(() => { .then(() => {
const { code, isOnlyBluetooth } = this.props.bluetoothDevice; const { code, isOnlyBluetooth } = this.props.bluetoothDevice;
let timer: NodeJS.Timeout | null = null; let timer: NodeJS.Timeout | null = null;
return new Promise(resolve => { return new Promise((resolve, reject) => {
if (isOnlyBluetooth) { if (isOnlyBluetooth) {
timer = setTimeout(() => { timer = setTimeout(() => {
Taro.stopBluetoothDevicesDiscovery(); reject({ msg: BlueToothError.DeviceNotFound });
this.sendStartShower();
}, 10000); }, 10000);
} else { } else {
timer = setTimeout(() => { timer = setTimeout(() => {
Taro.stopBluetoothDevicesDiscovery(); reject({ msg: BlueToothError.DeviceNotFound });
this.sendStartShower();
}, 5000); }, 5000);
} }
Taro.onBluetoothDeviceFound(res => { Taro.onBluetoothDeviceFound(res => {
...@@ -394,9 +393,18 @@ class Shower extends Component { ...@@ -394,9 +393,18 @@ class Shower extends Component {
}) })
.catch(err => { .catch(err => {
// Taro.stopBluetoothDevicesDiscovery(); // Taro.stopBluetoothDevicesDiscovery();
if (timer) {
clearInterval(timer);
}
Taro.hideLoading(); Taro.hideLoading();
console.error('startBluetoothDevicesDiscovery: ', err); console.error('startBluetoothDevicesDiscovery: ', err);
this.warnBluetoothOpen(); // if (err.msg === BlueToothError.DeviceNotFound) {
Taro.stopBluetoothDevicesDiscovery();
this.sendStartShower();
throw err;
// } else {
// return this.warnBluetoothOpen();
// }
}); });
} else { } else {
Taro.hideLoading(); 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