Browse Source

opt:修改手机钥匙和梯控二维码部分内容

Shu 2 months ago
parent
commit
7dd930e0d1

+ 23 - 71
mixins/bluetoothMixin.js

@@ -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;
 	},
 };

+ 8 - 13
subpkg/elevatorControl/elevatorControl.vue

@@ -12,7 +12,7 @@
 			<view class="info">
 				<view class="title">
 					<view class="hotel-name">
-						<u-text :text="checkinInfo.hotelName" bold color="#333333" size="30rpx"></u-text>
+						<u-text :text="currentHotel.name" bold color="#333333" size="30rpx"></u-text>
 					</view>
 					<view class="tips">
 						<u-text text="入住信息" color="#666666" size="24rpx"></u-text>
@@ -139,7 +139,7 @@
 					hotelId: this.currentHotel.hotelId,
 					building: 1,
 					floor: this.checkinInfo.floor,
-					customerId: this.checkinInfo.customerUserId,
+					customerId: this.userInfo.idNumber,
 					customerType: 1,
 					status: 1,
 					activeTime: moment().add(10, "m")
@@ -201,21 +201,16 @@
 			}
 		},
 		async onLoad() {
-			const info = await getCheckinInfo({
-				userIdNumber: this.userInfo.idNumber,
-				hotelId: this.currentHotel.hotelId,
-				status: 1,
-				pageNo: 1,
-				pageSize: 1,
-			})
-			// console.log("getCheckinInfo", info);
+			// 获取入住记录
+			let {data: infoRes} = await getCheckinInfo(this.currentHotel.hotelId)
+			console.log("获取入住记录", infoRes);
 
-			if (!info.data.data.records.length) {
-				console.log("未查询到入住记录");
+			if (infoRes.code !== 200 || !infoRes.success) {
+				console.log("获取入住记录失败", info.data.data);
 				return
 			}
 
-			this.checkinInfo = info.data.data.records[0];
+			this.checkinInfo = infoRes.data;
 			// console.log("入住记录", this.checkinInfo);
 
 			// #ifdef MP-WEIXIN

+ 1 - 1
subpkg/emergencyKey/emergencyKey.vue

@@ -12,7 +12,7 @@
 			<view class="info">
 				<view class="title">
 					<view class="hotel-name">
-						<u-text :text="checkinInfo.hotelName" bold color="#333333" size="30rpx"></u-text>
+						<u-text :text="currentHotel.name" bold color="#333333" size="30rpx"></u-text>
 					</view>
 					<view class="tips">
 						<u-text text="入住信息" color="#666666" size="24rpx"></u-text>

+ 10 - 29
utils/api.js

@@ -1,38 +1,19 @@
-// /api/v1/mobile/checkinRoomInfo   获取入住房间和门锁设备信息
-export const getCheckinInfoAndLockInfo = (data) => {
-  return uni.$http.get(`/mobile/checkinRoomInfo`, data);
+// 获取门锁设备信息
+export const getOpenDoorInfo = (data) => {
+  return uni.$http.post(`/user/openDoorInfo`, data);
 };
 
-// /api/v1/mobile/lockKey/{hotelId}   获取蓝牙设备密钥
-export const getBluetoothKey = (hotelId) => {
-  return uni.$http.get(`/mobile/lockKey/${hotelId}`);
-};
-
-// /api/v1/mobile/uploadDoorLog/{hotelId}   上传开门记录
-export const uploadDoorLog = (hotelId, data) => {
-  return uni.$http.post(`/mobile/uploadDoorLog/${hotelId}`, data);
-};
-
-// /api/v1/mobile/uploadPowerLog/{hotelId}    上传门锁电量
-export const uploadPowerLog = (hotelId, data) => {
-  return uni.$http.post(`/mobile/uploadPowerLog/${hotelId}`, data);
-};
-
-// 远程开门
-export const remoteOpenDoor = (hotelId, bluetoothId) => {
-  return uni.$http.post(`/mobile/openDoor/${hotelId}/${bluetoothId}`);
-};
-
-// 小程序上传每次的蓝牙开门的记录 /api/v1/miniScmApp/bleOpLogs
+// 小程序上传每次的蓝牙开门的记录
 export const unloadBLEOpenDoorLog = (data) => {
-  return uni.$http.post(`/bleOpLogs`, data);
+  return uni.$http.post(`/user/bleOpLogs`, data);
 };
+
 // 获取顾客入住记录
-export const getCheckinInfo = (data) => {
-  return uni.$http.post("/checkinInfo/queryByCondition", data)
-}
+export const getCheckinInfo = (hotelId) => {
+  return uni.$http.get(`/user/checkinInfo/${hotelId}`)
+};
 
 // 获取顾客梯控二维码
 export const getElevatorQRCode = (data) => {
-  return uni.$http.post("/qrCode", data)
+  return uni.$http.post("/user/qrCode", data)
 }