index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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)
  85. return app.Tips({
  86. title: '请输入价格'
  87. })
  88. data.price = price
  89. // 订单改价
  90. setAdminOrderPrice(data).then(
  91. function () {
  92. that.close()
  93. app.Tips({
  94. title: '改价成功'
  95. })
  96. that.triggerEvent('getIndex')
  97. },
  98. function () {
  99. that.close()
  100. app.Tips({
  101. title: '改价失败'
  102. })
  103. }
  104. )
  105. } else if (that.data.status == 0 && that.data.orderInfo.refund_status == 1) {
  106. if (type === '1' && !refund_price)
  107. return app.Tips({
  108. title: '请输入退款金额'
  109. })
  110. data.price = refund_price
  111. data.type = type
  112. // 确认退款 拒绝退款
  113. setOrderRefund(data).then(
  114. res => {
  115. that.close()
  116. app.Tips({
  117. title: res.msg
  118. })
  119. that.triggerEvent('getIndex')
  120. },
  121. err => {
  122. that.close()
  123. app.Tips({
  124. title: err
  125. })
  126. }
  127. )
  128. } else {
  129. if (!this.data.remark)
  130. return app.Tips({
  131. title: '请输入订单备注'
  132. })
  133. data.remark = remark
  134. // 订单备注
  135. setAdminOrderRemark(data).then(
  136. res => {
  137. that.close()
  138. that.setData({
  139. remark: ''
  140. })
  141. that.triggerEvent('getIndex')
  142. app.Tips({
  143. title: res.msg
  144. })
  145. },
  146. err => {
  147. that.close()
  148. app.Tips({
  149. title: err
  150. })
  151. }
  152. )
  153. }
  154. },
  155. close: function () {
  156. this.triggerEvent('onChangeFun', {
  157. action: 'change'
  158. })
  159. }
  160. }
  161. })