applyRefund.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. refundMoney: '',
  9. orderGoods: [],
  10. orderId: '',
  11. merchOrderSn: ''
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. // 页面初始化 options为页面跳转所带来的参数
  18. this.setData({
  19. orderId: options.orderId,
  20. merchOrderSn: options.merchOrderSn,
  21. refundMoney: options.refundMoney
  22. });
  23. },
  24. /**
  25. * 生命周期函数--监听页面初次渲染完成
  26. */
  27. onReady: function () {
  28. },
  29. /**
  30. * 生命周期函数--监听页面显示
  31. */
  32. onShow: function () {
  33. let that = this;
  34. // 页面显示
  35. if (wx.getStorageSync('userInfo') || wx.getStorageSync('token')) {
  36. if (wx.getStorageSync('storeId')) {
  37. util.request(api.ChooseStoreId, {
  38. storeId: wx.getStorageSync('storeId'),
  39. merchSn: wx.getStorageSync('merchSn')
  40. }, 'POST').then(function (res) {
  41. if (res.errno === 0) {
  42. wx.setStorageSync('storeId', wx.getStorageSync('storeId'));
  43. wx.setStorageSync('merchSn', wx.getStorageSync('merchSn'));
  44. }
  45. });
  46. util.request(api.OrderDetail, {
  47. orderId: that.data.orderId
  48. }).then(function (res) {
  49. if (res.errno === 0) {
  50. that.setData({
  51. orderGoods: res.data.orderGoods
  52. });
  53. }
  54. });
  55. }
  56. }
  57. },
  58. /**
  59. * 生命周期函数--监听页面隐藏
  60. */
  61. onHide: function () {
  62. },
  63. /**
  64. * 生命周期函数--监听页面卸载
  65. */
  66. onUnload: function () {
  67. },
  68. /**
  69. * 页面相关事件处理函数--监听用户下拉动作
  70. */
  71. onPullDownRefresh: function () {
  72. },
  73. /**
  74. * 页面上拉触底事件的处理函数
  75. */
  76. onReachBottom: function () {
  77. },
  78. /**
  79. * 用户点击右上角分享
  80. */
  81. onShareAppMessage: function () {
  82. },
  83. saveApplyRefund: function (e) {
  84. if (!e.detail.value.refundReason) {
  85. util.showErrorToast('退款原因不能为空');
  86. return false;
  87. }
  88. let that = this; console.log(that.data.merchOrderSn);
  89. util.request(api.saveApplyRefund, {
  90. refundReason: e.detail.value.refundReason,
  91. orderId: that.data.orderId,
  92. merchOrderSn: that.data.merchOrderSn
  93. }, 'POST').then(function (res) {
  94. if (res.errno === 0) {
  95. //成功提示
  96. wx.showModal({
  97. title: '',
  98. content: res.errmsg,
  99. showCancel: false,
  100. success: function (res) {
  101. if (res.confirm) {
  102. wx.navigateBack()
  103. }
  104. }
  105. });
  106. } else {
  107. wx.showModal({
  108. title: '',
  109. content: res.errmsg,
  110. showCancel: false
  111. });
  112. }
  113. });
  114. },
  115. })