mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-06-04 20:59:17 +08:00
[build] 0.5.0
This commit is contained in:
parent
8667235b15
commit
217879163e
127
dist/area/index.js
vendored
127
dist/area/index.js
vendored
@ -1,5 +1,6 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
VantComponent({
|
||||
classes: ['active-class', 'toolbar-class', 'column-class'],
|
||||
props: {
|
||||
title: String,
|
||||
value: String,
|
||||
@ -22,52 +23,69 @@ VantComponent({
|
||||
}
|
||||
},
|
||||
data: {
|
||||
pickerValue: [0, 0, 0],
|
||||
columns: []
|
||||
columns: [{
|
||||
values: []
|
||||
}, {
|
||||
values: []
|
||||
}, {
|
||||
values: []
|
||||
}],
|
||||
displayColumns: [{
|
||||
values: []
|
||||
}, {
|
||||
values: []
|
||||
}, {
|
||||
values: []
|
||||
}]
|
||||
},
|
||||
watch: {
|
||||
value: function value(_value) {
|
||||
this.code = _value;
|
||||
this.setValues();
|
||||
},
|
||||
areaList: 'setValues'
|
||||
areaList: 'setValues',
|
||||
columnsNum: function columnsNum(value) {
|
||||
this.set({
|
||||
displayColumns: this.data.columns.slice(0, +value)
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onCancel: function onCancel() {
|
||||
this.$emit('cancel', {
|
||||
values: this.getValues(),
|
||||
indexs: this.getIndexs(),
|
||||
detail: this.getDetail()
|
||||
});
|
||||
},
|
||||
onConfirm: function onConfirm() {
|
||||
this.$emit('confirm', {
|
||||
values: this.getValues(),
|
||||
indexs: this.getIndexs(),
|
||||
detail: this.getDetail()
|
||||
});
|
||||
},
|
||||
onChange: function onChange(event) {
|
||||
var value = event.detail.value;
|
||||
var pickerValue = this.data.pickerValue;
|
||||
var displayColumns = this.getDisplayColumns();
|
||||
var index = pickerValue.findIndex(function (item, index) {
|
||||
return item !== value[index];
|
||||
});
|
||||
var values = displayColumns[index];
|
||||
|
||||
if (index < 0 || value[index] < 0 || !values[value[index]]) {
|
||||
return;
|
||||
getPicker: function getPicker() {
|
||||
if (this.picker == null) {
|
||||
this.picker = this.selectComponent('.van-area__picker');
|
||||
}
|
||||
|
||||
this.code = values[value[index]].code;
|
||||
return this.picker;
|
||||
},
|
||||
onCancel: function onCancel(event) {
|
||||
this.emit('cancel', event.detail);
|
||||
},
|
||||
onConfirm: function onConfirm(event) {
|
||||
this.emit('confirm', event.detail);
|
||||
},
|
||||
emit: function emit(type, detail) {
|
||||
detail.values = detail.value;
|
||||
delete detail.value;
|
||||
this.$emit(type, detail);
|
||||
},
|
||||
onChange: function onChange(event) {
|
||||
var _event$detail = event.detail,
|
||||
index = _event$detail.index,
|
||||
picker = _event$detail.picker,
|
||||
value = _event$detail.value;
|
||||
this.code = value[index].code;
|
||||
this.setValues();
|
||||
this.$emit('change', {
|
||||
picker: this,
|
||||
values: this.getValues(),
|
||||
picker: picker,
|
||||
values: picker.getValues(),
|
||||
index: index
|
||||
});
|
||||
},
|
||||
getConfig: function getConfig(type) {
|
||||
var areaList = this.data.areaList;
|
||||
return areaList && areaList[type + "_list"] || {};
|
||||
},
|
||||
getList: function getList(type, code) {
|
||||
var result = [];
|
||||
|
||||
@ -75,7 +93,7 @@ VantComponent({
|
||||
return result;
|
||||
}
|
||||
|
||||
var list = this.data.areaList && this.data.areaList[type + "_list"] || {};
|
||||
var list = this.getConfig(type);
|
||||
result = Object.keys(list).map(function (code) {
|
||||
return {
|
||||
code: code,
|
||||
@ -115,38 +133,32 @@ VantComponent({
|
||||
return 0;
|
||||
},
|
||||
setValues: function setValues() {
|
||||
var code = this.code || this.data.areaList && Object.keys(this.data.areaList.county_list || {})[0] || '';
|
||||
var county = this.getConfig('county');
|
||||
var code = this.code || Object.keys(county)[0] || '';
|
||||
var province = this.getList('province');
|
||||
var city = this.getList('city', code.slice(0, 2));
|
||||
this.set({
|
||||
'columns[0]': province,
|
||||
'columns[1]': city
|
||||
});
|
||||
var picker = this.getPicker();
|
||||
|
||||
if (!picker) {
|
||||
return;
|
||||
}
|
||||
|
||||
picker.setColumnValues(0, province);
|
||||
picker.setColumnValues(1, city);
|
||||
|
||||
if (city.length && code.slice(2, 4) === '00') {
|
||||
;
|
||||
code = city[0].code;
|
||||
}
|
||||
|
||||
this.set({
|
||||
'columns[2]': this.getList('county', code.slice(0, 4)),
|
||||
pickerValue: [this.getIndex('province', code), this.getIndex('city', code), this.getIndex('county', code)]
|
||||
});
|
||||
picker.setColumnValues(2, this.getList('county', code.slice(0, 4)));
|
||||
picker.setIndexes([this.getIndex('province', code), this.getIndex('city', code), this.getIndex('county', code)]);
|
||||
},
|
||||
getValues: function getValues() {
|
||||
var _this$data$pickerValu = this.data.pickerValue,
|
||||
pickerValue = _this$data$pickerValu === void 0 ? [] : _this$data$pickerValu;
|
||||
var displayColumns = this.getDisplayColumns();
|
||||
return displayColumns.map(function (option, index) {
|
||||
return option[pickerValue[index]];
|
||||
}).filter(function (value) {
|
||||
var picker = this.getPicker();
|
||||
return picker ? picker.getValues().filter(function (value) {
|
||||
return !!value;
|
||||
});
|
||||
},
|
||||
getIndexs: function getIndexs() {
|
||||
var _this$data = this.data,
|
||||
pickerValue = _this$data.pickerValue,
|
||||
columnsNum = _this$data.columnsNum;
|
||||
return pickerValue.slice(0, columnsNum);
|
||||
}) : [];
|
||||
},
|
||||
getDetail: function getDetail() {
|
||||
var values = this.getValues();
|
||||
@ -181,13 +193,6 @@ VantComponent({
|
||||
reset: function reset() {
|
||||
this.code = '';
|
||||
this.setValues();
|
||||
},
|
||||
getDisplayColumns: function getDisplayColumns() {
|
||||
var _this$data2 = this.data,
|
||||
_this$data2$columns = _this$data2.columns,
|
||||
columns = _this$data2$columns === void 0 ? [] : _this$data2$columns,
|
||||
columnsNum = _this$data2.columnsNum;
|
||||
return columns.slice(0, +columnsNum);
|
||||
}
|
||||
}
|
||||
});
|
2
dist/area/index.json
vendored
2
dist/area/index.json
vendored
@ -1,6 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-loading": "../loading/index"
|
||||
"van-picker": "../picker/index"
|
||||
}
|
||||
}
|
||||
|
51
dist/area/index.wxml
vendored
51
dist/area/index.wxml
vendored
@ -1,35 +1,16 @@
|
||||
<view class="van-picker">
|
||||
<view class="van-picker__toolbar van-hairline--bottom">
|
||||
<view class="van-picker__cancel" bindtap="onCancel">取消</view>
|
||||
<view class="van-picker__title">{{ title }}</view>
|
||||
<view class="van-picker__confirm" bindtap="onConfirm">确定</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{ loading }}" class="van-picker__loading">
|
||||
<van-loading color="#1989fa"/>
|
||||
</view>
|
||||
|
||||
<picker-view
|
||||
indicator-style="height: {{ itemHeight }}px;"
|
||||
style="width: 100%; height: {{ itemHeight * visibleItemCount + 'px' }}"
|
||||
bindchange="onChange"
|
||||
value="{{ pickerValue }}"
|
||||
class="van-picker__columns"
|
||||
>
|
||||
<picker-view-column
|
||||
wx:if="{{ rowIndex < columnsNum }}"
|
||||
wx:for="{{ columns }}"
|
||||
wx:for-item="row"
|
||||
wx:for-index="rowIndex"
|
||||
wx:key="rowIndex"
|
||||
class="van-picker-column"
|
||||
>
|
||||
<view
|
||||
wx:for="{{ row }}"
|
||||
wx:key="{{ item.code }}"
|
||||
style="line-height: {{ itemHeight }}px;"
|
||||
class="van-picker-column__item {{ index === pickerValue[rowIndex] ? 'van-picker-column__item--selected' : '' }}"
|
||||
>{{ item.name }}</view>
|
||||
</picker-view-column>
|
||||
</picker-view>
|
||||
</view>
|
||||
<van-picker
|
||||
class="van-area__picker"
|
||||
active-class="active-class"
|
||||
toolbar-class="toolbar-class"
|
||||
column-class="column-class"
|
||||
show-toolbar
|
||||
value-key="name"
|
||||
title="{{ title }}"
|
||||
loading="{{ loading }}"
|
||||
columns="{{ displayColumns }}"
|
||||
item-height="{{ itemHeight }}"
|
||||
visible-item-count="{{ visibleItemCount }}"
|
||||
bind:change="onChange"
|
||||
bind:confirm="onConfirm"
|
||||
bind:cancel="onCancel"
|
||||
/>
|
||||
|
2
dist/area/index.wxss
vendored
2
dist/area/index.wxss
vendored
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-picker{-webkit-text-size-adjust:100%;position:relative;overflow:hidden;background-color:#fff;-webkit-user-select:none;user-select:none}.van-picker__toolbar{display:-webkit-flex;display:flex;-webkit-justify-content:space-between;justify-content:space-between;height:44px;line-height:44px}.van-picker__cancel,.van-picker__confirm{color:#1989fa;padding:0 15px;font-size:14px}.van-picker__cancel:active,.van-picker__confirm:active{background-color:#e8e8e8}.van-picker__title{max-width:50%;font-size:16px;font-weight:500;text-align:center}.van-picker__columns{position:relative}.van-picker__loading{display:-webkit-flex;display:flex;z-index:4;position:absolute;top:0;right:0;bottom:0;left:0;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;background-color:rgba(255,255,255,.9)}.van-picker-column{-webkit-flex:1;flex:1;overflow:hidden;font-size:16px;text-align:center}.van-picker-column__item{padding:0 5px;color:#333}.van-picker-column__item--selected{font-weight:500}.van-picker-column__item--disabled{opacity:.3}
|
||||
@import '../common/index.wxss';
|
58
dist/card/index.wxml
vendored
58
dist/card/index.wxml
vendored
@ -1,36 +1,38 @@
|
||||
<view class="custom-class van-card {{ centered ? 'van-card--center' : '' }}">
|
||||
<view class="van-card__thumb" bind:tap="onClickThumb">
|
||||
<image
|
||||
wx:if="{{ thumb }}"
|
||||
src="{{ thumb }}"
|
||||
mode="{{ thumbMode }}"
|
||||
lazy-load="{{ lazyLoad }}"
|
||||
class="van-card__img thumb-class"
|
||||
/>
|
||||
<slot name="thumb" />
|
||||
<van-tag
|
||||
wx:if="{{ tag }}"
|
||||
mark
|
||||
type="danger"
|
||||
custom-class="van-card__tag"
|
||||
>
|
||||
{{ tag }}
|
||||
</van-tag>
|
||||
</view>
|
||||
<view class="van-card__header">
|
||||
<view class="van-card__thumb" bind:tap="onClickThumb">
|
||||
<image
|
||||
wx:if="{{ thumb }}"
|
||||
src="{{ thumb }}"
|
||||
mode="{{ thumbMode }}"
|
||||
lazy-load="{{ lazyLoad }}"
|
||||
class="van-card__img thumb-class"
|
||||
/>
|
||||
<slot name="thumb" />
|
||||
<van-tag
|
||||
wx:if="{{ tag }}"
|
||||
mark
|
||||
type="danger"
|
||||
custom-class="van-card__tag"
|
||||
>
|
||||
{{ tag }}
|
||||
</van-tag>
|
||||
</view>
|
||||
|
||||
<view class="van-card__content">
|
||||
<view wx:if="{{ title }}" class="van-card__title van-multi-ellipsis--l2 title-class">{{ title }}</view>
|
||||
<slot wx:else name="title" />
|
||||
<view class="van-card__content">
|
||||
<view wx:if="{{ title }}" class="van-card__title van-multi-ellipsis--l2 title-class">{{ title }}</view>
|
||||
<slot wx:else name="title" />
|
||||
|
||||
<view wx:if="{{ desc }}" class="van-card__desc van-ellipsis desc-class">{{ desc }}</view>
|
||||
<slot wx:else name="desc" />
|
||||
<view wx:if="{{ desc }}" class="van-card__desc van-ellipsis desc-class">{{ desc }}</view>
|
||||
<slot wx:else name="desc" />
|
||||
|
||||
<slot name="tags" />
|
||||
<slot name="tags" />
|
||||
|
||||
<view class="van-card__bottom">
|
||||
<view wx:if="{{ price || price === 0 }}" class="van-card__price price-class">{{ currency }} {{ price }}</view>
|
||||
<view wx:if="{{ originPrice || originPrice === 0 }}" class="van-card__origin-price origin-price-class">{{ currency }} {{ originPrice }}</view>
|
||||
<view wx:if="{{ num }}" class="van-card__num num-class">x {{ num }}</view>
|
||||
<view class="van-card__bottom">
|
||||
<view wx:if="{{ price || price === 0 }}" class="van-card__price price-class">{{ currency }} {{ price }}</view>
|
||||
<view wx:if="{{ originPrice || originPrice === 0 }}" class="van-card__origin-price origin-price-class">{{ currency }} {{ originPrice }}</view>
|
||||
<view wx:if="{{ num }}" class="van-card__num num-class">x {{ num }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
2
dist/card/index.wxss
vendored
2
dist/card/index.wxss
vendored
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-card{position:relative;display:-webkit-flex;display:flex;padding:5px 15px;font-size:12px;color:#333;background:#fafafa;box-sizing:border-box;-webkit-flex-wrap:wrap;flex-wrap:wrap}.van-card--center{-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-card__thumb{position:relative;width:90px;height:90px;margin-right:10px;-webkit-flex:none;flex:none}.van-card__thumb:empty{display:none}.van-card__img{width:100%;height:100%}.van-card__content{position:relative;height:90px;-webkit-flex:1;flex:1}.van-card__desc,.van-card__title{line-height:17px;word-break:break-all}.van-card__title{max-height:34px;font-weight:700}.van-card__desc{max-height:17px;color:#7d7e80}.van-card__bottom{position:absolute;bottom:0;left:0;width:100%;line-height:17px}.van-card__price{display:inline-block;font-weight:700;color:#f44}.van-card__origin-price{display:inline-block;margin-left:5px;font-size:10px;color:#7d7e80;text-decoration:line-through}.van-card__num{float:right}.van-card__tag{position:absolute;top:2px;left:0}.van-card__footer{width:100%;text-align:right;-webkit-flex:none;flex:none}
|
||||
@import '../common/index.wxss';.van-card{position:relative;padding:5px 15px;font-size:12px;color:#333;box-sizing:border-box;background-color:#fafafa}.van-card--center{-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-card__header{display:-webkit-flex;display:flex}.van-card__thumb{position:relative;width:90px;height:90px;margin-right:10px;-webkit-flex:none;flex:none}.van-card__thumb:empty{display:none}.van-card__img{width:100%;height:100%}.van-card__content{position:relative;-webkit-flex:1;flex:1;height:90px;min-width:0}.van-card__desc,.van-card__title{word-break:break-all}.van-card__title{max-height:32px;line-height:16px;font-weight:700}.van-card__desc{max-height:20px;line-height:20px;color:#7d7e80}.van-card__bottom{position:absolute;bottom:0;left:0;width:100%;line-height:18px}.van-card__price{display:inline-block;font-weight:700;color:#f44}.van-card__origin-price{display:inline-block;margin-left:5px;font-size:10px;color:#7d7e80;text-decoration:line-through}.van-card__num{float:right}.van-card__tag{position:absolute;top:2px;left:0}.van-card__footer{width:100%;text-align:right;-webkit-flex:none;flex:none}
|
2
dist/collapse/index.js
vendored
2
dist/collapse/index.js
vendored
@ -5,7 +5,7 @@ VantComponent({
|
||||
type: 'descendant',
|
||||
linked: function linked(child) {
|
||||
this.set({
|
||||
items: this.data.items.concat([child])
|
||||
items: [].concat(this.data.items, [child])
|
||||
}, function () {
|
||||
child.updateExpanded();
|
||||
});
|
||||
|
167
dist/datetime-picker/index.js
vendored
167
dist/datetime-picker/index.js
vendored
@ -6,8 +6,6 @@ function isValidDate(date) {
|
||||
return isDef(date) && !isNaN(new Date(date).getTime());
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
function range(num, min, max) {
|
||||
return Math.min(Math.max(num, min), max);
|
||||
}
|
||||
@ -96,23 +94,8 @@ VantComponent({
|
||||
}
|
||||
},
|
||||
data: {
|
||||
pickerValue: [],
|
||||
innerValue: Date.now()
|
||||
},
|
||||
computed: {
|
||||
columns: function columns() {
|
||||
var results = this.getRanges().map(function (_ref) {
|
||||
var type = _ref.type,
|
||||
range = _ref.range;
|
||||
var values = times(range[1] - range[0] + 1, function (index) {
|
||||
var value = range[0] + index;
|
||||
value = type === 'year' ? "" + value : padZero(value);
|
||||
return value;
|
||||
});
|
||||
return values;
|
||||
});
|
||||
return results;
|
||||
}
|
||||
innerValue: Date.now(),
|
||||
columns: []
|
||||
},
|
||||
watch: {
|
||||
value: function value(val) {
|
||||
@ -123,17 +106,58 @@ VantComponent({
|
||||
var isEqual = val === data.innerValue;
|
||||
|
||||
if (!isEqual) {
|
||||
this.set({
|
||||
innerValue: val
|
||||
}, function () {
|
||||
_this.updateColumnValue(val);
|
||||
|
||||
this.updateColumnValue(val).then(function () {
|
||||
_this.$emit('input', val);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
type: 'updateColumns',
|
||||
minHour: 'updateColumns',
|
||||
maxHour: 'updateColumns',
|
||||
minMinute: 'updateColumns',
|
||||
maxMinute: 'updateColumns'
|
||||
},
|
||||
methods: {
|
||||
asyncSet: function asyncSet(data) {
|
||||
var _this2 = this;
|
||||
|
||||
return new Promise(function (resolve) {
|
||||
_this2.set(data, resolve);
|
||||
});
|
||||
},
|
||||
getPicker: function getPicker() {
|
||||
if (this.picker == null) {
|
||||
var picker = this.picker = this.selectComponent('.van-datetime-picker');
|
||||
var setColumnValues = picker.setColumnValues;
|
||||
|
||||
picker.setColumnValues = function () {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return setColumnValues.apply(picker, [].concat(args, [false]));
|
||||
};
|
||||
}
|
||||
|
||||
return this.picker;
|
||||
},
|
||||
updateColumns: function updateColumns() {
|
||||
var results = this.getRanges().map(function (_ref, index) {
|
||||
var type = _ref.type,
|
||||
range = _ref.range;
|
||||
var values = times(range[1] - range[0] + 1, function (index) {
|
||||
var value = range[0] + index;
|
||||
value = type === 'year' ? "" + value : padZero(value);
|
||||
return value;
|
||||
});
|
||||
return {
|
||||
values: values
|
||||
};
|
||||
});
|
||||
return this.asyncSet({
|
||||
columns: results
|
||||
});
|
||||
},
|
||||
getRanges: function getRanges() {
|
||||
var data = this.data;
|
||||
|
||||
@ -255,19 +279,18 @@ VantComponent({
|
||||
onConfirm: function onConfirm() {
|
||||
this.$emit('confirm', this.data.innerValue);
|
||||
},
|
||||
onChange: function onChange(event) {
|
||||
var _this2 = this;
|
||||
onChange: function onChange() {
|
||||
var _this3 = this;
|
||||
|
||||
var data = this.data;
|
||||
var pickerValue = event.detail.value;
|
||||
var values = pickerValue.slice(0, data.columns.length).map(function (value, index) {
|
||||
return data.columns[index][value];
|
||||
});
|
||||
var value;
|
||||
var picker = this.getPicker();
|
||||
|
||||
if (data.type === 'time') {
|
||||
value = values.join(':');
|
||||
var indexes = picker.getIndexes();
|
||||
value = indexes[0] + data.minHour + ":" + (indexes[1] + data.minMinute);
|
||||
} else {
|
||||
var values = picker.getValues();
|
||||
var year = getTrueValue(values[0]);
|
||||
var month = getTrueValue(values[1]);
|
||||
var maxDate = getMonthEndDay(year, month);
|
||||
@ -290,90 +313,50 @@ VantComponent({
|
||||
}
|
||||
|
||||
value = this.correctValue(value);
|
||||
this.set({
|
||||
innerValue: value
|
||||
}, function () {
|
||||
_this2.updateColumnValue(value);
|
||||
this.updateColumnValue(value).then(function () {
|
||||
_this3.$emit('input', value);
|
||||
|
||||
_this2.$emit('input', value);
|
||||
|
||||
_this2.$emit('change', _this2);
|
||||
});
|
||||
},
|
||||
getColumnValue: function getColumnValue(index) {
|
||||
return this.getValues()[index];
|
||||
},
|
||||
setColumnValue: function setColumnValue(index, value) {
|
||||
var _this$data = this.data,
|
||||
pickerValue = _this$data.pickerValue,
|
||||
columns = _this$data.columns;
|
||||
pickerValue[index] = columns[index].indexOf(value);
|
||||
this.set({
|
||||
pickerValue: pickerValue
|
||||
});
|
||||
},
|
||||
getColumnValues: function getColumnValues(index) {
|
||||
return this.data.columns[index];
|
||||
},
|
||||
setColumnValues: function setColumnValues(index, values) {
|
||||
var columns = this.data.columns;
|
||||
columns[index] = values;
|
||||
this.set({
|
||||
columns: columns
|
||||
});
|
||||
},
|
||||
getValues: function getValues() {
|
||||
var _this$data2 = this.data,
|
||||
pickerValue = _this$data2.pickerValue,
|
||||
columns = _this$data2.columns;
|
||||
return pickerValue.map(function (value, index) {
|
||||
return columns[index][value];
|
||||
});
|
||||
},
|
||||
setValues: function setValues(values) {
|
||||
var columns = this.data.columns;
|
||||
this.set({
|
||||
pickerValue: values.map(function (value, index) {
|
||||
return columns[index].indexOf(value);
|
||||
})
|
||||
_this3.$emit('change', picker);
|
||||
});
|
||||
},
|
||||
updateColumnValue: function updateColumnValue(value) {
|
||||
var _this4 = this;
|
||||
|
||||
var values = [];
|
||||
var data = this.data;
|
||||
var columns = data.columns;
|
||||
var picker = this.getPicker();
|
||||
|
||||
if (data.type === 'time') {
|
||||
var currentValue = value.split(':');
|
||||
values = [columns[0].indexOf(currentValue[0]), columns[1].indexOf(currentValue[1])];
|
||||
var pair = value.split(':');
|
||||
values = [pair[0], pair[1]];
|
||||
} else {
|
||||
var date = new Date(value);
|
||||
values = [columns[0].indexOf("" + date.getFullYear()), columns[1].indexOf(padZero(date.getMonth() + 1))];
|
||||
values = ["" + date.getFullYear(), padZero(date.getMonth() + 1)];
|
||||
|
||||
if (data.type === 'date') {
|
||||
values.push(columns[2].indexOf(padZero(date.getDate())));
|
||||
values.push(padZero(date.getDate()));
|
||||
}
|
||||
|
||||
if (data.type === 'datetime') {
|
||||
values.push(columns[2].indexOf(padZero(date.getDate())), columns[3].indexOf(padZero(date.getHours())), columns[4].indexOf(padZero(date.getMinutes())));
|
||||
values.push(padZero(date.getDate()), padZero(date.getHours()), padZero(date.getMinutes()));
|
||||
}
|
||||
}
|
||||
|
||||
this.set({
|
||||
pickerValue: values
|
||||
return this.asyncSet({
|
||||
innerValue: value
|
||||
}).then(function () {
|
||||
return _this4.updateColumns();
|
||||
}).then(function () {
|
||||
picker.setValues(values);
|
||||
});
|
||||
}
|
||||
},
|
||||
created: function created() {
|
||||
var _this3 = this;
|
||||
var _this5 = this;
|
||||
|
||||
var innerValue = this.correctValue(this.data.value);
|
||||
this.set({
|
||||
innerValue: innerValue
|
||||
}, function () {
|
||||
_this3.updateColumnValue(innerValue);
|
||||
|
||||
_this3.$emit('input', innerValue);
|
||||
this.updateColumnValue(innerValue).then(function () {
|
||||
_this5.$emit('input', innerValue);
|
||||
});
|
||||
}
|
||||
});
|
2
dist/datetime-picker/index.json
vendored
2
dist/datetime-picker/index.json
vendored
@ -1,6 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-loading": "../loading/index"
|
||||
"van-picker": "../picker/index"
|
||||
}
|
||||
}
|
||||
|
47
dist/datetime-picker/index.wxml
vendored
47
dist/datetime-picker/index.wxml
vendored
@ -1,34 +1,13 @@
|
||||
<view class="van-picker">
|
||||
<view wx:if="{{ showToolbar }}" class="van-picker__toolbar van-hairline--bottom">
|
||||
<view class="van-picker__cancel" bindtap="onCancel">{{ cancelButtonText }}</view>
|
||||
<view class="van-picker__title">{{ title }}</view>
|
||||
<view class="van-picker__confirm" bindtap="onConfirm">{{ confirmButtonText }}</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{ loading }}" class="van-picker__loading">
|
||||
<van-loading color="#1989fa"/>
|
||||
</view>
|
||||
|
||||
<picker-view
|
||||
indicator-style="height: {{ itemHeight }}px;"
|
||||
style="width: 100%; height: {{ itemHeight * visibleItemCount + 'px' }}"
|
||||
bindchange="onChange"
|
||||
value="{{ pickerValue }}"
|
||||
class="van-picker__columns"
|
||||
>
|
||||
<picker-view-column
|
||||
wx:for="{{ columns }}"
|
||||
wx:for-item="row"
|
||||
wx:for-index="rowIndex"
|
||||
wx:key="rowIndex"
|
||||
class="van-picker-column"
|
||||
>
|
||||
<view
|
||||
wx:for="{{ row }}"
|
||||
wx:key="{{ item }}"
|
||||
style="line-height: {{ itemHeight }}px;"
|
||||
class="van-picker-column__item {{ index === pickerValue[rowIndex] ? 'van-picker-column__item--selected' : '' }}"
|
||||
>{{ item }}</view>
|
||||
</picker-view-column>
|
||||
</picker-view>
|
||||
</view>
|
||||
<van-picker
|
||||
class="van-datetime-picker"
|
||||
title="{{ title }}"
|
||||
columns="{{ columns }}"
|
||||
item-height="{{ itemHeight }}"
|
||||
show-toolbar="{{ showToolbar }}"
|
||||
visible-item-count="{{ visibleItemCount }}"
|
||||
confirm-button-text="{{ confirmButtonText }}"
|
||||
cancel-button-text="{{ cancelButtonText }}"
|
||||
bind:change="onChange"
|
||||
bind:confirm="onConfirm"
|
||||
bind:cancel="onCancel"
|
||||
/>
|
||||
|
2
dist/icon/index.wxss
vendored
2
dist/icon/index.wxss
vendored
File diff suppressed because one or more lines are too long
4
dist/picker-column/index.js
vendored
4
dist/picker-column/index.js
vendored
@ -26,12 +26,16 @@ VantComponent({
|
||||
currentIndex: 0
|
||||
},
|
||||
created: function created() {
|
||||
var _this = this;
|
||||
|
||||
var _this$data = this.data,
|
||||
defaultIndex = _this$data.defaultIndex,
|
||||
initialOptions = _this$data.initialOptions;
|
||||
this.set({
|
||||
currentIndex: defaultIndex,
|
||||
options: initialOptions
|
||||
}, function () {
|
||||
_this.setIndex(defaultIndex);
|
||||
});
|
||||
},
|
||||
computed: {
|
||||
|
51
dist/picker/index.js
vendored
51
dist/picker/index.js
vendored
@ -1,4 +1,9 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
|
||||
function isSimple(columns) {
|
||||
return columns.length && !columns[0].values;
|
||||
}
|
||||
|
||||
VantComponent({
|
||||
classes: ['active-class', 'toolbar-class', 'column-class'],
|
||||
props: {
|
||||
@ -23,41 +28,39 @@ VantComponent({
|
||||
type: Array,
|
||||
value: [],
|
||||
observer: function observer(columns) {
|
||||
var _this = this;
|
||||
|
||||
if (columns === void 0) {
|
||||
columns = [];
|
||||
}
|
||||
|
||||
this.set({
|
||||
simple: columns.length && !columns[0].values
|
||||
}, function () {
|
||||
var children = _this.children = _this.selectAllComponents('.van-picker__column');
|
||||
this.simple = isSimple(columns);
|
||||
var children = this.children = this.selectAllComponents('.van-picker__column');
|
||||
|
||||
if (Array.isArray(children) && children.length) {
|
||||
_this.setColumns();
|
||||
}
|
||||
});
|
||||
if (Array.isArray(children) && children.length) {
|
||||
this.setColumns();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeCreate: function beforeCreate() {
|
||||
this.children = [];
|
||||
},
|
||||
methods: {
|
||||
noop: function noop() {},
|
||||
setColumns: function setColumns() {
|
||||
var _this2 = this;
|
||||
var _this = this;
|
||||
|
||||
var data = this.data;
|
||||
var columns = data.simple ? [{
|
||||
var columns = this.simple ? [{
|
||||
values: data.columns
|
||||
}] : data.columns;
|
||||
columns.forEach(function (columns, index) {
|
||||
_this2.setColumnValues(index, columns.values);
|
||||
_this.setColumnValues(index, columns.values);
|
||||
});
|
||||
},
|
||||
emit: function emit(event) {
|
||||
var type = event.currentTarget.dataset.type;
|
||||
|
||||
if (this.data.simple) {
|
||||
if (this.simple) {
|
||||
this.$emit(type, {
|
||||
value: this.getColumnValue(0),
|
||||
index: this.getColumnIndex(0)
|
||||
@ -70,7 +73,7 @@ VantComponent({
|
||||
}
|
||||
},
|
||||
onChange: function onChange(event) {
|
||||
if (this.data.simple) {
|
||||
if (this.simple) {
|
||||
this.$emit('change', {
|
||||
picker: this,
|
||||
value: this.getColumnValue(0),
|
||||
@ -112,14 +115,20 @@ VantComponent({
|
||||
return (this.children[index] || {}).data.options;
|
||||
},
|
||||
// set options of column by index
|
||||
setColumnValues: function setColumnValues(index, options) {
|
||||
setColumnValues: function setColumnValues(index, options, needReset) {
|
||||
if (needReset === void 0) {
|
||||
needReset = true;
|
||||
}
|
||||
|
||||
var column = this.children[index];
|
||||
|
||||
if (column && JSON.stringify(column.data.options) !== JSON.stringify(options)) {
|
||||
column.set({
|
||||
options: options
|
||||
}, function () {
|
||||
column.setIndex(0);
|
||||
if (needReset) {
|
||||
column.setIndex(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -131,10 +140,10 @@ VantComponent({
|
||||
},
|
||||
// set values of all columns
|
||||
setValues: function setValues(values) {
|
||||
var _this3 = this;
|
||||
var _this2 = this;
|
||||
|
||||
values.forEach(function (value, index) {
|
||||
_this3.setColumnValue(index, value);
|
||||
_this2.setColumnValue(index, value);
|
||||
});
|
||||
},
|
||||
// get indexes of all columns
|
||||
@ -145,10 +154,10 @@ VantComponent({
|
||||
},
|
||||
// set indexes of all columns
|
||||
setIndexes: function setIndexes(indexes) {
|
||||
var _this4 = this;
|
||||
var _this3 = this;
|
||||
|
||||
indexes.forEach(function (optionIndex, columnIndex) {
|
||||
_this4.setColumnIndex(columnIndex, optionIndex);
|
||||
_this3.setColumnIndex(columnIndex, optionIndex);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
13
dist/picker/index.wxml
vendored
13
dist/picker/index.wxml
vendored
@ -21,12 +21,12 @@
|
||||
>
|
||||
<picker-column
|
||||
class="van-picker__column"
|
||||
wx:for="{{ simple ? [columns] : columns }}"
|
||||
wx:key="index"
|
||||
wx:for="{{ isSimple(columns) ? [columns] : columns }}"
|
||||
wx:key="{{ index }}"
|
||||
data-index="{{ index }}"
|
||||
custom-class="column-class"
|
||||
value-key="{{ valueKey }}"
|
||||
initial-options="{{ simple ? item : item.values }}"
|
||||
initial-options="{{ isSimple(columns) ? item : item.values }}"
|
||||
default-index="{{ item.defaultIndex }}"
|
||||
item-height="{{ itemHeight }}"
|
||||
visible-item-count="{{ visibleItemCount }}"
|
||||
@ -39,3 +39,10 @@
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<wxs module="isSimple">
|
||||
function isSimple(columns) {
|
||||
return columns.length && !columns[0].values;
|
||||
}
|
||||
module.exports = isSimple;
|
||||
</wxs>
|
||||
|
2
dist/picker/index.wxss
vendored
2
dist/picker/index.wxss
vendored
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-picker{position:relative;overflow:hidden;-webkit-text-size-adjust:100%;background-color:#fff;-webkit-user-select:none;user-select:none}.van-picker__toolbar{display:-webkit-flex;display:flex;height:44px;line-height:44px;-webkit-justify-content:space-between;justify-content:space-between}.van-picker__cancel,.van-picker__confirm{padding:0 15px;font-size:14px;color:#1989fa}.van-picker__cancel:active,.van-picker__confirm:active{background-color:#e8e8e8}.van-picker__title{max-width:50%;font-size:16px;font-weight:500;text-align:center}.van-picker__columns{position:relative;display:-webkit-flex;display:flex}.van-picker__column{-webkit-flex:1;flex:1}.van-picker__loading{position:absolute;top:0;right:0;bottom:0;left:0;z-index:4;display:-webkit-flex;display:flex;background-color:rgba(255,255,255,.9);-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-picker__frame,.van-picker__loading .van-loading{position:absolute;top:50%;left:0;z-index:1;width:100%;pointer-events:none;-webkit-transform:translateY(-50%);transform:translateY(-50%)}
|
||||
@import '../common/index.wxss';.van-picker{position:relative;overflow:hidden;-webkit-text-size-adjust:100%;background-color:#fff;-webkit-user-select:none;user-select:none}.van-picker__toolbar{display:-webkit-flex;display:flex;height:44px;line-height:44px;-webkit-justify-content:space-between;justify-content:space-between}.van-picker__cancel,.van-picker__confirm{padding:0 15px;font-size:14px;color:#1989fa}.van-picker__cancel:active,.van-picker__confirm:active{background-color:#e8e8e8}.van-picker__title{max-width:50%;font-size:16px;font-weight:500;text-align:center}.van-picker__columns{position:relative;display:-webkit-flex;display:flex}.van-picker__column{-webkit-flex:1 1;flex:1 1;width:0}.van-picker__loading{position:absolute;top:0;right:0;bottom:0;left:0;z-index:4;display:-webkit-flex;display:flex;background-color:rgba(255,255,255,.9);-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-picker__frame,.van-picker__loading .van-loading{position:absolute;top:50%;left:0;z-index:1;width:100%;pointer-events:none;-webkit-transform:translateY(-50%);transform:translateY(-50%)}
|
10
dist/tab/index.js
vendored
10
dist/tab/index.js
vendored
@ -6,7 +6,10 @@ VantComponent({
|
||||
},
|
||||
props: {
|
||||
title: String,
|
||||
disabled: Boolean
|
||||
disabled: Boolean,
|
||||
dot: Boolean,
|
||||
info: null,
|
||||
titleStyle: String
|
||||
},
|
||||
data: {
|
||||
inited: false,
|
||||
@ -16,7 +19,10 @@ VantComponent({
|
||||
},
|
||||
watch: {
|
||||
title: 'update',
|
||||
disabled: 'update'
|
||||
disabled: 'update',
|
||||
dot: 'update',
|
||||
info: 'update',
|
||||
titleStyle: 'update'
|
||||
},
|
||||
methods: {
|
||||
update: function update() {
|
||||
|
4
dist/tab/index.wxml
vendored
4
dist/tab/index.wxml
vendored
@ -1,6 +1,8 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view
|
||||
wx:if="{{ animated || inited }}"
|
||||
class="custom-class van-tab__pane {{ active ? 'van-tab__pane--active' : 'van-tab__pane--inactive' }}"
|
||||
class="custom-class utils.bem('tab__pane', { active, inactive: !active }) }}"
|
||||
style="{{ animated || active ? '' : 'display: none;' }} {{ width ? 'width:' + width + 'px;' : '' }}"
|
||||
>
|
||||
<slot />
|
||||
|
7
dist/tabs/index.json
vendored
7
dist/tabs/index.json
vendored
@ -1,3 +1,6 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-info": "../info/index"
|
||||
}
|
||||
}
|
||||
|
11
dist/tabs/index.wxml
vendored
11
dist/tabs/index.wxml
vendored
@ -1,3 +1,5 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view class="custom-class van-tabs van-tabs--{{ type }}">
|
||||
<view style="z-index: {{ zIndex }}; {{ wrapStyle }}" class="van-tabs__wrap {{ scrollable ? 'van-tabs__wrap--scrollable' : '' }} {{ type === 'line' && border ? 'van-hairline--top-bottom' : '' }}">
|
||||
<scroll-view
|
||||
@ -13,12 +15,17 @@
|
||||
wx:for="{{ tabs }}"
|
||||
wx:key="index"
|
||||
data-index="{{ index }}"
|
||||
class="van-ellipsis van-tab {{ index === active ? 'van-tab--active' : '' }} {{ item.disabled ? 'van-tab--disabled' : '' }}"
|
||||
class="van-ellipsis {{ utils.bem('tab', { active: index === active, disabled: item.disabled }) }}"
|
||||
style="{{ color && index !== active && type === 'card' && !item.disabled ? 'color: ' + color : '' }} {{ color && index === active && type === 'card' ? ';background-color:' + color : '' }} {{ color ? ';border-color: ' + color : '' }} {{ scrollable ? ';flex-basis:' + (88 / swipeThreshold) + '%' : '' }}"
|
||||
bind:tap="onTap"
|
||||
>
|
||||
<view class="van-ellipsis van-tab__title">
|
||||
<view class="van-ellipsis {{ utils.bem('tab__title', { dot: item.dot }) }}" style="{{ item.titleStyle }}">
|
||||
{{ item.title }}
|
||||
<van-info
|
||||
wx:if="{{ item.info !== null }}"
|
||||
info="{{ item.info }}"
|
||||
custom-class="van-tab__title__info"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
2
dist/tabs/index.wxss
vendored
2
dist/tabs/index.wxss
vendored
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-tabs{position:relative;-webkit-tap-highlight-color:transparent}.van-tabs__wrap{top:0;left:0;right:0;position:absolute}.van-tabs__wrap--page-top{position:fixed}.van-tabs__wrap--content-bottom{top:auto;bottom:0}.van-tabs__wrap--scrollable .van-tab{-webkit-flex:0 0 22%;flex:0 0 22%}.van-tabs__scroll--card{border:1px solid #f44;border-radius:2px}.van-tabs__nav{display:-webkit-flex;display:flex;-webkit-user-select:none;user-select:none;position:relative;background-color:#fff}.van-tabs__nav--line{height:100%}.van-tabs__nav--card{height:30px}.van-tabs__nav--card .van-tab{color:#f44;border-right:1px solid #f44;line-height:30px}.van-tabs__nav--card .van-tab:last-child{border-right:none}.van-tabs__nav--card .van-tab.van-tab--active{color:#fff;background-color:#f44}.van-tabs__line{z-index:1;left:0;bottom:0;height:2px;position:absolute;background-color:#f44;border-radius:2px}.van-tabs--line{padding-top:44px}.van-tabs--line .van-tabs__wrap{height:44px}.van-tabs--card{padding-top:30px;margin:0 15px}.van-tabs--card .van-tabs__wrap{height:30px}.van-tabs__content{overflow:hidden}.van-tabs__track{position:relative}.van-tab{-webkit-flex:1;flex:1;cursor:pointer;padding:0 5px;font-size:14px;position:relative;color:#7d7e80;line-height:44px;text-align:center;box-sizing:border-box;background-color:#fff;min-width:0}.van-tab--active{font-weight:500;color:#333}.van-tab--disabled{color:#c9c9c9}
|
||||
@import '../common/index.wxss';.van-tabs{position:relative;-webkit-tap-highlight-color:transparent}.van-tabs__wrap{position:absolute;top:0;right:0;left:0}.van-tabs__wrap--page-top{position:fixed}.van-tabs__wrap--content-bottom{top:auto;bottom:0}.van-tabs__wrap--scrollable .van-tab{-webkit-flex:0 0 22%;flex:0 0 22%}.van-tabs__scroll--card{border:1px solid #f44;border-radius:2px}.van-tabs__nav{position:relative;display:-webkit-flex;display:flex;background-color:#fff;-webkit-user-select:none;user-select:none}.van-tabs__nav--line{height:100%}.van-tabs__nav--card{height:30px}.van-tabs__nav--card .van-tab{line-height:30px;color:#f44;border-right:1px solid #f44}.van-tabs__nav--card .van-tab:last-child{border-right:none}.van-tabs__nav--card .van-tab.van-tab--active{color:#fff;background-color:#f44}.van-tabs__line{position:absolute;bottom:0;left:0;z-index:1;height:2px;background-color:#f44;border-radius:2px}.van-tabs--line{padding-top:44px}.van-tabs--line .van-tabs__wrap{height:44px}.van-tabs--card{padding-top:30px;margin:0 15px}.van-tabs--card .van-tabs__wrap{height:30px}.van-tabs__content{overflow:hidden}.van-tabs__track{position:relative}.van-tab{position:relative;min-width:0;padding:0 5px;font-size:14px;line-height:44px;color:#7d7e80;text-align:center;cursor:pointer;background-color:#fff;box-sizing:border-box;-webkit-flex:1;flex:1}.van-tab--active{font-weight:500;color:#333}.van-tab--disabled{color:#c9c9c9}.van-tab__title--dot::after{display:inline-block;width:8px;height:8px;vertical-align:middle;background-color:#f44;border-radius:100%;content:''}.van-tab__title__info{position:relative!important;top:-1px!important;display:inline-block;-webkit-transform:translateX(0)!important;transform:translateX(0)!important}
|
2
dist/toast/index.wxss
vendored
2
dist/toast/index.wxss
vendored
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-toast{display:-webkit-flex;display:flex;color:#fff;font-size:14px;line-height:20px;border-radius:4px;word-break:break-all;-webkit-align-items:center;align-items:center;-webkit-flex-direction:column;flex-direction:column;-webkit-justify-content:center;justify-content:center;box-sizing:content-box;background-color:rgba(0,0,0,.7)}.van-toast__container{position:fixed;top:50%;left:50%;max-width:70%;width:-webkit-fit-content;width:fit-content;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.van-toast--text{padding:8px 12px;min-width:96px}.van-toast--icon{width:90px;padding:15px;min-height:90px}.van-toast--icon .van-toast__icon{font-size:48px}.van-toast--icon .van-toast__text{padding-top:5px}.van-toast__loading{margin:10px 0}.van-toast--top{-webkit-transform:translate(0,-30vh);transform:translate(0,-30vh)}.van-toast--bottom{-webkit-transform:translate(0,30vh);transform:translate(0,30vh)}
|
||||
@import '../common/index.wxss';.van-toast{display:-webkit-flex;display:flex;color:#fff;font-size:14px;line-height:20px;border-radius:4px;word-break:break-all;-webkit-align-items:center;align-items:center;-webkit-flex-direction:column;flex-direction:column;-webkit-justify-content:center;justify-content:center;box-sizing:content-box;background-color:rgba(51,51,51,.88)}.van-toast__container{position:fixed;top:50%;left:50%;max-width:70%;width:-webkit-fit-content;width:fit-content;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.van-toast--text{padding:8px 12px;min-width:96px}.van-toast--icon{width:90px;padding:15px;min-height:90px}.van-toast--icon .van-toast__icon{font-size:48px}.van-toast--icon .van-toast__text{padding-top:5px}.van-toast__loading{margin:10px 0}.van-toast--top{-webkit-transform:translate(0,-30vh);transform:translate(0,-30vh)}.van-toast--bottom{-webkit-transform:translate(0,30vh);transform:translate(0,30vh)}
|
Loading…
x
Reference in New Issue
Block a user