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.

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