Copyrefund.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. const util = require('../../../utils/util.js');
  2. const app = getApp();
  3. Page({
  4. data: {
  5. reasonData: [],
  6. current: 1,
  7. imgPath: util.config.imgPath,
  8. datas: {},
  9. reason: '',
  10. mask: false,
  11. refundBack: '',
  12. refundpwd: '',
  13. orderid: '',
  14. status: '',
  15. groupId: ''
  16. },
  17. onLoad(options) {
  18. this.setData({
  19. refundpwd: options.refundpwd,
  20. orderid: options.orderid,
  21. status: options.refundStatus,
  22. groupId: options.groupid || ''
  23. });
  24. let reasonData = [],
  25. current = 1;
  26. if (this.data.status == 15) {
  27. current = 4;
  28. }
  29. this.setData({
  30. current
  31. })
  32. this.getData();
  33. },
  34. getData() {
  35. let that = this;
  36. util.ajax({
  37. func: "v2/order/detail",
  38. data: {
  39. "orderid": that.data.orderid,
  40. "otype": 0,
  41. "password": that.data.refundpwd || "",
  42. }
  43. }, function (res) {
  44. if (res.code == 0) {
  45. let reasonData = [];
  46. if (res.data.atype == '1') { //电商
  47. reasonData = [{
  48. type: 5,
  49. txt: '不喜欢/不想要'
  50. },
  51. {
  52. type: 6,
  53. txt: '质量问题'
  54. },
  55. {
  56. type: 0,
  57. txt: '其他原因'
  58. }
  59. ];
  60. } else {
  61. if (that.data.status == 15) {
  62. reasonData = [{
  63. type: 4,
  64. txt: '候补退款'
  65. }], current = 4;
  66. } else {
  67. reasonData = [{
  68. type: 1,
  69. txt: '行程有变'
  70. },
  71. {
  72. type: 2,
  73. txt: '买多了/买错了'
  74. },
  75. {
  76. type: 3,
  77. txt: '孩子突发身体原因'
  78. },
  79. {
  80. type: 0,
  81. txt: '其他原因'
  82. }
  83. ];
  84. }
  85. }
  86. that.setData({
  87. datas: res.data,
  88. reasonData,
  89. current: reasonData[0].type
  90. });
  91. }
  92. })
  93. },
  94. backBtn() {
  95. wx.redirectTo({
  96. url: '/pages/order/index/order?otype=2'
  97. })
  98. },
  99. confirm(e) {
  100. this.setData({
  101. reason: e.detail.value
  102. });
  103. },
  104. bindreason(e) {
  105. this.setData({
  106. current: e.currentTarget.dataset.type
  107. });
  108. },
  109. img() {
  110. this.data.datas.logo = '/images/noimg.png';
  111. this.setData({
  112. datas: this.data.datas
  113. });
  114. },
  115. refundRequest() {
  116. console.log(this.data.orderInfo);
  117. let that = this,
  118. reason = this.data.reason,
  119. current = this.data.current;
  120. if (current == 0 && reason == '') {
  121. util.showTips('请输入退款原因。');
  122. return false;
  123. }
  124. util.ajax({
  125. func: "order/commit_refund",
  126. data: {
  127. "reasonType": current,
  128. "reason": reason,
  129. "orderid": that.data.orderid,
  130. "password": that.data.refundpwd || "",
  131. "type": '0',
  132. },
  133. method: 'POST',
  134. }, function (res) {
  135. if (res.code == 0) {
  136. wx.setStorageSync('_REFUND_', 'REFUND');
  137. that.setData({
  138. refundBack: res.reason,
  139. mask: true
  140. })
  141. } else {
  142. let pages = getCurrentPages();
  143. wx.showModal({
  144. title: '提交失败',
  145. content: res.reason,
  146. showCancel: false,
  147. success: function (res) {
  148. if (res.confirm) {
  149. wx.navigateBack({
  150. detail: 2
  151. });
  152. }
  153. }
  154. });
  155. }
  156. });
  157. }
  158. })