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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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. console.log("获取退货网点", state.outlets, nameList)
  303. });
  304. };
  305. //radio改变
  306. const radioChange = (e : any, item : any) => {
  307. if (item.value === "exchangeMode") {
  308. //退货方式
  309. state.exchangeMode =
  310. item.exchangeMode === "ON_LINE"
  311. ? state.formData[6][state.formData[6].value] ? state.formData[6][state.formData[6].value] : "SELF"
  312. : item.exchangeMode;
  313. } else if (item.value === "exchangeRgMode") {
  314. //收货方式
  315. state.exchangeMode = item.exchangeRgMode;
  316. }
  317. state.formData[4].hide = state.exchangeMode === "OFFLINE" ? true : false;
  318. state.formData[5].hide = state.exchangeMode === "OFFLINE" ? true : false;
  319. state.formData[6].hide = state.exchangeMode === "OFFLINE" ? true : false;
  320. for (let i = 7; i < 15; i++) {
  321. state.formData[i].hide = true;
  322. }
  323. if (state.exchangeMode === "MAIL") {
  324. //MAIL-线上-邮寄
  325. for (let i = 8; i < 14; i++) {
  326. state.formData[i].hide = false;
  327. }
  328. // #ifdef MP-ALIPAY
  329. state.formData[8].btnTitle = "获取支付宝地址"
  330. // #endif
  331. // #ifdef MP-WEIXIN
  332. state.formData[8].btnTitle = "获取微信地址"
  333. // #endif
  334. } else if (state.exchangeMode === "SELF") {
  335. //SELF-线上-营业点自提
  336. state.formData[7].hide = false;
  337. } else if (state.exchangeMode === "OFFLINE") {
  338. //OFFLINE-线下
  339. state.formData[14].hide = false;
  340. }
  341. console.log("全部数据", state.formData)
  342. };
  343. // const handleGetRegion = (e : any, item : any) => {
  344. // console.log("dizhi")
  345. // }
  346. //地址改变
  347. const addressInfo = (content : any) => {
  348. console.log("content", `${content.provinceName}${content.cityName}${content.countyName}`)
  349. // #ifdef MP-ALIPAY
  350. state.formData[9][state.formData[9].value] = content.fullname;
  351. state.formData[10][state.formData[10].value] = content.mobilePhone;
  352. let arr = [];
  353. arr.push(content.prov)
  354. arr.push(content.city)
  355. arr.push(content.area)
  356. state.formData[11][
  357. state.formData[11].value
  358. ] = arr;
  359. const addressArr = content.address.split("-")
  360. state.formData[12][state.formData[12].value] = addressArr[3];
  361. // #endif
  362. // #ifdef MP-WEIXIN
  363. state.formData[9][state.formData[9].value] = content.userName;
  364. state.formData[10][state.formData[10].value] = content.telNumber;
  365. let arr = [];
  366. arr.push(content.provinceName)
  367. arr.push(content.cityName)
  368. arr.push(content.countyName)
  369. state.formData[11][
  370. state.formData[11].value
  371. ] = arr;
  372. state.formData[12][state.formData[12].value] = content.detailInfo;
  373. state.formData[13][state.formData[13].value] = content.postalCode;
  374. // #endif
  375. };
  376. //提交换货申请
  377. const submit = (e : any) => {
  378. for (var k = 0; k < state.outlets.length; k++) {
  379. if (e.exchangeRgNetworkName == state.outlets[k]['name']) {
  380. e['exchangeRgNetworkId'] = state.outlets[k]['servicehallId']
  381. break;
  382. }
  383. }
  384. console.log("是否确认换货", e)
  385. confirm(
  386. "是否确认换货?",
  387. () => {
  388. const curOutletName =
  389. e.exchangeMode === "ON_LINE"
  390. ? e.exchangeRgNetworkName
  391. : e.exchangeNetworkName;
  392. const curOutlet = state.outlets.find((out) => out.name === curOutletName);
  393. const curRegin = e.region == null ? null : e.region;
  394. const options = {
  395. type: 2,
  396. data: {
  397. id: state.orderInfo.id,
  398. exchangeMode: e.exchangeMode,
  399. // exchangeNetworkId: curOutlet == null ? "" : curOutlet.servicehallId,
  400. exchangeNetworkId: e.exchangeNetworkName,
  401. exchangeNetworkName: e.exchangeNetworkName,
  402. exchangeRgMode: e.exchangeRgMode,
  403. // exchangeRgNetworkId: curOutlet == null ? "" : curOutlet.servicehallId,
  404. exchangeRgNetworkId: e.exchangeRgNetworkId,
  405. exchangeRgNetworkName: e.exchangeRgNetworkName,
  406. exchangeLogisticsCompany: e.exchangeLogisticsCompany,
  407. exchangeLogisticsNumber: e.exchangeLogisticsNumber,
  408. exchangeReason: e.exchangeReason,
  409. consignee: e.consignee,
  410. consigneeTel: e.consigneeTel,
  411. region: curRegin ? `${curRegin[0]}${curRegin[1]}${curRegin[2]}` : "",
  412. address: e.address,
  413. postalCode: e.postalCode,
  414. opId: getItem(StorageKeys.OpenId),
  415. },
  416. method: "POST",
  417. showLoading: true,
  418. };
  419. console.log("提交数据", options);
  420. request(orderExchange, options).then((res) => {
  421. confirm(
  422. "您申办的ETC订单已申请换货",
  423. () => {
  424. uni.$emit("refreshOrder");
  425. uni.navigateBack();
  426. },
  427. "申请成功",
  428. false
  429. );
  430. });
  431. },
  432. "换货确认",
  433. true
  434. );
  435. };
  436. onLoad((option) => {
  437. console.log(option);//id是申请的接口获取的id
  438. getOrderDetails(option.orderId);
  439. getLogisticsList();
  440. getOutletList();
  441. });
  442. </script>
  443. <style>
  444. page {
  445. background-color: #f3f3f3;
  446. padding-bottom: 30rpx;
  447. }
  448. </style>
  449. <style lang="scss" scoped>
  450. .box {
  451. margin: 20rpx 0rpx;
  452. background-color: white;
  453. padding: 0 20rpx 20rpx;
  454. }
  455. </style>