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.

apply-ex-goods.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <!-- 申请换货 -->
  2. <template>
  3. <view class="box">
  4. <form-builder
  5. :config="config"
  6. :formData="state.formData"
  7. @submit="submit"
  8. @addressInfo="addressInfo"
  9. @radioChange="radioChange"
  10. />
  11. </view>
  12. </template>
  13. <script setup lang="ts">
  14. import { reactive } from "vue";
  15. import { onLoad } from "@dcloudio/uni-app";
  16. import { msg, confirm, getOrderStatusName } from "@/utils/utils";
  17. import { request } from "@/utils/network/request";
  18. import {
  19. getLogistics,
  20. orderDetail,
  21. orderExchange,
  22. outletList,
  23. } from "@/utils/network/api";
  24. import { stringToJson } from "@/utils/network/encryption";
  25. import { getItem, StorageKeys } from "@/utils/storage";
  26. const config = {
  27. submitName: "申请换货",
  28. titleWidth: 160,
  29. };
  30. const state = reactive({
  31. //订单信息
  32. orderInfo: {} as any,
  33. //网点信息
  34. outlets: [],
  35. //换货类型: MAIL-线上-邮寄 SELF-线上-自提 OFFLINE-线下
  36. exchangeMode: "SELF",
  37. formData: [
  38. {
  39. title: "订单编号:",
  40. inputType: "number",
  41. type: 2,
  42. value: "id",
  43. hint: "订单编号",
  44. disabled: true,
  45. divider: true,
  46. },
  47. {
  48. title: "订单车牌号:",
  49. type: 2,
  50. value: "vehiclePlate",
  51. hint: "订单车牌号",
  52. disabled: true,
  53. divider: true,
  54. },
  55. {
  56. title: "订单状态:",
  57. type: 2,
  58. value: "orderStep",
  59. hint: "订单状态",
  60. disabled: true,
  61. divider: true,
  62. },
  63. {
  64. title: "退货方式:",
  65. type: 7,
  66. value: "exchangeMode",
  67. star: true,
  68. required: true,
  69. divider: true,
  70. emptyHint: "请选择退货方式",
  71. itemData: [
  72. {
  73. checked: false,
  74. value: "ON_LINE",
  75. name: "线上",
  76. },
  77. {
  78. checked: false,
  79. value: "OFFLINE",
  80. name: "线下",
  81. },
  82. ],
  83. },
  84. /* 区别-线上方式 */
  85. {
  86. title: "物流公司:",
  87. type: 4,
  88. value: "exchangeLogisticsCompany",
  89. required: true,
  90. star: true,
  91. hint: "请选择",
  92. divider: true,
  93. itemData: [],
  94. hide: false,
  95. emptyHint: "请选择物流公司",
  96. mode: "search",
  97. searchPickerVisible: false,
  98. },
  99. {
  100. title: "物流单号:",
  101. type: 2,
  102. value: "exchangeLogisticsNumber",
  103. required: true,
  104. maxlength: 20,
  105. hint: "请输入",
  106. emptyHint: "请输入物流单号",
  107. star: true,
  108. divider: true,
  109. hide: false,
  110. },
  111. {
  112. title: "收货方式:",
  113. type: 7,
  114. value: "exchangeRgMode",
  115. required: true,
  116. star: true,
  117. divider: true,
  118. itemData: [
  119. {
  120. checked: false,
  121. value: "SELF",
  122. name: "营业点自提",
  123. },
  124. {
  125. checked: false,
  126. value: "MAIL",
  127. name: "邮寄",
  128. },
  129. ],
  130. hide: false,
  131. emptyHint: "请选择收货方式",
  132. },
  133. /* 线上-营业点自提 */
  134. {
  135. title: "自提网点:",
  136. type: 4,
  137. value: "exchangeRgNetworkName",
  138. required: true,
  139. star: true,
  140. hint: "请选择",
  141. divider: true,
  142. hide: false,
  143. itemData: [],
  144. emptyHint: "请选择自提网点",
  145. mode: "search",
  146. searchPickerVisible: false,
  147. },
  148. /* 线上-邮寄 */
  149. {
  150. title: "收件人地址:",
  151. type: 2,
  152. value: "address",
  153. maxlength: 50,
  154. hint: " ",
  155. disabled: true,
  156. divider: true,
  157. btn: true,
  158. btnTitle: "获取微信地址",
  159. btnType: "address",
  160. hide: true,
  161. },
  162. {
  163. title: "姓名:",
  164. type: 2,
  165. value: "consignee",
  166. maxlength: 20,
  167. required: true,
  168. hint: "请输入",
  169. emptyHint: "请输入收件人姓名",
  170. star: true,
  171. divider: true,
  172. hide: true,
  173. },
  174. {
  175. title: "电话:",
  176. type: 2,
  177. value: "consigneeTel",
  178. required: true,
  179. inputType: "number",
  180. maxlength: 11,
  181. hint: "请输入",
  182. emptyHint: "请输入收件人电话",
  183. star: true,
  184. divider: true,
  185. hide: true,
  186. },
  187. {
  188. title: "地区:",
  189. type: 10,
  190. value: "region",
  191. required: true,
  192. hint: "选择省/市/区",
  193. emptyHint: "请选择收件人所在地区",
  194. star: true,
  195. divider: true,
  196. hide: true,
  197. },
  198. {
  199. title: "详细地址:",
  200. type: 2,
  201. value: "address",
  202. maxlength: 100,
  203. required: true,
  204. hint: "街道门牌、楼层房间号等信息",
  205. emptyHint: "请输入收件人详细地址",
  206. star: true,
  207. divider: true,
  208. hide: true,
  209. },
  210. {
  211. title: "邮政编码:",
  212. type: 2,
  213. value: "postalCode",
  214. inputType: "number",
  215. maxlength: 20,
  216. hint: "请输入邮政编码",
  217. emptyHint: "请输入邮政编码",
  218. divider: true,
  219. hide: true,
  220. },
  221. /* 区别-线下方式 */
  222. {
  223. title: "退货网点:",
  224. type: 4,
  225. value: "exchangeNetworkName",
  226. required: true,
  227. star: true,
  228. hint: "请选择",
  229. divider: true,
  230. itemData: [],
  231. hide: true,
  232. emptyHint: "请选择退货网点",
  233. mode: "search",
  234. searchPickerVisible: false,
  235. },
  236. {
  237. title: "换货原因:",
  238. required: true,
  239. type: 5,
  240. vertical: 2,
  241. value: "exchangeReason",
  242. maxlength: 50,
  243. bg: true,
  244. star: true,
  245. hint: "请输入换货原因,限制50字以内",
  246. emptyHint: "请输入换货原因",
  247. },
  248. ],
  249. });
  250. /* 获取订单详情 */
  251. const getOrderDetails = (id) => {
  252. const options = {
  253. type: 2,
  254. data: { id: id },
  255. method: "POST",
  256. showLoading: true,
  257. };
  258. request(orderDetail, options).then((res) => {
  259. //回显订单信息
  260. state.orderInfo = stringToJson(res.bizContent);
  261. state.formData[0].hint = state.orderInfo.orderId;
  262. state.formData[1].hint = state.orderInfo.vehiclePlate;
  263. state.formData[2].hint = getOrderStatusName(state.orderInfo.orderStep);
  264. //回显收件人地址
  265. state.formData[9][state.formData[9].value] =
  266. state.orderInfo.orderInfoExt.consignee;
  267. state.formData[10][state.formData[10].value] =
  268. state.orderInfo.orderInfoExt.consigneeTel;
  269. state.formData[11][state.formData[11].value] =
  270. state.orderInfo.orderInfoExt.region;
  271. state.formData[12][state.formData[12].value] =
  272. state.orderInfo.orderInfoExt.address;
  273. state.formData[13][state.formData[13].value] =
  274. state.orderInfo.orderInfoExt.postalCode;
  275. });
  276. };
  277. /* 获取所有的快递公司 */
  278. const getLogisticsList = () => {
  279. const options = {
  280. type: 2,
  281. data: {},
  282. method: "POST",
  283. showLoading: true,
  284. };
  285. request(getLogistics, options).then((res) => {
  286. const data = stringToJson(res.bizContent);
  287. state.formData[4].itemData = data;
  288. });
  289. };
  290. /* 获取退货网点 */
  291. const getOutletList = () => {
  292. const options = {
  293. type: 2,
  294. data: {},
  295. method: "POST",
  296. showLoading: true,
  297. };
  298. request(outletList, options).then((res) => {
  299. state.outlets = stringToJson(res.bizContent);
  300. let nameList = [];
  301. state.outlets.map((item) => {
  302. nameList.push(item.name);
  303. });
  304. state.formData[7].itemData = nameList;
  305. state.formData[14].itemData = nameList;
  306. });
  307. };
  308. //radio改变
  309. const radioChange = (e: any, item: any) => {
  310. if (item.value === "exchangeMode") {
  311. //退货方式
  312. state.exchangeMode =
  313. item.exchangeMode === "ON_LINE"
  314. ? state.formData[6][state.formData[6].value] ?? "SELF"
  315. : item.exchangeMode;
  316. } else if (item.value === "exchangeRgMode") {
  317. //收货方式
  318. state.exchangeMode = item.exchangeRgMode;
  319. }
  320. state.formData[4].hide = state.exchangeMode === "OFFLINE" ? true : false;
  321. state.formData[5].hide = state.exchangeMode === "OFFLINE" ? true : false;
  322. state.formData[6].hide = state.exchangeMode === "OFFLINE" ? true : false;
  323. for (let i = 7; i < 15; i++) {
  324. state.formData[i].hide = true;
  325. }
  326. if (state.exchangeMode === "MAIL") {
  327. //MAIL-线上-邮寄
  328. for (let i = 8; i < 14; i++) {
  329. state.formData[i].hide = false;
  330. }
  331. } else if (state.exchangeMode === "SELF") {
  332. //SELF-线上-营业点自提
  333. state.formData[7].hide = false;
  334. } else if (state.exchangeMode === "OFFLINE") {
  335. //OFFLINE-线下
  336. state.formData[14].hide = false;
  337. }
  338. };
  339. //地址改变
  340. const addressInfo = (content: any) => {
  341. state.formData[9][state.formData[9].value] = content.userName;
  342. state.formData[10][state.formData[10].value] = content.telNumber;
  343. state.formData[11][
  344. state.formData[11].value
  345. ] = `${content.provinceName}/${content.cityName}/${content.countyName}`;
  346. state.formData[12][state.formData[12].value] = content.detailInfo;
  347. state.formData[13][state.formData[13].value] = content.postalCode;
  348. };
  349. //提交换货申请
  350. const submit = (e: any) => {
  351. confirm(
  352. "是否确认换货?",
  353. () => {
  354. const curOutletName =
  355. e.exchangeMode === "ON_LINE"
  356. ? e.exchangeRgNetworkName
  357. : e.exchangeNetworkName;
  358. const curOutlet = state.outlets.find((out) => out.name === curOutletName);
  359. const curRegin = e.region == null ? null : e.region.split("/");
  360. const options = {
  361. type: 2,
  362. data: {
  363. id: state.orderInfo.id,
  364. exchangeMode: e.exchangeMode,
  365. exchangeNetworkId: curOutlet == null ? "" : curOutlet.servicehallId,
  366. exchangeNetworkName: e.exchangeNetworkName,
  367. exchangeRgMode: e.exchangeRgMode,
  368. exchangeRgNetworkId: curOutlet == null ? "" : curOutlet.servicehallId,
  369. exchangeRgNetworkName: e.exchangeRgNetworkName,
  370. exchangeLogisticsCompany: e.exchangeLogisticsCompany,
  371. exchangeLogisticsNumber: e.exchangeLogisticsNumber,
  372. exchangeReason: e.exchangeReason,
  373. consignee: e.consignee,
  374. consigneeTel: e.consigneeTel,
  375. region: curRegin ? `${curRegin[0]}${curRegin[1]}${curRegin[2]}` : "",
  376. address: e.address,
  377. postalCode: e.postalCode,
  378. opId: getItem(StorageKeys.OpenId),
  379. },
  380. method: "POST",
  381. showLoading: true,
  382. };
  383. request(orderExchange, options).then((res) => {
  384. confirm(
  385. "您申办的ETC订单已申请换货",
  386. () => {
  387. uni.$emit("refreshOrder");
  388. uni.navigateBack();
  389. },
  390. "申请成功",
  391. false
  392. );
  393. });
  394. },
  395. "换货确认",
  396. true
  397. );
  398. };
  399. onLoad((option) => {
  400. getOrderDetails(option.id);
  401. getLogisticsList();
  402. getOutletList();
  403. });
  404. </script>
  405. <style>
  406. page {
  407. background-color: #f3f3f3;
  408. padding-bottom: 30rpx;
  409. }
  410. </style>
  411. <style lang="scss" scoped>
  412. .box {
  413. margin: 20rpx 0rpx;
  414. background-color: white;
  415. padding: 0 20rpx 20rpx;
  416. }
  417. </style>