|
|
|
@ -5,7 +5,7 @@
|
|
|
|
|
<div class="address__msg-line flex flex-middle">
|
|
|
|
|
<img src="@/assets/img/goods/point.png" alt="收货地址" />
|
|
|
|
|
<span class="address__msg-line--txt">默认地址</span>
|
|
|
|
|
<UiButton type="yellow_panel">修改</UiButton>
|
|
|
|
|
<UiButton type="yellow_panel" @click="onEdit()">修改</UiButton>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="address__msg-line flex flex-middle">
|
|
|
|
|
<span class="address__msg-line--type">收货地址:</span>
|
|
|
|
@ -73,6 +73,7 @@
|
|
|
|
|
type="textarea"
|
|
|
|
|
:rows="3"
|
|
|
|
|
class="max-ipt"
|
|
|
|
|
maxlength="60"
|
|
|
|
|
></el-input>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="address__msg-line flex flex-middle">
|
|
|
|
@ -88,11 +89,11 @@
|
|
|
|
|
</article>
|
|
|
|
|
<div class="hr" v-if="!isAccount"></div>
|
|
|
|
|
<div
|
|
|
|
|
class="address__operation flex flex-middle"
|
|
|
|
|
class="address__edit flex flex-middle"
|
|
|
|
|
:class="!isAccount ? 'flex-column' : ''"
|
|
|
|
|
>
|
|
|
|
|
<el-checkbox v-model="defaultAddress">设为默认地址</el-checkbox>
|
|
|
|
|
<div>
|
|
|
|
|
<div class="address__edit--btns flex flex-middle">
|
|
|
|
|
<UiButton
|
|
|
|
|
v-if="addressList && addressList.length && !isAccount"
|
|
|
|
|
type="grey"
|
|
|
|
@ -100,7 +101,7 @@
|
|
|
|
|
>取消</UiButton
|
|
|
|
|
>
|
|
|
|
|
<UiButton type="yellow_panel" @click="onAddAddress"
|
|
|
|
|
>保存地址</UiButton
|
|
|
|
|
>{{ getEditState ? "保存" : "新增" }}地址</UiButton
|
|
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
@ -115,13 +116,25 @@
|
|
|
|
|
<div class="address__list">
|
|
|
|
|
<section
|
|
|
|
|
@click="onAddressItem(item)"
|
|
|
|
|
class="address__list--item"
|
|
|
|
|
class="address__list-item"
|
|
|
|
|
:class="
|
|
|
|
|
item.id == curAddressListItem.id ? 'address__list-active' : ''
|
|
|
|
|
"
|
|
|
|
|
v-for="item in addressList"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
>
|
|
|
|
|
<div>收货人:{{ item.name }}</div>
|
|
|
|
|
<div>手机号码:{{ item.phone }}</div>
|
|
|
|
|
<div>收货地址:{{ item.detailAddress }}</div>
|
|
|
|
|
<div class="address__list-item--name">
|
|
|
|
|
<span class="address__list-item--label">收 货 人 :</span
|
|
|
|
|
>{{ item.name }}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="address__list-item--phone">
|
|
|
|
|
<span class="address__list-item--label">手机号码:</span
|
|
|
|
|
>{{ item.phone }}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="address__list-item--detail">
|
|
|
|
|
<span class="address__list-item--label">收货地址:</span>
|
|
|
|
|
{{ item.province + item.city + item.area + item.detailAddress }}
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</div>
|
|
|
|
|
<span slot="footer" class="dialog-footer flex flex-between">
|
|
|
|
@ -150,7 +163,7 @@ export default {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false,
|
|
|
|
|
},
|
|
|
|
|
isEdit: {
|
|
|
|
|
isParentEdit: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false,
|
|
|
|
|
},
|
|
|
|
@ -159,14 +172,20 @@ export default {
|
|
|
|
|
prop: "addressData",
|
|
|
|
|
event: "emitAddress",
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
getEditState() {
|
|
|
|
|
return this.isEdit || this.isParentEdit;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
isEdit: false,
|
|
|
|
|
isOperation: false,
|
|
|
|
|
dialogVisible: false,
|
|
|
|
|
detailAddress: "",
|
|
|
|
|
addressUser: "",
|
|
|
|
|
addressPhone: "",
|
|
|
|
|
defaultAddress: true,
|
|
|
|
|
defaultAddress: false,
|
|
|
|
|
selectData: {
|
|
|
|
|
area: {
|
|
|
|
|
value: "",
|
|
|
|
@ -187,12 +206,24 @@ export default {
|
|
|
|
|
this.getAddressData();
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
onEdit() {
|
|
|
|
|
let vm = this;
|
|
|
|
|
let curIndex = vm.addressList.findIndex(
|
|
|
|
|
(item) => item.id == vm.curAddressListItem.id
|
|
|
|
|
);
|
|
|
|
|
vm.isOperation = true;
|
|
|
|
|
vm.isEdit = true;
|
|
|
|
|
vm.setAddressData(curIndex);
|
|
|
|
|
},
|
|
|
|
|
async getAddressData() {
|
|
|
|
|
let vm = this;
|
|
|
|
|
let res = await ApiGetAddress();
|
|
|
|
|
if (res.result && res.result.length) {
|
|
|
|
|
vm.isOperation = false;
|
|
|
|
|
vm.addressList = res.result;
|
|
|
|
|
if (!vm.addressList.length) {
|
|
|
|
|
vm.defaultAddress = true;
|
|
|
|
|
}
|
|
|
|
|
let curIndex = vm.addressList.findIndex((item) => item.isDefault);
|
|
|
|
|
vm.curAddressListItem =
|
|
|
|
|
curIndex > -1 ? vm.addressList[curIndex] : vm.addressList[0];
|
|
|
|
@ -257,7 +288,7 @@ export default {
|
|
|
|
|
provinceCode: vm.selectData.province.code,
|
|
|
|
|
};
|
|
|
|
|
let res;
|
|
|
|
|
if (vm.isEdit) {
|
|
|
|
|
if (vm.getEditState) {
|
|
|
|
|
let editParams = Object.assign(vm.addressList[vm.editIndex], params);
|
|
|
|
|
res = await ApiPutAddress(editParams);
|
|
|
|
|
} else {
|
|
|
|
@ -265,6 +296,15 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
if (!res.error) {
|
|
|
|
|
vm.$message.success("添加成功!");
|
|
|
|
|
vm.$set(vm.selectData.area, "value", "");
|
|
|
|
|
vm.$set(vm.selectData.city, "value", "");
|
|
|
|
|
vm.$set(vm.selectData.province, "value", "");
|
|
|
|
|
vm.$set(vm, "detailAddress", "");
|
|
|
|
|
vm.$set(vm, "defaultAddress", "");
|
|
|
|
|
vm.$set(vm, "addressUser", "");
|
|
|
|
|
vm.$set(vm, "addressPhone", "");
|
|
|
|
|
vm.$emit("onSaveSuccess");
|
|
|
|
|
vm.isEdit = false;
|
|
|
|
|
vm.getAddressData();
|
|
|
|
|
}
|
|
|
|
|
console.log(res);
|
|
|
|
@ -355,6 +395,22 @@ export default {
|
|
|
|
|
margin-right: 10px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&__edit {
|
|
|
|
|
flex: 1;
|
|
|
|
|
&--btns {
|
|
|
|
|
margin-top: 30px;
|
|
|
|
|
/deep/.ui-button__grey {
|
|
|
|
|
width: 90px;
|
|
|
|
|
height: 30px;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
color: #666666;
|
|
|
|
|
margin-right: 38px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.address__list {
|
|
|
|
@ -376,11 +432,41 @@ export default {
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
background-color: #eeeeee;
|
|
|
|
|
}
|
|
|
|
|
&--item {
|
|
|
|
|
&-item {
|
|
|
|
|
width: 320px;
|
|
|
|
|
height: 120px;
|
|
|
|
|
border: 1px solid #dddddd;
|
|
|
|
|
margin-bottom: 24px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
padding: 16px 20px;
|
|
|
|
|
> div {
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&--detail {
|
|
|
|
|
@include ellipses(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&--label {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
color: #999999;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&-active {
|
|
|
|
|
border: 1px solid #ff875b;
|
|
|
|
|
position: relative;
|
|
|
|
|
&::after {
|
|
|
|
|
content: "";
|
|
|
|
|
position: absolute;
|
|
|
|
|
right: 0;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
width: 24px;
|
|
|
|
|
height: 24px;
|
|
|
|
|
background: url(@/assets/img/goods/active.png);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|