applyRefund.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. isRefusedLogin: wx.getStorageSync('isRefusedLogin')
  41. }, 'POST').then(function (res) {
  42. if (res.errno === 0) {
  43. wx.setStorageSync('storeId', wx.getStorageSync('storeId'));
  44. wx.setStorageSync('merchSn', wx.getStorageSync('merchSn'));
  45. }
  46. });
  47. util.request(api.OrderDetail, {
  48. orderId: that.data.orderId
  49. }).then(function (res) {
  50. if (res.errno === 0) {
  51. that.setData({
  52. orderGoods: res.data.orderGoods
  53. });
  54. }
  55. });
  56. }
  57. }
  58. },
  59. /**
  60. * 生命周期函数--监听页面隐藏
  61. */
  62. onHide: function () {
  63. },
  64. /**
  65. * 生命周期函数--监听页面卸载
  66. */
  67. onUnload: function () {
  68. },
  69. /**
  70. * 页面相关事件处理函数--监听用户下拉动作
  71. */
  72. onPullDownRefresh: function () {
  73. },
  74. /**
  75. * 页面上拉触底事件的处理函数
  76. */
  77. onReachBottom: function () {
  78. },
  79. // /**
  80. // * 用户点击右上角分享
  81. // */
  82. // onShareAppMessage: function () {
  83. // },
  84. saveApplyRefund: function (e) {
  85. if (!e.detail.value.refundReason) {
  86. util.showErrorToast('退款原因不能为空');
  87. return false;
  88. }
  89. let that = this; console.log(that.data.merchOrderSn);
  90. util.request(api.saveApplyRefund, {
  91. refundReason: e.detail.value.refundReason,
  92. orderId: that.data.orderId,
  93. merchOrderSn: that.data.merchOrderSn
  94. }, 'POST').then(function (res) {
  95. if (res.errno === 0) {
  96. //成功提示
  97. wx.showModal({
  98. title: '',
  99. content: res.errmsg,
  100. showCancel: false,
  101. success: function (res) {
  102. if (res.confirm) {
  103. wx.navigateBack()
  104. }
  105. }
  106. });
  107. } else {
  108. wx.showModal({
  109. title: '',
  110. content: res.errmsg,
  111. showCancel: false
  112. });
  113. }
  114. });
  115. },
  116. })