pay-result.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // pages/pay-result/pay-result.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. wx.navigateTo({
  21. url: '/pages/orderList/orderList?sts=0'
  22. })
  23. },
  24. toIndex: function () {
  25. wx.switchTab({
  26. url: '/pages/index/index'
  27. })
  28. },
  29. payAgain: function () {
  30. wx.showLoading({
  31. mask: true
  32. });
  33. var params = {
  34. url: "/p/order/pay",
  35. method: "POST",
  36. data: {
  37. payType: 1,
  38. orderNumbers: this.data.orderNumbers
  39. },
  40. callBack: function (res) {
  41. //console.log(res);
  42. wx.hideLoading();
  43. wx.requestPayment({
  44. timeStamp: res.timeStamp,
  45. nonceStr: res.nonceStr,
  46. package: res.packageValue,
  47. signType: res.signType,
  48. paySign: res.paySign,
  49. success: e => {
  50. //console.log("支付成功");
  51. wx.redirectTo({
  52. url: '/pages/pay-result/pay-result?sts=1&orderNum=' + orderNumbers + "&orderType=" + this.data.orderType,
  53. })
  54. },
  55. fail: err => {
  56. }
  57. })
  58. }
  59. };
  60. http.request(params);
  61. },
  62. /**
  63. * 生命周期函数--监听页面初次渲染完成
  64. */
  65. onReady: function () {
  66. },
  67. /**
  68. * 生命周期函数--监听页面显示
  69. */
  70. onShow: function () {
  71. },
  72. /**
  73. * 生命周期函数--监听页面隐藏
  74. */
  75. onHide: function () {
  76. },
  77. /**
  78. * 生命周期函数--监听页面卸载
  79. */
  80. onUnload: function () {
  81. },
  82. /**
  83. * 页面相关事件处理函数--监听用户下拉动作
  84. */
  85. onPullDownRefresh: function () {
  86. },
  87. /**
  88. * 页面上拉触底事件的处理函数
  89. */
  90. onReachBottom: function () {
  91. },
  92. /**
  93. * 用户点击右上角分享
  94. */
  95. onShareAppMessage: function () {
  96. }
  97. })