index.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. // nova-tourism/pages/my/my-order/my-refund/index.js
  2. let Parse = getApp().Parse;
  3. const company = getApp().globalData.company
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. statusBarHeight: 0,
  10. screenHeight: 0,
  11. customHeight: 0,
  12. bottomNavHeight: 0,
  13. contentHeight: 0,
  14. roomList:[]
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. const systemInfo = wx.getSystemInfoSync();
  21. const statusBarHeight = systemInfo.statusBarHeight || 0;
  22. const screenHeight = systemInfo.screenHeight || 0;
  23. const custom = wx.getMenuButtonBoundingClientRect();
  24. const customHeight = custom.height + 10 + 2 || 0;
  25. const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
  26. const contentHeight = (screenHeight - bottomNavHeight - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
  27. this.setData({
  28. statusBarHeight,
  29. screenHeight,
  30. customHeight,
  31. bottomNavHeight,
  32. contentHeight
  33. });
  34. this.getRoomOrder()
  35. },
  36. gourl2(e) {
  37. const url = e.currentTarget.dataset.url;
  38. const id = e.currentTarget.dataset.id;
  39. console.log('info',id);
  40. // 构造要传递的信息
  41. const info = {
  42. objectId: id,
  43. value:'民宿'
  44. };
  45. // 将信息转为查询字符串
  46. const queryString = Object.keys(info)
  47. .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(info[key])}`)
  48. .join('&');
  49. // 使用查询字符串跳转
  50. wx.navigateTo({
  51. url: `${url}?${queryString}`,
  52. });
  53. },
  54. async getRoomOrder() {
  55. let Order = new Parse.Query('RoomOrder');
  56. Order.equalTo('company', company);
  57. Order.include('room');
  58. Order.equalTo('user', Parse.User.current().id);
  59. Order.include('shopStore');
  60. Order.containedIn('status', [102,103,104])
  61. // 添加排序条件
  62. Order.descending('updatedAt');
  63. let room = await Order.find();
  64. let roomList = room.map(async item => {
  65. let roomItme = item.toJSON();
  66. roomItme.tiem = await this.formatDate2(roomItme.startTime.iso, roomItme.endTime.iso)
  67. return roomItme
  68. });
  69. let roomList2 = await Promise.all(roomList);
  70. this.setData({
  71. roomList: roomList2
  72. })
  73. console.log(this.data.roomList);
  74. },
  75. formatDate2(date1, date2) {
  76. date1 = new Date(date1);
  77. date2 = new Date(date2);
  78. // 获取年份、月份和日期
  79. const year1 = date1.getFullYear();
  80. const month1 = date1.getMonth() + 1; // 月份从0开始,所以要加1
  81. const day1 = date1.getDate();
  82. const year2 = date2.getFullYear();
  83. const month2 = date2.getMonth() + 1; // 月份从0开始,所以要加1
  84. const day2 = date2.getDate();
  85. // 返回格式化的字符串
  86. return `${year1}年${month1}月${day1}日入住 - ${year2}年${month2}月${day2}日离店`;
  87. },
  88. /**
  89. * 生命周期函数--监听页面初次渲染完成
  90. */
  91. onReady: function () {
  92. },
  93. /**
  94. * 生命周期函数--监听页面显示
  95. */
  96. onShow: function () {
  97. },
  98. /**
  99. * 生命周期函数--监听页面隐藏
  100. */
  101. onHide: function () {
  102. },
  103. /**
  104. * 生命周期函数--监听页面卸载
  105. */
  106. onUnload: function () {
  107. },
  108. /**
  109. * 页面相关事件处理函数--监听用户下拉动作
  110. */
  111. onPullDownRefresh: function () {
  112. },
  113. /**
  114. * 页面上拉触底事件的处理函数
  115. */
  116. onReachBottom: function () {
  117. },
  118. /**
  119. * 用户点击右上角分享
  120. */
  121. onShareAppMessage: function () {
  122. },
  123. gourl(e) {
  124. const url = e.currentTarget.dataset.url;
  125. // const id = e.currentTarget.dataset.id;
  126. // 使用查询字符串跳转
  127. wx.navigateTo({
  128. url: `${url}`,
  129. });
  130. },
  131. })