Authored by 张文文

买家和卖家修改一次寄回地址

... ... @@ -122,7 +122,7 @@ export default {
//编辑地址时保存item
if (!isAdd) {
let addressInfo = JSON.parse(item || '{}');
Object.assign(addressInfo, { isUpdate: !isAdd, orderCode: '' });
Object.assign(addressInfo, { isUpdate: !isAdd });
this.STORE_UPDATE_ADDRESS_INFO(addressInfo);
} else {
... ...
... ... @@ -23,7 +23,7 @@
<FormItem>
<div class="wrapper-area">
<label class="input-label">所在区域</label>
<div class="wrapper-arrow" @click="chooseArea">
<div class="wrapper-arrow" @click="popArea">
<template v-if="area">
<label class="text-label">{{ area }}</label>
</template>
... ... @@ -44,8 +44,8 @@
:textValue="address"
></CInput>
</FormItem>
<!-- 订单修改地址隐藏 -->
<div v-if="!orderCode" class="wrapper-tag">
<div class="wrapper-tag">
<p v-if="addressTags.length" class="tag-text">设置标签:</p>
<div class="radio-container">
<RadioGroup class="wrapper-radio">
... ... @@ -60,8 +60,8 @@
</RadioGroup>
</div>
</div>
<!-- 订单修改地址隐藏 -->
<div v-if="!orderCode" class="wrapper-del">
<div class="wrapper-default">
<Radio
class="radio"
:label="{ text: '设为默认地址', value: true }"
... ... @@ -74,13 +74,12 @@
<div class="white-space"></div>
<div :class="submitClass" @touchend="onSubmit">确 认</div>
<AddressAct
class="address-act"
ref="addressAct"
v-show="isShowProvince"
<EditAreaAct
ref="areaAct"
v-show="showAreaAct"
@popHidden="popHidden"
@modifyAddressAct="modifyAddressAct"
></AddressAct>
@modifyAreaInfo="modifyAreaInfo"
></EditAreaAct>
</LayoutApp>
</template>
... ... @@ -89,12 +88,10 @@ import Layout from '../../../components/layout/layout-app';
import Input from './components/input';
import FormItem from './components/form-item';
import Radio from './components/radio';
import AddressAct from './components/address-act';
import RadioGroup from './components/radio-group';
import { Scroll } from 'cube-ui';
import EditAreaAct from './components/edit-area-act';
import { createNamespacedHelpers } from 'vuex';
const { mapState, mapMutations, mapActions } = createNamespacedHelpers(
'address/address'
);
... ... @@ -105,19 +102,18 @@ export default {
LayoutApp: Layout,
CInput: Input,
FormItem,
Radio,
AddressAct,
RadioGroup,
Scroll
Radio,
EditAreaAct
},
data() {
return {
isShowProvince: false,
showAreaAct: false,
isUpdate: false,
updateMobileNum: '',
isMobileNumEdit: false,
title: '',
orderCode: '',
mobileNumEdit: false,
mobileNum: '',
consignee: '',
address_id: '',
... ... @@ -131,10 +127,10 @@ export default {
},
watch: {
mobile: function(val) {
if (val === this.updateMobileNum) {
this.isMobileNumEdit = false;
if (val === this.mobileNum) {
this.mobileNumEdit = false;
} else {
this.isMobileNumEdit = true;
this.mobileNumEdit = true;
}
}
},
... ... @@ -163,14 +159,11 @@ export default {
'fetchAddressTags',
'addUserAddress',
'updateUserAddress',
'deleteUserAddress',
'updateReceiptAddressInOrder'
'deleteUserAddress'
]),
async onSubmit() {
let data = this.validator();
// 订单编辑地址
const orderCode = this.orderCode;
if (!data) {
return;
... ... @@ -179,15 +172,7 @@ export default {
let result = {};
if (this.isUpdate) {
//更新和添加地址接口不同
if (orderCode) {
result = await this.updateReceiptAddressInOrder({
...data,
orderCode
});
} else {
result = await this.updateUserAddress(data);
}
} else {
result = await this.addUserAddress(data);
}
... ... @@ -223,7 +208,7 @@ export default {
}
let reg;
if (this.isUpdate && !this.isMobileNumEdit) {
if (this.isUpdate && !this.mobileNumEdit) {
reg = /^[0123456789*]{11}$/;
} else {
reg = /^[0123456789]{11}$/;
... ... @@ -277,21 +262,19 @@ export default {
}).show();
}
},
chooseArea() {
this.isShowProvince = true;
popArea() {
this.showAreaAct = true;
this.$refs.paneBody.style.overflow = 'hidden';
this.$refs.addressAct.parentHandleclick({
this.$refs.areaAct.parentHandleclick({
areaCode: this.area_code
});
},
popHidden() {
let that = this;
this.$refs.paneBody.style.overflow = 'auto';
that.isShowProvince = false;
this.showAreaAct = false;
},
modifyAddressAct(info) {
modifyAreaInfo(info) {
if (info) {
let that = this;
that.area_code = info.code;
... ... @@ -314,22 +297,18 @@ export default {
},
activated() {
this.fetchAddressTags();
let addressInfo = this.updateAddressInfo;
this.isUpdate = addressInfo.isUpdate;
this.orderCode = addressInfo.orderCode;
this.title = addressInfo.isUpdate ? '编辑地址' : '添加地址';
// 订单编辑 不查标签
if (!this.orderCode) {
this.fetchAddressTags();
}
if (addressInfo.isUpdate) {
this.updateMobileNum = addressInfo.mobile;
this.consignee = addressInfo.consignee;
this.address_id = addressInfo.address_id;
this.mobile = addressInfo.mobile;
this.mobileNum = addressInfo.mobile;
this.area_code = addressInfo.area_code || addressInfo.areaCode;
this.area = addressInfo.area;
this.address = addressInfo.address;
... ... @@ -353,22 +332,6 @@ export default {
padding-right: 40px;
}
.wrapper-del {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
height: 80px;
.del-address {
width: 150px;
text-align: center;
line-height: 80px;
color: #cd001a;
font-size: 26px;
}
}
.wrapper-area {
display: flex;
flex-direction: column;
... ... @@ -423,6 +386,14 @@ export default {
}
}
.wrapper-default {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
height: 80px;
}
.radio-container {
width: 100%;
margin-top: 30px;
... ...
<template>
<LayoutApp title="修改地址" :show-back="true">
<div class="pane-body" ref="paneBody">
<FormItem>
<CInput
label="收货人"
place-holder="请写姓名"
v-model="consignee"
:textValue="consignee"
type="text"
></CInput>
</FormItem>
<FormItem>
<CInput
label="手机号"
place-holder="请填写手机号"
v-model="mobile"
:textValue="mobile"
></CInput>
</FormItem>
<template>
<FormItem>
<div class="wrapper-province">
<label class="province-label">所在省</label>
<label class="province-text">{{province}}</label>
</div>
</FormItem>
</template>
<template>
<FormItem>
<div class="wrapper-area">
<label class="input-label">所在区域</label>
<div class="wrapper-arrow" @click="popArea">
<template v-if="area">
<label class="text-label">{{ area }}</label>
</template>
<template v-else>
<label class="choose-area">请选择</label>
</template>
<div class="arrow"></div>
</div>
</div>
</FormItem>
</template>
<FormItem>
<CInput
label="详细地址"
place-holder="请输入详细地址"
v-model="address"
:textValue="address"
></CInput>
</FormItem>
<div class="tip-wrapper">
<span><i class="iconfont iconquestion icon-class"></i></span>
<p class="tip">暂不支持省地址修改,地址仅可修改一次,请您谅解</p>
</div>
</div>
<div class="white-space"></div>
<div :class="submitClass" @touchend="onSubmit">确认修改</div>
<ModifyAreaAct
ref="areaAct"
v-show="showAreaAct"
@popHidden="popHidden"
@modifyAreaInfo="modifyAreaInfo"
></ModifyAreaAct>
</LayoutApp>
</template>
<script>
import Layout from '../../../components/layout/layout-app';
import Input from './components/input';
import FormItem from './components/form-item';
import Radio from './components/radio';
import RadioGroup from './components/radio-group';
import ModifyAreaAct from './components/modify-area-act';
import { createNamespacedHelpers } from 'vuex';
const { mapState, mapMutations, mapActions } = createNamespacedHelpers(
'address/address'
);
export default {
name: 'addressModify',
components: {
LayoutApp: Layout,
CInput: Input,
FormItem,
RadioGroup,
Radio,
ModifyAreaAct
},
data() {
return {
showAreaAct: false,
mobileNum: '',
mobileNumEdit: false,
orderCode: '',
fromPage: '',
consignee: '',
address_id: '',
mobile: '',
area_code: '',
area: '',
fullArea: '',
province: '',
address: '',
};
},
watch: {
mobile: function(val) {
if (val === this.mobileNum) {
this.mobileNumEdit = false;
} else {
this.mobileNumEdit = true;
}
}
},
computed: {
...mapState(['updateAddressInfo']),
submitClass() {
return [
'sure-btn',
{
active: this.inNotEmpty
}
];
},
inNotEmpty() {
return (
this.consignee &&
this.mobile &&
this.area &&
this.address
);
}
},
methods: {
...mapMutations({}),
...mapActions(['updateReceiptAddressInOrder', 'updateDeliverAddressInOrder', 'fetchAddressProvinces']),
async onSubmit() {
let data = this.validator();
if (!data) {
return;
}
let result = {};
const orderCode = this.orderCode;
if (this.fromPage === 'BuyerOrder') {
result = await this.updateReceiptAddressInOrder({
...data,
orderCode
});
} else { //fromPage='SellerOrder'
result = await this.updateDeliverAddressInOrder({
...data,
orderCode
});
}
if (result && result.code === 200) {
this.$createToast({
type: 'txt',
txt: result.message.split('.').join('')
}).show();
await this.sleep(1000);
this.$router.go(-1);
} else {
this.$createToast({
type: 'error',
txt: result.message,
mask: true
}).show();
}
},
validator() {
let username = this.consignee.replace(/(^\s+)|(\s+$)/g, '');
// 简单的表单校验
if (!username) {
this.showToast('收件人不能为空');
return false;
}
if (!/^[\u4E00-\u9FA5A-Za-z0-9*]+$/gi.test(username)) {
this.showToast('收货人姓名不支持特殊符号');
return false;
}
let reg;
if (!this.mobileNumEdit) {
reg = /^[0123456789*]{11}$/;
} else {
reg = /^[0123456789]{11}$/;
}
if (!this.mobile) {
this.showToast('手机号不能为空');
return false;
} else {
if (!reg.test(this.mobile)) {
this.showToast('请输入正确11位手机号码');
return;
}
}
if (!this.area_code || !this.area) {
this.showToast('省市区不能为空');
return false;
}
if (!this.address) {
this.showToast('地址不能为空');
return false;
}
let fullArea = this.province + this.area;
return {
id: this.address_id || '',
consignee: username,
mobile: this.mobile,
area_code: this.area_code,
area: fullArea,
address: this.address,
is_default: 'N', //is_default和tag_code直接设置空即可
tag_code: ''
};
},
popArea() {
this.showAreaAct = true;
this.$refs.paneBody.style.overflow = 'hidden';
this.$refs.areaAct.parentHandleclick({
areaCode: this.area_code,
provinceTitle: this.province
});
},
popHidden() {
this.$refs.paneBody.style.overflow = 'auto';
this.showAreaAct = false;
},
modifyAreaInfo(info) {
if (info) {
let that = this;
that.area_code = info.code;
that.area = info.area.split(this.province).join('');
}
},
showToast(tip) {
this.$createToast({
type: 'txt',
txt: tip
}).show();
},
sleep(n) {
return new Promise(resolve => {
setTimeout(() => {
resolve();
}, n);
});
}
},
async activated() {
let addressInfo = this.updateAddressInfo;
this.fromPage = this.$route.query.fromPage;
this.orderCode = addressInfo.orderCode;
this.consignee = addressInfo.consignee;
this.address_id = addressInfo.address_id;
this.mobile = addressInfo.mobile;
this.mobileNum = addressInfo.mobile; //用作监听有没有修改电话
this.area_code = addressInfo.area_code || addressInfo.areaCode;
this.fullArea = addressInfo.area;
this.address = addressInfo.address;
let provinceId = this.area_code.substring(0, 2);
let provinceCaption = '';
const provinceResult = await this.fetchAddressProvinces(0);
let provinces = provinceResult.data;
provinces.map(info => {
if (info.id === provinceId) {
provinceCaption = info.caption;
}
});
this.province = provinceCaption;
this.area = this.fullArea.split(this.province).join('');
}
};
</script>
<style lang="scss" scoped>
.pane-body {
height: 100%;
overflow-y: auto;
padding-top: 12px;
padding-left: 40px;
padding-right: 40px;
}
.wrapper-province {
display: flex;
flex-direction: column;
.province-label {
font-size: 36px;
display: inline-block;
font-weight: bold;
margin-bottom: 30px;
color: #ccc;
}
.province-text {
font-size: 28px;
width: 100%;
color: #ccc;
display: inline-block;
}
}
.wrapper-area {
display: flex;
flex-direction: column;
.input-label {
font-size: 36px;
display: inline-block;
font-weight: bold;
margin-bottom: 30px;
}
.text-label {
font-size: 28px;
width: 100%;
color: #444444;
display: inline-block;
}
.choose-area {
font-size: 28px;
width: 100%;
color: #cccccc;
}
.wrapper-arrow {
display: flex;
justify-content: space-between;
}
.arrow {
height: 44px;
width: 44px;
background: url("~statics/image/address/arrow-right.png");
background-size: cover;
}
}
.tip-wrapper {
display: flex;
flex-direction: row;
margin-top: 5px;
height: 40px;
.icon-class {
line-height: 40px;
color: #d8d8d8;
font-size: 24px;
}
.tip {
margin-left: 8px;
line-height: 40px;
font-size: 24px;
color: #a1a1a1;
}
}
.white-space {
position: relative;
display: block;
overflow: hidden;
height: 120px;
}
.sure-btn {
height: 80px;
line-height: 80px;
font-size: 32px;
font-weight: bold;
text-align: center;
background-color: #cccccc;
color: white;
border-radius: 40px;
position: fixed;
left: 32px;
right: 32px;
bottom: 24px;
&.active {
background-color: #002b47;
}
}
</style>
... ...
... ... @@ -234,7 +234,7 @@ export default {
let returnTitle = this.returnTitle();
this.$emit("popHidden");
this.$emit("modifyAddressAct", {
this.$emit("modifyAreaInfo", {
code: id,
area: returnTitle
});
... ...
<template>
<div class="address-select-component">
<div class="address-select-box">
<div class="component-title">
<span class="title">选择地区</span>
<span class="icon-close close" @click="closeAddBox"></span>
</div>
<ul class="head-address-ul">
<li
v-if="province.title"
:class="{ 'head-address-li': province.titleActive }"
>{{province.title}}</li>
<li
v-if="city.title"
:class="{ 'head-address-li': city.titleActive }"
@click="clickTitle('city')"
>{{city.title}}</li>
<li
v-if="area.title"
:class="{ 'head-address-li': area.titleActive }"
@click="clickTitle('area')"
>{{area.title}}</li>
<li
v-if="street.title"
:class="{ 'head-address-li': street.titleActive }"
@click="clickTitle('street')"
>{{street.title}}</li>
</ul>
<div class="address-container">
<div class="address-content">
<ul v-if="province.showList" class="address-ul">
<li
v-for="(pprovince, index) in provinces"
:key="index"
:class="{active: pprovince.id === province.id}"
>
{{pprovince.caption}}
<span v-if="pprovince.id === province.id" class="icon-check"></span>
</li>
</ul>
<ul v-if="city.showList" class="address-ul">
<li
v-for="(pcity, index) in citys"
:key="index"
:class="{active: pcity.id === city.id}"
@click="switchAddress(pcity.id, pcity.caption)"
>
{{pcity.caption}}
<span v-if="pcity.id === city.id" class="icon-check"></span>
</li>
</ul>
<ul v-if="area.showList" class="address-ul">
<li
v-for="(parea, index) in areas"
:key="index"
:class="{active: parea.id === area.id}"
@click="switchAddress(parea.id, parea.caption)"
>
{{parea.caption}}
<span v-if="parea.id === area.id" class="icon-check"></span>
</li>
</ul>
<ul v-if="street.showList" class="address-ul">
<li
v-for="(pstreet, index) in streets"
:key="index"
:class="{active: pstreet.id === street.id}"
@click="switchAddress(pstreet.id, pstreet.caption)"
>
{{pstreet.caption}}
<span v-if="pstreet.id === street.id" class="icon-check"></span>
</li>
</ul>
</div>
</div>
</div>
</div>
</template>
<script>
import { createNamespacedHelpers } from "vuex";
const { mapState, mapMutations, mapActions } = createNamespacedHelpers(
"address/address"
);
export default {
data() {
return {
provinces: [],
citys: [],
areas: [],
streets: [],
province: {
id: "",
title: "",
allTitle: "",
showList: false,
titleActive: false
},
city: {
id: "",
title: "",
allTitle: "",
showList: false,
titleActive: false
},
area: {
id: "",
title: "",
allTitle: "",
showList: false,
titleActive: false
},
street: {
id: "",
title: "",
allTitle: "",
showList: false,
titleActive: false
}
};
},
computed: {
...mapState(["provincesList"])
},
methods: {
...mapMutations({}),
...mapActions(["fetchAddressProvinces"]),
/* 处理编辑时父组件传递的省市区 */
async parentHandleclick({ areaCode, provinceTitle }) {
if (areaCode === "" || areaCode === undefined) {
return;
}
if (areaCode.length < 2) {
return;
}
//省
this.province.allTitle = provinceTitle;
this.province.title = this.titleHandle(provinceTitle);
if (areaCode.length < 4) {
return;
}
//市
let citysCaption = "";
this.city.id = areaCode.substring(0, 4);
const cityResult = await this.fetchAddressProvinces(
areaCode.substring(0, 2)
);
this.citys = cityResult.data;
this.citys.map(info => {
if (info.id === this.city.id) {
citysCaption = info.caption;
}
});
this.city.allTitle = citysCaption;
this.city.title = this.titleHandle(citysCaption);
if (areaCode.length < 6) {
return;
}
//县
let areasCaption = "";
this.area.id = areaCode.substring(0, 6);
const areaResult = await this.fetchAddressProvinces(
areaCode.substring(0, 4)
);
this.areas = areaResult.data;
this.areas.map(info => {
if (info.id === this.area.id) {
areasCaption = info.caption;
}
});
this.area.allTitle = areasCaption;
this.area.title = this.titleHandle(areasCaption);
if (areaCode.length < 9) {
return;
}
//街道
let streetsCaption = "";
this.street.id = areaCode.substring(0, 9);
const result = await this.fetchAddressProvinces(areaCode.substring(0, 6));
this.streets = result.data;
this.streets.map(info => {
if (info.id === this.street.id) {
streetsCaption = info.caption;
}
});
this.street.allTitle = streetsCaption;
this.street.title = this.titleHandle(streetsCaption);
this.street.showList = this.street.titleActive = true;
this.province.showList = this.city.showList = this.area.showList = false;
this.province.titleActive = this.city.titleActive = this.area.titleActive = false;
},
/* 获取地址数据绑定 */
async switchAddress(id, caption) {
if (!id) {
return;
}
this.changeShow(id, caption);
const result = await this.fetchAddressProvinces(id);
let resultData = result.data;
//length小于1时弹窗消失并传数据给上层
if (resultData && resultData.length < 1) {
let returnTitle = this.returnTitle();
this.$emit("popHidden");
this.$emit("modifyAreaInfo", {
code: id,
area: returnTitle
});
}
/* 数据绑定 */
switch ((id + "").length) {
case 2:
this.citys = resultData;
break;
case 4:
this.areas = resultData;
break;
case 6:
this.streets = resultData;
break;
default:
this.provinces = resultData;
break;
}
},
/* 选择地址后的显示控制 */
changeShow(id, caption) {
switch ((id + "").length) {
case 2:
if (this.province.id && this.province.id !== id) {
this.area.title = this.street.title = "";
}
this.city.title = "请选择";
this.province.id = id;
this.province.allTitle = caption;
this.province.title = this.titleHandle(caption);
this.city.showList = this.city.titleActive = true;
this.province.showList = this.area.showList = this.street.showList = false;
this.province.titleActive = this.area.titleActive = this.street.titleActive = false;
break;
case 4:
if (this.city.id && this.city.id !== id) {
this.street.title = "";
}
this.area.title = "请选择";
this.city.id = id;
this.city.allTitle = caption;
this.city.title = this.titleHandle(caption);
this.area.showList = this.area.titleActive = true;
this.province.showList = this.city.showList = this.street.showList = false;
this.province.titleActive = this.city.titleActive = this.street.titleActive = false;
break;
case 6:
this.street.title = "请选择";
this.area.id = id;
this.area.allTitle = caption;
this.area.title = this.titleHandle(caption);
this.street.showList = this.street.titleActive = true;
this.province.showList = this.city.showList = this.area.showList = false;
this.province.titleActive = this.city.titleActive = this.area.titleActive = false;
break;
case 9:
this.street.id = id;
this.street.allTitle = caption;
this.street.title = this.titleHandle(caption);
break;
default:
if (this.province.id.length === 0) {
this.province.title = "请选择";
}
this.province.showList = this.province.titleActive = true;
this.city.showList = this.area.showList = this.street.showList = false;
this.city.titleActive = this.area.titleActive = this.street.titleActive = false;
break;
}
},
/* 点击地址标题时的处理 */
clickTitle(type) {
switch (type) {
case "city":
this.city.titleActive = true;
this.city.showList = true;
this.province.titleActive = this.area.titleActive = this.street.titleActive = false;
this.province.showList = this.area.showList = this.street.showList = false;
break;
case "area":
this.area.titleActive = true;
this.area.showList = true;
this.province.titleActive = this.city.titleActive = this.street.titleActive = false;
this.province.showList = this.city.showList = this.street.showList = false;
break;
case "street":
this.street.titleActive = true;
this.street.showList = true;
this.province.titleActive = this.city.titleActive = this.area.titleActive = false;
this.province.showList = this.city.showList = this.area.showList = false;
break;
default:
break;
}
},
/* 关闭地址选择组件 */
closeAddBox() {
this.$emit("popHidden");
},
/* 返回标题处理 */
returnTitle() {
let getTitle = "";
let returnTitle = "";
getTitle =
this.province.allTitle +
this.city.allTitle +
this.area.allTitle +
this.street.allTitle;
if (getTitle.length > 18) {
returnTitle = getTitle.substr(0, 8) + "..." + getTitle.substr(-8);
} else {
returnTitle = getTitle;
}
return returnTitle;
},
/* 标题长度处理 */
titleHandle(caption) {
if (caption && caption.length > 3) {
return caption.substring(0, 3) + "...";
} else {
return caption;
}
}
},
activated() {
// 重置data数据
Object.assign(this.$data, this.$options.data());
}
};
</script>
<style lang="scss">
.disable {
color: #a6a6a6;
}
.address-select-component {
position: fixed;
bottom: 0;
left: 0;
top: 0;
width: 100%;
background: rgba(0, 0, 0, 0.5);
.address-select-box {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background: #fff;
.component-title {
text-align: center;
line-height: 88px;
font-size: 34px;
font-weight: bold;
color: #000;
padding: 0 30px;
.close {
float: right;
}
.icon-close {
height: 40px;
width: 40px;
margin-top: 24px;
background: url("~statics/image/address/close.png");
background-size: cover;
}
}
.head-address-ul {
padding: 0;
margin: 0 0 0 30px;
list-style: none;
overflow: hidden;
font-size: 28px;
color: #999;
li {
display: block;
float: left;
height: 60px;
font-size: 28px;
line-height: 60px;
position: relative;
margin-right: 70px;
}
li:last-child {
margin-right: 30px;
}
.head-address-li {
color: #000;
}
.head-address-li:after {
width: 100%;
border-bottom: 4px solid #000;
position: absolute;
bottom: 0;
left: 0;
content: "";
}
}
.address-container {
margin: 0;
overflow: hidden;
height: 100%;
width: 100%;
border-top: solid 1px #eee;
.address-content {
transform: translate(0, 0) translateZ(0);
height: 620px;
}
}
.address-ul {
padding: 0;
margin: 0;
list-style: none;
height: 100%;
overflow: auto;
font-size: 28px;
color: #999;
justify-content: center;
li {
height: 80px;
line-height: 80px;
padding-left: 30px;
position: relative;
overflow: hidden;
display: flex;
align-items: center;
&.active {
font-size: 30px;
color: #000;
font-weight: bold;
}
.icon-check {
display: inline-block;
margin-left: 18px;
height: 30px;
width: 30px;
background-repeat: no-repeat;
background: url("~statics/image/address/check.png");
background-size: 100% 100%;
}
}
}
}
}
</style>
... ...
... ... @@ -6,7 +6,12 @@ export default [
},
{
name: 'addressEdit',
path: '/xianyu/address/edit/:orderCode?', // code 订单编码
path: '/xianyu/address/edit',
component: () => import(/* webpackChunkName: "address" */ './addressEdit'),
},
{
name: 'addressModify',
path: '/xianyu/address/modify',
component: () => import(/* webpackChunkName: "address" */ './addressModify'),
},
];
... ...
... ... @@ -117,12 +117,12 @@ export default {
let info = JSON.stringify(addressInfo || userAddress || {});
let updateInfo = JSON.parse(info || '{}');
Object.assign(updateInfo, { isUpdate: true, orderCode: orderCode });
Object.assign(updateInfo, { orderCode: orderCode });
this.STORE_UPDATE_ADDRESS_INFO(updateInfo);
this.$router.push({
name: 'addressEdit',
name: 'addressModify',
query: {
fromPage: 'OrderList',
fromPage: 'BuyerOrder',
},
});
break;
... ...
... ... @@ -34,6 +34,10 @@
{{ userAddress.area }}{{ userAddress.address || "" }}
</p>
<p class="mobile">{{ userAddress.mobile }}</p>
<div v-if="userAddress.canModify" class="edit-address" @click="jumpToAddressModify">
<span class="mobile">编辑地址</span>
<i class="cubeic-arrow" ></i>
</div>
</div>
</div>
</div>
... ... @@ -42,7 +46,11 @@
<script>
import { createNamespacedHelpers } from "vuex";
import Clipboard from "clipboard";
import { STORE_UPDATE_ADDRESS_INFO } from 'store/address/address/types';
const { mapGetters } = createNamespacedHelpers("order/orderDetail");
const { mapMutations: addressMutations } = createNamespacedHelpers(
'address/address',
);
export default {
props: {
... ... @@ -52,7 +60,25 @@ export default {
}
},
computed: {
...mapGetters(["userAddress", "appraiseAddress"])
...mapGetters(["userAddress", "appraiseAddress", "orderCode"])
},
methods: {
...addressMutations(['STORE_UPDATE_ADDRESS_INFO']),
jumpToAddressModify() {
const orderCode = this.orderCode;
// 保存地址到store
let info = JSON.stringify(this.userAddress || {});
let updateInfo = JSON.parse(info || '{}');
Object.assign(updateInfo, { orderCode: orderCode });
this.STORE_UPDATE_ADDRESS_INFO(updateInfo);
this.$router.push({
name: 'addressModify',
query: {
fromPage: 'SellerOrder',
},
});
}
},
activated() {
this.$nextTick(() => {
... ... @@ -101,9 +127,29 @@ export default {
}
}
.edit-address {
display: flex;
align-items: center;
position: absolute;
bottom: 0;
right: 40px;
z-index: 99;
}
.address-wrapper {
display: flex;
align-items: center;
position: relative;
&:before {
content: "";
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 1;
}
.consignee {
font-size: 32px;
... ...
... ... @@ -112,4 +112,30 @@ export default {
}
return res || {};
},
// 卖家修改寄回地址
async updateDeliverAddressInOrder({ commit }, data) {
const {
address,
area,
consignee,
mobile,
orderCode,
area_code: areaCode,
} = data;
const res = await this.$api.get('/api/seller/modifyDeliverAddress', {
orderCode,
mobile,
areaCode,
consignee,
address,
area,
});
const { code, message } = res || {};
if (code === 200) {
res.message = message || '修改成功';
}
return res || {};
},
};
... ...
... ... @@ -21,6 +21,9 @@ export default function() {
// 鉴定平台地址
appraiseAddress: state => state.orderDetail.appraiseAddress || null,
// 订单编号
orderCode: state => state.orderDetail.orderCode || ''
},
actions: {
/**
... ...
... ... @@ -48,4 +48,17 @@ module.exports = {
address: { type: String, require: true },
},
},
'/api/seller/modifyDeliverAddress': {
auth: true,
ufo: true,
api: 'ufo.sellerOrder.modifyDeliverAddress',
params: {
orderCode: { type: Number, require: true },
mobile: { type: String, require: true },
consignee: { type: String, require: true },
area: { type: String, require: true },
areaCode: { type: String, require: true },
address: { type: String, require: true },
},
},
};
... ...