|
@@ -9,9 +9,7 @@ import {
|
|
|
hexStringToUint8Array
|
|
|
} from "../utils/bluetoothUtils";
|
|
|
import {
|
|
|
- getCheckinInfoAndLockInfo,
|
|
|
- getBluetoothKey,
|
|
|
- remoteOpenDoor,
|
|
|
+ getOpenDoorInfo,
|
|
|
unloadBLEOpenDoorLog,
|
|
|
getCheckinInfo
|
|
|
} from "../utils/api";
|
|
@@ -83,6 +81,8 @@ export const bluetooth = {
|
|
|
bluetoothAuthorized: false, // 蓝牙授权开启情况
|
|
|
errMessage: '',
|
|
|
// 剩下的为上传相关记录的操作
|
|
|
+ floor: Number(this.checkinInfo.floor),
|
|
|
+ room: this.checkinInfo.room
|
|
|
};
|
|
|
|
|
|
/**
|
|
@@ -907,83 +907,35 @@ export const bluetooth = {
|
|
|
async onLoad() {
|
|
|
// console.log("currentHotelId", this.currentHotelId);
|
|
|
// 先获取入住记录
|
|
|
- let info = await getCheckinInfo({
|
|
|
- userIdNumber: this.userInfo.idNumber,
|
|
|
- hotelId: this.currentHotel.hotelId,
|
|
|
- status: 1,
|
|
|
- pageNo: 1,
|
|
|
- pageSize: 1,
|
|
|
- })
|
|
|
- console.log("获取入住记录", info);
|
|
|
- if (!info.data.data.records.length) {
|
|
|
- console.log("获取入住记录失败", info.data.data);
|
|
|
+ let { data: infoRes } = await getCheckinInfo(this.currentHotel.hotelId)
|
|
|
+ // console.log("获取入住记录", infoRes);
|
|
|
+
|
|
|
+ if (infoRes.code !== 200 || !infoRes.success || !infoRes.data) {
|
|
|
+ console.log("获取入住记录失败", infoRes);
|
|
|
return
|
|
|
}
|
|
|
- this.checkinInfo = info.data.data.records[0];
|
|
|
+
|
|
|
+ this.checkinInfo = infoRes.data;
|
|
|
this.checkinInfo.startTime = moment(this.checkinInfo.startTime).format("YYYY/MM/DD HH:mm:ss");
|
|
|
this.checkinInfo.endTime = moment(this.checkinInfo.endTime).format("YYYY/MM/DD HH:mm:ss");
|
|
|
|
|
|
- // 然后获取门锁信息
|
|
|
- let checkinInfoAndLockInfo = await getCheckinInfoAndLockInfo({
|
|
|
+ // 获取门锁信息
|
|
|
+ const { data:openDoorInfoRes } = await getOpenDoorInfo({
|
|
|
hotelId: this.currentHotel.hotelId,
|
|
|
+ floor: Number(this.checkinInfo.floor),
|
|
|
+ room: this.checkinInfo.room
|
|
|
})
|
|
|
- console.log("获取入住记录和门锁记录", checkinInfoAndLockInfo);
|
|
|
- let {
|
|
|
- data
|
|
|
- } = checkinInfoAndLockInfo.data;
|
|
|
- // 没查询到入住
|
|
|
- if (!checkinInfoAndLockInfo.data.success) {
|
|
|
- if (checkinInfoAndLockInfo.data.msg === "账号的身份证号信息不全") {
|
|
|
- uni.showModal({
|
|
|
- title: "身份信息不全",
|
|
|
- content: "请至我的账户页面,输入您的身份证号信息。",
|
|
|
- success: (res) => {
|
|
|
- if (res.confirm) {
|
|
|
- uni.navigateTo({
|
|
|
- url: "/subpkg/myAccount/myAccount"
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- });
|
|
|
- } else {
|
|
|
- uni.showModal({
|
|
|
- title: "温馨提示",
|
|
|
- content: checkinInfoAndLockInfo.data.msg,
|
|
|
- });
|
|
|
- uni.switchTab({
|
|
|
- url: '/pages/home/home'
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 查询到入住,更新信息,同时后台直接查询门锁秘钥
|
|
|
- this.hotelId = data.hotelId;
|
|
|
- this.openDoorInfo.gatewayDeviceId = data.gatewayDeviceId;
|
|
|
- this.openDoorInfo.bluetoothDeviceId = data.deviceId;
|
|
|
- this.openDoorInfo.bluetoothName = data.name;
|
|
|
+ // console.log("获取入住记录和门锁记录", openDoorInfoRes);
|
|
|
+
|
|
|
+ const { data: doorLockInfo } = openDoorInfoRes
|
|
|
+ // 更新门锁设备相关信息
|
|
|
+ this.openDoorInfo.bluetoothDeviceId = doorLockInfo.doorLockDeviceId;
|
|
|
+ this.openDoorInfo.bluetoothName = doorLockInfo.doorLockName;
|
|
|
this.openDoorInfo.androidOptimization =
|
|
|
- data.androidOptimization === false ? false : true;
|
|
|
- this.openDoorInfo.openDoorParam = JSON.parse(data.openDoorParam)
|
|
|
+ doorLockInfo.androidOptimization === false ? false : true;
|
|
|
+ this.openDoorInfo.openDoorParam = JSON.parse(doorLockInfo.openDoorParam)
|
|
|
// console.log("this.openDoorInfo.openDoorParam", this.openDoorInfo.openDoorParam);
|
|
|
-
|
|
|
- // 查询门锁蓝牙秘钥
|
|
|
- let bluetoothKey = await getBluetoothKey(data.hotelId)
|
|
|
- console.log("获取蓝牙秘钥", bluetoothKey);
|
|
|
- // 查询门锁蓝牙秘钥失败
|
|
|
- if (!bluetoothKey.data.success) {
|
|
|
- uni.showModal({
|
|
|
- title: "获取门锁信息失败",
|
|
|
- content: "获取门锁信息失败,请稍后重试。",
|
|
|
- });
|
|
|
- uni.switchTab({
|
|
|
- url: '/pages/home/home'
|
|
|
- })
|
|
|
- return;
|
|
|
- }
|
|
|
- // 查询门锁蓝牙秘钥成功
|
|
|
- this.openDoorInfo.bluetoothKey = bluetoothKey.data.data;
|
|
|
+ this.openDoorInfo.bluetoothKey = doorLockInfo.doorLockKey;
|
|
|
this.allowedOpenDoor = 0;
|
|
|
},
|
|
|
};
|