开始做登录
This commit is contained in:
1
miniprogram_npm/@vant/weapp/picker/index.d.ts
vendored
Normal file
1
miniprogram_npm/@vant/weapp/picker/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
161
miniprogram_npm/@vant/weapp/picker/index.js
Normal file
161
miniprogram_npm/@vant/weapp/picker/index.js
Normal file
@@ -0,0 +1,161 @@
|
||||
"use strict";
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var component_1 = require("../common/component");
|
||||
var shared_1 = require("./shared");
|
||||
(0, component_1.VantComponent)({
|
||||
classes: ['active-class', 'toolbar-class', 'column-class'],
|
||||
props: __assign(__assign({}, shared_1.pickerProps), { valueKey: {
|
||||
type: String,
|
||||
value: 'text',
|
||||
}, toolbarPosition: {
|
||||
type: String,
|
||||
value: 'top',
|
||||
}, defaultIndex: {
|
||||
type: Number,
|
||||
value: 0,
|
||||
}, columns: {
|
||||
type: Array,
|
||||
value: [],
|
||||
observer: function (columns) {
|
||||
if (columns === void 0) { columns = []; }
|
||||
this.simple = columns.length && !columns[0].values;
|
||||
if (Array.isArray(this.children) && this.children.length) {
|
||||
this.setColumns().catch(function () { });
|
||||
}
|
||||
},
|
||||
} }),
|
||||
beforeCreate: function () {
|
||||
var _this = this;
|
||||
Object.defineProperty(this, 'children', {
|
||||
get: function () { return _this.selectAllComponents('.van-picker__column') || []; },
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
noop: function () { },
|
||||
setColumns: function () {
|
||||
var _this = this;
|
||||
var data = this.data;
|
||||
var columns = this.simple ? [{ values: data.columns }] : data.columns;
|
||||
var stack = columns.map(function (column, index) {
|
||||
return _this.setColumnValues(index, column.values);
|
||||
});
|
||||
return Promise.all(stack);
|
||||
},
|
||||
emit: function (event) {
|
||||
var type = event.currentTarget.dataset.type;
|
||||
if (this.simple) {
|
||||
this.$emit(type, {
|
||||
value: this.getColumnValue(0),
|
||||
index: this.getColumnIndex(0),
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.$emit(type, {
|
||||
value: this.getValues(),
|
||||
index: this.getIndexes(),
|
||||
});
|
||||
}
|
||||
},
|
||||
onChange: function (event) {
|
||||
if (this.simple) {
|
||||
this.$emit('change', {
|
||||
picker: this,
|
||||
value: this.getColumnValue(0),
|
||||
index: this.getColumnIndex(0),
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.$emit('change', {
|
||||
picker: this,
|
||||
value: this.getValues(),
|
||||
index: event.currentTarget.dataset.index,
|
||||
});
|
||||
}
|
||||
},
|
||||
// get column instance by index
|
||||
getColumn: function (index) {
|
||||
return this.children[index];
|
||||
},
|
||||
// get column value by index
|
||||
getColumnValue: function (index) {
|
||||
var column = this.getColumn(index);
|
||||
return column && column.getValue();
|
||||
},
|
||||
// set column value by index
|
||||
setColumnValue: function (index, value) {
|
||||
var column = this.getColumn(index);
|
||||
if (column == null) {
|
||||
return Promise.reject(new Error('setColumnValue: 对应列不存在'));
|
||||
}
|
||||
return column.setValue(value);
|
||||
},
|
||||
// get column option index by column index
|
||||
getColumnIndex: function (columnIndex) {
|
||||
return (this.getColumn(columnIndex) || {}).data.currentIndex;
|
||||
},
|
||||
// set column option index by column index
|
||||
setColumnIndex: function (columnIndex, optionIndex) {
|
||||
var column = this.getColumn(columnIndex);
|
||||
if (column == null) {
|
||||
return Promise.reject(new Error('setColumnIndex: 对应列不存在'));
|
||||
}
|
||||
return column.setIndex(optionIndex);
|
||||
},
|
||||
// get options of column by index
|
||||
getColumnValues: function (index) {
|
||||
return (this.children[index] || {}).data.options;
|
||||
},
|
||||
// set options of column by index
|
||||
setColumnValues: function (index, options, needReset) {
|
||||
if (needReset === void 0) { needReset = true; }
|
||||
var column = this.children[index];
|
||||
if (column == null) {
|
||||
return Promise.reject(new Error('setColumnValues: 对应列不存在'));
|
||||
}
|
||||
var isSame = JSON.stringify(column.data.options) === JSON.stringify(options);
|
||||
if (isSame) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return column.set({ options: options }).then(function () {
|
||||
if (needReset) {
|
||||
column.setIndex(0);
|
||||
}
|
||||
});
|
||||
},
|
||||
// get values of all columns
|
||||
getValues: function () {
|
||||
return this.children.map(function (child) { return child.getValue(); });
|
||||
},
|
||||
// set values of all columns
|
||||
setValues: function (values) {
|
||||
var _this = this;
|
||||
var stack = values.map(function (value, index) {
|
||||
return _this.setColumnValue(index, value);
|
||||
});
|
||||
return Promise.all(stack);
|
||||
},
|
||||
// get indexes of all columns
|
||||
getIndexes: function () {
|
||||
return this.children.map(function (child) { return child.data.currentIndex; });
|
||||
},
|
||||
// set indexes of all columns
|
||||
setIndexes: function (indexes) {
|
||||
var _this = this;
|
||||
var stack = indexes.map(function (optionIndex, columnIndex) {
|
||||
return _this.setColumnIndex(columnIndex, optionIndex);
|
||||
});
|
||||
return Promise.all(stack);
|
||||
},
|
||||
},
|
||||
});
|
7
miniprogram_npm/@vant/weapp/picker/index.json
Normal file
7
miniprogram_npm/@vant/weapp/picker/index.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"picker-column": "../picker-column/index",
|
||||
"loading": "../loading/index"
|
||||
}
|
||||
}
|
37
miniprogram_npm/@vant/weapp/picker/index.wxml
Normal file
37
miniprogram_npm/@vant/weapp/picker/index.wxml
Normal file
@@ -0,0 +1,37 @@
|
||||
<wxs src="./index.wxs" module="computed" />
|
||||
|
||||
<view class="van-picker custom-class">
|
||||
<include wx:if="{{ toolbarPosition === 'top' }}" src="./toolbar.wxml" />
|
||||
|
||||
<view wx:if="{{ loading }}" class="van-picker__loading">
|
||||
<loading color="#1989fa"/>
|
||||
</view>
|
||||
|
||||
<view
|
||||
class="van-picker__columns"
|
||||
style="{{ computed.columnsStyle({ itemHeight, visibleItemCount }) }}"
|
||||
catch:touchmove="noop"
|
||||
>
|
||||
<picker-column
|
||||
class="van-picker__column"
|
||||
wx:for="{{ computed.columns(columns) }}"
|
||||
wx:key="index"
|
||||
data-index="{{ index }}"
|
||||
custom-class="column-class"
|
||||
value-key="{{ valueKey }}"
|
||||
initial-options="{{ item.values }}"
|
||||
default-index="{{ item.defaultIndex || defaultIndex }}"
|
||||
item-height="{{ itemHeight }}"
|
||||
visible-item-count="{{ visibleItemCount }}"
|
||||
active-class="active-class"
|
||||
bind:change="onChange"
|
||||
/>
|
||||
<view class="van-picker__mask" style="{{ computed.maskStyle({ itemHeight, visibleItemCount }) }}" />
|
||||
<view
|
||||
class="van-picker__frame van-hairline--top-bottom"
|
||||
style="{{ computed.frameStyle({ itemHeight }) }}"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<include wx:if="{{ toolbarPosition === 'bottom' }}" src="./toolbar.wxml" />
|
||||
</view>
|
42
miniprogram_npm/@vant/weapp/picker/index.wxs
Normal file
42
miniprogram_npm/@vant/weapp/picker/index.wxs
Normal file
@@ -0,0 +1,42 @@
|
||||
/* eslint-disable */
|
||||
var style = require('../wxs/style.wxs');
|
||||
var addUnit = require('../wxs/add-unit.wxs');
|
||||
var array = require('../wxs/array.wxs');
|
||||
|
||||
function columnsStyle(data) {
|
||||
return style({
|
||||
height: addUnit(data.itemHeight * data.visibleItemCount),
|
||||
});
|
||||
}
|
||||
|
||||
function maskStyle(data) {
|
||||
return style({
|
||||
'background-size':
|
||||
'100% ' + addUnit((data.itemHeight * (data.visibleItemCount - 1)) / 2),
|
||||
});
|
||||
}
|
||||
|
||||
function frameStyle(data) {
|
||||
return style({
|
||||
height: addUnit(data.itemHeight),
|
||||
});
|
||||
}
|
||||
|
||||
function columns(columns) {
|
||||
if (!array.isArray(columns)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (columns.length && !columns[0].values) {
|
||||
return [{ values: columns }];
|
||||
}
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
columnsStyle: columnsStyle,
|
||||
frameStyle: frameStyle,
|
||||
maskStyle: maskStyle,
|
||||
columns: columns,
|
||||
};
|
1
miniprogram_npm/@vant/weapp/picker/index.wxss
Normal file
1
miniprogram_npm/@vant/weapp/picker/index.wxss
Normal file
@@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-picker{-webkit-text-size-adjust:100%;background-color:var(--picker-background-color,#fff);overflow:hidden;position:relative;-webkit-user-select:none;user-select:none}.van-picker__toolbar{display:flex;height:var(--picker-toolbar-height,44px);justify-content:space-between;line-height:var(--picker-toolbar-height,44px)}.van-picker__cancel,.van-picker__confirm{font-size:var(--picker-action-font-size,14px);padding:var(--picker-action-padding,0 16px)}.van-picker__cancel--hover,.van-picker__confirm--hover{opacity:.7}.van-picker__confirm{color:var(--picker-confirm-action-color,#576b95)}.van-picker__cancel{color:var(--picker-cancel-action-color,#969799)}.van-picker__title{font-size:var(--picker-option-font-size,16px);font-weight:var(--font-weight-bold,500);max-width:50%;text-align:center}.van-picker__columns{display:flex;position:relative}.van-picker__column{flex:1 1;width:0}.van-picker__loading{align-items:center;background-color:var(--picker-loading-mask-color,hsla(0,0%,100%,.9));bottom:0;display:flex;justify-content:center;left:0;position:absolute;right:0;top:0;z-index:4}.van-picker__mask{-webkit-backface-visibility:hidden;backface-visibility:hidden;background-image:linear-gradient(180deg,hsla(0,0%,100%,.9),hsla(0,0%,100%,.4)),linear-gradient(0deg,hsla(0,0%,100%,.9),hsla(0,0%,100%,.4));background-position:top,bottom;background-repeat:no-repeat;height:100%;left:0;top:0;width:100%;z-index:2}.van-picker__frame,.van-picker__mask{pointer-events:none;position:absolute}.van-picker__frame{left:16px;right:16px;top:50%;transform:translateY(-50%);z-index:1}
|
21
miniprogram_npm/@vant/weapp/picker/shared.d.ts
vendored
Normal file
21
miniprogram_npm/@vant/weapp/picker/shared.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
export declare const pickerProps: {
|
||||
title: StringConstructor;
|
||||
loading: BooleanConstructor;
|
||||
showToolbar: BooleanConstructor;
|
||||
cancelButtonText: {
|
||||
type: StringConstructor;
|
||||
value: string;
|
||||
};
|
||||
confirmButtonText: {
|
||||
type: StringConstructor;
|
||||
value: string;
|
||||
};
|
||||
visibleItemCount: {
|
||||
type: NumberConstructor;
|
||||
value: number;
|
||||
};
|
||||
itemHeight: {
|
||||
type: NumberConstructor;
|
||||
value: number;
|
||||
};
|
||||
};
|
24
miniprogram_npm/@vant/weapp/picker/shared.js
Normal file
24
miniprogram_npm/@vant/weapp/picker/shared.js
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.pickerProps = void 0;
|
||||
exports.pickerProps = {
|
||||
title: String,
|
||||
loading: Boolean,
|
||||
showToolbar: Boolean,
|
||||
cancelButtonText: {
|
||||
type: String,
|
||||
value: '取消',
|
||||
},
|
||||
confirmButtonText: {
|
||||
type: String,
|
||||
value: '确认',
|
||||
},
|
||||
visibleItemCount: {
|
||||
type: Number,
|
||||
value: 6,
|
||||
},
|
||||
itemHeight: {
|
||||
type: Number,
|
||||
value: 44,
|
||||
},
|
||||
};
|
23
miniprogram_npm/@vant/weapp/picker/toolbar.wxml
Normal file
23
miniprogram_npm/@vant/weapp/picker/toolbar.wxml
Normal file
@@ -0,0 +1,23 @@
|
||||
<view wx:if="{{ showToolbar }}" class="van-picker__toolbar toolbar-class">
|
||||
<view
|
||||
class="van-picker__cancel"
|
||||
hover-class="van-picker__cancel--hover"
|
||||
hover-stay-time="70"
|
||||
data-type="cancel"
|
||||
bindtap="emit"
|
||||
>
|
||||
{{ cancelButtonText }}
|
||||
</view>
|
||||
<view wx:if="{{ title }}" class="van-picker__title van-ellipsis">{{
|
||||
title
|
||||
}}</view>
|
||||
<view
|
||||
class="van-picker__confirm"
|
||||
hover-class="van-picker__confirm--hover"
|
||||
hover-stay-time="70"
|
||||
data-type="confirm"
|
||||
bindtap="emit"
|
||||
>
|
||||
{{ confirmButtonText }}
|
||||
</view>
|
||||
</view>
|
Reference in New Issue
Block a user