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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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. exchangeMode: "ON_LINE",
  63. star: true,
  64. required: true,
  65. divider: true,
  66. emptyHint: "请选择换货方式",
  67. itemData: [
  68. {
  69. checked: true,
  70. value: "ON_LINE",
  71. name: "线上",
  72. },
  73. {
  74. checked: false,
  75. value: "OFFLINE",
  76. name: "线下",
  77. },
  78. ],
  79. },
  80. /* 区别-线上方式 */
  81. {
  82. title: "物流公司:",
  83. type: 4,
  84. value: "exchangeLogisticsCompany",
  85. required: true,
  86. star: true,
  87. hint: "请输入",
  88. divider: true,
  89. itemData: [],
  90. hide: false,
  91. emptyHint: "请选择物流公司",
  92. mode: "search",
  93. searchPickerVisible: false,
  94. },
  95. {
  96. title: "物流单号:",
  97. type: 2,
  98. value: "exchangeLogisticsNumber",
  99. required: true,
  100. maxlength: 20,
  101. hint: "请输入",
  102. emptyHint: "请输入物流单号",
  103. star: true,
  104. divider: true,
  105. hide: false,
  106. },
  107. {
  108. title: "收货方式:",
  109. type: 7,
  110. value: "exchangeRgMode",
  111. required: true,
  112. star: true,
  113. divider: true,
  114. itemData: [
  115. // {
  116. // checked: false,
  117. // value: "SELF",
  118. // name: "营业点自提",
  119. // },
  120. {
  121. checked: false,
  122. value: "MAIL",
  123. name: "邮寄",
  124. },
  125. ],
  126. hide: false,
  127. emptyHint: "请选择收货方式",
  128. },
  129. /* 线上-营业点自提 */
  130. {
  131. title: "自提网点:",
  132. type: 4,
  133. value: "exchangeRgNetworkName",
  134. required: true,
  135. star: true,
  136. hint: "请输入",
  137. divider: true,
  138. hide: true,
  139. itemData: [],
  140. emptyHint: "请选择自提网点",
  141. mode: "search",
  142. searchPickerVisible: false,
  143. },
  144. /* 线上-邮寄 */
  145. {
  146. title: "收件人地址:",
  147. type: 2,
  148. value: "address",
  149. maxlength: 50,
  150. hint: " ",
  151. disabled: true,
  152. divider: true,
  153. btn: true,
  154. btnTitle: "获取微信地址",
  155. btnType: "address",
  156. hide: true,
  157. },
  158. {
  159. title: "姓名:",
  160. type: 2,
  161. value: "consignee",
  162. maxlength: 20,
  163. required: true,
  164. hint: "请输入",
  165. emptyHint: "请输入收件人姓名",
  166. star: true,
  167. divider: true,
  168. hide: true,
  169. },
  170. {
  171. title: "电话:",
  172. type: 2,
  173. value: "consigneeTel",
  174. required: true,
  175. inputType: "number",
  176. maxlength: 11,
  177. hint: "请输入",
  178. emptyHint: "请输入收件人电话",
  179. star: true,
  180. divider: true,
  181. hide: true,
  182. },
  183. {
  184. title: "地区:",
  185. type: 10,
  186. value: "region",
  187. required: true,
  188. hint: "选择省/市/区",
  189. emptyHint: "请选择收件人所在地区",
  190. star: true,
  191. divider: true,
  192. hide: true,
  193. },
  194. {
  195. title: "详细地址:",
  196. type: 2,
  197. value: "address",
  198. maxlength: 100,
  199. required: true,
  200. hint: "街道门牌、楼层房间号等信息",
  201. emptyHint: "请输入收件人详细地址",
  202. star: true,
  203. divider: true,
  204. hide: true,
  205. },
  206. {
  207. title: "邮政编码:",
  208. type: 2,
  209. value: "postalCode",
  210. inputType: "number",
  211. maxlength: 20,
  212. hint: "请输入邮政编码",
  213. emptyHint: "请输入邮政编码",
  214. divider: true,
  215. hide: true,
  216. },
  217. /* 区别-线下方式 */
  218. {
  219. title: "换货网点:",
  220. type: 4,
  221. value: "exchangeNetworkName",
  222. required: true,
  223. star: true,
  224. hint: "请输入",
  225. divider: true,
  226. itemData: ["1"],
  227. hide: true,
  228. emptyHint: "请选择换货网点",
  229. mode: "search",
  230. searchPickerVisible: false,
  231. },
  232. {
  233. title: "换货原因:",
  234. required: true,
  235. type: 5,
  236. vertical: 2,
  237. value: "exchangeReason",
  238. maxlength: 50,
  239. bg: true,
  240. star: true,
  241. hint: "请输入换货原因,限制50字以内",
  242. emptyHint: "请输入换货原因",
  243. },
  244. ],
  245. });
  246. /* 获取订单详情 */
  247. const getOrderDetails = (id) => {
  248. const options = {
  249. type: 2,
  250. data: { id: id },
  251. method: "POST",
  252. showLoading: true,
  253. };
  254. request(orderDetail, options).then((res) => {
  255. //回显订单信息
  256. console.log("回显订单信息", stringToJson(res.bizContent))
  257. state.orderInfo = stringToJson(res.bizContent);
  258. state.formData[0].hint = state.orderInfo.orderId;
  259. state.formData[1].hint = state.orderInfo.vehiclePlate;
  260. state.formData[2].hint = getOrderStatusName(state.orderInfo.orderStep);
  261. //回显收件人地址
  262. state.formData[9][state.formData[9].value] =
  263. state.orderInfo.orderInfoExt.consignee;
  264. state.formData[10][state.formData[10].value] =
  265. state.orderInfo.orderInfoExt.consigneeTel;
  266. state.formData[11][state.formData[11].value] =
  267. state.orderInfo.orderInfoExt.regionList.slice(0, 3);
  268. state.formData[12][state.formData[12].value] =
  269. state.orderInfo.orderInfoExt.address;
  270. state.formData[13][state.formData[13].value] =
  271. state.orderInfo.orderInfoExt.postalCode;
  272. });
  273. };
  274. /* 获取所有的快递公司 */
  275. const getLogisticsList = () => {
  276. const options = {
  277. type: 2,
  278. data: {},
  279. method: "POST",
  280. showLoading: true,
  281. };
  282. request(getLogistics, options).then((res) => {
  283. const data = stringToJson(res.bizContent);
  284. state.formData[4].itemData = data;
  285. });
  286. };
  287. /* 获取换货网点 */
  288. const getOutletList = () => {
  289. const options = {
  290. type: 2,
  291. data: {},
  292. method: "POST",
  293. showLoading: true,
  294. };
  295. request(outletList, options).then((res) => {
  296. state.outlets = stringToJson(res.bizContent);
  297. let nameList = [];
  298. state.outlets.map((item) => {
  299. nameList.push(item.name);
  300. });
  301. state.formData[7].itemData = nameList;
  302. state.formData[14].itemData = nameList;
  303. console.log("获取换货网点", state.outlets, nameList)
  304. });
  305. };
  306. //radio改变
  307. const radioChange = (e : any, item : any) => {
  308. console.log("e", e, item)
  309. if (item.value === "exchangeMode") {
  310. //退货方式
  311. state.exchangeMode =
  312. item.exchangeMode === "ON_LINE" ? state.formData[6][state.formData[6].value] ? state.formData[6][state.formData[6].value] : "SELF"
  313. : item.exchangeMode;
  314. } else if (item.value === "exchangeRgMode") {
  315. //收货方式
  316. state.exchangeMode = item.exchangeRgMode;
  317. console.log("item", item, state.exchangeMode)
  318. }
  319. state.formData[4].hide = state.exchangeMode === "OFFLINE" ? true : false;
  320. state.formData[5].hide = state.exchangeMode === "OFFLINE" ? true : false;
  321. // state.formData[6].hide = state.exchangeMode === "OFFLINE" ? true : false;
  322. for (let i = 7; i < 15; i++) {
  323. state.formData[i].hide = true;
  324. }
  325. if (state.exchangeMode === "MAIL") {
  326. //MAIL-线上-邮寄
  327. for (let i = 9; i < 14; i++) {
  328. state.formData[i].hide = false;
  329. }
  330. // #ifdef MP-ALIPAY
  331. state.formData[8].btnTitle = "获取支付宝地址"
  332. // #endif
  333. // #ifdef MP-WEIXIN
  334. state.formData[8].btnTitle = "获取微信地址"
  335. // #endif
  336. } else if (state.exchangeMode === "SELF") {
  337. //SELF-线上-营业点自提
  338. // state.formData[7].hide = false;
  339. state.formData[4].hide = true;
  340. state.formData[5].hide = true;
  341. state.formData[14].hide = false;
  342. console.log("1111111111111111111111111111")
  343. } else if (state.exchangeMode === "OFFLINE") {
  344. //OFFLINE-线下
  345. state.formData[14].hide = false;
  346. state.formData[6].itemData = [
  347. {
  348. checked: false,
  349. value: "SELF",
  350. name: "营业点自提",
  351. },
  352. ]
  353. }
  354. if (item.exchangeMode == "ON_LINE") {
  355. state.formData[14].hide = true;
  356. state.formData[6].itemData = [
  357. {
  358. checked: false,
  359. value: "MAIL",
  360. name: "邮寄",
  361. },
  362. ]
  363. }
  364. console.log("全部数据", state.formData)
  365. };
  366. //地址改变
  367. const addressInfo = (content : any) => {
  368. console.log("content", `${content.provinceName}${content.cityName}${content.countyName}`)
  369. // #ifdef MP-ALIPAY
  370. state.formData[9][state.formData[9].value] = content.fullname;
  371. state.formData[10][state.formData[10].value] = content.mobilePhone;
  372. let arr = [];
  373. arr.push(content.prov)
  374. arr.push(content.city)
  375. arr.push(content.area)
  376. state.formData[11][
  377. state.formData[11].value
  378. ] = arr;
  379. const addressArr = content.address.split("-")
  380. state.formData[12][state.formData[12].value] = addressArr[3];
  381. // #endif
  382. // #ifdef MP-WEIXIN
  383. state.formData[9][state.formData[9].value] = content.userName;
  384. state.formData[10][state.formData[10].value] = content.telNumber;
  385. let arr = [];
  386. arr.push(content.provinceName)
  387. arr.push(content.cityName)
  388. arr.push(content.countyName)
  389. state.formData[11][
  390. state.formData[11].value
  391. ] = arr;
  392. state.formData[12][state.formData[12].value] = content.detailInfo;
  393. state.formData[13][state.formData[13].value] = content.postalCode;
  394. // #endif
  395. };
  396. //提交换货申请
  397. const submit = (e : any) => {
  398. if (e.exchangeMode == "OFFLINE") {
  399. for (var k = 0; k < state.outlets.length; k++) {
  400. if (e.exchangeNetworkName == state.outlets[k]['name']) {
  401. e['exchangeNetworkId'] = state.outlets[k]['servicehallId']
  402. e['exchangeRgNetworkId'] = state.outlets[k]['servicehallId']
  403. console.log("e.exchangeRgNetworkName", e.exchangeNetworkName, e['exchangeNetworkId'])
  404. break;
  405. }
  406. }
  407. } else {
  408. for (var k = 0; k < state.outlets.length; k++) {
  409. if (e.exchangeRgNetworkName == state.outlets[k]['name']) {
  410. e['exchangeNetworkId'] = state.outlets[k]['servicehallId']
  411. e['exchangeRgNetworkId'] = state.outlets[k]['servicehallId']
  412. console.log("e.exchangeRgNetworkName", e.exchangeRgNetworkName, e['exchangeNetworkId'])
  413. break;
  414. }
  415. }
  416. }
  417. console.log("是否确认换货", e)
  418. confirm(
  419. "是否确认换货?",
  420. () => {
  421. const curOutletName =
  422. e.exchangeMode === "ON_LINE"
  423. ? e.exchangeRgNetworkName
  424. : e.exchangeNetworkName;
  425. const curOutlet = state.outlets.find((out) => out.name === curOutletName);
  426. const curRegin = e.region == null ? null : e.region;
  427. const options = {
  428. type: 2,
  429. data: {
  430. id: state.orderInfo.id,
  431. exchangeMode: e.exchangeMode,
  432. exchangeNetworkId: e.exchangeNetworkId,
  433. exchangeNetworkName: e.exchangeRgNetworkName ? e.exchangeRgNetworkName : e.exchangeNetworkName, //换货网点
  434. exchangeRgMode: e.exchangeMode == "ON_LINE" ? 'MAIL' : "SELF",
  435. exchangeRgNetworkId: e.exchangeRgNetworkId,
  436. exchangeRgNetworkName: e.exchangeRgNetworkName ? e.exchangeRgNetworkName : e.exchangeNetworkName, //自提网点
  437. exchangeLogisticsCompany: e.exchangeLogisticsCompany,
  438. exchangeLogisticsNumber: e.exchangeLogisticsNumber,
  439. exchangeReason: e.exchangeReason,
  440. consignee: e.consignee,
  441. consigneeTel: e.consigneeTel,
  442. region: curRegin ? `${curRegin[0]}${curRegin[1]}${curRegin[2]}` : "",
  443. address: e.address,
  444. postalCode: e.postalCode,
  445. opId: getItem(StorageKeys.OpenId),
  446. },
  447. method: "POST",
  448. showLoading: true,
  449. };
  450. console.log("提交数据", options);
  451. request(orderExchange, options).then((res) => {
  452. confirm(
  453. "您申办的ETC订单已申请换货",
  454. () => {
  455. uni.$emit("refreshOrder");
  456. uni.navigateBack();
  457. },
  458. "申请成功",
  459. false
  460. );
  461. });
  462. },
  463. "换货确认",
  464. true
  465. );
  466. };
  467. onLoad((option) => {
  468. console.log(option);//id是申请的接口获取的id
  469. getOrderDetails(option.orderId);
  470. getLogisticsList();
  471. getOutletList();
  472. });
  473. </script>
  474. <style>
  475. page {
  476. background-color: #f3f3f3;
  477. padding-bottom: 30rpx;
  478. }
  479. </style>
  480. <style lang="scss" scoped>
  481. .box {
  482. margin: 20rpx 0rpx;
  483. background-color: white;
  484. padding: 0 20rpx 20rpx;
  485. }
  486. </style>