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.

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