|
@@ -1,4 +1,6 @@
|
|
|
// nova-tourism/pages/my/my-order/my-refund/index.js
|
|
|
+let Parse = getApp().Parse;
|
|
|
+const company = getApp().globalData.company
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
@@ -10,6 +12,8 @@ Page({
|
|
|
customHeight: 0,
|
|
|
bottomNavHeight: 0,
|
|
|
contentHeight: 0,
|
|
|
+
|
|
|
+ roomList:[]
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -31,9 +35,67 @@ Page({
|
|
|
bottomNavHeight,
|
|
|
contentHeight
|
|
|
});
|
|
|
+
|
|
|
+ this.getRoomOrder()
|
|
|
},
|
|
|
+ gourl2(e) {
|
|
|
+ const url = e.currentTarget.dataset.url;
|
|
|
+ const id = e.currentTarget.dataset.id;
|
|
|
+ console.log('info',id);
|
|
|
+ // 构造要传递的信息
|
|
|
+ const info = {
|
|
|
+ objectId: id,
|
|
|
+ value:'民宿'
|
|
|
+ };
|
|
|
+
|
|
|
+ // 将信息转为查询字符串
|
|
|
+ const queryString = Object.keys(info)
|
|
|
+ .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(info[key])}`)
|
|
|
+ .join('&');
|
|
|
|
|
|
+ // 使用查询字符串跳转
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `${url}?${queryString}`,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ async getRoomOrder() {
|
|
|
+ let Order = new Parse.Query('RoomOrder');
|
|
|
+ Order.equalTo('company', company);
|
|
|
+ Order.include('room');
|
|
|
+ Order.equalTo('user', Parse.User.current().id);
|
|
|
+ Order.include('shopStore');
|
|
|
+ Order.containedIn('status', [102,103,104])
|
|
|
+
|
|
|
+ // 添加排序条件
|
|
|
+ Order.descending('updatedAt');
|
|
|
+ let room = await Order.find();
|
|
|
+ let roomList = room.map(async item => {
|
|
|
+ let roomItme = item.toJSON();
|
|
|
+ roomItme.tiem = await this.formatDate2(roomItme.startTime.iso, roomItme.endTime.iso)
|
|
|
+ return roomItme
|
|
|
+ });
|
|
|
+ let roomList2 = await Promise.all(roomList);
|
|
|
+ this.setData({
|
|
|
+ roomList: roomList2
|
|
|
+ })
|
|
|
+ console.log(this.data.roomList);
|
|
|
+ },
|
|
|
+ formatDate2(date1, date2) {
|
|
|
+ date1 = new Date(date1);
|
|
|
+ date2 = new Date(date2);
|
|
|
|
|
|
+ // 获取年份、月份和日期
|
|
|
+ const year1 = date1.getFullYear();
|
|
|
+ const month1 = date1.getMonth() + 1; // 月份从0开始,所以要加1
|
|
|
+ const day1 = date1.getDate();
|
|
|
+
|
|
|
+ const year2 = date2.getFullYear();
|
|
|
+ const month2 = date2.getMonth() + 1; // 月份从0开始,所以要加1
|
|
|
+ const day2 = date2.getDate();
|
|
|
+
|
|
|
+ // 返回格式化的字符串
|
|
|
+ return `${year1}年${month1}月${day1}日入住 - ${year2}年${month2}月${day2}日离店`;
|
|
|
+ },
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|