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 3.1KB

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