index.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. const Parse = getApp().Parse;
  2. const company = getApp().globalData.company
  3. const dateF = require('../../../../utils/date')
  4. let navigationBarHeight = getApp().globalData.statusBarHeight + 44;
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. active: 0,
  11. goodsList: null,
  12. stickytop: navigationBarHeight,
  13. activeColor:''
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. this.setData({
  20. activeColor:getApp().globalData.activeColor || '#229293'
  21. })
  22. this.queryOrder()
  23. },
  24. onChange(event) {
  25. this.setData({ active: event.detail.name })
  26. this.queryOrder()
  27. },
  28. async queryOrder() {
  29. let active = this.data.active
  30. console.log(active);
  31. let user = Parse.User.current()
  32. console.log(user.id);
  33. let Order = new Parse.Query('Order')
  34. Order.equalTo('company', company)
  35. Order.equalTo('user', user.id)
  36. Order.include('targetObject')
  37. Order.include('store')
  38. if (active == 1) {
  39. Order.equalTo('status', '100')
  40. }
  41. if (active == 2) {
  42. Order.greaterThan('status', '200')
  43. Order.lessThan('status', '400')
  44. }
  45. if (active == 3) {
  46. Order.equalTo('status', '400')
  47. }
  48. Order.equalTo('type', 'shop')
  49. let orders = await Order.find()
  50. if (orders && orders.length > 0) {
  51. let orderJSON = []
  52. orders.forEach(order => {
  53. let orderObj = order.toJSON()
  54. orderObj.orderTime = dateF.formatTime("YYYY-mm-dd HH:MM:SS", orderObj.createdAt)
  55. orderJSON.push(orderObj)
  56. })
  57. this.setData({
  58. goodsList: orderJSON
  59. })
  60. console.log(this.data.goodsList);
  61. } else {
  62. this.setData({
  63. goodsList: null
  64. })
  65. }
  66. },
  67. details(e) {
  68. let id = e.currentTarget.dataset.item.objectId
  69. wx.navigateTo({
  70. url: '/nova-tourism/pages/shop/order/index?id=' + id
  71. })
  72. },
  73. /**
  74. * 生命周期函数--监听页面初次渲染完成
  75. */
  76. onReady: function () {
  77. },
  78. /**
  79. * 生命周期函数--监听页面显示
  80. */
  81. onShow: function () {
  82. this.queryOrder()
  83. },
  84. /**
  85. * 生命周期函数--监听页面隐藏
  86. */
  87. onHide: function () {
  88. },
  89. /**
  90. * 生命周期函数--监听页面卸载
  91. */
  92. onUnload: function () {
  93. },
  94. /**
  95. * 页面相关事件处理函数--监听用户下拉动作
  96. */
  97. onPullDownRefresh: function () {
  98. },
  99. /**
  100. * 页面上拉触底事件的处理函数
  101. */
  102. onReachBottom: function () {
  103. },
  104. /**
  105. * 用户点击右上角分享
  106. */
  107. onShareAppMessage: function () {
  108. }
  109. })