index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. orderId: '',
  10. address: null,
  11. goods: null,
  12. shipper: null,
  13. trackingNumber: null,
  14. order: null,
  15. companyInfo: null
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function(options) {
  21. let orderId = options.id
  22. console.log(orderId);
  23. this.setData({
  24. orderId: orderId
  25. })
  26. this.queryOrder(orderId)
  27. },
  28. async queryOrder(id) {
  29. let ShopOrder = new Parse.Query('Order')
  30. ShopOrder.include('goods')
  31. ShopOrder.include('address')
  32. let shopOrder = await ShopOrder.get(id)
  33. if (shopOrder && shopOrder.id) {
  34. let order = shopOrder.toJSON()
  35. order.orderTime = dateF.formatTime("YYYY-mm-dd HH:MM:SS", order.createdAt)
  36. this.setData({
  37. order: order,
  38. goods: order.goods,
  39. address: order.address,
  40. shipper: order.shipper,
  41. trackingNumber: order.trackingNumber
  42. })
  43. console.log(this.data.order);
  44. }
  45. },
  46. async getCompany() {
  47. let Company = new Parse.Query('Company')
  48. let companyInfo = await Company.get(company)
  49. if (companyInfo) {
  50. this.setData({
  51. companyInfo: companyInfo.toJSON()
  52. })
  53. }
  54. console.log(this.data.companyInfo);
  55. },
  56. //更换地址
  57. toAddress() {
  58. let { order } = this.data
  59. if (order.status != 200) {
  60. wx.showToast({
  61. title: '已发货物件不支持更换地址',
  62. icon: 'none',
  63. image: '',
  64. duration: 1500,
  65. mask: false,
  66. });
  67. return
  68. }
  69. wx.navigateTo({
  70. url: "/common-page/pages/address/index?type=1"
  71. })
  72. },
  73. async refund() {
  74. let that = this
  75. wx.showModal({
  76. title: '',
  77. content: '你确定要申请退款吗?',
  78. showCancel: true,
  79. cancelText: '取消',
  80. cancelColor: '#000000',
  81. confirmText: '确定',
  82. confirmColor: '#3CC51F',
  83. success: (result) => {
  84. if (result.confirm) {
  85. that.upRefund()
  86. }
  87. },
  88. fail: () => {},
  89. complete: () => {}
  90. });
  91. },
  92. async upRefund() {
  93. let { order } = this.data
  94. let ShopOrder = new Parse.Query("Order")
  95. let res = await ShopOrder.get(order.objectId)
  96. if (res && res.id) {
  97. res.set("status", '500')
  98. await res.save()
  99. wx.showToast({
  100. title: '已申请退款',
  101. icon: 'none',
  102. image: '',
  103. duration: 1500,
  104. mask: false,
  105. });
  106. order.status = '500'
  107. this.setData({
  108. order
  109. })
  110. }
  111. },
  112. /**
  113. * 生命周期函数--监听页面初次渲染完成
  114. */
  115. onReady: function() {
  116. this.getCompany()
  117. },
  118. /**
  119. * 生命周期函数--监听页面显示
  120. */
  121. onShow: function() {
  122. },
  123. /**
  124. * 生命周期函数--监听页面隐藏
  125. */
  126. onHide: function() {
  127. },
  128. /**
  129. * 生命周期函数--监听页面卸载
  130. */
  131. onUnload: function() {
  132. },
  133. /**
  134. * 页面相关事件处理函数--监听用户下拉动作
  135. */
  136. onPullDownRefresh: function() {
  137. },
  138. /**
  139. * 页面上拉触底事件的处理函数
  140. */
  141. onReachBottom: function() {
  142. },
  143. /**
  144. * 用户点击右上角分享
  145. */
  146. onShareAppMessage: function() {
  147. }
  148. })