index.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import { getOrderDetail } from '../../api/order.js'
  2. import { openOrderSubscribe } from '../../utils/SubscribeMessage.js'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. parameter: {
  10. navbar: '1',
  11. return: '0',
  12. title: '支付成功'
  13. },
  14. orderId: '',
  15. order_pay_info: {
  16. paid: 0
  17. }
  18. },
  19. onLoadFun: function () {
  20. this.getOrderPayInfo()
  21. },
  22. /**
  23. * 生命周期函数--监听页面加载
  24. */
  25. onLoad: function (options) {
  26. if (!options.order_id)
  27. return app.Tips(
  28. {
  29. title: '缺少参数无法查看订单支付状态'
  30. },
  31. {
  32. tab: 3,
  33. url: 1
  34. }
  35. )
  36. this.setData({
  37. orderId: options.order_id,
  38. status: options.status || 0,
  39. msg: options.msg || ''
  40. })
  41. },
  42. /**
  43. * 支付完成查询支付状态
  44. */
  45. getOrderPayInfo: function () {
  46. var that = this
  47. wx.showLoading({
  48. title: '正在加载中'
  49. })
  50. getOrderDetail(this.data.orderId)
  51. .then(res => {
  52. wx.hideLoading()
  53. that.setData({
  54. order_pay_info: res.data,
  55. 'parameter.title': res.data.paid ? '支付成功' : '支付失败'
  56. })
  57. })
  58. .catch(err => {
  59. wx.hideLoading()
  60. })
  61. },
  62. /**
  63. * 去首页关闭当前所有页面
  64. */
  65. goIndex: function (e) {
  66. wx.switchTab({
  67. url: '/pages/index/index'
  68. })
  69. },
  70. /**
  71. * 去订单详情页面
  72. */
  73. goOrderDetails: function (e) {
  74. let that = this
  75. wx.showLoading({
  76. title: '正在加载'
  77. })
  78. openOrderSubscribe()
  79. .then(res => {
  80. wx.hideLoading()
  81. wx.navigateTo({
  82. url: '/pages/order_list/index'
  83. })
  84. })
  85. .catch(() => {
  86. wx.hideLoading()
  87. })
  88. }
  89. })