payResult.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. var util = require('../../../utils/jmsUtil.js');
  2. var mall = require('../../../api/mall.js');
  3. var app = getApp();
  4. Page({
  5. data: {
  6. imgUrl:'',
  7. type:'',
  8. status: false,
  9. orderId: 0,
  10. payAmount:''
  11. },
  12. onLoad: function(options) {
  13. // 页面初始化 options为页面跳转所带来的参数
  14. this.setData({
  15. orderId: options.orderId,
  16. payAmount:options.actualPrice,
  17. // type:app.globalData.infoGoods.type,
  18. // status: options.status === '1' ? true : false,
  19. // imgUrl:app.globalData.infoGoods.type=='2'?'https://jzmall.lifejingzhi.com/file/jzmall/weixin/new/icon-jpjzs.png':app.globalData.infoGoods.picUrl
  20. })
  21. },
  22. goIndex(){
  23. wx.switchTab({
  24. url: '/pages/index/index',
  25. })
  26. },
  27. goOrder(){
  28. wx.redirectTo({
  29. url: '/pages/mall/order/order',
  30. })
  31. },
  32. onReady: function() {
  33. },
  34. onShow: function() {
  35. // 页面显示
  36. },
  37. onHide: function() {
  38. // 页面隐藏
  39. },
  40. onUnload: function() {
  41. // 页面关闭
  42. },
  43. payOrder() {
  44. let that = this;
  45. util.request(mall.OrderPrepay, {
  46. orderId: that.data.orderId
  47. }, 'POST').then(function(res) {
  48. if (res.errno === 0) {
  49. const payParam = res.data;
  50. console.log("支付过程开始")
  51. wx.requestPayment({
  52. 'timeStamp': payParam.timeStamp,
  53. 'nonceStr': payParam.nonceStr,
  54. 'package': payParam.packageValue,
  55. 'signType': payParam.signType,
  56. 'paySign': payParam.paySign,
  57. 'success': function(res) {
  58. console.log("支付过程成功")
  59. that.setData({
  60. status: true
  61. });
  62. },
  63. 'fail': function(res) {
  64. console.log("支付过程失败")
  65. util.showErrorToast('支付失败');
  66. },
  67. 'complete': function(res) {
  68. console.log("支付过程结束")
  69. }
  70. });
  71. }
  72. });
  73. }
  74. })