mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 10:20:19 +08:00
Merge branch 'dev' of https://github.com/youzan/vant into dev
This commit is contained in:
commit
287c265202
@ -73,9 +73,7 @@ export default {
|
||||
.van-cell-text {
|
||||
margin-right: 5px;
|
||||
}
|
||||
.van-cell__right-icon {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.van-cell-text,
|
||||
.van-tag--danger {
|
||||
vertical-align: middle;
|
||||
|
@ -52,6 +52,7 @@ export default {
|
||||
| right-text | Right Text | `String` | `''` | - |
|
||||
| left-arrow | Whether to show left arrow | `Boolean` | `false` | - |
|
||||
| fixed | Whether to fixed top | `Boolean` | `false` | - |
|
||||
| z-index | Z-index | `Number` | `1` | - |
|
||||
|
||||
### Slot
|
||||
|
||||
|
@ -53,6 +53,7 @@ export default {
|
||||
| right-text | 右侧文案 | `String` | `''` | - |
|
||||
| left-arrow | 是否显示左侧箭头 | `Boolean` | `false` | - |
|
||||
| fixed | 是否固定在顶部 | `Boolean` | `false` | - |
|
||||
| z-index | 元素 z-index | `Number` | `1` | - |
|
||||
|
||||
### Slot
|
||||
|
||||
|
@ -263,10 +263,12 @@ export default create({
|
||||
setAreaCode(code) {
|
||||
this.currentInfo.area_code = code;
|
||||
this.$nextTick(() => {
|
||||
const { area } = this.$refs;
|
||||
if (area) {
|
||||
this.assignAreaValues(area.getValues());
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
const { area } = this.$refs;
|
||||
if (area) {
|
||||
this.assignAreaValues(area.getValues());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -35,11 +35,14 @@ export default create({
|
||||
},
|
||||
|
||||
computed: {
|
||||
listValid() {
|
||||
return this.areaList && typeof this.areaList.province_list === 'object';
|
||||
},
|
||||
|
||||
columns() {
|
||||
const columns = [];
|
||||
const { areaList } = this;
|
||||
|
||||
if (!areaList || typeof areaList.province_list !== 'object') {
|
||||
if (!this.listValid) {
|
||||
return columns;
|
||||
}
|
||||
|
||||
@ -91,6 +94,10 @@ export default create({
|
||||
|
||||
// 根据省市县类型和对应的`code`获取对应列表
|
||||
getList(type, code) {
|
||||
if (!this.listValid) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const { areaList } = this;
|
||||
const list =
|
||||
type === 'province'
|
||||
@ -118,11 +125,10 @@ export default create({
|
||||
getIndex(type, code) {
|
||||
const compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6;
|
||||
const areaList = this.getList(type, code.slice(0, compareNum - 2));
|
||||
code = code.slice(0, compareNum);
|
||||
|
||||
for (let i = 0; i < areaList.length; i++) {
|
||||
if (
|
||||
+areaList[i].code.slice(0, compareNum) === +code.slice(0, compareNum)
|
||||
) {
|
||||
if (areaList[i].code.slice(0, compareNum) === code) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -86,9 +86,9 @@ export default {
|
||||
name: '名字',
|
||||
tel: '手机或固定电话',
|
||||
postal: '邮政编码(选填)',
|
||||
province: '选择省',
|
||||
city: '选择市',
|
||||
county: '选择区'
|
||||
province: '选择省份',
|
||||
city: '选择城市',
|
||||
county: '选择地区'
|
||||
}
|
||||
},
|
||||
vanAddressEditDetail: {
|
||||
|
@ -1,5 +1,9 @@
|
||||
<template>
|
||||
<div class="van-nav-bar van-hairline--top-bottom" :class="{ 'van-nav-bar--fixed': fixed }">
|
||||
<div
|
||||
class="van-nav-bar van-hairline--top-bottom"
|
||||
:class="{ 'van-nav-bar--fixed': fixed }"
|
||||
:style="style"
|
||||
>
|
||||
<div class="van-nav-bar__left" @click="$emit('click-left')">
|
||||
<slot name="left">
|
||||
<icon v-if="leftArrow" class="van-nav-bar__arrow" name="arrow" />
|
||||
@ -28,7 +32,19 @@ export default create({
|
||||
leftText: String,
|
||||
rightText: String,
|
||||
leftArrow: Boolean,
|
||||
fixed: Boolean
|
||||
fixed: Boolean,
|
||||
zIndex: {
|
||||
type: Number,
|
||||
default: 1
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
style() {
|
||||
return {
|
||||
zIndex: this.zIndex
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
@ -17,7 +17,7 @@
|
||||
'van-picker-column--disabled': isDisabled(option),
|
||||
'van-picker-column--selected': index === currentIndex
|
||||
}"
|
||||
@click="setIndex(index)"
|
||||
@click="setIndex(index, true)"
|
||||
/>
|
||||
</ul>
|
||||
</div>
|
||||
@ -134,8 +134,7 @@ export default create({
|
||||
0,
|
||||
this.count - 1
|
||||
]);
|
||||
this.setIndex(index);
|
||||
this.$emit('change', index);
|
||||
this.setIndex(index, true);
|
||||
}
|
||||
},
|
||||
|
||||
@ -157,10 +156,14 @@ export default create({
|
||||
return typeof option === 'object' && this.valueKey in option ? option[this.valueKey] : option;
|
||||
},
|
||||
|
||||
setIndex(index) {
|
||||
setIndex(index, userAction) {
|
||||
index = this.adjustIndex(index);
|
||||
this.offset = -index * this.itemHeight;
|
||||
this.currentIndex = index;
|
||||
|
||||
if (index !== this.currentIndex) {
|
||||
this.currentIndex = index;
|
||||
userAction && this.$emit('change', index);
|
||||
}
|
||||
},
|
||||
|
||||
setValue(value) {
|
||||
|
@ -111,9 +111,9 @@ export default create({
|
||||
|
||||
if (this.ceiling && this.deltaY >= 0) {
|
||||
if (this.direction === 'vertical') {
|
||||
this.getStatus(this.ease(this.deltaY));
|
||||
event.preventDefault();
|
||||
}
|
||||
this.getStatus(this.ease(this.deltaY));
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -56,7 +56,7 @@
|
||||
}
|
||||
|
||||
&--link {
|
||||
padding-right: 20px;
|
||||
padding-right: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,13 +17,13 @@ describe('AddressEdit', () => {
|
||||
expect(wrapper.find('.van-field__control')[2].element.value).to.equal('');
|
||||
expect(
|
||||
wrapper.find('.van-address-edit__area .van-cell__value span')[0].text()
|
||||
).to.equal('选择省');
|
||||
).to.equal('选择省份');
|
||||
expect(
|
||||
wrapper.find('.van-address-edit__area .van-cell__value span')[1].text()
|
||||
).to.equal('选择市');
|
||||
).to.equal('选择城市');
|
||||
expect(
|
||||
wrapper.find('.van-address-edit__area .van-cell__value span')[2].text()
|
||||
).to.equal('选择区');
|
||||
).to.equal('选择地区');
|
||||
});
|
||||
|
||||
it('create a AddressEdit with props', () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user