您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

apply-return-goods.vue 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <!-- 申请退货 -->
  2. <template>
  3. <view class="box">
  4. <form-builder
  5. :config="config"
  6. :formData="state.formData"
  7. @submit="submit"
  8. @radioChange="radioChange"
  9. />
  10. </view>
  11. </template>
  12. <script setup lang="ts">
  13. import { reactive } from "vue";
  14. import { onLoad } from "@dcloudio/uni-app";
  15. import { msg, confirm, getOrderStatusName } from "@/utils/utils";
  16. import { request } from "@/utils/network/request";
  17. import { getLogistics, orderReturn, outletList } from "@/utils/network/api";
  18. import { stringToJson } from "@/utils/network/encryption";
  19. import { getItem, StorageKeys } from "@/utils/storage";
  20. const config = {
  21. submitName: "申请退货",
  22. titleWidth: 160,
  23. divider: true,
  24. };
  25. const state = reactive({
  26. //订单信息
  27. orderInfo: {} as any,
  28. //退货类型: OFFLINE-线下 ON_LINE-线上
  29. returnMode: "ON_LINE",
  30. //网点列表
  31. outlets: [],
  32. //表单数据
  33. formData: [
  34. {
  35. title: "订单编号:",
  36. inputType: "number",
  37. type: 2,
  38. value: "id",
  39. hint: "订单编号",
  40. disabled: true,
  41. divider: true,
  42. },
  43. {
  44. title: "订单车牌号:",
  45. type: 2,
  46. value: "vehiclePlate",
  47. hint: "订单车牌号",
  48. disabled: true,
  49. divider: true,
  50. },
  51. {
  52. title: "订单状态:",
  53. type: 2,
  54. value: "orderStep",
  55. hint: "订单状态",
  56. disabled: true,
  57. divider: true,
  58. },
  59. {
  60. title: "退货方式:",
  61. type: 7,
  62. value: "returnMode",
  63. star: true,
  64. required: true,
  65. divider: true,
  66. emptyHint: "请选择退货方式",
  67. itemData: [
  68. {
  69. checked: false,
  70. value: "ON_LINE",
  71. name: "线上",
  72. },
  73. {
  74. checked: false,
  75. value: "OFFLINE",
  76. name: "线下",
  77. },
  78. ],
  79. },
  80. {
  81. title: "物流公司:",
  82. type: 4,
  83. value: "returnLogisticsCompany",
  84. required: true,
  85. star: true,
  86. hint: "请选择",
  87. divider: true,
  88. itemData: [],
  89. hide: false,
  90. emptyHint: "请选择物流公司",
  91. mode: "search",
  92. searchPickerVisible: false,
  93. },
  94. {
  95. title: "物流单号:",
  96. type: 2,
  97. value: "returnLogisticsNumber",
  98. required: true,
  99. maxlength: 20,
  100. hint: "请输入",
  101. emptyHint: "请输入物流单号",
  102. star: true,
  103. divider: true,
  104. hide: false,
  105. },
  106. {
  107. title: "退货网点:",
  108. type: 4,
  109. value: "returnNetworkName",
  110. required: true,
  111. star: true,
  112. hint: "请选择",
  113. emptyHint: "请选择退货网点",
  114. divider: true,
  115. itemData: [],
  116. hide: true,
  117. mode: "search",
  118. searchPickerVisible: false,
  119. },
  120. {
  121. title: "退货原因:",
  122. required: true,
  123. type: 5,
  124. vertical: 2,
  125. value: "returnReason",
  126. maxlength: 50,
  127. bg: true,
  128. star: true,
  129. hint: "请输入退货原因,限制50字以内",
  130. emptyHint: "请输入退货原因",
  131. },
  132. ],
  133. });
  134. /* 获取所有的快递公司 */
  135. const getLogisticsList = () => {
  136. const options = {
  137. type: 2,
  138. data: {},
  139. method: "POST",
  140. showLoading: true,
  141. };
  142. request(getLogistics, options).then((res) => {
  143. const data = stringToJson(res.bizContent);
  144. state.formData[4].itemData = data;
  145. });
  146. };
  147. /* 获取退货网点 */
  148. const getOutletList = () => {
  149. const options = {
  150. type: 2,
  151. data: {},
  152. method: "POST",
  153. showLoading: true,
  154. };
  155. request(outletList, options).then((res) => {
  156. state.outlets = stringToJson(res.bizContent);
  157. let nameList = [];
  158. state.outlets.map((item) => {
  159. nameList.push(item.name);
  160. });
  161. state.formData[6].itemData = nameList;
  162. });
  163. };
  164. //radio改变
  165. const radioChange = (e: any, item: any) => {
  166. if (item.value === "returnMode") {
  167. //退货方式
  168. state.returnMode = item.returnMode;
  169. state.formData[4].hide = state.returnMode === "ON_LINE" ? false : true;
  170. state.formData[5].hide = state.returnMode === "ON_LINE" ? false : true;
  171. state.formData[6].hide = state.returnMode === "ON_LINE" ? true : false;
  172. }
  173. };
  174. //提交退货申请
  175. const submit = (e: any) => {
  176. confirm(
  177. "是否确认退货?",
  178. () => {
  179. const curOutlet = state.outlets.find(
  180. (out) => out.name === e.returnNetworkName
  181. );
  182. const options = {
  183. type: 2,
  184. data: {
  185. id: state.orderInfo.id,
  186. returnMode: e.returnMode,
  187. returnNetworkId: curOutlet == null ? "" : curOutlet.servicehallId,
  188. returnNetworkName: e.returnNetworkName,
  189. returnLogisticsCompany: e.returnLogisticsCompany,
  190. returnLogisticsNumber: e.returnLogisticsNumber,
  191. returnReason: e.returnReason,
  192. opId: getItem(StorageKeys.OpenId),
  193. },
  194. method: "POST",
  195. showLoading: true,
  196. };
  197. request(orderReturn, options).then((res) => {
  198. confirm(
  199. "您申办的ETC订单已申请退货",
  200. () => {
  201. uni.$emit("refreshOrder");
  202. uni.navigateBack();
  203. },
  204. "申请成功",
  205. false
  206. );
  207. });
  208. },
  209. "退货确认",
  210. true
  211. );
  212. };
  213. onLoad((option) => {
  214. state.orderInfo = JSON.parse(option.data);
  215. state.formData[0].hint = state.orderInfo.orderId;
  216. state.formData[1].hint = state.orderInfo.vehiclePlate;
  217. state.formData[2].hint = getOrderStatusName(state.orderInfo.orderStep);
  218. //获取物流公司
  219. getLogisticsList();
  220. //获取退货网点
  221. getOutletList();
  222. });
  223. </script>
  224. <style>
  225. page {
  226. background-color: #f3f3f3;
  227. padding-bottom: 30rpx;
  228. }
  229. </style>
  230. <style lang="scss" scoped>
  231. .box {
  232. margin: 20rpx 0rpx;
  233. background-color: white;
  234. padding: 0 20rpx 20rpx;
  235. }
  236. </style>