index.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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:null,
  10. schema:null,
  11. order:{},
  12. explain: '',
  13. show:false,
  14. causes:[
  15. {
  16. label: '多拍/拍错/不想要',
  17. value: '多拍/拍错/不想要',
  18. checked: false
  19. },
  20. {
  21. label: '时间变更',
  22. value: '时间变更',
  23. checked: false
  24. },
  25. {
  26. label: '其他',
  27. value: '其他',
  28. checked: false
  29. }
  30. ],
  31. causeVal:'',
  32. activeColor:''
  33. },
  34. /**
  35. * 生命周期函数--监听页面加载
  36. */
  37. onLoad: function (options) {
  38. this.setData({
  39. activeColor:getApp().globalData.activeColor || '#229293'
  40. })
  41. let {id,schema}=options;
  42. this.setData({
  43. id,
  44. schema
  45. })
  46. if(schema == 'RoomOrder'){
  47. this.getRoomOrder()
  48. return
  49. }
  50. this.getOrder()
  51. },
  52. async getRoomOrder() {
  53. console.log(this.data.schema,this.data.id);
  54. let Order = new Parse.Query("RoomOrder")
  55. Order.include('shopStore')
  56. Order.include('room')
  57. let parseOrder = await Order.get(this.data.id)
  58. console.log(parseOrder);
  59. if(parseOrder && parseOrder.id){
  60. let order = parseOrder.toJSON()
  61. order.startTime = dateF.formatTime("YYYY/mm/dd", order.startTime.iso)
  62. order.endTime = dateF.formatTime("YYYY/mm/dd", order.endTime.iso)
  63. this.setData({
  64. parseOrder,
  65. order
  66. })
  67. }
  68. console.log(this.data.order);
  69. },
  70. async getOrder() {
  71. console.log(this.data.schema,this.data.id);
  72. let Order = new Parse.Query(this.data.schema || 'ShopOrder')
  73. Order.include('shopStore')
  74. let parseOrder = await Order.get(this.data.id)
  75. console.log(parseOrder);
  76. if(parseOrder && parseOrder.id){
  77. let order = parseOrder.toJSON()
  78. this.setData({
  79. parseOrder,
  80. order
  81. })
  82. }
  83. console.log(this.data.order);
  84. },
  85. async submit(){
  86. if(this.data.causeVal.trim() == '' ){
  87. wx.showToast({
  88. title: '请选择退款原因',
  89. icon: 'none'
  90. })
  91. return
  92. }
  93. let parseOrder = this.data.parseOrder;
  94. parseOrder.fetch().then((res) =>{
  95. console.log(res);
  96. parseOrder.set("status", 500);
  97. parseOrder.set("refundCause", this.data.causeVal);
  98. parseOrder.set("refundExplain", this.data.explain);
  99. parseOrder.save();
  100. wx.showToast({
  101. title: '提交成功',
  102. icon: 'none'
  103. })
  104. setTimeout(() => {
  105. wx.navigateBack({
  106. delta: 1,
  107. })
  108. }, 1000);
  109. },err =>{
  110. console.log(err);
  111. })
  112. },
  113. showPopup() {
  114. this.setData({ show: true });
  115. },
  116. onClose() {
  117. this.setData({ show: false });
  118. },
  119. causeChange(event){
  120. console.log(event);
  121. this.setData({ causeVal: event.detail.value });
  122. },
  123. /**
  124. * 生命周期函数--监听页面初次渲染完成
  125. */
  126. onReady: function () {
  127. },
  128. /**
  129. * 生命周期函数--监听页面显示
  130. */
  131. onShow: function () {
  132. },
  133. /**
  134. * 生命周期函数--监听页面隐藏
  135. */
  136. onHide: function () {
  137. },
  138. /**
  139. * 生命周期函数--监听页面卸载
  140. */
  141. onUnload: function () {
  142. },
  143. /**
  144. * 页面相关事件处理函数--监听用户下拉动作
  145. */
  146. onPullDownRefresh: function () {
  147. },
  148. /**
  149. * 页面上拉触底事件的处理函数
  150. */
  151. onReachBottom: function () {
  152. },
  153. /**
  154. * 用户点击右上角分享
  155. */
  156. onShareAppMessage: function () {
  157. }
  158. })