...
|
...
|
@@ -79,6 +79,25 @@ const { mapState, mapMutations, mapActions } = createNamespacedHelpers( |
|
|
"address/address"
|
|
|
);
|
|
|
export default {
|
|
|
props: {
|
|
|
areaTitle: {
|
|
|
type: String,
|
|
|
default() {
|
|
|
return "";
|
|
|
}
|
|
|
},
|
|
|
areaId: {
|
|
|
type: String,
|
|
|
default() {
|
|
|
return "";
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
areaTitle: function(newVal, oldVal) {
|
|
|
newVal && this.handleAreaTitle();
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
supportChangeProvince: true, // 是否支持修改省
|
...
|
...
|
@@ -125,6 +144,63 @@ export default { |
|
|
methods: {
|
|
|
...mapMutations({}),
|
|
|
...mapActions(["fetchAddressProvinces"]),
|
|
|
/* 处理父组件传递的区域 */
|
|
|
async handleAreaTitle() {
|
|
|
let areaId = this.areaId;
|
|
|
let areaCaption = this.areaTitle;
|
|
|
|
|
|
let returnTitle = this.returnTitle();
|
|
|
|
|
|
if (returnTitle.length > 0) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let arrList = areaCaption.trim().split(" ");
|
|
|
|
|
|
if (!areaId) {
|
|
|
areaId = 0;
|
|
|
}
|
|
|
|
|
|
this.province.id = areaId.substring(0, 2);
|
|
|
this.province.allTitle = arrList[0];
|
|
|
this.province.title = this.titleHandle(arrList[0]);
|
|
|
|
|
|
const provinceResult = await this.fetchAddressProvinces(0);
|
|
|
this.provinces = provinceResult.data;
|
|
|
|
|
|
this.city.id = areaId.substring(0, 4);
|
|
|
this.city.allTitle = arrList[1];
|
|
|
this.city.title = this.titleHandle(arrList[1]);
|
|
|
|
|
|
const cityResult = await this.fetchAddressProvinces(
|
|
|
areaId.substring(0, 2)
|
|
|
);
|
|
|
this.citys = cityResult.data;
|
|
|
|
|
|
this.area.id = areaId.substring(0, 6);
|
|
|
this.area.allTitle = arrList[2];
|
|
|
this.area.title = this.titleHandle(arrList[2]);
|
|
|
|
|
|
const areaResult = await this.fetchAddressProvinces(
|
|
|
areaId.substring(0, 4)
|
|
|
);
|
|
|
this.areas = areaResult.data;
|
|
|
|
|
|
this.street.id = areaId;
|
|
|
this.street.allTitle = arrList[3];
|
|
|
this.street.title = this.titleHandle(arrList[3]);
|
|
|
|
|
|
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;
|
|
|
|
|
|
this.common.titleActive = false;
|
|
|
this.area.titleActive = true;
|
|
|
|
|
|
//根据前6位请求显示列表
|
|
|
const result = await this.fetchAddressProvinces(areaId.substring(0, 6));
|
|
|
this.streets = result.data;
|
|
|
},
|
|
|
/* 返回标题处理 */
|
|
|
returnTitle() {
|
|
|
let getTitle = "";
|
...
|
...
|
@@ -141,8 +217,8 @@ export default { |
|
|
this.city.allTitle + this.area.allTitle + this.street.allTitle;
|
|
|
}
|
|
|
|
|
|
if (getTitle.length > 11) {
|
|
|
returnTitle = getTitle.substr(0, 5) + "..." + getTitle.substr(-5);
|
|
|
if (getTitle.length > 18) {
|
|
|
returnTitle = getTitle.substr(0, 8) + "..." + getTitle.substr(-8);
|
|
|
} else {
|
|
|
returnTitle = getTitle;
|
|
|
}
|
...
|
...
|
@@ -152,7 +228,7 @@ export default { |
|
|
|
|
|
/* 标题长度处理 */
|
|
|
titleHandle(caption) {
|
|
|
if (caption.length > 3) {
|
|
|
if (caption && caption.length > 3) {
|
|
|
return caption.substring(0, 3) + "...";
|
|
|
} else {
|
|
|
return caption;
|
...
|
...
|
@@ -218,7 +294,7 @@ export default { |
|
|
let resultData = result.data;
|
|
|
|
|
|
//length小于1时弹窗消失并传数据给上层
|
|
|
if (resultData.length < 1) {
|
|
|
if (resultData && resultData.length < 1) {
|
|
|
let returnTitle = this.returnTitle();
|
|
|
|
|
|
this.$emit("popHidden");
|
...
|
...
|
@@ -248,7 +324,7 @@ export default { |
|
|
|
|
|
/* 关闭地址选择组件 */
|
|
|
closeAddBox() {
|
|
|
this.$emit("hidden");
|
|
|
this.$emit("popHidden");
|
|
|
},
|
|
|
|
|
|
/* 点击地址标题时的处理 */
|
...
|
...
|
|