123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518 |
- <!-- 申请换货 -->
- <template>
- <view class="box">
- <form-builder :config="config" :formData="state.formData" @submit="submit" @addressInfo="addressInfo"
- @radioChange="radioChange" @handleGetRegion="handleGetRegion" />
- </view>
- </template>
-
- <script setup lang="ts">
- import { reactive } from "vue";
- import { onLoad } from "@dcloudio/uni-app";
- import { msg, confirm, getOrderStatusName } from "@/utils/utils";
- import { request } from "@/utils/network/request";
- import {
- getLogistics,
- orderDetail,
- orderExchange,
- outletList,
- } from "@/utils/network/api";
- import { stringToJson } from "@/utils/network/encryption";
- import { getItem, StorageKeys } from "@/utils/storage";
-
- const config = {
- submitName: "申请换货",
- titleWidth: 160,
- };
-
- const state = reactive({
- address:"",
- //订单信息
- orderInfo: {} as any,
- //网点信息
- outlets: [],
- //换货类型: MAIL-线上-邮寄 SELF-线上-自提 OFFLINE-线下
- exchangeMode: "SELF",
- formData: [
- {
- title: "订单编号:",
- inputType: "number",
- type: 2,
- value: "id",
- hint: "订单编号",
- disabled: true,
- divider: true,
- },
- {
- title: "订单车牌号:",
- type: 2,
- value: "vehiclePlate",
- hint: "订单车牌号",
- disabled: true,
- divider: true,
- },
- {
- title: "订单状态:",
- type: 2,
- value: "orderStep",
- hint: "订单状态",
- disabled: true,
- divider: true,
- },
- {
- title: "换货方式:",
- type: 7,
- value: "exchangeMode",
- exchangeMode: "ON_LINE",
- star: true,
- required: true,
- divider: true,
- emptyHint: "请选择换货方式",
- itemData: [
- {
- checked: true,
- value: "ON_LINE",
- name: "线上",
- },
- // 取消线下网点退货,隐藏对应模式,不要删除,后期可能还会重提业务修改
- // {
- // checked: false,
- // value: "OFFLINE",
- // name: "线下",
- // },
- ],
- },
-
- /* 区别-线上方式 */
- {
- title: "物流公司:",
- type: 4,
- value: "exchangeLogisticsCompany",
- required: true,
- star: true,
- hint: "请输入",
- divider: true,
- itemData: [],
- hide: false,
- emptyHint: "请选择物流公司",
- mode: "search",
- searchPickerVisible: false,
- },
- {
- title: "物流单号:",
- type: 2,
- value: "exchangeLogisticsNumber",
- required: true,
- maxlength: 20,
- hint: "请输入",
- emptyHint: "请输入物流单号",
- star: true,
- divider: true,
- hide: false,
- },
- {
- title: "收货方式:",
- type: 7,
- value: "exchangeRgMode",
- required: true,
- star: true,
- divider: true,
- itemData: [
- // {
- // checked: false,
- // value: "SELF",
- // name: "营业点自提",
- // },
- {
- checked: false,
- value: "MAIL",
- name: "邮寄",
- },
- ],
- hide: false,
- emptyHint: "请选择收货方式",
- },
-
- /* 线上-营业点自提 */
- {
- title: "自提网点:",
- type: 4,
- value: "exchangeRgNetworkName",
- required: true,
- star: true,
- hint: "请输入",
- divider: true,
- hide: true,
- itemData: [],
- emptyHint: "请选择自提网点",
- mode: "search",
- searchPickerVisible: false,
- },
-
- /* 线上-邮寄 */
- {
- title: "收件人地址:",
- type: 2,
- value: "address",
- maxlength: 50,
- hint: " ",
- disabled: true,
- divider: true,
- btn: true,
- btnTitle: "获取微信地址",
- btnType: "address",
- hide: true,
- },
- {
- title: "姓名:",
- type: 2,
- value: "consignee",
- maxlength: 20,
- required: true,
- hint: "请输入",
- emptyHint: "请输入收件人姓名",
- star: true,
- divider: true,
- hide: true,
- },
- {
- title: "电话:",
- type: 2,
- value: "consigneeTel",
- required: true,
- inputType: "number",
- maxlength: 11,
- hint: "请输入",
- emptyHint: "请输入收件人电话",
- star: true,
- divider: true,
- hide: true,
- },
- {
- title: "地区:",
- type: 10,
- value: "region",
- required: true,
- hint: "选择省/市/区",
- emptyHint: "请选择收件人所在地区",
- star: true,
- divider: true,
- hide: true,
- },
- {
- title: "详细地址:",
- type: 2,
- value: "address",
- maxlength: 100,
- required: true,
- hint: "街道门牌、楼层房间号等信息",
- emptyHint: "请输入收件人详细地址",
- star: true,
- divider: true,
- hide: true,
- // disabled: true,
- },
- {
- title: "邮政编码:",
- type: 2,
- value: "postalCode",
- inputType: "number",
- maxlength: 20,
- hint: "请输入邮政编码",
- emptyHint: "请输入邮政编码",
- divider: true,
- hide: true,
- },
-
- /* 区别-线下方式 */
- {
- title: "换货网点:",
- type: 4,
- value: "exchangeNetworkName",
- required: true,
- star: true,
- hint: "请输入",
- divider: true,
- itemData: ["1"],
- hide: true,
- emptyHint: "请选择换货网点",
- mode: "search",
- searchPickerVisible: false,
- },
-
- {
- title: "换货原因:",
- required: true,
- type: 5,
- vertical: 2,
- value: "exchangeReason",
- maxlength: 50,
- bg: true,
- star: true,
- hint: "请输入换货原因,限制50字以内",
- emptyHint: "请输入换货原因",
- },
- ],
- });
-
- /* 获取订单详情 */
- const getOrderDetails = (id) => {
- const options = {
- type: 2,
- data: { id: id },
- method: "POST",
- showLoading: true,
- };
- request(orderDetail, options).then((res) => {
- //回显订单信息
- console.log("回显订单信息", stringToJson(res.bizContent))
- state.orderInfo = stringToJson(res.bizContent);
- state.formData[0].hint = state.orderInfo.orderId;
- state.formData[1].hint = state.orderInfo.vehiclePlate;
- state.formData[2].hint = getOrderStatusName(state.orderInfo.orderStep);
-
- //回显收件人地址
- state.formData[9][state.formData[9].value] =
- state.orderInfo.orderInfoExt.consignee;
- state.formData[10][state.formData[10].value] =
- state.orderInfo.orderInfoExt.consigneeTel;
- state.formData[11][state.formData[11].value] =
- state.orderInfo.orderInfoExt.regionList.slice(0, 3);
- state.formData[12][state.formData[12].value] =
- state.orderInfo.orderInfoExt.address;
- state.formData[13][state.formData[13].value] =
- state.orderInfo.orderInfoExt.postalCode;
- });
- };
-
- /* 获取所有的快递公司 */
- const getLogisticsList = () => {
- const options = {
- type: 2,
- data: {},
- method: "POST",
- showLoading: true,
- };
- request(getLogistics, options).then((res) => {
- const data = stringToJson(res.bizContent);
- state.formData[4].itemData = data;
- });
- };
-
- /* 获取换货网点 */
- const getOutletList = () => {
- const options = {
- type: 2,
- data: {},
- method: "POST",
- showLoading: true,
- };
- request(outletList, options).then((res) => {
- state.outlets = stringToJson(res.bizContent);
-
- let nameList = [];
- state.outlets.map((item) => {
- nameList.push(item.name);
- });
-
- state.formData[7].itemData = nameList;
- state.formData[14].itemData = nameList;
- console.log("获取换货网点", state.outlets, nameList)
- });
-
- };
-
- //radio改变
- const radioChange = (e : any, item : any) => {
- console.log("e", e, item)
- if (item.value === "exchangeMode") {
- //退货方式
- state.exchangeMode =
- item.exchangeMode === "ON_LINE" ? state.formData[6][state.formData[6].value] ? state.formData[6][state.formData[6].value] : "SELF"
- : item.exchangeMode;
-
- } else if (item.value === "exchangeRgMode") {
- //收货方式
- state.exchangeMode = item.exchangeRgMode;
- console.log("item", item, state.exchangeMode)
- }
-
- state.formData[4].hide = state.exchangeMode === "OFFLINE" ? true : false;
- state.formData[5].hide = state.exchangeMode === "OFFLINE" ? true : false;
- // state.formData[6].hide = state.exchangeMode === "OFFLINE" ? true : false;
- for (let i = 7; i < 15; i++) {
- state.formData[i].hide = true;
- }
- if (state.exchangeMode === "MAIL") {
- //MAIL-线上-邮寄
- for (let i = 9; i < 14; i++) {
- state.formData[i].hide = false;
- }
- // #ifdef MP-ALIPAY
- state.formData[8].btnTitle = "获取支付宝地址"
- // #endif
- // #ifdef MP-WEIXIN
- state.formData[8].btnTitle = "获取微信地址"
- // #endif
- } else if (state.exchangeMode === "SELF") {
- //SELF-线上-营业点自提
- // state.formData[7].hide = false;
- state.formData[4].hide = true;
- state.formData[5].hide = true;
- state.formData[14].hide = false;
- console.log("1111111111111111111111111111")
- } else if (state.exchangeMode === "OFFLINE") {
- //OFFLINE-线下
- state.formData[14].hide = false;
- state.formData[6].itemData = [
- {
- checked: false,
- value: "SELF",
- name: "营业点自提",
- },
- ]
- }
- if (item.exchangeMode == "ON_LINE") {
- state.formData[14].hide = true;
- state.formData[6].itemData = [
- {
- checked: false,
- value: "MAIL",
- name: "邮寄",
- },
- ]
- for (let i = 9; i < 14; i++) {
- state.formData[i].hide = false;
- }
- }
- console.log("全部数据", state.formData)
- };
- //地址改变
- const addressInfo = (content : any) => {
- console.log("content", `${content.provinceName}${content.cityName}${content.countyName}`)
- // #ifdef MP-ALIPAY
- state.formData[9][state.formData[9].value] = content.fullname;
- state.formData[10][state.formData[10].value] = content.mobilePhone;
- let arr = [];
- arr.push(content.prov)
- arr.push(content.city)
- arr.push(content.area)
- state.formData[11][
- state.formData[11].value
- ] = arr;
- const addressArr = content.address.split("-")
- state.formData[12][state.formData[12].value] = addressArr[3];
- // #endif
- // #ifdef MP-WEIXIN
- state.formData[9][state.formData[9].value] = content.userName;
- state.formData[10][state.formData[10].value] = content.telNumber;
- let arr = [];
- arr.push(content.provinceName)
- arr.push(content.cityName)
- arr.push(content.countyName)
- state.formData[11][
- state.formData[11].value
- ] = arr;
- state.formData[12][state.formData[12].value] = content.detailInfo;
- state.formData[13][state.formData[13].value] = content.postalCode;
- // #endif
- };
-
- //提交换货申请
- const submit = (e : any) => {
- if (e.exchangeMode == "OFFLINE") {
- for (var k = 0; k < state.outlets.length; k++) {
- if (e.exchangeNetworkName == state.outlets[k]['name']) {
- e['exchangeNetworkId'] = state.outlets[k]['servicehallId']
- e['exchangeRgNetworkId'] = state.outlets[k]['servicehallId']
- console.log("e.exchangeRgNetworkName", e.exchangeNetworkName, e['exchangeNetworkId'])
- break;
- }
- }
- } else {
- for (var k = 0; k < state.outlets.length; k++) {
- if (e.exchangeRgNetworkName == state.outlets[k]['name']) {
- e['exchangeNetworkId'] = state.outlets[k]['servicehallId']
- e['exchangeRgNetworkId'] = state.outlets[k]['servicehallId']
- console.log("e.exchangeRgNetworkName", e.exchangeRgNetworkName, e['exchangeNetworkId'])
- break;
- }
- }
- }
-
- console.log("是否确认换货", e)
- confirm(
- "是否确认换货?",
- () => {
- const curOutletName =
- e.exchangeMode === "ON_LINE"
- ? e.exchangeRgNetworkName
- : e.exchangeNetworkName;
- const curOutlet = state.outlets.find((out) => out.name === curOutletName);
- const curRegin = e.region == null ? null : e.region;
- const options = {
- type: 2,
- data: {
- id: state.orderInfo.id,
- exchangeMode: e.exchangeMode,
- exchangeNetworkId: e.exchangeNetworkId,
- exchangeNetworkName: e.exchangeRgNetworkName ? e.exchangeRgNetworkName : e.exchangeNetworkName, //换货网点
- exchangeRgMode: e.exchangeMode == "ON_LINE" ? 'MAIL' : "SELF",
- exchangeRgNetworkId: e.exchangeRgNetworkId,
- exchangeRgNetworkName: e.exchangeRgNetworkName ? e.exchangeRgNetworkName : e.exchangeNetworkName, //自提网点
- exchangeLogisticsCompany: e.exchangeLogisticsCompany,
- exchangeLogisticsNumber: e.exchangeLogisticsNumber,
- exchangeReason: e.exchangeReason,
- consignee: e.consignee,
- consigneeTel: e.consigneeTel,
- region: curRegin ? `${curRegin[0]}${curRegin[1]}${curRegin[2]}` : "",
- address: e.address,
- postalCode: e.postalCode,
- opId: getItem(StorageKeys.OpenId),
- goodsAddress:state.address
- },
- method: "POST",
- showLoading: true,
- };
- console.log("提交数据", options);
- request(orderExchange, options).then((res) => {
- confirm(
- "您申办的ETC订单已申请换货,待审核,请到【查询服务】的【业务审核查询】查看进度",
- () => {
- uni.$emit("refreshOrder");
- uni.navigateBack({
- delta: 2
- })
- },
- "申请成功",
- false
- );
- });
- },
- "换货确认",
- true
- );
- };
-
- onLoad((option) => {
- console.log(option);//id是申请的接口获取的id
- getOrderDetails(option.orderId);
- getLogisticsList();
- getOutletList();
- state.address=option.address
- });
- </script>
-
- <style>
- page {
- background-color: #f3f3f3;
- padding-bottom: 30rpx;
- }
- </style>
- <style lang="scss" scoped>
- .box {
- margin: 20rpx 0rpx;
- background-color: white;
- padding: 0 20rpx 20rpx;
- }
- </style>
|