Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

apply-ex-goods.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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. console.log(stringToJson(res.bizContent))
  261. state.orderInfo = stringToJson(res.bizContent);
  262. state.formData[0].hint = state.orderInfo.orderId;
  263. state.formData[1].hint = state.orderInfo.vehiclePlate;
  264. state.formData[2].hint = getOrderStatusName(state.orderInfo.orderStep);
  265. //回显收件人地址
  266. state.formData[9][state.formData[9].value] =
  267. state.orderInfo.orderInfoExt.consignee;
  268. state.formData[10][state.formData[10].value] =
  269. state.orderInfo.orderInfoExt.consigneeTel;
  270. state.formData[11][state.formData[11].value] =
  271. state.orderInfo.orderInfoExt.region;
  272. state.formData[12][state.formData[12].value] =
  273. state.orderInfo.orderInfoExt.address;
  274. state.formData[13][state.formData[13].value] =
  275. state.orderInfo.orderInfoExt.postalCode;
  276. });
  277. };
  278. /* 获取所有的快递公司 */
  279. const getLogisticsList = () => {
  280. const options = {
  281. type: 2,
  282. data: {},
  283. method: "POST",
  284. showLoading: true,
  285. };
  286. request(getLogistics, options).then((res) => {
  287. const data = stringToJson(res.bizContent);
  288. state.formData[4].itemData = data;
  289. });
  290. };
  291. /* 获取退货网点 */
  292. const getOutletList = () => {
  293. const options = {
  294. type: 2,
  295. data: {},
  296. method: "POST",
  297. showLoading: true,
  298. };
  299. request(outletList, options).then((res) => {
  300. state.outlets = stringToJson(res.bizContent);
  301. let nameList = [];
  302. state.outlets.map((item) => {
  303. nameList.push(item.name);
  304. });
  305. state.formData[7].itemData = nameList;
  306. state.formData[14].itemData = nameList;
  307. });
  308. };
  309. //radio改变
  310. const radioChange = (e: any, item: any) => {
  311. if (item.value === "exchangeMode") {
  312. //退货方式
  313. state.exchangeMode =
  314. item.exchangeMode === "ON_LINE"
  315. ? state.formData[6][state.formData[6].value] ?state.formData[6][state.formData[6].value]: "SELF"
  316. : item.exchangeMode;
  317. } else if (item.value === "exchangeRgMode") {
  318. //收货方式
  319. state.exchangeMode = item.exchangeRgMode;
  320. }
  321. state.formData[4].hide = state.exchangeMode === "OFFLINE" ? true : false;
  322. state.formData[5].hide = state.exchangeMode === "OFFLINE" ? true : false;
  323. state.formData[6].hide = state.exchangeMode === "OFFLINE" ? true : false;
  324. for (let i = 7; i < 15; i++) {
  325. state.formData[i].hide = true;
  326. }
  327. if (state.exchangeMode === "MAIL") {
  328. //MAIL-线上-邮寄
  329. for (let i = 8; i < 14; i++) {
  330. state.formData[i].hide = false;
  331. }
  332. } else if (state.exchangeMode === "SELF") {
  333. //SELF-线上-营业点自提
  334. state.formData[7].hide = false;
  335. } else if (state.exchangeMode === "OFFLINE") {
  336. //OFFLINE-线下
  337. state.formData[14].hide = false;
  338. }
  339. };
  340. //地址改变
  341. const addressInfo = (content: any) => {
  342. state.formData[9][state.formData[9].value] = content.userName;
  343. state.formData[10][state.formData[10].value] = content.telNumber;
  344. state.formData[11][
  345. state.formData[11].value
  346. ] = `${content.provinceName}/${content.cityName}/${content.countyName}`;
  347. state.formData[12][state.formData[12].value] = content.detailInfo;
  348. state.formData[13][state.formData[13].value] = content.postalCode;
  349. };
  350. //提交换货申请
  351. const submit = (e: any) => {
  352. confirm(
  353. "是否确认换货?",
  354. () => {
  355. const curOutletName =
  356. e.exchangeMode === "ON_LINE"
  357. ? e.exchangeRgNetworkName
  358. : e.exchangeNetworkName;
  359. const curOutlet = state.outlets.find((out) => out.name === curOutletName);
  360. const curRegin = e.region == null ? null : e.region.split("/");
  361. const options = {
  362. type: 2,
  363. data: {
  364. id: state.orderInfo.id,
  365. exchangeMode: e.exchangeMode,
  366. exchangeNetworkId: curOutlet == null ? "" : curOutlet.servicehallId,
  367. exchangeNetworkName: e.exchangeNetworkName,
  368. exchangeRgMode: e.exchangeRgMode,
  369. exchangeRgNetworkId: curOutlet == null ? "" : curOutlet.servicehallId,
  370. exchangeRgNetworkName: e.exchangeRgNetworkName,
  371. exchangeLogisticsCompany: e.exchangeLogisticsCompany,
  372. exchangeLogisticsNumber: e.exchangeLogisticsNumber,
  373. exchangeReason: e.exchangeReason,
  374. consignee: e.consignee,
  375. consigneeTel: e.consigneeTel,
  376. region: curRegin ? `${curRegin[0]}${curRegin[1]}${curRegin[2]}` : "",
  377. address: e.address,
  378. postalCode: e.postalCode,
  379. opId: getItem(StorageKeys.OpenId),
  380. },
  381. method: "POST",
  382. showLoading: true,
  383. };
  384. request(orderExchange, options).then((res) => {
  385. confirm(
  386. "您申办的ETC订单已申请换货",
  387. () => {
  388. uni.$emit("refreshOrder");
  389. uni.navigateBack();
  390. },
  391. "申请成功",
  392. false
  393. );
  394. });
  395. },
  396. "换货确认",
  397. true
  398. );
  399. };
  400. onLoad((option) => {
  401. console.log(option);//id是申请的接口获取的id
  402. getOrderDetails(option.orderId);
  403. getLogisticsList();
  404. getOutletList();
  405. });
  406. </script>
  407. <style>
  408. page {
  409. background-color: #f3f3f3;
  410. padding-bottom: 30rpx;
  411. }
  412. </style>
  413. <style lang="scss" scoped>
  414. .box {
  415. margin: 20rpx 0rpx;
  416. background-color: white;
  417. padding: 0 20rpx 20rpx;
  418. }
  419. </style>