index.js 2.7 KB

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