You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cancel-order.vue 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 } 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. request(cancelOrder, options).then((res) => {
  80. cancelOrderSuccess();
  81. });
  82. },
  83. "取消确认"
  84. );
  85. };
  86. const cancelOrderSuccess = () => {
  87. const content =
  88. state.orderInfo.orderStep == 4
  89. ? "您的订单已取消"
  90. : "您的订单已取消,我们将在1-2个工作日内将费用原路退回";
  91. confirm(
  92. content,
  93. () => {
  94. uni.$emit("refreshOrder");
  95. uni.navigateBack();
  96. },
  97. "取消成功",
  98. false
  99. );
  100. };
  101. onLoad((options) => {
  102. state.orderInfo = JSON.parse(options.data) ?JSON.parse(options.data): {};
  103. state.formData[0].hint = state.orderInfo.orderId;
  104. state.formData[1].hint = state.orderInfo.vehiclePlate;
  105. state.formData[2].hint = getOrderStatusName(state.orderInfo.orderStep);
  106. });
  107. </script>
  108. <style lang="scss" scoped>
  109. .form {
  110. border-top: 1px solid #f7f7f7;
  111. padding: 20rpx;
  112. }
  113. </style>