[new feature] Area: add is-oversea-code prop (#4163)

This commit is contained in:
neverland
2019-08-20 17:22:24 +08:00
committed by GitHub
parent 112839984d
commit 89a980466f
3 changed files with 13 additions and 3 deletions
+11 -3
View File
@@ -4,6 +4,10 @@ import { pickerProps } from '../picker/shared';
const [createComponent, bem] = createNamespace('area');
function isOverseaCode(code) {
return code[0] === '9';
}
export default createComponent({
props: {
...pickerProps,
@@ -15,6 +19,10 @@ export default createComponent({
columnsNum: {
type: [Number, String],
default: 3
},
isOverseaCode: {
type: Function,
default: isOverseaCode
}
},
@@ -81,7 +89,7 @@ export default createComponent({
if (code) {
// oversea code
if (code[0] === '9' && type === 'city') {
if (this.isOverseaCode(code) && type === 'city') {
code = '9';
}
@@ -97,7 +105,7 @@ export default createComponent({
const list = this.getList(type, code.slice(0, compareNum - 2));
// oversea code
if (code[0] === '9' && type === 'province') {
if (this.isOverseaCode(code) && type === 'province') {
compareNum = 1;
}
@@ -163,7 +171,7 @@ export default createComponent({
const names = values.map(item => item.name);
area.code = values[values.length - 1].code;
if (area.code[0] === '9') {
if (this.isOverseaCode(area.code)) {
area.country = names[1] || '';
area.province = names[2] || '';
} else {