index.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. import {
  2. getAdminOrderList,
  3. setAdminOrderPrice,
  4. setAdminOrderRemark,
  5. setOfflinePay,
  6. setOrderRefund
  7. } from "../../api/admin";
  8. const app = getApp();
  9. Component({
  10. properties: {
  11. orderInfo: {
  12. type: Object,
  13. value: null,
  14. },
  15. change: {
  16. type: Boolean,
  17. value: false,
  18. },
  19. status: {
  20. type: Number,
  21. value: 0
  22. }
  23. },
  24. data: {
  25. remark: '', //备注信息
  26. price: '', //实际支付
  27. refund_price: '' //退款金额
  28. },
  29. attached: function () {
  30. this.setData({
  31. price: this.properties.orderInfo.pay_price ? this.properties.orderInfo.pay_price : ''
  32. });
  33. },
  34. methods: {
  35. /**
  36. * 事件回调
  37. */
  38. bindHideKeyboard: function (e) {
  39. this.setData({
  40. remark: e.detail.value
  41. });
  42. },
  43. /**
  44. * 实际支付
  45. */
  46. bindPrice: function (e) {
  47. this.setData({
  48. price: e.detail.value
  49. });
  50. },
  51. /**
  52. * 退款金额
  53. */
  54. bindRefundPrice: function (e) {
  55. this.setData({
  56. refund_price: e.detail.value
  57. });
  58. },
  59. /**
  60. * 提交
  61. */
  62. save: function (e) {
  63. let type = e.currentTarget.dataset.type;
  64. this.savePrice(type);
  65. },
  66. /**
  67. * 拒绝退款
  68. */
  69. refuse: function (e) {
  70. let type = e.currentTarget.dataset.type;
  71. this.savePrice(type);
  72. },
  73. /**
  74. * 事件回调
  75. */
  76. savePrice: function (type) {
  77. let that = this,
  78. data = {},
  79. price = this.data.price,
  80. remark = this.data.remark,
  81. refund_price = this.data.refund_price;
  82. data.order_id = that.data.orderInfo.order_id;
  83. if (that.data.status == 0 && that.data.orderInfo.refund_status === 0) {
  84. if (!that.data.price) return app.Tips({
  85. title: '请输入价格'
  86. });
  87. data.price = price;
  88. // 订单改价
  89. setAdminOrderPrice(data).then(
  90. function () {
  91. that.close();
  92. app.Tips({
  93. title: '改价成功'
  94. });
  95. that.triggerEvent('getIndex');
  96. },
  97. function () {
  98. that.close();
  99. app.Tips({
  100. title: '改价失败'
  101. });
  102. }
  103. );
  104. } else if (that.data.status == 0 && that.data.orderInfo.refund_status == 1) {
  105. if (type === '1' && !refund_price) return app.Tips({
  106. title: '请输入退款金额'
  107. });
  108. data.price = refund_price;
  109. data.type = type;
  110. // 确认退款 拒绝退款
  111. setOrderRefund(data).then(
  112. res => {
  113. that.close();
  114. app.Tips({
  115. title: res.msg
  116. });
  117. that.triggerEvent('getIndex');
  118. },
  119. err => {
  120. that.close();
  121. app.Tips({
  122. title: err
  123. });
  124. }
  125. );
  126. } else {
  127. if (!this.data.remark) return app.Tips({
  128. title: '请输入订单备注'
  129. });
  130. data.remark = remark;
  131. // 订单备注
  132. setAdminOrderRemark(data).then(
  133. res => {
  134. that.close();
  135. that.setData({
  136. remark: ''
  137. });
  138. that.triggerEvent('getIndex');
  139. app.Tips({
  140. title: res.msg
  141. });
  142. },
  143. err => {
  144. that.close();
  145. app.Tips({
  146. title: err
  147. });
  148. }
  149. );
  150. }
  151. },
  152. close: function () {
  153. this.triggerEvent('onChangeFun', {
  154. action: 'change'
  155. });
  156. }
  157. }
  158. })