Merge branch 'dev' of https://github.com/youzan/vant into dev

This commit is contained in:
陈嘉涵 2018-01-12 13:36:30 +08:00
commit 287c265202
11 changed files with 54 additions and 27 deletions

View File

@ -73,9 +73,7 @@ export default {
.van-cell-text { .van-cell-text {
margin-right: 5px; margin-right: 5px;
} }
.van-cell__right-icon {
font-size: 16px;
}
.van-cell-text, .van-cell-text,
.van-tag--danger { .van-tag--danger {
vertical-align: middle; vertical-align: middle;

View File

@ -52,6 +52,7 @@ export default {
| right-text | Right Text | `String` | `''` | - | | right-text | Right Text | `String` | `''` | - |
| left-arrow | Whether to show left arrow | `Boolean` | `false` | - | | left-arrow | Whether to show left arrow | `Boolean` | `false` | - |
| fixed | Whether to fixed top | `Boolean` | `false` | - | | fixed | Whether to fixed top | `Boolean` | `false` | - |
| z-index | Z-index | `Number` | `1` | - |
### Slot ### Slot

View File

@ -53,6 +53,7 @@ export default {
| right-text | 右侧文案 | `String` | `''` | - | | right-text | 右侧文案 | `String` | `''` | - |
| left-arrow | 是否显示左侧箭头 | `Boolean` | `false` | - | | left-arrow | 是否显示左侧箭头 | `Boolean` | `false` | - |
| fixed | 是否固定在顶部 | `Boolean` | `false` | - | | fixed | 是否固定在顶部 | `Boolean` | `false` | - |
| z-index | 元素 z-index | `Number` | `1` | - |
### Slot ### Slot

View File

@ -263,10 +263,12 @@ export default create({
setAreaCode(code) { setAreaCode(code) {
this.currentInfo.area_code = code; this.currentInfo.area_code = code;
this.$nextTick(() => { this.$nextTick(() => {
const { area } = this.$refs; this.$nextTick(() => {
if (area) { const { area } = this.$refs;
this.assignAreaValues(area.getValues()); if (area) {
} this.assignAreaValues(area.getValues());
}
});
}); });
} }
} }

View File

@ -35,11 +35,14 @@ export default create({
}, },
computed: { computed: {
listValid() {
return this.areaList && typeof this.areaList.province_list === 'object';
},
columns() { columns() {
const columns = []; const columns = [];
const { areaList } = this;
if (!areaList || typeof areaList.province_list !== 'object') { if (!this.listValid) {
return columns; return columns;
} }
@ -91,6 +94,10 @@ export default create({
// `code` // `code`
getList(type, code) { getList(type, code) {
if (!this.listValid) {
return [];
}
const { areaList } = this; const { areaList } = this;
const list = const list =
type === 'province' type === 'province'
@ -118,11 +125,10 @@ export default create({
getIndex(type, code) { getIndex(type, code) {
const compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6; const compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6;
const areaList = this.getList(type, code.slice(0, compareNum - 2)); const areaList = this.getList(type, code.slice(0, compareNum - 2));
code = code.slice(0, compareNum);
for (let i = 0; i < areaList.length; i++) { for (let i = 0; i < areaList.length; i++) {
if ( if (areaList[i].code.slice(0, compareNum) === code) {
+areaList[i].code.slice(0, compareNum) === +code.slice(0, compareNum)
) {
return i; return i;
} }
} }

View File

@ -86,9 +86,9 @@ export default {
name: '名字', name: '名字',
tel: '手机或固定电话', tel: '手机或固定电话',
postal: '邮政编码(选填)', postal: '邮政编码(选填)',
province: '选择省', province: '选择省',
city: '选择市', city: '选择市',
county: '选择区' county: '选择区'
} }
}, },
vanAddressEditDetail: { vanAddressEditDetail: {

View File

@ -1,5 +1,9 @@
<template> <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')"> <div class="van-nav-bar__left" @click="$emit('click-left')">
<slot name="left"> <slot name="left">
<icon v-if="leftArrow" class="van-nav-bar__arrow" name="arrow" /> <icon v-if="leftArrow" class="van-nav-bar__arrow" name="arrow" />
@ -28,7 +32,19 @@ export default create({
leftText: String, leftText: String,
rightText: String, rightText: String,
leftArrow: Boolean, leftArrow: Boolean,
fixed: Boolean fixed: Boolean,
zIndex: {
type: Number,
default: 1
}
},
computed: {
style() {
return {
zIndex: this.zIndex
};
}
} }
}); });
</script> </script>

View File

@ -17,7 +17,7 @@
'van-picker-column--disabled': isDisabled(option), 'van-picker-column--disabled': isDisabled(option),
'van-picker-column--selected': index === currentIndex 'van-picker-column--selected': index === currentIndex
}" }"
@click="setIndex(index)" @click="setIndex(index, true)"
/> />
</ul> </ul>
</div> </div>
@ -134,8 +134,7 @@ export default create({
0, 0,
this.count - 1 this.count - 1
]); ]);
this.setIndex(index); this.setIndex(index, true);
this.$emit('change', index);
} }
}, },
@ -157,10 +156,14 @@ export default create({
return typeof option === 'object' && this.valueKey in option ? option[this.valueKey] : option; return typeof option === 'object' && this.valueKey in option ? option[this.valueKey] : option;
}, },
setIndex(index) { setIndex(index, userAction) {
index = this.adjustIndex(index); index = this.adjustIndex(index);
this.offset = -index * this.itemHeight; this.offset = -index * this.itemHeight;
this.currentIndex = index;
if (index !== this.currentIndex) {
this.currentIndex = index;
userAction && this.$emit('change', index);
}
}, },
setValue(value) { setValue(value) {

View File

@ -111,9 +111,9 @@ export default create({
if (this.ceiling && this.deltaY >= 0) { if (this.ceiling && this.deltaY >= 0) {
if (this.direction === 'vertical') { if (this.direction === 'vertical') {
this.getStatus(this.ease(this.deltaY));
event.preventDefault(); event.preventDefault();
} }
this.getStatus(this.ease(this.deltaY));
} }
}, },

View File

@ -56,7 +56,7 @@
} }
&--link { &--link {
padding-right: 20px; padding-right: 15px;
} }
} }

View File

@ -17,13 +17,13 @@ describe('AddressEdit', () => {
expect(wrapper.find('.van-field__control')[2].element.value).to.equal(''); expect(wrapper.find('.van-field__control')[2].element.value).to.equal('');
expect( expect(
wrapper.find('.van-address-edit__area .van-cell__value span')[0].text() wrapper.find('.van-address-edit__area .van-cell__value span')[0].text()
).to.equal('选择省'); ).to.equal('选择省');
expect( expect(
wrapper.find('.van-address-edit__area .van-cell__value span')[1].text() wrapper.find('.van-address-edit__area .van-cell__value span')[1].text()
).to.equal('选择市'); ).to.equal('选择市');
expect( expect(
wrapper.find('.van-address-edit__area .van-cell__value span')[2].text() wrapper.find('.van-address-edit__area .van-cell__value span')[2].text()
).to.equal('选择区'); ).to.equal('选择区');
}); });
it('create a AddressEdit with props', () => { it('create a AddressEdit with props', () => {