選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

apply-ex-goods - 副本.vue 13KB

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