index.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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: { paid :1 }
  16. },
  17. onLoadFun:function(){
  18. this.getOrderPayInfo();
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. if (!options.order_id) return app.Tips({title:'缺少参数无法查看订单支付状态'},{tab:3,url:1});
  25. this.setData({ orderId: options.order_id, status: options.status || 0, msg: options.msg || ''});
  26. },
  27. /**
  28. *
  29. * 支付完成查询支付状态
  30. *
  31. */
  32. getOrderPayInfo:function(){
  33. var that=this;
  34. wx.showLoading({title: '正在加载中'});
  35. getOrderDetail(this.data.orderId).then(res=>{
  36. wx.hideLoading();
  37. that.setData({ order_pay_info: res.data, 'parameter.title': res.data.paid ? '支付成功' : '支付失败' });
  38. }).catch(err=>{
  39. wx.hideLoading();
  40. });
  41. },
  42. /**
  43. * 去首页关闭当前所有页面
  44. */
  45. goIndex:function(e){
  46. wx.switchTab({url:'/pages/index/index'});
  47. },
  48. /**
  49. *
  50. * 去订单详情页面
  51. */
  52. goOrderDetails:function(e)
  53. {
  54. let that = this;
  55. wx.showLoading({
  56. title: '正在加载',
  57. })
  58. openOrderSubscribe().then(res => {
  59. wx.hideLoading();
  60. wx.navigateTo({
  61. url: '/pages/order_details/index?order_id=' + that.data.orderId
  62. });
  63. }).catch(() => {
  64. wx.hideLoading();
  65. });
  66. }
  67. })