Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

apply-ex-goods.vue 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  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. disabled: true,
  206. },
  207. {
  208. title: "邮政编码:",
  209. type: 2,
  210. value: "postalCode",
  211. inputType: "number",
  212. maxlength: 20,
  213. hint: "请输入邮政编码",
  214. emptyHint: "请输入邮政编码",
  215. divider: true,
  216. hide: true,
  217. },
  218. /* 区别-线下方式 */
  219. {
  220. title: "换货网点:",
  221. type: 4,
  222. value: "exchangeNetworkName",
  223. required: true,
  224. star: true,
  225. hint: "请输入",
  226. divider: true,
  227. itemData: ["1"],
  228. hide: true,
  229. emptyHint: "请选择换货网点",
  230. mode: "search",
  231. searchPickerVisible: false,
  232. },
  233. {
  234. title: "换货原因:",
  235. required: true,
  236. type: 5,
  237. vertical: 2,
  238. value: "exchangeReason",
  239. maxlength: 50,
  240. bg: true,
  241. star: true,
  242. hint: "请输入换货原因,限制50字以内",
  243. emptyHint: "请输入换货原因",
  244. },
  245. ],
  246. });
  247. /* 获取订单详情 */
  248. const getOrderDetails = (id) => {
  249. const options = {
  250. type: 2,
  251. data: { id: id },
  252. method: "POST",
  253. showLoading: true,
  254. };
  255. request(orderDetail, options).then((res) => {
  256. //回显订单信息
  257. console.log("回显订单信息", stringToJson(res.bizContent))
  258. state.orderInfo = stringToJson(res.bizContent);
  259. state.formData[0].hint = state.orderInfo.orderId;
  260. state.formData[1].hint = state.orderInfo.vehiclePlate;
  261. state.formData[2].hint = getOrderStatusName(state.orderInfo.orderStep);
  262. //回显收件人地址
  263. state.formData[9][state.formData[9].value] =
  264. state.orderInfo.orderInfoExt.consignee;
  265. state.formData[10][state.formData[10].value] =
  266. state.orderInfo.orderInfoExt.consigneeTel;
  267. state.formData[11][state.formData[11].value] =
  268. state.orderInfo.orderInfoExt.regionList.slice(0, 3);
  269. state.formData[12][state.formData[12].value] =
  270. state.orderInfo.orderInfoExt.address;
  271. state.formData[13][state.formData[13].value] =
  272. state.orderInfo.orderInfoExt.postalCode;
  273. });
  274. };
  275. /* 获取所有的快递公司 */
  276. const getLogisticsList = () => {
  277. const options = {
  278. type: 2,
  279. data: {},
  280. method: "POST",
  281. showLoading: true,
  282. };
  283. request(getLogistics, options).then((res) => {
  284. const data = stringToJson(res.bizContent);
  285. state.formData[4].itemData = data;
  286. });
  287. };
  288. /* 获取换货网点 */
  289. const getOutletList = () => {
  290. const options = {
  291. type: 2,
  292. data: {},
  293. method: "POST",
  294. showLoading: true,
  295. };
  296. request(outletList, options).then((res) => {
  297. state.outlets = stringToJson(res.bizContent);
  298. let nameList = [];
  299. state.outlets.map((item) => {
  300. nameList.push(item.name);
  301. });
  302. state.formData[7].itemData = nameList;
  303. state.formData[14].itemData = nameList;
  304. console.log("获取换货网点", state.outlets, nameList)
  305. });
  306. };
  307. //radio改变
  308. const radioChange = (e : any, item : any) => {
  309. console.log("e", e, item)
  310. if (item.value === "exchangeMode") {
  311. //退货方式
  312. state.exchangeMode =
  313. item.exchangeMode === "ON_LINE" ? state.formData[6][state.formData[6].value] ? state.formData[6][state.formData[6].value] : "SELF"
  314. : item.exchangeMode;
  315. } else if (item.value === "exchangeRgMode") {
  316. //收货方式
  317. state.exchangeMode = item.exchangeRgMode;
  318. console.log("item", item, state.exchangeMode)
  319. }
  320. state.formData[4].hide = state.exchangeMode === "OFFLINE" ? true : false;
  321. state.formData[5].hide = state.exchangeMode === "OFFLINE" ? true : false;
  322. // state.formData[6].hide = state.exchangeMode === "OFFLINE" ? true : false;
  323. for (let i = 7; i < 15; i++) {
  324. state.formData[i].hide = true;
  325. }
  326. if (state.exchangeMode === "MAIL") {
  327. //MAIL-线上-邮寄
  328. for (let i = 9; i < 14; i++) {
  329. state.formData[i].hide = false;
  330. }
  331. // #ifdef MP-ALIPAY
  332. state.formData[8].btnTitle = "获取支付宝地址"
  333. // #endif
  334. // #ifdef MP-WEIXIN
  335. state.formData[8].btnTitle = "获取微信地址"
  336. // #endif
  337. } else if (state.exchangeMode === "SELF") {
  338. //SELF-线上-营业点自提
  339. // state.formData[7].hide = false;
  340. state.formData[4].hide = true;
  341. state.formData[5].hide = true;
  342. state.formData[14].hide = false;
  343. console.log("1111111111111111111111111111")
  344. } else if (state.exchangeMode === "OFFLINE") {
  345. //OFFLINE-线下
  346. state.formData[14].hide = false;
  347. state.formData[6].itemData = [
  348. {
  349. checked: false,
  350. value: "SELF",
  351. name: "营业点自提",
  352. },
  353. ]
  354. }
  355. if (item.exchangeMode == "ON_LINE") {
  356. state.formData[14].hide = true;
  357. state.formData[6].itemData = [
  358. {
  359. checked: false,
  360. value: "MAIL",
  361. name: "邮寄",
  362. },
  363. ]
  364. for (let i = 9; i < 14; i++) {
  365. state.formData[i].hide = false;
  366. }
  367. }
  368. console.log("全部数据", state.formData)
  369. };
  370. //地址改变
  371. const addressInfo = (content : any) => {
  372. console.log("content", `${content.provinceName}${content.cityName}${content.countyName}`)
  373. // #ifdef MP-ALIPAY
  374. state.formData[9][state.formData[9].value] = content.fullname;
  375. state.formData[10][state.formData[10].value] = content.mobilePhone;
  376. let arr = [];
  377. arr.push(content.prov)
  378. arr.push(content.city)
  379. arr.push(content.area)
  380. state.formData[11][
  381. state.formData[11].value
  382. ] = arr;
  383. const addressArr = content.address.split("-")
  384. state.formData[12][state.formData[12].value] = addressArr[3];
  385. // #endif
  386. // #ifdef MP-WEIXIN
  387. state.formData[9][state.formData[9].value] = content.userName;
  388. state.formData[10][state.formData[10].value] = content.telNumber;
  389. let arr = [];
  390. arr.push(content.provinceName)
  391. arr.push(content.cityName)
  392. arr.push(content.countyName)
  393. state.formData[11][
  394. state.formData[11].value
  395. ] = arr;
  396. state.formData[12][state.formData[12].value] = content.detailInfo;
  397. state.formData[13][state.formData[13].value] = content.postalCode;
  398. // #endif
  399. };
  400. //提交换货申请
  401. const submit = (e : any) => {
  402. if (e.exchangeMode == "OFFLINE") {
  403. for (var k = 0; k < state.outlets.length; k++) {
  404. if (e.exchangeNetworkName == state.outlets[k]['name']) {
  405. e['exchangeNetworkId'] = state.outlets[k]['servicehallId']
  406. e['exchangeRgNetworkId'] = state.outlets[k]['servicehallId']
  407. console.log("e.exchangeRgNetworkName", e.exchangeNetworkName, e['exchangeNetworkId'])
  408. break;
  409. }
  410. }
  411. } else {
  412. for (var k = 0; k < state.outlets.length; k++) {
  413. if (e.exchangeRgNetworkName == state.outlets[k]['name']) {
  414. e['exchangeNetworkId'] = state.outlets[k]['servicehallId']
  415. e['exchangeRgNetworkId'] = state.outlets[k]['servicehallId']
  416. console.log("e.exchangeRgNetworkName", e.exchangeRgNetworkName, e['exchangeNetworkId'])
  417. break;
  418. }
  419. }
  420. }
  421. console.log("是否确认换货", e)
  422. confirm(
  423. "是否确认换货?",
  424. () => {
  425. const curOutletName =
  426. e.exchangeMode === "ON_LINE"
  427. ? e.exchangeRgNetworkName
  428. : e.exchangeNetworkName;
  429. const curOutlet = state.outlets.find((out) => out.name === curOutletName);
  430. const curRegin = e.region == null ? null : e.region;
  431. const options = {
  432. type: 2,
  433. data: {
  434. id: state.orderInfo.id,
  435. exchangeMode: e.exchangeMode,
  436. exchangeNetworkId: e.exchangeNetworkId,
  437. exchangeNetworkName: e.exchangeRgNetworkName ? e.exchangeRgNetworkName : e.exchangeNetworkName, //换货网点
  438. exchangeRgMode: e.exchangeMode == "ON_LINE" ? 'MAIL' : "SELF",
  439. exchangeRgNetworkId: e.exchangeRgNetworkId,
  440. exchangeRgNetworkName: e.exchangeRgNetworkName ? e.exchangeRgNetworkName : e.exchangeNetworkName, //自提网点
  441. exchangeLogisticsCompany: e.exchangeLogisticsCompany,
  442. exchangeLogisticsNumber: e.exchangeLogisticsNumber,
  443. exchangeReason: e.exchangeReason,
  444. consignee: e.consignee,
  445. consigneeTel: e.consigneeTel,
  446. region: curRegin ? `${curRegin[0]}${curRegin[1]}${curRegin[2]}` : "",
  447. address: e.address,
  448. postalCode: e.postalCode,
  449. opId: getItem(StorageKeys.OpenId),
  450. },
  451. method: "POST",
  452. showLoading: true,
  453. };
  454. console.log("提交数据", options);
  455. request(orderExchange, options).then((res) => {
  456. confirm(
  457. "您申办的ETC订单已申请换货",
  458. () => {
  459. uni.$emit("refreshOrder");
  460. uni.navigateBack();
  461. },
  462. "申请成功",
  463. false
  464. );
  465. });
  466. },
  467. "换货确认",
  468. true
  469. );
  470. };
  471. onLoad((option) => {
  472. console.log(option);//id是申请的接口获取的id
  473. getOrderDetails(option.orderId);
  474. getLogisticsList();
  475. getOutletList();
  476. });
  477. </script>
  478. <style>
  479. page {
  480. background-color: #f3f3f3;
  481. padding-bottom: 30rpx;
  482. }
  483. </style>
  484. <style lang="scss" scoped>
  485. .box {
  486. margin: 20rpx 0rpx;
  487. background-color: white;
  488. padding: 0 20rpx 20rpx;
  489. }
  490. </style>