index.js 2.0 KB

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