|
@@ -38,7 +38,7 @@ Page({
|
|
|
//
|
|
|
show: false,
|
|
|
date_start1: '',
|
|
|
- date_end1:'',
|
|
|
+ date_end1: '',
|
|
|
|
|
|
},
|
|
|
|
|
@@ -101,11 +101,11 @@ Page({
|
|
|
console.log('istoday', this.data.istoday);
|
|
|
this.hanshu()
|
|
|
},
|
|
|
- async hanshu(){
|
|
|
- await this.gethomestay()
|
|
|
- await this.getroom()
|
|
|
- // await this.getpic()
|
|
|
- await this.getcurrentdate()
|
|
|
+ async hanshu() {
|
|
|
+ await this.gethomestay()
|
|
|
+ await this.getroom()
|
|
|
+ // await this.getpic()
|
|
|
+ await this.getcurrentdate()
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -185,7 +185,7 @@ Page({
|
|
|
storeList
|
|
|
});
|
|
|
this.setData({
|
|
|
- imageUrls:storeList[0].image
|
|
|
+ imageUrls: storeList[0].image
|
|
|
})
|
|
|
this.Getlocation()
|
|
|
console.log(this.data.storeList);
|
|
@@ -198,17 +198,17 @@ Page({
|
|
|
room.equalTo('isEnabled', 'true');
|
|
|
room.include('benefitMap');
|
|
|
room.notEqualTo('isDeleted', 'true');
|
|
|
-
|
|
|
+
|
|
|
let room2 = await room.find();
|
|
|
// 使用 Promise.all 来处理异步操作
|
|
|
let roomList = await Promise.all(room2.map(async item => {
|
|
|
let roomItem = item.toJSON();
|
|
|
let count = await this.checkOrderCount(roomItem.objectId, this.data.start, this.data.end);
|
|
|
- console.log(count, roomItem.total);
|
|
|
+ console.log(count, roomItem.total);
|
|
|
roomItem.isroom = count < roomItem.total; // 简化判断
|
|
|
return roomItem;
|
|
|
}));
|
|
|
-
|
|
|
+
|
|
|
// 对 roomList 进行排序
|
|
|
roomList.sort((a, b) => {
|
|
|
// 首先比较 isroom,true 排在前面
|
|
@@ -225,13 +225,13 @@ Page({
|
|
|
}
|
|
|
return a.isroom ? -1 : 1; // true 排在前面,false 排在后面
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
this.setData({
|
|
|
roomList
|
|
|
});
|
|
|
console.log('房间', this.data.roomList);
|
|
|
},
|
|
|
- async checkOrderCount(roomId,start,end) {
|
|
|
+ async checkOrderCount(roomId, start, end) {
|
|
|
const startTime = new Date(start);
|
|
|
const endTime = new Date(end);
|
|
|
let now = dateServ.changeDateTime(new Date(), '14:00:00')
|
|
@@ -239,7 +239,7 @@ Page({
|
|
|
Order.equalTo("room", roomId)
|
|
|
Order.equalTo("company", company)
|
|
|
Order.exists("status")
|
|
|
- Order.notContainedIn('status',[100,400,601,700])
|
|
|
+ Order.notContainedIn('status', [100, 400, 601, 700])
|
|
|
Order.greaterThanOrEqualTo("startTime", endTime) //20 23 21 22
|
|
|
Order.lessThanOrEqualTo("endTime", startTime)
|
|
|
Order.select("startTime", "endTime")
|
|
@@ -288,57 +288,60 @@ Page({
|
|
|
//获取当前位置信息
|
|
|
Getlocation() {
|
|
|
// 假设 this.storeList[0].location 是一个 Parse.GeoPoint 对象
|
|
|
- const storeLocation = this.data.storeList[0].location;
|
|
|
- console.log();
|
|
|
- // 从 GeoPoint 对象中获取经纬度
|
|
|
- const latitude = storeLocation.latitude; // 纬度
|
|
|
- const longitude = storeLocation.longitude; // 经度
|
|
|
-
|
|
|
- console.log('获取到的经纬度:', latitude, longitude); // 添加日志
|
|
|
-
|
|
|
- // 调用 API 解析地址
|
|
|
- wx.request({
|
|
|
- url: 'https://api.map.baidu.com/reverse_geocoding/v3/?ak=sHZTomd7grslfP7sPKB8tRgT49FK9TEu&output=json&coordtype=gcj02&location=' + latitude + ',' + longitude,
|
|
|
- data: {},
|
|
|
- header: {
|
|
|
- 'Content-Type': 'application/json'
|
|
|
- },
|
|
|
- success: (ops) => { // 使用箭头函数
|
|
|
- console.log(ops);
|
|
|
- const address = ops.data.result.formatted_address;
|
|
|
- this.setData({
|
|
|
- address: address,
|
|
|
- latitude: latitude, // 保证 latitude 被设置
|
|
|
- longitude: longitude, // 保证 longitude 被设置
|
|
|
- markers: [{ // 设置 markers
|
|
|
- id: 1,
|
|
|
- latitude: latitude,
|
|
|
- longitude: longitude,
|
|
|
- iconPath: 'https://file-cloud.fmode.cn/13WZ0W7u3l/20240724/7ebg0k104325941.png?imageView2/1/w/200/h/200', // 自定义标记图标
|
|
|
- width: 30,
|
|
|
- height: 30,
|
|
|
- callout: {
|
|
|
- content: this.data.storeList[0].storeName, // 可以显示解析出的地址
|
|
|
- color: '#ffffff',
|
|
|
- bgColor: '#7F56B2',
|
|
|
- padding: 10,
|
|
|
- borderRadius: 5,
|
|
|
- display: 'ALWAYS'
|
|
|
- }
|
|
|
- }]
|
|
|
- });
|
|
|
- console.log(this.data.address);
|
|
|
- },
|
|
|
- fail: function (resq) {
|
|
|
- wx.showModal({
|
|
|
- title: '信息提示',
|
|
|
- content: '请求失败',
|
|
|
- showCancel: false,
|
|
|
- confirmColor: '#f37938'
|
|
|
- });
|
|
|
- },
|
|
|
- complete: function () {}
|
|
|
- });
|
|
|
+ if (this.data.storeList[0].location) {
|
|
|
+ const storeLocation = this.data.storeList[0].location;
|
|
|
+ console.log('地址存在');
|
|
|
+ // 从 GeoPoint 对象中获取经纬度
|
|
|
+ const latitude = storeLocation.latitude; // 纬度
|
|
|
+ const longitude = storeLocation.longitude; // 经度
|
|
|
+
|
|
|
+ console.log('获取到的经纬度:', latitude, longitude); // 添加日志
|
|
|
+
|
|
|
+ // 调用 API 解析地址
|
|
|
+ wx.request({
|
|
|
+ url: 'https://api.map.baidu.com/reverse_geocoding/v3/?ak=sHZTomd7grslfP7sPKB8tRgT49FK9TEu&output=json&coordtype=gcj02&location=' + latitude + ',' + longitude,
|
|
|
+ data: {},
|
|
|
+ header: {
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
+ },
|
|
|
+ success: (ops) => { // 使用箭头函数
|
|
|
+ console.log(ops);
|
|
|
+ const address = ops.data.result.formatted_address;
|
|
|
+ this.setData({
|
|
|
+ address: address,
|
|
|
+ latitude: latitude, // 保证 latitude 被设置
|
|
|
+ longitude: longitude, // 保证 longitude 被设置
|
|
|
+ markers: [{ // 设置 markers
|
|
|
+ id: 1,
|
|
|
+ latitude: latitude,
|
|
|
+ longitude: longitude,
|
|
|
+ iconPath: 'https://file-cloud.fmode.cn/13WZ0W7u3l/20240724/7ebg0k104325941.png?imageView2/1/w/200/h/200', // 自定义标记图标
|
|
|
+ width: 30,
|
|
|
+ height: 30,
|
|
|
+ callout: {
|
|
|
+ content: this.data.storeList[0].storeName, // 可以显示解析出的地址
|
|
|
+ color: '#ffffff',
|
|
|
+ bgColor: '#7F56B2',
|
|
|
+ padding: 10,
|
|
|
+ borderRadius: 5,
|
|
|
+ display: 'ALWAYS'
|
|
|
+ }
|
|
|
+ }]
|
|
|
+ });
|
|
|
+ console.log(this.data.address);
|
|
|
+ },
|
|
|
+ fail: function (resq) {
|
|
|
+ wx.showModal({
|
|
|
+ title: '信息提示',
|
|
|
+ content: '请求失败',
|
|
|
+ showCancel: false,
|
|
|
+ confirmColor: '#f37938'
|
|
|
+ });
|
|
|
+ },
|
|
|
+ complete: function () {}
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
//点击预定
|
|
|
navigate(e) {
|
|
@@ -365,31 +368,31 @@ Page({
|
|
|
// url: `../homestay-order/index?${queryString}`
|
|
|
// })
|
|
|
// } else {
|
|
|
- // wx.showToast({
|
|
|
- // title: '请先进行实名认证',
|
|
|
- // icon: 'none'
|
|
|
- // })
|
|
|
- //实名
|
|
|
- // wx.navigateTo({
|
|
|
- // url: `/common-page/pages/info/cauth/cauth?themeColor=#FFE300`
|
|
|
- // })
|
|
|
-
|
|
|
- // 构造要传递的信息
|
|
|
- const info = {
|
|
|
- objectId: objectId,
|
|
|
- date_start: this.data.start,
|
|
|
- date_end: this.data.end,
|
|
|
- };
|
|
|
- console.log('info', info);
|
|
|
-
|
|
|
- // 将信息转为查询字符串
|
|
|
- var queryString = Object.keys(info)
|
|
|
- .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(info[key])}`)
|
|
|
- .join('&');
|
|
|
- console.log(queryString);
|
|
|
- wx.navigateTo({
|
|
|
- url: `../homestay-order2/index?${queryString}`
|
|
|
- })
|
|
|
+ // wx.showToast({
|
|
|
+ // title: '请先进行实名认证',
|
|
|
+ // icon: 'none'
|
|
|
+ // })
|
|
|
+ //实名
|
|
|
+ // wx.navigateTo({
|
|
|
+ // url: `/common-page/pages/info/cauth/cauth?themeColor=#FFE300`
|
|
|
+ // })
|
|
|
+
|
|
|
+ // 构造要传递的信息
|
|
|
+ const info = {
|
|
|
+ objectId: objectId,
|
|
|
+ date_start: this.data.start,
|
|
|
+ date_end: this.data.end,
|
|
|
+ };
|
|
|
+ console.log('info', info);
|
|
|
+
|
|
|
+ // 将信息转为查询字符串
|
|
|
+ var queryString = Object.keys(info)
|
|
|
+ .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(info[key])}`)
|
|
|
+ .join('&');
|
|
|
+ console.log(queryString);
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `../homestay-order2/index?${queryString}`
|
|
|
+ })
|
|
|
// }
|
|
|
|
|
|
},
|
|
@@ -465,13 +468,17 @@ Page({
|
|
|
phoneNumber: phone
|
|
|
})
|
|
|
},
|
|
|
- callMap(){
|
|
|
- const latitude = this.data.storeList[0].location.latitude
|
|
|
- const longitude = this.data.storeList[0].location.longitude
|
|
|
- wx.openLocation({
|
|
|
- latitude,
|
|
|
- longitude,
|
|
|
- scale: 18
|
|
|
- })
|
|
|
+ callMap() {
|
|
|
+ if (this.data.storeList[0].location) {
|
|
|
+ const latitude = this.data.storeList[0].location.latitude
|
|
|
+ const longitude = this.data.storeList[0].location.longitude
|
|
|
+ wx.openLocation({
|
|
|
+ name: this.data.storeList[0].storeName,
|
|
|
+ latitude,
|
|
|
+ longitude,
|
|
|
+ scale: 18
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
})
|