diffOrderDetail.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. const app = getApp()
  2. const util = require("../../utils/util");
  3. const api = require('../../config/api.js');
  4. Page({
  5. data: {
  6. difNo:'',
  7. orderDiff:{},
  8. diffItemList:[],
  9. },
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad: function (options) {
  14. console.log(options);
  15. if(options.difNo){
  16. this.setData({
  17. difNo:options.difNo
  18. });
  19. }
  20. if(options.scene){
  21. let scene = decodeURIComponent(options.scene);
  22. let difNo=scene.split("=")[1];
  23. this.setData({
  24. difNo:difNo
  25. });
  26. }
  27. },
  28. getDiffOrderDetail(){
  29. wx.showLoading({
  30. title: '加载中...',
  31. });
  32. util.request(api.getDiffDetail, {
  33. diffOrderNo:this.data.difNo
  34. }, 'GET').then(res => {
  35. wx.hideLoading();
  36. if (res.errno === 0) {
  37. this.setData({
  38. orderDiff:res.data.orderDiff,
  39. diffItemList:res.data.diffItemList
  40. });
  41. }else{
  42. wx.showToast({
  43. title: res.errmsg,
  44. icon: 'none',
  45. duration:3000,
  46. mask:true,
  47. });
  48. }
  49. }).catch(err => {
  50. wx.hideLoading();
  51. });
  52. },
  53. /**
  54. * 生命周期函数--监听页面初次渲染完成
  55. */
  56. onReady: function () {
  57. },
  58. goPay(){
  59. let that=this;
  60. wx.showLoading({
  61. title: '加载中'
  62. });
  63. util.request(api.prepayDiff, {
  64. diffOrderNo: this.data.difNo
  65. }).then(res=> {
  66. wx.hideLoading();
  67. if (res.errno === 0) {
  68. let payParam=res.data;
  69. wx.requestPayment({
  70. 'timeStamp': payParam.timeStamp,
  71. 'nonceStr': payParam.nonceStr,
  72. 'package': payParam.packageValue,
  73. 'signType': payParam.signType,
  74. 'paySign': payParam.paySign,
  75. success: function(res) {
  76. console.log("支付过程成功");
  77. wx.showToast({
  78. title: '支付成功',
  79. duration:3000,
  80. mask:true,
  81. });
  82. setTimeout(()=>{
  83. that.getDiffOrderDetail();
  84. },4000);
  85. },
  86. fail: function(res) {
  87. console.log("支付过程失败");
  88. util.showErrorToast('支付失败');
  89. },
  90. complete: function(res) {
  91. console.log("支付过程结束")
  92. }
  93. });
  94. }
  95. }).catch(err=> {
  96. console.log(err);
  97. wx.hideLoading();
  98. });
  99. },
  100. /**
  101. * 生命周期函数--监听页面显示
  102. */
  103. onShow: function () {
  104. this.getDiffOrderDetail();
  105. },
  106. onHide: function () {
  107. },
  108. onUnload: function () {
  109. },
  110. /**
  111. * 页面相关事件处理函数--监听用户下拉动作
  112. */
  113. onPullDownRefresh: function () {
  114. wx.showNavigationBarLoading(); //在标题栏中显示加载
  115. this.getDiffOrderDetail();
  116. wx.hideNavigationBarLoading(); //完成停止加载
  117. wx.stopPullDownRefresh(); //停止下拉刷新
  118. },
  119. /**
  120. * 页面上拉触底事件的处理函数
  121. */
  122. onReachBottom: function () {
  123. },
  124. /**
  125. * 用户点击右上角分享
  126. */
  127. onShareAppMessage: function () {
  128. },
  129. })