index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. let Parse = getApp().Parse
  2. const company = getApp().globalData.company
  3. let navigationBarHeight = getApp().globalData.statusBarHeight + 44;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. roomId: null,
  10. comments: []
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function(options) {
  16. console.log(options)
  17. let roomId = options.id
  18. if (!roomId) {
  19. wx.navigateTo({
  20. url: `/nova-tourism/pages/index/index`
  21. })
  22. }
  23. this.setData({ roomId })
  24. this.getComments()
  25. },
  26. loadMore() {
  27. this.data.loadIndex++
  28. console.log('ddddddddddddd', this.loadIndex)
  29. this.getRooms()
  30. },
  31. async getComments() {
  32. let Order = new Parse.Query('RoomOrder')
  33. Order.equalTo("room", this.data.roomId);
  34. Order.include("user");
  35. Order.greaterThanOrEqualTo("status", 800);
  36. Order.skip((this.data.loadIndex - 1) * 10)
  37. Order.ascending('updatedAt')
  38. Order.limit(10)
  39. let orders = await Order.find()
  40. orders = orders.map((order) =>
  41. {
  42. order = order.toJSON()
  43. order['time'] = dateServ.formatTime('YY-mm-dd HH:MM',order.updatedAt)
  44. return order;
  45. })
  46. console.log(orders)
  47. orders = this.data.loadIndex == 1 ? orders : this.data.comments.concat(orders)
  48. this.setData({
  49. comments: orders
  50. })
  51. let commentCount = await Order.count()
  52. console.log(commentCount);
  53. this.setData({
  54. commentCount
  55. })
  56. console.log(this.data.comments);
  57. },
  58. /**
  59. * 生命周期函数--监听页面初次渲染完成
  60. */
  61. onReady: function() {
  62. },
  63. /**
  64. * 生命周期函数--监听页面显示
  65. */
  66. onShow: function() {
  67. },
  68. /**
  69. * 生命周期函数--监听页面隐藏
  70. */
  71. onHide: function() {
  72. },
  73. /**
  74. * 生命周期函数--监听页面卸载
  75. */
  76. onUnload: function() {
  77. },
  78. /**
  79. * 页面相关事件处理函数--监听用户下拉动作
  80. */
  81. onPullDownRefresh: function() {
  82. },
  83. /**
  84. * 页面上拉触底事件的处理函数
  85. */
  86. onReachBottom: function() {
  87. },
  88. /**
  89. * 用户点击右上角分享
  90. */
  91. onShareAppMessage: function() {
  92. }
  93. })