payResult.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. var app = getApp();
  4. Page({
  5. data: {
  6. imgUrl: '',
  7. type: '',
  8. status: false,
  9. orderId: 0,
  10. payAmount: '',
  11. appointShow: false
  12. },
  13. onLoad: function (options) {
  14. // 页面初始化 options为页面跳转所带来的参数
  15. this.setData({
  16. orderId: options.orderId,
  17. payAmount: options.actualPrice,
  18. type: app.globalData.infoGoods.type,
  19. // status: options.status === '1' ? true : false,
  20. imgUrl: app.globalData.infoGoods.type == '2' ? 'https://jzmall.lifejingzhi.com/file/jzmall/weixin/new/icon-jpjzs.png' : app.globalData.infoGoods.picUrl
  21. });
  22. var appType = wx.getStorageSync('appType');
  23. if (appType == 0 && (this.data.type == 0||this.data.type == 3)) {
  24. this.setData({
  25. appointShow: true
  26. });
  27. }
  28. },
  29. goIndex() {
  30. wx.switchTab({
  31. url: '/pages/index/index',
  32. })
  33. },
  34. goOrder() {
  35. wx.redirectTo({
  36. url: '/pages/ucenter/order/order',
  37. })
  38. },
  39. onReady: function () {
  40. },
  41. onShow: function () {
  42. // 页面显示
  43. },
  44. onHide: function () {
  45. // 页面隐藏
  46. },
  47. onUnload: function () {
  48. // 页面关闭
  49. },
  50. payOrder() {
  51. let that = this;
  52. util.request(api.OrderPrepay, {
  53. orderId: that.data.orderId
  54. }, 'POST').then(function (res) {
  55. if (res.errno === 0) {
  56. const payParam = res.data;
  57. console.log("支付过程开始")
  58. wx.requestPayment({
  59. 'timeStamp': payParam.timeStamp,
  60. 'nonceStr': payParam.nonceStr,
  61. 'package': payParam.packageValue,
  62. 'signType': payParam.signType,
  63. 'paySign': payParam.paySign,
  64. 'success': function (res) {
  65. console.log("支付过程成功")
  66. that.setData({
  67. status: true
  68. });
  69. },
  70. 'fail': function (res) {
  71. console.log("支付过程失败")
  72. util.showErrorToast('支付失败');
  73. },
  74. 'complete': function (res) {
  75. console.log("支付过程结束")
  76. }
  77. });
  78. }
  79. });
  80. },
  81. onClickHide() {
  82. this.setData({
  83. appointShow: false
  84. });
  85. },
  86. appointClick() {
  87. // this.setData({
  88. // appointShow:false
  89. // });
  90. },
  91. goAppoint() {
  92. this.setData({
  93. appointShow: false
  94. });
  95. wx.navigateTo({
  96. url: '/pages/ucenter/appointOrder/appointOrder?orderId=' + this.data.orderId
  97. })
  98. // wx.navigateTo({
  99. // url: '/pages/ucenter/serviceDetail/serviceDetail?orderId=' + this.data.orderId
  100. // })
  101. // wx.navigateTo({
  102. // url: '/pages/checkout/appointResult/appointResult?id='+this.data.orderId,
  103. // })
  104. }
  105. })