index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. orderId: '',
  10. order: null,
  11. showReplyModal: '',
  12. reply:''
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. let orderId = options.id
  19. console.log(options.id);
  20. this.setData({
  21. orderId
  22. })
  23. this.getOrder()
  24. },
  25. /**
  26. * 生命周期函数--监听页面初次渲染完成
  27. */
  28. onReady: function () {
  29. },
  30. /**
  31. * 生命周期函数--监听页面显示
  32. */
  33. onShow: function () {
  34. },
  35. async getOrder(){
  36. let Order = new Parse.Query('RoomOrder')
  37. Order.include('user')
  38. Order.include('room')
  39. Order.get(this.data.orderId)
  40. let order = await Order.first()
  41. order = order.toJSON()
  42. order['time'] = dateServ.formatTime('YY-mm-dd HH:MM',order.updatedAt)
  43. order['day'] = parseInt((new Date(order.endTime.iso).getTime() - new Date(order.startTime.iso).getTime()) / (1000 * 60 * 60 * 24));
  44. order.startTime = dateServ.formatTime('mm月dd日',order.startTime.iso)
  45. order.endTime = dateServ.formatTime('mm月dd日',order.endTime.iso)
  46. console.log(order)
  47. this.setData({
  48. order
  49. })
  50. },
  51. showModal(){
  52. this.setData({
  53. showReplyModal: true
  54. })
  55. },
  56. closeModal(){
  57. this.setData({
  58. showReplyModal: false
  59. })
  60. },
  61. replyChange(event){
  62. console.log(event.detail);
  63. this.data.reply = event.detail.value;
  64. },
  65. async replyComment(){
  66. try {
  67. let Order = new Parse.Query('RoomOrder')
  68. Order.get(this.data.orderId)
  69. let order = await Order.first()
  70. order.set("reply",this.data.reply)
  71. let res = await order.save()
  72. if(res && res.id){
  73. this.getOrder()
  74. this.setData({
  75. showReplyModal: false
  76. })
  77. wx.showToast({
  78. title: '回复成功',
  79. icon: 'none'
  80. })
  81. }
  82. } catch (error) {
  83. this.setData({
  84. showReplyModal: false
  85. })
  86. wx.showToast({
  87. title: `回复失败,${error}`,
  88. icon: 'none'
  89. })
  90. }
  91. },
  92. /**
  93. * 生命周期函数--监听页面隐藏
  94. */
  95. onHide: function () {
  96. },
  97. /**
  98. * 生命周期函数--监听页面卸载
  99. */
  100. onUnload: function () {
  101. },
  102. /**
  103. * 页面相关事件处理函数--监听用户下拉动作
  104. */
  105. onPullDownRefresh: function () {
  106. },
  107. /**
  108. * 页面上拉触底事件的处理函数
  109. */
  110. onReachBottom: function () {
  111. },
  112. /**
  113. * 用户点击右上角分享
  114. */
  115. onShareAppMessage: function () {
  116. }
  117. })