index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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({ price: this.properties.orderInfo.pay_price ? this.properties.orderInfo.pay_price : ''});
  31. },
  32. methods: {
  33. /**
  34. * 事件回调
  35. */
  36. bindHideKeyboard: function (e) {
  37. this.setData({ remark: e.detail.value });
  38. },
  39. /**
  40. * 实际支付
  41. */
  42. bindPrice: function (e) {
  43. this.setData({ price: e.detail.value });
  44. },
  45. /**
  46. * 退款金额
  47. */
  48. bindRefundPrice: function(e) {
  49. this.setData({ refund_price: e.detail.value });
  50. },
  51. /**
  52. * 提交
  53. */
  54. save: function (e) {
  55. let type = e.currentTarget.dataset.type;
  56. this.savePrice(type);
  57. },
  58. /**
  59. * 拒绝退款
  60. */
  61. refuse: function (e) {
  62. let type = e.currentTarget.dataset.type;
  63. this.savePrice(type);
  64. },
  65. /**
  66. * 事件回调
  67. *
  68. */
  69. savePrice: function (type) {
  70. let that = this,
  71. data = {},
  72. price = this.data.price,
  73. remark = this.data.remark,
  74. refund_price = this.data.refund_price;
  75. data.order_id = that.data.orderInfo.order_id;
  76. if (that.data.status == 0 && that.data.orderInfo.refund_status === 0) {
  77. if (!that.data.price) return app.Tips({ title: '请输入价格' });
  78. data.price = price;
  79. // 订单改价
  80. setAdminOrderPrice(data).then(
  81. function () {
  82. that.close();
  83. app.Tips({ title: '改价成功' });
  84. that.triggerEvent('getIndex');
  85. },
  86. function () {
  87. that.close();
  88. app.Tips({ title: '改价失败' });
  89. }
  90. );
  91. } else if (that.data.status == 0 && that.data.orderInfo.refund_status == 1) {
  92. if (type === '1' && !refund_price) return app.Tips({ title: '请输入退款金额' });
  93. data.price = refund_price;
  94. data.type = type;
  95. // 确认退款 拒绝退款
  96. setOrderRefund(data).then(
  97. res => {
  98. that.close();
  99. app.Tips({ title: res.msg });
  100. that.triggerEvent('getIndex');
  101. },
  102. err => {
  103. that.close();
  104. app.Tips({ title: err });
  105. }
  106. );
  107. } else {
  108. if(!this.data.remark) return app.Tips({ title: '请输入订单备注' });
  109. data.remark = remark;
  110. // 订单备注
  111. setAdminOrderRemark(data).then(
  112. res => {
  113. that.close();
  114. that.setData({ remark: '' });
  115. that.triggerEvent('getIndex');
  116. app.Tips({ title: res.msg });
  117. },
  118. err => {
  119. that.close();
  120. app.Tips({ title: err });
  121. }
  122. );
  123. }
  124. },
  125. close:function(){
  126. this.triggerEvent('onChangeFun',{action:'change'});
  127. }
  128. }
  129. })