index.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. const Parse = getApp().Parse;
  2. const company = getApp().globalData.company
  3. const dateF = require('../../../../../utils/date')
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. id: "",
  10. order: {},
  11. value: 3.5,
  12. fileList: {},
  13. content: null,
  14. },
  15. onChange(event) {
  16. this.setData({
  17. value: event.detail,
  18. });
  19. },
  20. blur(e) {
  21. let name = e.currentTarget.dataset.name
  22. this.setData({
  23. [name]: e.detail.value
  24. })
  25. },
  26. changeFile(e) {
  27. console.log(e);
  28. let fileList = e.detail
  29. this.setData({
  30. fileList
  31. })
  32. },
  33. async getShopOrder() {
  34. let id = this.data.id
  35. console.log(id);
  36. let ShopOrder = new Parse.Query('RoomOrder')
  37. ShopOrder.include('room')
  38. let shopOrder = await ShopOrder.get(id)
  39. let orderTime = dateF.formatTime("mm-dd", shopOrder.toJSON().startTime.iso)
  40. let Time = dateF.formatTime("mm-dd", shopOrder.toJSON().endTime.iso)
  41. let a = dateF.formatTime("YYYY-mm-dd HH:MM:SS", shopOrder.toJSON().startTime.iso)
  42. let e = dateF.formatTime("YYYY-mm-dd HH:MM:SS", shopOrder.toJSON().endTime.iso)
  43. //计算天数
  44. let day = parseInt((new Date(e.replace(/-/g, '/')).getTime() - new Date(a.replace(/-/g, '/')).getTime()) / (1000 * 60 * 60 * 24))
  45. console.log(day, Time, orderTime);
  46. this.setData({
  47. order: shopOrder.toJSON(),
  48. day: day,
  49. orderTime: orderTime,
  50. Time: Time
  51. })
  52. console.log(this.data.order);
  53. },
  54. async submit() {
  55. const _this = this
  56. let images = []
  57. for (let index = 0; index < this.data.fileList.length; index++) {
  58. let item = this.data.fileList[index];
  59. images.push(item.url)
  60. }
  61. console.log(this.data.content, images, this.data.value);
  62. if (!this.data.content) {
  63. wx.showToast({
  64. title: '请填写完整信息',
  65. icon: 'none'
  66. })
  67. return
  68. }
  69. let shopOrder
  70. let query = new Parse.Query("RoomOrder")
  71. shopOrder = await query.get(this.data.id)
  72. shopOrder.set("content", this.data.content)
  73. shopOrder.set("images", images)
  74. shopOrder.set("status", 800)
  75. shopOrder.set("score", this.data.value)
  76. shopOrder.save().then(res => {
  77. console.log(res)
  78. wx.showToast({
  79. title: '修改成功',
  80. icon: 'none'
  81. })
  82. _this.setData({
  83. })
  84. wx.navigateBack({
  85. delta: 1,
  86. });
  87. })
  88. },
  89. /**
  90. * 生命周期函数--监听页面加载
  91. */
  92. onLoad: function(options) {
  93. let id = options.id
  94. this.setData({
  95. id: id
  96. })
  97. this.getShopOrder()
  98. },
  99. /**
  100. * 生命周期函数--监听页面初次渲染完成
  101. */
  102. onReady: function() {
  103. },
  104. /**
  105. * 生命周期函数--监听页面显示
  106. */
  107. onShow: function() {
  108. },
  109. /**
  110. * 生命周期函数--监听页面隐藏
  111. */
  112. onHide: function() {
  113. },
  114. /**
  115. * 生命周期函数--监听页面卸载
  116. */
  117. onUnload: function() {
  118. },
  119. /**
  120. * 页面相关事件处理函数--监听用户下拉动作
  121. */
  122. onPullDownRefresh: function() {
  123. },
  124. /**
  125. * 页面上拉触底事件的处理函数
  126. */
  127. onReachBottom: function() {
  128. },
  129. /**
  130. * 用户点击右上角分享
  131. */
  132. onShareAppMessage: function() {
  133. }
  134. })