Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

cancel-order.vue 2.8KB

2 år sedan
1 år sedan
2 år sedan
1 år sedan
2 år sedan
1 år sedan
2 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <!-- 取消订单 -->
  2. <template>
  3. <view class="form">
  4. <form-builder
  5. :formData="state.formData"
  6. :config="config"
  7. @submit="doCancelOrder"
  8. />
  9. </view>
  10. </template>
  11. <script setup lang="ts">
  12. import { reactive } from "vue";
  13. import { onLoad } from "@dcloudio/uni-app";
  14. import { request } from "@/utils/network/request.js";
  15. import { msg, confirm, getOrderStatusName } from "@/utils/utils";
  16. import { cancelOrder,cancelOrderNew } from "@/utils/network/api";
  17. import { getItem, StorageKeys } from "@/utils/storage";
  18. const config = {
  19. submitName: "取消订单", //按钮名称(默认提交)
  20. titleWidth: 160, //标题最小宽度
  21. };
  22. const state = reactive({
  23. orderInfo: {} as any, //订单数据
  24. formData: [
  25. {
  26. title: "订单编号",
  27. inputType: "number",
  28. type: 2,
  29. value: "orderNumber",
  30. bg: true,
  31. hint: "订单编号",
  32. disabled: true,
  33. },
  34. {
  35. title: "订单车牌号",
  36. type: 2,
  37. value: "carNumber",
  38. bg: true,
  39. hint: "订单车牌号",
  40. disabled: true,
  41. },
  42. {
  43. title: "订单状态",
  44. type: 2,
  45. value: "orderStatus",
  46. bg: true,
  47. hint: "订单状态",
  48. disabled: true,
  49. },
  50. {
  51. title: "请输入取消原因",
  52. required: true,
  53. type: 5,
  54. vertical: 2,
  55. value: "orderReason",
  56. maxlength: 100,
  57. bg: true,
  58. hint: "限制100字符以内",
  59. emptyHint: "请输入取消的原因",
  60. },
  61. ],
  62. });
  63. //取消订单
  64. const doCancelOrder = (e: any) => {
  65. confirm(
  66. "是否确认取消订单",
  67. () => {
  68. const options = {
  69. type: 2,
  70. data: {
  71. id: state.orderInfo.id,
  72. source: "WECHAT",
  73. reason: e.orderReason,
  74. opId: getItem(StorageKeys.OpenId),
  75. },
  76. method: "POST",
  77. showLoading: true,
  78. };
  79. // #ifdef MP-WEIXIN
  80. request(cancelOrder, options).then((res) => {
  81. cancelOrderSuccess();
  82. });
  83. // #endif
  84. // #ifdef MP-ALIPAY
  85. request(cancelOrderNew, options).then((res) => {
  86. cancelOrderSuccess();
  87. });
  88. // #endif
  89. },
  90. "取消确认"
  91. );
  92. };
  93. const cancelOrderSuccess = () => {
  94. const content =
  95. state.orderInfo.orderStep == 4
  96. ? "您的订单已取消"
  97. : "您的订单已取消,我们将在1-2个工作日内将费用原路退回";
  98. confirm(
  99. content,
  100. () => {
  101. uni.$emit("refreshOrder");
  102. uni.navigateBack();
  103. },
  104. "取消成功",
  105. false
  106. );
  107. };
  108. onLoad((options) => {
  109. state.orderInfo = JSON.parse(options.data) ?JSON.parse(options.data): {};
  110. state.formData[0].hint = state.orderInfo.orderId;
  111. state.formData[1].hint = state.orderInfo.vehiclePlate;
  112. state.formData[2].hint = getOrderStatusName(state.orderInfo.orderStep);
  113. });
  114. </script>
  115. <style lang="scss" scoped>
  116. .form {
  117. border-top: 1px solid #f7f7f7;
  118. padding: 20rpx;
  119. }
  120. </style>