...
|
...
|
@@ -2,10 +2,21 @@ |
|
|
<LayoutApp title="添加地址" :show-back="true">
|
|
|
<div class="pane-body">
|
|
|
<FormItem>
|
|
|
<CInput label="收货人" place-holder="请写姓名" v-model="model.receiverName"></CInput>
|
|
|
<CInput
|
|
|
label="收货人"
|
|
|
place-holder="请写姓名"
|
|
|
v-model="model.receiverName"
|
|
|
:textValue="model.receiverName"
|
|
|
type="text"
|
|
|
></CInput>
|
|
|
</FormItem>
|
|
|
<FormItem>
|
|
|
<CInput label="手机号" place-holder="请填写手机号" v-model="model.receiverMobile"></CInput>
|
|
|
<CInput
|
|
|
label="手机号"
|
|
|
place-holder="请填写手机号"
|
|
|
v-model="model.receiverMobile"
|
|
|
:textValue="model.receiverMobile"
|
|
|
></CInput>
|
|
|
</FormItem>
|
|
|
|
|
|
<template>
|
...
|
...
|
@@ -26,7 +37,12 @@ |
|
|
</template>
|
|
|
|
|
|
<FormItem>
|
|
|
<CInput label="详细地址" place-holder="请输入详细地址" v-model="model.receiverAddress"></CInput>
|
|
|
<CInput
|
|
|
label="详细地址"
|
|
|
place-holder="请输入详细地址"
|
|
|
v-model="model.receiverAddress"
|
|
|
:textValue="model.receiverAddress"
|
|
|
></CInput>
|
|
|
</FormItem>
|
|
|
|
|
|
<label
|
...
|
...
|
@@ -41,6 +57,7 @@ |
|
|
<label class="label-text">
|
|
|
<input
|
|
|
type="radio"
|
|
|
checked="tag.code === model.tagType"
|
|
|
name="tag"
|
|
|
:value="tag.code"
|
|
|
class="label-tag"
|
...
|
...
|
@@ -51,12 +68,16 @@ |
|
|
</div>
|
|
|
</label>
|
|
|
|
|
|
<Radio
|
|
|
class="radio"
|
|
|
:label="{text: '设为默认地址', value: 1}"
|
|
|
style="flex: 0 1 100%;"
|
|
|
v-model="model.defaultType"
|
|
|
></Radio>
|
|
|
<div class="wrapper-del">
|
|
|
<Radio
|
|
|
class="radio"
|
|
|
:label="{text: '设为默认地址', value: 'Y'}"
|
|
|
style="flex: 0 1 100%;"
|
|
|
checked="model.tagType === 'Y'"
|
|
|
v-model="model.defaultType"
|
|
|
></Radio>
|
|
|
<div v-if="isUpdate" class="del-address" @click="delAddress">删除地址</div>
|
|
|
</div>
|
|
|
|
|
|
<div :class="submitClass" @touchend="onSubmit">确定</div>
|
|
|
</div>
|
...
|
...
|
@@ -88,6 +109,7 @@ export default { |
|
|
data() {
|
|
|
return {
|
|
|
isShowPop: false,
|
|
|
isUpdate: false,
|
|
|
model: {
|
|
|
addressId: "",
|
|
|
receiverName: "",
|
...
|
...
|
@@ -96,7 +118,7 @@ export default { |
|
|
receiverArea: "",
|
|
|
receiverAddress: "",
|
|
|
tagType: "",
|
|
|
defaultType: false
|
|
|
defaultType: "N"
|
|
|
}
|
|
|
};
|
|
|
},
|
...
|
...
|
@@ -121,7 +143,12 @@ export default { |
|
|
},
|
|
|
methods: {
|
|
|
...mapMutations({}),
|
|
|
...mapActions(["fetchAddressTags", "addUserAddress"]),
|
|
|
...mapActions([
|
|
|
"fetchAddressTags",
|
|
|
"addUserAddress",
|
|
|
"updateUserAddress",
|
|
|
"deleteUserAddress"
|
|
|
]),
|
|
|
|
|
|
async onSubmit() {
|
|
|
let that = this;
|
...
|
...
|
@@ -137,16 +164,20 @@ export default { |
|
|
mask: true
|
|
|
}).show();
|
|
|
|
|
|
const result = await this.addUserAddress(data);
|
|
|
let result = {};
|
|
|
|
|
|
if (this.isUpdate) {
|
|
|
//更新和添加地址接口不同
|
|
|
result = await this.updateUserAddress(data);
|
|
|
} else {
|
|
|
result = await this.addUserAddress(data);
|
|
|
}
|
|
|
|
|
|
await this.sleep(1000);
|
|
|
|
|
|
this.toast && this.toast.hide();
|
|
|
|
|
|
if (result && result.code === 200) {
|
|
|
this.$store.commit("address/address/ADD_USER_ADDRESS_INFO", {
|
|
|
status: 0
|
|
|
});
|
|
|
this.$router.go(-1);
|
|
|
} else {
|
|
|
this.$createToast({
|
...
|
...
|
@@ -199,7 +230,7 @@ export default { |
|
|
area_code: info.areaCode,
|
|
|
area: info.receiverArea,
|
|
|
address: info.receiverAddress,
|
|
|
is_default: info.defaultType ? "Y" : "N",
|
|
|
is_default: info.defaultType,
|
|
|
tag_code: info.tagType
|
|
|
};
|
|
|
},
|
...
|
...
|
@@ -223,10 +254,39 @@ export default { |
|
|
that.model.areaCode = info.code;
|
|
|
that.model.receiverArea = info.area;
|
|
|
}
|
|
|
},
|
|
|
async delAddress() {
|
|
|
const result = await this.deleteUserAddress(this.model.addressId);
|
|
|
if (result && result.code === 200) {
|
|
|
this.$router.go(-1);
|
|
|
} else {
|
|
|
this.$createToast({
|
|
|
type: "error",
|
|
|
txt: result.message,
|
|
|
mask: true
|
|
|
}).show();
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
this.fetchAddressTags();
|
|
|
|
|
|
this.isUpdate = this.$route.params.update;
|
|
|
|
|
|
if (this.$route.params.update) {
|
|
|
let item = JSON.parse(this.$route.params.item);
|
|
|
if (item) {
|
|
|
let that = this;
|
|
|
that.model.receiverName = item.consignee;
|
|
|
that.model.addressId = item.address_id;
|
|
|
that.model.receiverMobile = item.mobile;
|
|
|
that.model.areaCode = item.area_code;
|
|
|
that.model.receiverArea = item.area;
|
|
|
that.model.receiverAddress = item.address;
|
|
|
that.model.tagType = item.tag_code;
|
|
|
that.model.defaultType = item.is_default;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
</script>
|
...
|
...
|
@@ -240,6 +300,21 @@ export default { |
|
|
padding-right: 40px;
|
|
|
}
|
|
|
|
|
|
.wrapper-del {
|
|
|
display: flex;
|
|
|
flex-direction: row;
|
|
|
justify-content: space-between;
|
|
|
align-items: center;
|
|
|
|
|
|
.del-address {
|
|
|
width: 150px;
|
|
|
text-align: center;
|
|
|
line-height: 80px;
|
|
|
color: #cd001a;
|
|
|
font-size: 26px;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
.wrapper-area {
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
...
|
...
|
|