pay-result.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. var http = require('../../utils/http.js');
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. sts: 0,
  8. orderNumbers: ''
  9. },
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad: function (options) {
  14. this.setData({
  15. sts: options.sts,
  16. orderNumbers: options.orderNumbers
  17. });
  18. },
  19. toOrderList: function () {
  20. const pages = getCurrentPages()
  21. let deltaNum = 0
  22. pages.forEach((page, pageIndex) => {
  23. if (page.route == 'pages/orderList/orderList') {
  24. deltaNum = pages.length - pageIndex
  25. }
  26. })
  27. wx.redirectTo({
  28. // url: '/pages/orderList/orderList?sts=' + (this.data.sts == 0 ? '1' : '2')
  29. url: '/pages/orderList/orderList?sts=' + (this.data.sts == 0 ? '1' : '3')//成功跳转待收货
  30. })
  31. },
  32. toIndex: function () {
  33. wx.switchTab({
  34. url: '/pages/index/index'
  35. })
  36. },
  37. payAgain: function () {
  38. wx.showLoading({
  39. mask: true
  40. });
  41. var params = {
  42. url: "/p/order/pay",
  43. method: "POST",
  44. data: {
  45. payType: 1,
  46. orderNumbers: this.data.orderNumbers
  47. },
  48. callBack: (res) => {
  49. //console.log(res);
  50. wx.hideLoading();
  51. wx.requestPayment({
  52. timeStamp: res.timeStamp,
  53. nonceStr: res.nonceStr,
  54. package: res.package,
  55. signType: res.signType,
  56. paySign: res.paySign,
  57. success: e => {
  58. //console.log("支付成功");
  59. this.setData({
  60. sts : 1
  61. })
  62. wx.redirectTo({
  63. url: '/pages/pay-result/pay-result?sts=' + this.data.sts + '&orderNum=' + orderNumbers + "&orderType=" + this.data.orderType,
  64. })
  65. },
  66. fail: err => {
  67. }
  68. })
  69. }
  70. };
  71. http.request(params);
  72. },
  73. /**
  74. * 生命周期函数--监听页面初次渲染完成
  75. */
  76. onReady: function () {
  77. },
  78. /**
  79. * 生命周期函数--监听页面显示
  80. */
  81. onShow: function () {
  82. },
  83. /**
  84. * 生命周期函数--监听页面隐藏
  85. */
  86. onHide: function () {
  87. },
  88. /**
  89. * 生命周期函数--监听页面卸载
  90. */
  91. onUnload: function () {
  92. },
  93. /**
  94. * 页面相关事件处理函数--监听用户下拉动作
  95. */
  96. onPullDownRefresh: function () {
  97. },
  98. /**
  99. * 页面上拉触底事件的处理函数
  100. */
  101. onReachBottom: function () {
  102. },
  103. /**
  104. * 用户点击右上角分享
  105. */
  106. onShareAppMessage: function () {
  107. }
  108. })