index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. const Parse = getApp().Parse;
  2. const company = getApp().globalData.company;
  3. const dateServ = require('../../../../../../utils/date')
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. active: "noreply",
  10. orders: [],
  11. loadIndex:1,
  12. storeId:''
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. let merchant = wx.getStorageSync('merchant')
  19. let merchantId = merchant.objectId;
  20. let Store = new Parse.Query('ShopStore')
  21. Store.notEqualTo('isDeleted', "true")
  22. Store.equalTo('company', company)
  23. Store.equalTo('user', merchantId)
  24. Store.first().then(store =>{
  25. this.setData({
  26. storeId:store.id
  27. })
  28. this.getOrders()
  29. })
  30. },
  31. /**
  32. * 生命周期函数--监听页面初次渲染完成
  33. */
  34. onReady: function () {
  35. },
  36. async getOrders(replyStatus){
  37. let Order = new Parse.Query('RoomOrder')
  38. Order.equalTo('company', company)
  39. Order.equalTo('status', 800)
  40. Order.equalTo('shopStore', this.data.storeId)
  41. if(replyStatus == 'replied'){
  42. Order.exists('reply')
  43. }else {
  44. Order.doesNotExist('reply')
  45. }
  46. Order.include('user')
  47. Order.include('room')
  48. Order.descending('updatedAt')
  49. Order.skip((this.data.loadIndex - 1) * 10)
  50. Order.limit(10)
  51. let orders = await Order.find()
  52. orders = orders.map((order) => {
  53. order = order.toJSON()
  54. order['time'] = dateServ.formatTime('YY-mm-dd HH:MM',order.updatedAt)
  55. order['day'] = parseInt((new Date(order.endTime.iso).getTime() - new Date(order.startTime.iso).getTime()) / (1000 * 60 * 60 * 24));
  56. order.startTime = dateServ.formatTime('mm月dd日',order.startTime.iso)
  57. order.endTime = dateServ.formatTime('mm月dd日',order.endTime.iso)
  58. return order;
  59. })
  60. orders = this.data.loadIndex == 1 ? orders : this.data.orders.concat(orders)
  61. console.log(orders)
  62. this.setData({
  63. orders
  64. })
  65. },
  66. details(event){
  67. let orderId = event.currentTarget.dataset.id
  68. wx.navigateTo({
  69. url: `/nova-tourism/pages/my/merchant/comments/hotel/comment-detail/index?id=${orderId}`
  70. })
  71. },
  72. tabChange(event) {
  73. this.data.active = event.detail.name
  74. this.data.loadIndex = 1
  75. console.log(this.data.active)
  76. this.getOrders(event.detail.name)
  77. },
  78. loadMore() {
  79. this.data.loadIndex++
  80. console.log('ddddddddddddd', this.data.loadIndex)
  81. this.getOrders()
  82. },
  83. /**
  84. * 生命周期函数--监听页面显示
  85. */
  86. onShow: function () {
  87. this.selectComponent("#tabs").resize()
  88. },
  89. /**
  90. * 生命周期函数--监听页面隐藏
  91. */
  92. onHide: function () {
  93. },
  94. /**
  95. * 生命周期函数--监听页面卸载
  96. */
  97. onUnload: function () {
  98. },
  99. /**
  100. * 页面相关事件处理函数--监听用户下拉动作
  101. */
  102. onPullDownRefresh: function () {
  103. },
  104. /**
  105. * 页面上拉触底事件的处理函数
  106. */
  107. onReachBottom: function () {
  108. },
  109. /**
  110. * 用户点击右上角分享
  111. */
  112. onShareAppMessage: function () {
  113. }
  114. })