index.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. let Parse = getApp().Parse
  2. const company = getApp().globalData.company
  3. let navigationBarHeight = getApp().globalData.statusBarHeight + 44;
  4. const rechText = require('../../../../../utils/rech-text')
  5. const dateF = require('../../../../../utils/date')
  6. const dateServ = require('../../../../../utils/date')
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. id: "",
  13. order: null,
  14. },
  15. async getRoomOrder() {
  16. let id = this.data.id
  17. console.log(id, 12222323);
  18. let RoomOrder = new Parse.Query('RoomOrder')
  19. RoomOrder.include('room')
  20. RoomOrder.include('shopStore')
  21. let roomOrder = await RoomOrder.get(id)
  22. console.log(roomOrder, 666666);
  23. let Order = roomOrder.toJSON()
  24. Order.createdAt = dateF.formatTime("YYYY-mm-dd HH:MM:SS", Order.createdAt)
  25. Order.room.note = rechText.formatRichText(Order.room.note)
  26. Order['day'] = parseInt((new Date(Order.endTime.iso).getTime() - new Date(Order.startTime.iso).getTime()) / (1000 * 60 * 60 * 24));
  27. Order.startTime = dateServ.formatTime('YYYY-mm-dd', Order.startTime.iso)
  28. Order.endTime = dateServ.formatTime('YYYY-mm-dd', Order.endTime.iso)
  29. this.setData({
  30. order: Order
  31. })
  32. console.log(this.data.order);
  33. },
  34. async submit() {
  35. try {
  36. let id = this.data.id
  37. let RoomOrder = new Parse.Query("RoomOrder")
  38. let roomOrder = await RoomOrder.get(id)
  39. roomOrder.set("status", 400)
  40. await roomOrder.save()
  41. console.log(res)
  42. wx.showToast({
  43. title: '核销成功',
  44. icon: 'none'
  45. })
  46. } catch (error) {
  47. wx.showToast({
  48. title: '核销失败',
  49. icon: 'none'
  50. })
  51. }
  52. wx.navigateBack({
  53. delta: 1,
  54. });
  55. },
  56. /**
  57. * 生命周期函数--监听页面加载
  58. */
  59. onLoad: function(options) {
  60. let id = options.id
  61. this.setData({ id: id })
  62. this.getRoomOrder()
  63. },
  64. /**
  65. * 生命周期函数--监听页面初次渲染完成
  66. */
  67. onReady: function() {
  68. },
  69. /**
  70. * 生命周期函数--监听页面显示
  71. */
  72. onShow: function() {
  73. },
  74. /**
  75. * 生命周期函数--监听页面隐藏
  76. */
  77. onHide: function() {
  78. },
  79. /**
  80. * 生命周期函数--监听页面卸载
  81. */
  82. onUnload: function() {
  83. },
  84. /**
  85. * 页面相关事件处理函数--监听用户下拉动作
  86. */
  87. onPullDownRefresh: function() {
  88. },
  89. /**
  90. * 页面上拉触底事件的处理函数
  91. */
  92. onReachBottom: function() {
  93. },
  94. /**
  95. * 用户点击右上角分享
  96. */
  97. onShareAppMessage: function() {
  98. }
  99. })