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

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