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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. reason: e.orderReason,
  69. openId: getItem(StorageKeys.OpenId),
  70. },
  71. method: "POST",
  72. showLoading: true,
  73. };
  74. // #ifdef MP-WEIXIN
  75. options.data['source'] = 'WECHAT'
  76. // #endif
  77. // #ifdef MP-ALIPAY
  78. options.data['source'] = 'ALI'
  79. // #endif
  80. console.log("options", options)
  81. request(cancelOrder, options).then((res) => {
  82. cancelOrderSuccess();
  83. });
  84. },
  85. "取消确认"
  86. );
  87. };
  88. const cancelOrderSuccess = () => {
  89. const content =
  90. state.orderInfo.orderStep == 4
  91. ? "您的订单已取消"
  92. : "您的订单已取消,我们将在1-2个工作日内将费用原路退回";
  93. confirm(
  94. content,
  95. () => {
  96. uni.$emit("refreshOrder");
  97. uni.navigateBack();
  98. },
  99. "取消成功",
  100. false
  101. );
  102. };
  103. onLoad((options) => {
  104. state.orderInfo = JSON.parse(options.data) ? JSON.parse(options.data) : {};
  105. state.formData[0].hint = state.orderInfo.orderId;
  106. state.formData[1].hint = state.orderInfo.vehiclePlate;
  107. state.formData[2].hint = getOrderStatusName(state.orderInfo.orderStep);
  108. console.log("options", options, getOrderStatusName(state.orderInfo.orderStep))
  109. });
  110. </script>
  111. <style lang="scss" scoped>
  112. .form {
  113. border-top: 1px solid #f7f7f7;
  114. padding: 20rpx;
  115. }
  116. </style>