Authored by 张文文

fix

... ... @@ -5,18 +5,13 @@
<CInput
label="收货人"
place-holder="请写姓名"
v-model="model.receiverName"
:textValue="model.receiverName"
v-model="model.consignee"
:textValue="model.consignee"
type="text"
></CInput>
</FormItem>
<FormItem>
<CInput
label="手机号"
place-holder="请填写手机号"
v-model="model.receiverMobile"
:textValue="model.receiverMobile"
></CInput>
<CInput label="手机号" place-holder="请填写手机号" v-model="model.mobile" :textValue="model.mobile"></CInput>
</FormItem>
<template>
... ... @@ -24,8 +19,8 @@
<div class="wrapper-area">
<label class="input-label">所在区域</label>
<div class="wrapper-arrow" @click="chooseArea">
<template v-if="model.receiverArea">
<label class="text-label">{{model.receiverArea}}</label>
<template v-if="model.area">
<label class="text-label">{{model.area}}</label>
</template>
<template v-else>
<label class="choose-area">请选择</label>
... ... @@ -40,8 +35,8 @@
<CInput
label="详细地址"
place-holder="请输入详细地址"
v-model="model.receiverAddress"
:textValue="model.receiverAddress"
v-model="model.address"
:textValue="model.address"
></CInput>
</FormItem>
... ... @@ -50,10 +45,10 @@
<RadioGroup class="wrapper-radio">
<div v-for="(tag, index) in addressTags" :key="index">
<Radio
:label="{text: `${tag.name}`, value: `${tag.code}`}"
v-model="model.tagType"
checked="tag.code === model.tagType"
class="tag-radio"
:label="{text: `${tag.name}`, value: `${tag.code}`}"
v-model="model.tag_code"
checked="tag.code === model.tag_code"
></Radio>
</div>
</RadioGroup>
... ... @@ -64,8 +59,8 @@
class="radio"
:label="{text: '设为默认地址', value: true}"
style="flex: 0 1 100%;"
checked="model.defaultType"
v-model="model.defaultType"
checked="model.is_default"
v-model="model.is_default"
></Radio>
<div v-if="isUpdate" class="del-address" @click="delAddress">删除地址</div>
</div>
... ... @@ -74,9 +69,9 @@
</div>
<AddressAct
v-show="isShowPop"
:areaId="model.areaCode"
:areaTitle="model.receiverArea"
v-show="isShowProvince"
:areaId="model.area_code"
:areaTitle="model.area"
@popHidden="popHidden"
@modifyAddressAct="modifyAddressAct"
></AddressAct>
... ... @@ -108,18 +103,18 @@ export default {
},
data() {
return {
isShowPop: false,
isShowProvince: false,
isUpdate: false,
title: "添加地址",
title: "",
model: {
addressId: "",
receiverName: "",
receiverMobile: "",
areaCode: "",
receiverArea: "",
receiverAddress: "",
tagType: "",
defaultType: false
consignee: "",
address_id: "",
mobile: "",
area_code: "",
area: "",
address: "",
tag_code: "",
is_default: false
}
};
},
... ... @@ -135,10 +130,10 @@ export default {
},
inNotEmpty() {
return (
this.model.receiverName &&
this.model.receiverMobile &&
this.model.receiverArea &&
this.model.receiverAddress
this.model.consignee &&
this.model.mobile &&
this.model.area &&
this.model.address
);
}
},
... ... @@ -187,7 +182,7 @@ export default {
},
validator() {
let info = this.model;
let username = info.receiverName.replace(/(^\s+)|(\s+$)/g, "");
let username = info.consignee.replace(/(^\s+)|(\s+$)/g, "");
// 简单的表单校验
if (!username) {
... ... @@ -200,40 +195,40 @@ export default {
return false;
}
let reg = /^1[34578]\d{9}$/;
let reg = /^[0123456789]{11}$/;
if (!info.receiverMobile) {
if (!info.mobile) {
this.showToast("手机号不能为空");
return false;
} else {
if (!reg.test(info.receiverMobile)) {
this.showToast("手机号码输入不正确");
if (!reg.test(info.mobile)) {
this.showToast("请输入正确11位手机号码");
return;
}
}
if (!info.areaCode || !info.receiverArea) {
if (!info.area_code || !info.area) {
this.showToast("省市区不能为空");
return false;
}
if (!info.receiverAddress) {
if (!info.address) {
this.showToast("地址不能为空");
return false;
}
return {
id: info.addressId || "",
id: info.address_id || "",
consignee: username,
mobile: info.receiverMobile,
area_code: info.areaCode,
area: info.receiverArea,
address: info.receiverAddress,
is_default: info.defaultType ? "Y" : "N",
tag_code: info.tagType
mobile: info.mobile,
area_code: info.area_code,
area: info.area,
address: info.address,
is_default: info.is_default ? "Y" : "N",
tag_code: info.tag_code
};
},
async delAddress() {
const result = await this.deleteUserAddress(this.model.addressId);
const result = await this.deleteUserAddress(this.model.address_id);
if (result && result.code === 200) {
this.$createToast({
type: "txt",
... ... @@ -251,17 +246,17 @@ export default {
}
},
chooseArea() {
this.isShowPop = true;
this.isShowProvince = true;
},
popHidden() {
let that = this;
that.isShowPop = false;
that.isShowProvince = false;
},
modifyAddressAct(info) {
if (info) {
let that = this;
that.model.areaCode = info.code;
that.model.receiverArea = info.area;
that.model.area_code = info.code;
that.model.area = info.area;
}
},
showToast(tip) {
... ... @@ -283,20 +278,22 @@ export default {
this.fetchAddressTags();
this.isUpdate = this.$route.params.update;
this.title = this.$route.params.title;
this.title = this.$route.params.title
? this.$route.params.title
: "添加地址";
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 === "Y" ? true : false;
that.model.consignee = item.consignee;
that.model.address_id = item.address_id;
that.model.mobile = item.mobile;
that.model.area_code = item.area_code;
that.model.area = item.area;
that.model.address = item.address;
that.model.tag_code = item.tag_code;
that.model.is_default = item.is_default === "Y" ? true : false;
}
}
}
... ...