orderMethod.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import {
  2. apiOrderPay,
  3. apiOrderClose,
  4. apiOrderTakedelivery,
  5. apiMemberVirtualTakeDelivery
  6. } from "@/api/order/order"
  7. export default {
  8. methods: {
  9. /**
  10. * 订单支付
  11. * @param {Object} out_trade_no
  12. */
  13. orderPay(orderData) {
  14. if (orderData.adjust_money == 0) {
  15. apiOrderPay({
  16. order_ids: orderData.order_id
  17. }).then(res => {
  18. if (res.code >= 0) {
  19. this.$router.push({
  20. path: "/pay",
  21. query: {
  22. code: res.data
  23. }
  24. })
  25. } else {
  26. this.$message({
  27. message: res.message,
  28. type: "warning"
  29. })
  30. }
  31. })
  32. } else {
  33. this.$confirm("商家已将支付金额调整为" + orderData.pay_money + "元,是否继续支付?", "提示", {
  34. confirmButtonText: "确定",
  35. cancelButtonText: "取消",
  36. type: "warning"
  37. }).then(() => {
  38. apiOrderPay({
  39. order_ids: orderData.order_id
  40. }).then(res => {
  41. if (res.code >= 0) {
  42. this.$router.push({
  43. path: "/pay",
  44. query: {
  45. code: res.data
  46. }
  47. })
  48. } else {
  49. this.$message({
  50. message: res.message,
  51. type: "warning"
  52. })
  53. }
  54. })
  55. })
  56. }
  57. },
  58. /**
  59. * 关闭订单
  60. * @param {Object} order_id
  61. */
  62. orderClose(order_id, callback) {
  63. this.$confirm("您确定要关闭该订单吗?", "提示", {
  64. confirmButtonText: "确定",
  65. cancelButtonText: "取消",
  66. type: "warning"
  67. }).then(() => {
  68. apiOrderClose({
  69. order_id
  70. }).then(res => {
  71. this.$message({
  72. message: "订单关闭成功",
  73. type: "success"
  74. })
  75. typeof callback == "function" && callback()
  76. })
  77. })
  78. },
  79. /**
  80. * 订单收货
  81. * @param {Object} order_id
  82. */
  83. orderDelivery(order_id, callback) {
  84. this.$confirm("您确定已经收到货物了吗?", "提示", {
  85. confirmButtonText: "确定",
  86. cancelButtonText: "取消",
  87. type: "warning"
  88. }).then(() => {
  89. apiOrderTakedelivery({
  90. order_id
  91. }).then(res => {
  92. this.$message({
  93. message: "订单收货成功",
  94. type: "success"
  95. })
  96. typeof callback == "function" && callback()
  97. })
  98. .catch(res => {
  99. this.$message({
  100. message: res.message,
  101. type: "warning"
  102. })
  103. typeof callback == "function" && callback()
  104. })
  105. })
  106. },
  107. /**
  108. * 订单虚拟商品收货
  109. * @param {Object} order_id
  110. * @param {Object} callback
  111. */
  112. orderVirtualDelivery(order_id, callback) {
  113. this.$confirm("您确定要进行收货吗?", "提示", {
  114. confirmButtonText: "确定",
  115. cancelButtonText: "取消",
  116. type: "warning"
  117. }).then(() => {
  118. apiMemberVirtualTakeDelivery({
  119. order_id
  120. }).then(res => {
  121. this.$message({
  122. message: "订单收货成功",
  123. type: "success"
  124. })
  125. typeof callback == "function" && callback()
  126. })
  127. })
  128. },
  129. }
  130. }