|
|
@ -1,6 +1,6 @@
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<div class="address flex flex-middle" v-if="!isEdit">
|
|
|
|
<div class="address flex flex-middle" v-if="!isOperation && !isAccount">
|
|
|
|
<article class="address__msg">
|
|
|
|
<article class="address__msg">
|
|
|
|
<div class="address__msg-line flex flex-middle">
|
|
|
|
<div class="address__msg-line flex flex-middle">
|
|
|
|
<img src="@/assets/img/goods/point.png" alt="收货地址" />
|
|
|
|
<img src="@/assets/img/goods/point.png" alt="收货地址" />
|
|
|
@ -39,13 +39,21 @@
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
切换地址
|
|
|
|
切换地址
|
|
|
|
</UiButton>
|
|
|
|
</UiButton>
|
|
|
|
<UiButton type="grey" @click="isEdit = true" class="flex flex-middle">
|
|
|
|
<UiButton
|
|
|
|
|
|
|
|
type="grey"
|
|
|
|
|
|
|
|
@click="isOperation = true"
|
|
|
|
|
|
|
|
class="flex flex-middle"
|
|
|
|
|
|
|
|
>
|
|
|
|
<img class="icon" src="@/assets/img/goods/add.png" alt="新建地址" />
|
|
|
|
<img class="icon" src="@/assets/img/goods/add.png" alt="新建地址" />
|
|
|
|
新建地址
|
|
|
|
新建地址
|
|
|
|
</UiButton>
|
|
|
|
</UiButton>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="address flex flex-middle" v-else>
|
|
|
|
<div
|
|
|
|
|
|
|
|
class="address"
|
|
|
|
|
|
|
|
:class="isAccount ? 'account' : 'flex flex-middle'"
|
|
|
|
|
|
|
|
v-else
|
|
|
|
|
|
|
|
>
|
|
|
|
<article class="address__msg">
|
|
|
|
<article class="address__msg">
|
|
|
|
<div class="address__msg-line flex flex-middle">
|
|
|
|
<div class="address__msg-line flex flex-middle">
|
|
|
|
<span class="address__msg-line--type">所在区域</span>
|
|
|
|
<span class="address__msg-line--type">所在区域</span>
|
|
|
@ -71,14 +79,17 @@
|
|
|
|
></el-input>
|
|
|
|
></el-input>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</article>
|
|
|
|
</article>
|
|
|
|
<div class="hr"></div>
|
|
|
|
<div class="hr" v-if="!isAccount"></div>
|
|
|
|
<div class="address__operation flex flex-column flex-middle">
|
|
|
|
<div
|
|
|
|
|
|
|
|
class="address__operation flex flex-middle"
|
|
|
|
|
|
|
|
:class="!isAccount ? 'flex-column' : ''"
|
|
|
|
|
|
|
|
>
|
|
|
|
<el-checkbox v-model="defaultAddress">设为默认地址</el-checkbox>
|
|
|
|
<el-checkbox v-model="defaultAddress">设为默认地址</el-checkbox>
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<UiButton
|
|
|
|
<UiButton
|
|
|
|
v-if="addressList && addressList.length"
|
|
|
|
v-if="addressList && addressList.length && !isAccount"
|
|
|
|
type="grey"
|
|
|
|
type="grey"
|
|
|
|
@click="isEdit = false"
|
|
|
|
@click="isOperation = false"
|
|
|
|
>取消</UiButton
|
|
|
|
>取消</UiButton
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<UiButton type="yellow_panel" @click="onAddAddress"
|
|
|
|
<UiButton type="yellow_panel" @click="onAddAddress"
|
|
|
@ -115,8 +126,12 @@
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
import UiButton from "@/components/UiButton.vue";
|
|
|
|
import UiButton from "@/components/UiButton.vue";
|
|
|
|
|
|
|
|
import { IsPhone } from "@/plugins/utils/index.js";
|
|
|
|
import { ApiGetAddress, ApiPostAddress } from "@/plugins/api/base";
|
|
|
|
import {
|
|
|
|
|
|
|
|
ApiGetAddress,
|
|
|
|
|
|
|
|
ApiPostAddress,
|
|
|
|
|
|
|
|
ApiPutAddress,
|
|
|
|
|
|
|
|
} from "@/plugins/api/base";
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
|
components: { UiButton },
|
|
|
|
components: { UiButton },
|
|
|
|
props: {
|
|
|
|
props: {
|
|
|
@ -124,6 +139,14 @@ export default {
|
|
|
|
type: Object,
|
|
|
|
type: Object,
|
|
|
|
default: () => {},
|
|
|
|
default: () => {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
isAccount: {
|
|
|
|
|
|
|
|
type: Boolean,
|
|
|
|
|
|
|
|
default: false,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
isEdit: {
|
|
|
|
|
|
|
|
type: Boolean,
|
|
|
|
|
|
|
|
default: false,
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
model: {
|
|
|
|
model: {
|
|
|
|
prop: "addressData",
|
|
|
|
prop: "addressData",
|
|
|
@ -131,7 +154,7 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
isEdit: false,
|
|
|
|
isOperation: false,
|
|
|
|
dialogVisible: false,
|
|
|
|
dialogVisible: false,
|
|
|
|
detailAddress: "",
|
|
|
|
detailAddress: "",
|
|
|
|
addressUser: "",
|
|
|
|
addressUser: "",
|
|
|
@ -150,17 +173,21 @@ export default {
|
|
|
|
let vm = this;
|
|
|
|
let vm = this;
|
|
|
|
let res = await ApiGetAddress();
|
|
|
|
let res = await ApiGetAddress();
|
|
|
|
if (res.result && res.result.length) {
|
|
|
|
if (res.result && res.result.length) {
|
|
|
|
vm.isEdit = false;
|
|
|
|
vm.isOperation = false;
|
|
|
|
vm.addressList = res.result;
|
|
|
|
vm.addressList = res.result;
|
|
|
|
let curIndex = vm.addressList.findIndex((item) => item.id == 3);
|
|
|
|
let curIndex = vm.addressList.findIndex((item) => item.isDefault);
|
|
|
|
vm.curAddressListItem =
|
|
|
|
vm.curAddressListItem =
|
|
|
|
curIndex > -1 ? vm.addressList[curIndex] : vm.addressList[0];
|
|
|
|
curIndex > -1 ? vm.addressList[curIndex] : vm.addressList[0];
|
|
|
|
|
|
|
|
vm.$emit("getList", vm.addressList);
|
|
|
|
vm.$emit("emitAddress", vm.curAddressListItem);
|
|
|
|
vm.$emit("emitAddress", vm.curAddressListItem);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
vm.isEdit = true;
|
|
|
|
vm.isOperation = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log("获取收货地址", res);
|
|
|
|
console.log("获取收货地址", res);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
setAddressData(i) {
|
|
|
|
|
|
|
|
let vm = this;
|
|
|
|
|
|
|
|
},
|
|
|
|
onSwtich() {
|
|
|
|
onSwtich() {
|
|
|
|
this.dialogVisible = true;
|
|
|
|
this.dialogVisible = true;
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -185,7 +212,7 @@ export default {
|
|
|
|
vm.$message.error("请输入收货人~");
|
|
|
|
vm.$message.error("请输入收货人~");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!vm.addressPhone) {
|
|
|
|
if (!IsPhone(vm.addressPhone)) {
|
|
|
|
vm.$message.error("请输入收货人手机号码~");
|
|
|
|
vm.$message.error("请输入收货人手机号码~");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -201,7 +228,12 @@ export default {
|
|
|
|
province: vm.selectData.province.value,
|
|
|
|
province: vm.selectData.province.value,
|
|
|
|
provinceCode: vm.selectData.province.code,
|
|
|
|
provinceCode: vm.selectData.province.code,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let res = await ApiPostAddress(params);
|
|
|
|
let res;
|
|
|
|
|
|
|
|
if (vm.isEdit) {
|
|
|
|
|
|
|
|
res = await ApiPutAddress(params);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
res = await ApiPostAddress(params);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (!res.error) {
|
|
|
|
if (!res.error) {
|
|
|
|
vm.$message.success("添加成功!");
|
|
|
|
vm.$message.success("添加成功!");
|
|
|
|
vm.getAddressData();
|
|
|
|
vm.getAddressData();
|
|
|
@ -355,4 +387,8 @@ export default {
|
|
|
|
padding: 0;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.account {
|
|
|
|
|
|
|
|
width: 1000px;
|
|
|
|
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</style>
|
|
|
|