index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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('ShopOrder')
  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('goods')
  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. return order;
  56. })
  57. orders = this.data.loadIndex == 1 ? orders : this.data.orders.concat(orders)
  58. console.log(orders)
  59. this.setData({
  60. orders
  61. })
  62. },
  63. details(event){
  64. let orderId = event.currentTarget.dataset.id
  65. wx.navigateTo({
  66. url: `/nova-tourism/pages/my/merchant/comments/setmeal/comment-detail/index?id=${orderId}`
  67. })
  68. },
  69. tabChange(event) {
  70. this.data.active = event.detail.name
  71. this.data.loadIndex = 1
  72. console.log(this.data.active)
  73. this.getOrders(event.detail.name)
  74. },
  75. loadMore() {
  76. this.data.loadIndex++
  77. console.log('ddddddddddddd', this.data.loadIndex)
  78. this.getOrders()
  79. },
  80. /**
  81. * 生命周期函数--监听页面显示
  82. */
  83. onShow: function () {
  84. this.selectComponent("#tabs").resize()
  85. },
  86. /**
  87. * 生命周期函数--监听页面隐藏
  88. */
  89. onHide: function () {
  90. },
  91. /**
  92. * 生命周期函数--监听页面卸载
  93. */
  94. onUnload: function () {
  95. },
  96. /**
  97. * 页面相关事件处理函数--监听用户下拉动作
  98. */
  99. onPullDownRefresh: function () {
  100. },
  101. /**
  102. * 页面上拉触底事件的处理函数
  103. */
  104. onReachBottom: function () {
  105. },
  106. /**
  107. * 用户点击右上角分享
  108. */
  109. onShareAppMessage: function () {
  110. }
  111. })