Commit d6447b62 by 姜雷

修改蓝牙洗浴设备开启逻辑

parent 56c23f9a
......@@ -29,6 +29,10 @@ import OrderTitle from '../Order/components/OrderTitle/OrderTitle';
import OrderInfo from '../Order/components/OrderInfo/OrderInfo';
import OrderPayway from '../Order/components/OrderPayway/OrderPayway';
enum BlueToothError {
BlueToothNotOpen = 'BlueToothNotOpen',
}
type DeviceInfo = {
deviceId: string;
uuid: string;
......@@ -392,7 +396,7 @@ class Shower extends Component {
}
warnBluetoothOpen() {
Taro.showModal({
return Taro.showModal({
title: '警告',
content: '为保障正常使用,请打开蓝牙功能',
});
......@@ -448,10 +452,12 @@ class Shower extends Component {
if (isOnlyBluetooth) {
timer = setTimeout(() => {
Taro.stopBluetoothDevicesDiscovery();
this.sendStartShower();
}, 10000);
} else {
timer = setTimeout(() => {
Taro.stopBluetoothDevicesDiscovery();
this.sendStartShower();
}, 5000);
}
Taro.onBluetoothDeviceFound(res => {
......@@ -478,8 +484,24 @@ class Shower extends Component {
});
} else {
Taro.hideLoading();
this.warnBluetoothOpen();
throw '未开启蓝牙';
return this.warnBluetoothOpen().then(res => {
if (res.confirm) {
const { isOnlyBluetooth } = this.props.bluetoothDevice;
if (!isOnlyBluetooth) {
Taro.showLoading({
title: '开启中',
mask: true,
});
return new Promise((resolve, reject) => {
setTimeout(() => {
this.sendStartShower();
reject();
}, 5000);
});
}
}
throw BlueToothError.BlueToothNotOpen;
});
}
}
......
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