Compare commits
6 Commits
zjj_branch
...
main
Author | SHA1 | Date |
---|---|---|
|
59193debec | 1 year ago |
|
50476f2f75 | 1 year ago |
|
6105c294e5 | 1 year ago |
|
4560149a26 | 1 year ago |
|
0fdd0633e0 | 1 year ago |
|
7084ff2e52 | 1 year ago |
After Width: | Height: | Size: 248 KiB |
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Eslint config file
|
||||
* Documentation: https://eslint.org/docs/user-guide/configuring/
|
||||
* Install the Eslint extension before using this feature.
|
||||
*/
|
||||
module.exports = {
|
||||
env: {
|
||||
es6: true,
|
||||
browser: true,
|
||||
node: true,
|
||||
},
|
||||
ecmaFeatures: {
|
||||
modules: true,
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaVersion: 2018,
|
||||
sourceType: 'module',
|
||||
},
|
||||
globals: {
|
||||
wx: true,
|
||||
App: true,
|
||||
Page: true,
|
||||
getCurrentPages: true,
|
||||
getApp: true,
|
||||
Component: true,
|
||||
requirePlugin: true,
|
||||
requireMiniProgram: true,
|
||||
},
|
||||
// extends: 'eslint:recommended',
|
||||
rules: {},
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 jwhuang
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -0,0 +1,38 @@
|
||||
// app.js
|
||||
const amapFile = require('utils/amap-wx.js');
|
||||
App({
|
||||
onLaunch() {
|
||||
// 展示本地存储能力
|
||||
const logs = wx.getStorageSync('logs') || []
|
||||
logs.unshift(Date.now())
|
||||
wx.setStorageSync('logs', logs)
|
||||
|
||||
// 登录
|
||||
wx.login({
|
||||
success: res => {
|
||||
// 发送 res.code 到后台换取 openId, sessionKey, unionId
|
||||
}
|
||||
})
|
||||
|
||||
wx.cloud.init({
|
||||
env:'cloud-travel-7gc7n4zqa50965ff', //xxx填写云开发环境id
|
||||
traceUser: true
|
||||
})
|
||||
|
||||
},
|
||||
globalData: {
|
||||
mapInfo:"",
|
||||
mapApi:"https://restapi.amap.com/v3/",
|
||||
history:[],
|
||||
historyRoute:[],
|
||||
homePart: {
|
||||
homeText: '设置一个地址',
|
||||
homePoint: ''
|
||||
|
||||
},
|
||||
companyPart: {
|
||||
companyText: '设置一个地址',
|
||||
companyPoint: '',
|
||||
},
|
||||
}
|
||||
})
|
@ -0,0 +1,74 @@
|
||||
{
|
||||
"pages":[
|
||||
"pages/home/home",
|
||||
"pages/my/my",
|
||||
"pages/information/information",
|
||||
"pages/calendar/calendar",
|
||||
"pages/newslist/newslist",
|
||||
"pages/details/details",
|
||||
"pages/course/course",
|
||||
"pages/login/login",
|
||||
"pages/index/index",
|
||||
"pages/logs/logs",
|
||||
"pages/search/search",
|
||||
"pages/nearby/nearby",
|
||||
"pages/site/site",
|
||||
"pages/route/route",
|
||||
"pages/detail/detail",
|
||||
"pages/admin/admin",
|
||||
"pages/navigation/navigation",
|
||||
"pages/collect/collect"
|
||||
],
|
||||
"requiredPrivateInfos":[
|
||||
"getLocation",
|
||||
"chooseAddress",
|
||||
"onLocationChange",
|
||||
"startLocationUpdate",
|
||||
"startLocationUpdateBackground",
|
||||
"choosePoi",
|
||||
"chooseLocation"
|
||||
],
|
||||
"window":{
|
||||
"backgroundTextStyle":"light",
|
||||
"navigationBarBackgroundColor": "#fff",
|
||||
"navigationBarTitleText": "HDY",
|
||||
"navigationBarTextStyle":"black"
|
||||
},
|
||||
"navigateToMiniProgramAppIdList": [
|
||||
"wxbbec65de8931cc38"
|
||||
],
|
||||
"tabBar": {
|
||||
"borderStyle":"black",
|
||||
"selectedColor": "#00BCD4",
|
||||
"backgroundColor": "#ffffff",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/home/home",
|
||||
"text": "首页",
|
||||
"iconPath": "/images/home.png",
|
||||
"selectedIconPath": "/images/home.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/index/index",
|
||||
"text": "导航",
|
||||
"iconPath": "/images/navigate.png",
|
||||
"selectedIconPath": "/images/navigate.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/my/my",
|
||||
"text": "个人中心",
|
||||
"iconPath": "/images/my.png",
|
||||
"selectedIconPath": "images/my.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"style": "v2",
|
||||
"sitemapLocation": "sitemap.json",
|
||||
"permission": {
|
||||
"scope.userLocation": {
|
||||
"desc": "你的位置信息将用于小程序位置接口的效果展示"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
/**app.wxss**/
|
||||
.container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 200rpx 0;
|
||||
box-sizing: border-box;
|
||||
}
|
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 8.0 KiB |
After Width: | Height: | Size: 7.4 KiB |
After Width: | Height: | Size: 410 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 8.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 595 B |
After Width: | Height: | Size: 924 B |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 9.3 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 8.0 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 835 B |
After Width: | Height: | Size: 6.6 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 84 KiB |
After Width: | Height: | Size: 61 KiB |
After Width: | Height: | Size: 910 B |
After Width: | Height: | Size: 6.8 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 6.4 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 9.3 KiB |
After Width: | Height: | Size: 538 B |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 6.7 KiB |
After Width: | Height: | Size: 8.0 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 9.5 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 587 B |
@ -0,0 +1,64 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
var component_1 = require('../common/component');
|
||||
var button_1 = require('../mixins/button');
|
||||
var open_type_1 = require('../mixins/open-type');
|
||||
component_1.VantComponent({
|
||||
mixins: [button_1.button, open_type_1.openType],
|
||||
props: {
|
||||
show: Boolean,
|
||||
title: String,
|
||||
cancelText: String,
|
||||
description: String,
|
||||
round: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
zIndex: {
|
||||
type: Number,
|
||||
value: 100,
|
||||
},
|
||||
actions: {
|
||||
type: Array,
|
||||
value: [],
|
||||
},
|
||||
overlay: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
closeOnClickOverlay: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
closeOnClickAction: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
safeAreaInsetBottom: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
onSelect: function (event) {
|
||||
var index = event.currentTarget.dataset.index;
|
||||
var item = this.data.actions[index];
|
||||
if (item && !item.disabled && !item.loading) {
|
||||
this.$emit('select', item);
|
||||
if (this.data.closeOnClickAction) {
|
||||
this.onClose();
|
||||
}
|
||||
}
|
||||
},
|
||||
onCancel: function () {
|
||||
this.$emit('cancel');
|
||||
},
|
||||
onClose: function () {
|
||||
this.$emit('close');
|
||||
},
|
||||
onClickOverlay: function () {
|
||||
this.$emit('click-overlay');
|
||||
this.onClose();
|
||||
},
|
||||
},
|
||||
});
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-icon": "../icon/index",
|
||||
"van-popup": "../popup/index",
|
||||
"van-loading": "../loading/index"
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-action-sheet{max-height:90%!important;max-height:var(--action-sheet-max-height,90%)!important;color:#323233;color:var(--action-sheet-item-text-color,#323233)}.van-action-sheet__cancel,.van-action-sheet__item{text-align:center;font-size:16px;font-size:var(--action-sheet-item-font-size,16px);line-height:50px;line-height:var(--action-sheet-item-height,50px);background-color:#fff;background-color:var(--action-sheet-item-background,#fff)}.van-action-sheet__cancel--hover,.van-action-sheet__item--hover{background-color:#f2f3f5;background-color:var(--active-color,#f2f3f5)}.van-action-sheet__cancel:before{display:block;content:" ";height:8px;height:var(--action-sheet-cancel-padding-top,8px);background-color:#f7f8fa;background-color:var(--action-sheet-cancel-padding-color,#f7f8fa)}.van-action-sheet__item--disabled{color:#c8c9cc;color:var(--action-sheet-item-disabled-text-color,#c8c9cc)}.van-action-sheet__item--disabled.van-action-sheet__item--hover{background-color:#fff;background-color:var(--action-sheet-item-background,#fff)}.van-action-sheet__subname{margin-left:4px;margin-left:var(--padding-base,4px);font-size:12px;font-size:var(--action-sheet-subname-font-size,12px);color:#646566;color:var(--action-sheet-subname-color,#646566)}.van-action-sheet__header{text-align:center;font-weight:500;font-weight:var(--font-weight-bold,500);font-size:16px;font-size:var(--action-sheet-header-font-size,16px);line-height:44px;line-height:var(--action-sheet-header-height,44px)}.van-action-sheet__description{text-align:center;padding:16px;padding:var(--padding-md,16px);color:#646566;color:var(--action-sheet-description-color,#646566);font-size:14px;font-size:var(--action-sheet-description-font-size,14px);line-height:20px;line-height:var(--action-sheet-description-line-height,20px)}.van-action-sheet__close{position:absolute!important;top:0;right:0;line-height:inherit!important;padding:0 12px;padding:var(--action-sheet-close-icon-padding,0 12px);font-size:18px!important;font-size:var(--action-sheet-close-icon-size,18px)!important;color:#969799;color:var(--action-sheet-close-icon-color,#969799)}.van-action-sheet__loading{display:-webkit-flex!important;display:flex!important;height:50px;height:var(--action-sheet-item-height,50px)}
|
@ -0,0 +1,257 @@
|
||||
'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('../picker/shared');
|
||||
var COLUMNSPLACEHOLDERCODE = '000000';
|
||||
component_1.VantComponent({
|
||||
classes: ['active-class', 'toolbar-class', 'column-class'],
|
||||
props: __assign(__assign({}, shared_1.pickerProps), {
|
||||
value: {
|
||||
type: String,
|
||||
observer: function (value) {
|
||||
this.code = value;
|
||||
this.setValues();
|
||||
},
|
||||
},
|
||||
areaList: {
|
||||
type: Object,
|
||||
value: {},
|
||||
observer: 'setValues',
|
||||
},
|
||||
columnsNum: {
|
||||
type: null,
|
||||
value: 3,
|
||||
observer: function (value) {
|
||||
this.setData({
|
||||
displayColumns: this.data.columns.slice(0, +value),
|
||||
});
|
||||
},
|
||||
},
|
||||
columnsPlaceholder: {
|
||||
type: Array,
|
||||
observer: function (val) {
|
||||
this.setData({
|
||||
typeToColumnsPlaceholder: {
|
||||
province: val[0] || '',
|
||||
city: val[1] || '',
|
||||
county: val[2] || '',
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
}),
|
||||
data: {
|
||||
columns: [{ values: [] }, { values: [] }, { values: [] }],
|
||||
displayColumns: [{ values: [] }, { values: [] }, { values: [] }],
|
||||
typeToColumnsPlaceholder: {},
|
||||
},
|
||||
mounted: function () {
|
||||
var _this = this;
|
||||
setTimeout(function () {
|
||||
_this.setValues();
|
||||
}, 0);
|
||||
},
|
||||
methods: {
|
||||
getPicker: function () {
|
||||
if (this.picker == null) {
|
||||
this.picker = this.selectComponent('.van-area__picker');
|
||||
}
|
||||
return this.picker;
|
||||
},
|
||||
onCancel: function (event) {
|
||||
this.emit('cancel', event.detail);
|
||||
},
|
||||
onConfirm: function (event) {
|
||||
var index = event.detail.index;
|
||||
var value = event.detail.value;
|
||||
value = this.parseOutputValues(value);
|
||||
this.emit('confirm', { value: value, index: index });
|
||||
},
|
||||
emit: function (type, detail) {
|
||||
detail.values = detail.value;
|
||||
delete detail.value;
|
||||
this.$emit(type, detail);
|
||||
},
|
||||
// parse output columns data
|
||||
parseOutputValues: function (values) {
|
||||
var columnsPlaceholder = this.data.columnsPlaceholder;
|
||||
return values.map(function (value, index) {
|
||||
// save undefined value
|
||||
if (!value) return value;
|
||||
value = JSON.parse(JSON.stringify(value));
|
||||
if (!value.code || value.name === columnsPlaceholder[index]) {
|
||||
value.code = '';
|
||||
value.name = '';
|
||||
}
|
||||
return value;
|
||||
});
|
||||
},
|
||||
onChange: function (event) {
|
||||
var _this = this;
|
||||
var _a = event.detail,
|
||||
index = _a.index,
|
||||
picker = _a.picker,
|
||||
value = _a.value;
|
||||
this.code = value[index].code;
|
||||
this.setValues().then(function () {
|
||||
_this.$emit('change', {
|
||||
picker: picker,
|
||||
values: _this.parseOutputValues(picker.getValues()),
|
||||
index: index,
|
||||
});
|
||||
});
|
||||
},
|
||||
getConfig: function (type) {
|
||||
var areaList = this.data.areaList;
|
||||
return (areaList && areaList[type + '_list']) || {};
|
||||
},
|
||||
getList: function (type, code) {
|
||||
var typeToColumnsPlaceholder = this.data.typeToColumnsPlaceholder;
|
||||
var result = [];
|
||||
if (type !== 'province' && !code) {
|
||||
return result;
|
||||
}
|
||||
var list = this.getConfig(type);
|
||||
result = Object.keys(list).map(function (code) {
|
||||
return {
|
||||
code: code,
|
||||
name: list[code],
|
||||
};
|
||||
});
|
||||
if (code) {
|
||||
// oversea code
|
||||
if (code[0] === '9' && type === 'city') {
|
||||
code = '9';
|
||||
}
|
||||
result = result.filter(function (item) {
|
||||
return item.code.indexOf(code) === 0;
|
||||
});
|
||||
}
|
||||
if (typeToColumnsPlaceholder[type] && result.length) {
|
||||
// set columns placeholder
|
||||
var codeFill =
|
||||
type === 'province'
|
||||
? ''
|
||||
: type === 'city'
|
||||
? COLUMNSPLACEHOLDERCODE.slice(2, 4)
|
||||
: COLUMNSPLACEHOLDERCODE.slice(4, 6);
|
||||
result.unshift({
|
||||
code: '' + code + codeFill,
|
||||
name: typeToColumnsPlaceholder[type],
|
||||
});
|
||||
}
|
||||
return result;
|
||||
},
|
||||
getIndex: function (type, code) {
|
||||
var compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6;
|
||||
var list = this.getList(type, code.slice(0, compareNum - 2));
|
||||
// oversea code
|
||||
if (code[0] === '9' && type === 'province') {
|
||||
compareNum = 1;
|
||||
}
|
||||
code = code.slice(0, compareNum);
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (list[i].code.slice(0, compareNum) === code) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
setValues: function () {
|
||||
var _this = this;
|
||||
var county = this.getConfig('county');
|
||||
var code = this.code;
|
||||
if (!code) {
|
||||
if (this.data.columnsPlaceholder.length) {
|
||||
code = COLUMNSPLACEHOLDERCODE;
|
||||
} else if (Object.keys(county)[0]) {
|
||||
code = Object.keys(county)[0];
|
||||
} else {
|
||||
code = '';
|
||||
}
|
||||
}
|
||||
var province = this.getList('province');
|
||||
var city = this.getList('city', code.slice(0, 2));
|
||||
var picker = this.getPicker();
|
||||
if (!picker) {
|
||||
return;
|
||||
}
|
||||
var stack = [];
|
||||
stack.push(picker.setColumnValues(0, province, false));
|
||||
stack.push(picker.setColumnValues(1, city, false));
|
||||
if (city.length && code.slice(2, 4) === '00') {
|
||||
code = city[0].code;
|
||||
}
|
||||
stack.push(
|
||||
picker.setColumnValues(
|
||||
2,
|
||||
this.getList('county', code.slice(0, 4)),
|
||||
false
|
||||
)
|
||||
);
|
||||
return Promise.all(stack)
|
||||
.catch(function () {})
|
||||
.then(function () {
|
||||
return picker.setIndexes([
|
||||
_this.getIndex('province', code),
|
||||
_this.getIndex('city', code),
|
||||
_this.getIndex('county', code),
|
||||
]);
|
||||
})
|
||||
.catch(function () {});
|
||||
},
|
||||
getValues: function () {
|
||||
var picker = this.getPicker();
|
||||
return picker
|
||||
? picker.getValues().filter(function (value) {
|
||||
return !!value;
|
||||
})
|
||||
: [];
|
||||
},
|
||||
getDetail: function () {
|
||||
var values = this.getValues();
|
||||
var area = {
|
||||
code: '',
|
||||
country: '',
|
||||
province: '',
|
||||
city: '',
|
||||
county: '',
|
||||
};
|
||||
if (!values.length) {
|
||||
return area;
|
||||
}
|
||||
var names = values.map(function (item) {
|
||||
return item.name;
|
||||
});
|
||||
area.code = values[values.length - 1].code;
|
||||
if (area.code[0] === '9') {
|
||||
area.country = names[1] || '';
|
||||
area.province = names[2] || '';
|
||||
} else {
|
||||
area.province = names[0] || '';
|
||||
area.city = names[1] || '';
|
||||
area.county = names[2] || '';
|
||||
}
|
||||
return area;
|
||||
},
|
||||
reset: function (code) {
|
||||
this.code = code || '';
|
||||
return this.setValues();
|
||||
},
|
||||
},
|
||||
});
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-picker": "../picker/index"
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<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 }}"
|
||||
cancel-button-text="{{ cancelButtonText }}"
|
||||
confirm-button-text="{{ confirmButtonText }}"
|
||||
bind:change="onChange"
|
||||
bind:confirm="onConfirm"
|
||||
bind:cancel="onCancel"
|
||||
/>
|
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';
|
@ -0,0 +1,81 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
var component_1 = require('../common/component');
|
||||
var button_1 = require('../mixins/button');
|
||||
var open_type_1 = require('../mixins/open-type');
|
||||
var version_1 = require('../common/version');
|
||||
var mixins = [button_1.button, open_type_1.openType];
|
||||
if (version_1.canIUseFormFieldButton()) {
|
||||
mixins.push('wx://form-field-button');
|
||||
}
|
||||
component_1.VantComponent({
|
||||
mixins: mixins,
|
||||
classes: ['hover-class', 'loading-class'],
|
||||
data: {
|
||||
baseStyle: '',
|
||||
},
|
||||
props: {
|
||||
formType: String,
|
||||
icon: String,
|
||||
classPrefix: {
|
||||
type: String,
|
||||
value: 'van-icon',
|
||||
},
|
||||
plain: Boolean,
|
||||
block: Boolean,
|
||||
round: Boolean,
|
||||
square: Boolean,
|
||||
loading: Boolean,
|
||||
hairline: Boolean,
|
||||
disabled: Boolean,
|
||||
loadingText: String,
|
||||
customStyle: String,
|
||||
loadingType: {
|
||||
type: String,
|
||||
value: 'circular',
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
value: 'default',
|
||||
},
|
||||
dataset: null,
|
||||
size: {
|
||||
type: String,
|
||||
value: 'normal',
|
||||
},
|
||||
loadingSize: {
|
||||
type: String,
|
||||
value: '20px',
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
observer: function (color) {
|
||||
var style = '';
|
||||
if (color) {
|
||||
style += 'color: ' + (this.data.plain ? color : 'white') + ';';
|
||||
if (!this.data.plain) {
|
||||
// Use background instead of backgroundColor to make linear-gradient work
|
||||
style += 'background: ' + color + ';';
|
||||
}
|
||||
// hide border when color is linear-gradient
|
||||
if (color.indexOf('gradient') !== -1) {
|
||||
style += 'border: 0;';
|
||||
} else {
|
||||
style += 'border-color: ' + color + ';';
|
||||
}
|
||||
}
|
||||
if (style !== this.data.baseStyle) {
|
||||
this.setData({ baseStyle: style });
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
onClick: function () {
|
||||
if (!this.data.loading) {
|
||||
this.$emit('click');
|
||||
}
|
||||
},
|
||||
noop: function () {},
|
||||
},
|
||||
});
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-icon": "../icon/index",
|
||||
"van-loading": "../loading/index"
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<button
|
||||
id="{{ id }}"
|
||||
data-detail="{{ dataset }}"
|
||||
class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, hairline, unclickable: disabled || loading }]) }} {{ hairline ? 'van-hairline--surround' : '' }}"
|
||||
hover-class="van-button--active hover-class"
|
||||
lang="{{ lang }}"
|
||||
form-type="{{ formType }}"
|
||||
style="{{ baseStyle }} {{ customStyle }}"
|
||||
open-type="{{ disabled ? '' : openType }}"
|
||||
business-id="{{ businessId }}"
|
||||
session-from="{{ sessionFrom }}"
|
||||
send-message-title="{{ sendMessageTitle }}"
|
||||
send-message-path="{{ sendMessagePath }}"
|
||||
send-message-img="{{ sendMessageImg }}"
|
||||
show-message-card="{{ showMessageCard }}"
|
||||
app-parameter="{{ appParameter }}"
|
||||
aria-label="{{ ariaLabel }}"
|
||||
bindtap="{{ !disabled ? 'onClick' : 'noop' }}"
|
||||
bindgetuserinfo="bindGetUserInfo"
|
||||
bindcontact="bindContact"
|
||||
bindgetphonenumber="bindGetPhoneNumber"
|
||||
binderror="bindError"
|
||||
bindlaunchapp="bindLaunchApp"
|
||||
bindopensetting="bindOpenSetting"
|
||||
>
|
||||
<block wx:if="{{ loading }}">
|
||||
<van-loading
|
||||
custom-class="loading-class"
|
||||
size="{{ loadingSize }}"
|
||||
type="{{ loadingType }}"
|
||||
color="{{ loadingColor(type,color,plain) }}"
|
||||
/>
|
||||
<view wx:if="{{ loadingText }}" class="van-button__loading-text">
|
||||
{{ loadingText }}
|
||||
</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<van-icon
|
||||
wx:if="{{ icon }}"
|
||||
size="1.2em"
|
||||
name="{{ icon }}"
|
||||
class-prefix="{{ classPrefix }}"
|
||||
class="van-button__icon"
|
||||
custom-style="line-height: inherit;"
|
||||
/>
|
||||
<view class="van-button__text">
|
||||
<slot />
|
||||
</view>
|
||||
</block>
|
||||
</button>
|
||||
|
||||
|
||||
<wxs module="loadingColor">
|
||||
function get(type, color,plain) {
|
||||
if(plain) {
|
||||
return color ? color: '#c9c9c9';
|
||||
}
|
||||
|
||||
if(type === 'default') {
|
||||
return '#c9c9c9';
|
||||
}
|
||||
return 'white';
|
||||
}
|
||||
|
||||
module.exports = get;
|
||||
</wxs>
|
@ -0,0 +1 @@
|
||||
@import '../common/index.wxss';.van-button{position:relative;display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0;text-align:center;vertical-align:middle;-webkit-appearance:none;-webkit-text-size-adjust:100%;height:44px;height:var(--button-default-height,44px);line-height:20px;line-height:var(--button-line-height,20px);font-size:16px;font-size:var(--button-default-font-size,16px);transition:opacity .2s;transition:opacity var(--animation-duration-fast,.2s);border-radius:2px;border-radius:var(--button-border-radius,2px)}.van-button:before{position:absolute;top:50%;left:50%;width:100%;height:100%;border:inherit;border-radius:inherit;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);opacity:0;content:" ";background-color:#000;background-color:var(--black,#000);border-color:#000;border-color:var(--black,#000)}.van-button:after{border-width:0}.van-button--active:before{opacity:.15}.van-button--unclickable:after{display:none}.van-button--default{color:#323233;color:var(--button-default-color,#323233);background:#fff;background:var(--button-default-background-color,#fff);border:1px solid #ebedf0;border:var(--button-border-width,1px) solid var(--button-default-border-color,#ebedf0)}.van-button--primary{color:#fff;color:var(--button-primary-color,#fff);background:#07c160;background:var(--button-primary-background-color,#07c160);border:1px solid #07c160;border:var(--button-border-width,1px) solid var(--button-primary-border-color,#07c160)}.van-button--info{color:#fff;color:var(--button-info-color,#fff);background:#1989fa;background:var(--button-info-background-color,#1989fa);border:1px solid #1989fa;border:var(--button-border-width,1px) solid var(--button-info-border-color,#1989fa)}.van-button--danger{color:#fff;color:var(--button-danger-color,#fff);background:#ee0a24;background:var(--button-danger-background-color,#ee0a24);border:1px solid #ee0a24;border:var(--button-border-width,1px) solid var(--button-danger-border-color,#ee0a24)}.van-button--warning{color:#fff;color:var(--button-warning-color,#fff);background:#ff976a;background:var(--button-warning-background-color,#ff976a);border:1px solid #ff976a;border:var(--button-border-width,1px) solid var(--button-warning-border-color,#ff976a)}.van-button--plain{background:#fff;background:var(--button-plain-background-color,#fff)}.van-button--plain.van-button--primary{color:#07c160;color:var(--button-primary-background-color,#07c160)}.van-button--plain.van-button--info{color:#1989fa;color:var(--button-info-background-color,#1989fa)}.van-button--plain.van-button--danger{color:#ee0a24;color:var(--button-danger-background-color,#ee0a24)}.van-button--plain.van-button--warning{color:#ff976a;color:var(--button-warning-background-color,#ff976a)}.van-button--large{width:100%;height:50px;height:var(--button-large-height,50px)}.van-button--normal{padding:0 15px;font-size:14px;font-size:var(--button-normal-font-size,14px)}.van-button--small{min-width:60px;min-width:var(--button-small-min-width,60px);height:30px;height:var(--button-small-height,30px);padding:0 8px;padding:0 var(--padding-xs,8px);font-size:12px;font-size:var(--button-small-font-size,12px)}.van-button--mini{display:inline-block;min-width:50px;min-width:var(--button-mini-min-width,50px);height:22px;height:var(--button-mini-height,22px);font-size:10px;font-size:var(--button-mini-font-size,10px)}.van-button--mini+.van-button--mini{margin-left:5px}.van-button--block{display:-webkit-flex;display:flex;width:100%}.van-button--round{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--square{border-radius:0}.van-button--disabled{opacity:.5;opacity:var(--button-disabled-opacity,.5)}.van-button__text{display:inline}.van-button__icon+.van-button__text:not(:empty),.van-button__loading-text{margin-left:4px}.van-button__icon{min-width:1em;line-height:inherit!important;vertical-align:top}.van-button--hairline{padding-top:1px;border-width:0}.van-button--hairline:after{border-color:inherit;border-width:1px;border-radius:4px;border-radius:calc(var(--button-border-radius, 2px)*2)}.van-button--hairline.van-button--round:after{border-radius:999px;border-radius:var(--button-round-border-radius,999px)}.van-button--hairline.van-button--square:after{border-radius:0}
|
@ -0,0 +1,57 @@
|
||||
<wxs src="./index.wxs" module="computed"></wxs>
|
||||
|
||||
<template name="calendar">
|
||||
<view class="van-calendar">
|
||||
<header
|
||||
title="{{ title }}"
|
||||
showTitle="{{ showTitle }}"
|
||||
subtitle="{{ subtitle }}"
|
||||
showSubtitle="{{ showSubtitle }}"
|
||||
>
|
||||
<slot name="title" slot="title"></slot>
|
||||
</header>
|
||||
|
||||
<scroll-view class="van-calendar__body" scroll-y scroll-into-view="{{ scrollIntoView }}">
|
||||
<month
|
||||
wx:for="{{ computed.getMonths(minDate, maxDate) }}"
|
||||
wx:key="index"
|
||||
id="month{{ index }}"
|
||||
class="month"
|
||||
data-date="{{ item }}"
|
||||
date="{{ item }}"
|
||||
type="{{ type }}"
|
||||
color="{{ color }}"
|
||||
minDate="{{ minDate }}"
|
||||
maxDate="{{ maxDate }}"
|
||||
showMark="{{ showMark }}"
|
||||
formatter="{{ formatter }}"
|
||||
rowHeight="{{ rowHeight }}"
|
||||
currentDate="{{ currentDate }}"
|
||||
showSubtitle="{{ showSubtitle }}"
|
||||
allowSameDay="{{ allowSameDay }}"
|
||||
showMonthTitle="{{ index !== 0 || !showSubtitle }}"
|
||||
bind:click="onClickDay"
|
||||
/>
|
||||
</scroll-view>
|
||||
|
||||
<view class="van-calendar__footer {{ safeAreaInsetBottom ? 'van-calendar__footer--safe-area-inset-bottom' : '' }}">
|
||||
<slot name="footer"></slot>
|
||||
</view>
|
||||
|
||||
<view class="van-calendar__footer {{ safeAreaInsetBottom ? 'van-calendar__footer--safe-area-inset-bottom' : '' }}">
|
||||
<van-button
|
||||
wx:if="{{ showConfirm }}"
|
||||
round
|
||||
block
|
||||
type="danger"
|
||||
color="{{ color }}"
|
||||
custom-class="van-calendar__confirm"
|
||||
disabled="{{ computed.getButtonDisabled(type, currentDate) }}"
|
||||
nativeType="text"
|
||||
bind:click="onConfirm"
|
||||
>
|
||||
{{ computed.getButtonDisabled(type, currentDate) ? confirmDisabledText : confirmText }}
|
||||
</van-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
var component_1 = require('../../../common/component');
|
||||
component_1.VantComponent({
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
value: '日期选择',
|
||||
},
|
||||
subtitle: String,
|
||||
showTitle: Boolean,
|
||||
showSubtitle: Boolean,
|
||||
},
|
||||
data: {
|
||||
weekdays: ['日', '一', '二', '三', '四', '五', '六'],
|
||||
},
|
||||
methods: {},
|
||||
});
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<view class="van-calendar__header">
|
||||
<block wx:if="{{ showTitle }}">
|
||||
<view class="van-calendar__header-title"><slot name="title"></slot></view>
|
||||
<view class="van-calendar__header-title">{{ title }}</view>
|
||||
</block>
|
||||
|
||||
<view wx:if="{{ showSubtitle }}" class="van-calendar__header-subtitle">
|
||||
{{ subtitle }}
|
||||
</view>
|
||||
|
||||
<view class="van-calendar__weekdays">
|
||||
<view wx:for="{{ weekdays }}" wx:key="index" class="van-calendar__weekday">
|
||||
{{ item }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
@ -0,0 +1 @@
|
||||
@import '../../../common/index.wxss';.van-calendar__header{-webkit-flex-shrink:0;flex-shrink:0;box-shadow:0 2px 10px rgba(125,126,128,.16);box-shadow:var(--calendar-header-box-shadow,0 2px 10px rgba(125,126,128,.16))}.van-calendar__header-subtitle,.van-calendar__header-title{text-align:center;height:44px;height:var(--calendar-header-title-height,44px);font-weight:500;font-weight:var(--font-weight-bold,500);line-height:44px;line-height:var(--calendar-header-title-height,44px)}.van-calendar__header-title+.van-calendar__header-title,.van-calendar__header-title:empty{display:none}.van-calendar__header-title:empty+.van-calendar__header-title{display:block!important}.van-calendar__weekdays{display:-webkit-flex;display:flex}.van-calendar__weekday{-webkit-flex:1;flex:1;text-align:center;font-size:12px;font-size:var(--calendar-weekdays-font-size,12px);line-height:30px;line-height:var(--calendar-weekdays-height,30px)}
|
@ -0,0 +1,167 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
var component_1 = require('../../../common/component');
|
||||
var utils_1 = require('../../utils');
|
||||
component_1.VantComponent({
|
||||
props: {
|
||||
date: {
|
||||
type: null,
|
||||
observer: 'setDays',
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
observer: 'setDays',
|
||||
},
|
||||
color: String,
|
||||
minDate: {
|
||||
type: null,
|
||||
observer: 'setDays',
|
||||
},
|
||||
maxDate: {
|
||||
type: null,
|
||||
observer: 'setDays',
|
||||
},
|
||||
showMark: Boolean,
|
||||
rowHeight: [Number, String],
|
||||
formatter: {
|
||||
type: null,
|
||||
observer: 'setDays',
|
||||
},
|
||||
currentDate: {
|
||||
type: [null, Array],
|
||||
observer: 'setDays',
|
||||
},
|
||||
allowSameDay: Boolean,
|
||||
showSubtitle: Boolean,
|
||||
showMonthTitle: Boolean,
|
||||
},
|
||||
data: {
|
||||
visible: true,
|
||||
days: [],
|
||||
},
|
||||
methods: {
|
||||
onClick: function (event) {
|
||||
var index = event.currentTarget.dataset.index;
|
||||
var item = this.data.days[index];
|
||||
if (item.type !== 'disabled') {
|
||||
this.$emit('click', item);
|
||||
}
|
||||
},
|
||||
setDays: function () {
|
||||
var days = [];
|
||||
var startDate = new Date(this.data.date);
|
||||
var year = startDate.getFullYear();
|
||||
var month = startDate.getMonth();
|
||||
var totalDay = utils_1.getMonthEndDay(
|
||||
startDate.getFullYear(),
|
||||
startDate.getMonth() + 1
|
||||
);
|
||||
for (var day = 1; day <= totalDay; day++) {
|
||||
var date = new Date(year, month, day);
|
||||
var type = this.getDayType(date);
|
||||
var config = {
|
||||
date: date,
|
||||
type: type,
|
||||
text: day,
|
||||
bottomInfo: this.getBottomInfo(type),
|
||||
};
|
||||
if (this.data.formatter) {
|
||||
config = this.data.formatter(config);
|
||||
}
|
||||
days.push(config);
|
||||
}
|
||||
this.setData({ days: days });
|
||||
},
|
||||
getMultipleDayType: function (day) {
|
||||
var currentDate = this.data.currentDate;
|
||||
if (!Array.isArray(currentDate)) {
|
||||
return '';
|
||||
}
|
||||
var isSelected = function (date) {
|
||||
return currentDate.some(function (item) {
|
||||
return utils_1.compareDay(item, date) === 0;
|
||||
});
|
||||
};
|
||||
if (isSelected(day)) {
|
||||
var prevDay = utils_1.getPrevDay(day);
|
||||
var nextDay = utils_1.getNextDay(day);
|
||||
var prevSelected = isSelected(prevDay);
|
||||
var nextSelected = isSelected(nextDay);
|
||||
if (prevSelected && nextSelected) {
|
||||
return 'multiple-middle';
|
||||
}
|
||||
if (prevSelected) {
|
||||
return 'end';
|
||||
}
|
||||
return nextSelected ? 'start' : 'multiple-selected';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
getRangeDayType: function (day) {
|
||||
var _a = this.data,
|
||||
currentDate = _a.currentDate,
|
||||
allowSameDay = _a.allowSameDay;
|
||||
if (!Array.isArray(currentDate)) {
|
||||
return;
|
||||
}
|
||||
var startDay = currentDate[0],
|
||||
endDay = currentDate[1];
|
||||
if (!startDay) {
|
||||
return;
|
||||
}
|
||||
var compareToStart = utils_1.compareDay(day, startDay);
|
||||
if (!endDay) {
|
||||
return compareToStart === 0 ? 'start' : '';
|
||||
}
|
||||
var compareToEnd = utils_1.compareDay(day, endDay);
|
||||
if (compareToStart === 0 && compareToEnd === 0 && allowSameDay) {
|
||||
return 'start-end';
|
||||
}
|
||||
if (compareToStart === 0) {
|
||||
return 'start';
|
||||
}
|
||||
if (compareToEnd === 0) {
|
||||
return 'end';
|
||||
}
|
||||
if (compareToStart > 0 && compareToEnd < 0) {
|
||||
return 'middle';
|
||||
}
|
||||
},
|
||||
getDayType: function (day) {
|
||||
var _a = this.data,
|
||||
type = _a.type,
|
||||
minDate = _a.minDate,
|
||||
maxDate = _a.maxDate,
|
||||
currentDate = _a.currentDate;
|
||||
if (
|
||||
utils_1.compareDay(day, minDate) < 0 ||
|
||||
utils_1.compareDay(day, maxDate) > 0
|
||||
) {
|
||||
return 'disabled';
|
||||
}
|
||||
if (type === 'single') {
|
||||
return utils_1.compareDay(day, currentDate) === 0 ? 'selected' : '';
|
||||
}
|
||||
if (type === 'multiple') {
|
||||
return this.getMultipleDayType(day);
|
||||
}
|
||||
/* istanbul ignore else */
|
||||
if (type === 'range') {
|
||||
return this.getRangeDayType(day);
|
||||
}
|
||||
},
|
||||
getBottomInfo: function (type) {
|
||||
if (this.data.type === 'range') {
|
||||
if (type === 'start') {
|
||||
return '开始';
|
||||
}
|
||||
if (type === 'end') {
|
||||
return '结束';
|
||||
}
|
||||
if (type === 'start-end') {
|
||||
return '开始/结束';
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
<wxs src="./index.wxs" module="computed"></wxs>
|
||||
<wxs src="../../../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view class="van-calendar__month" style="{{ computed.getMonthStyle(visible, date, rowHeight) }}">
|
||||
<view wx:if="{{ showMonthTitle }}" class="van-calendar__month-title">
|
||||
{{ computed.formatMonthTitle(date) }}
|
||||
</view>
|
||||
|
||||
<view wx:if="{{ visible }}" class="van-calendar__days">
|
||||
<view wx:if="{{ showMark }}" class="van-calendar__month-mark">
|
||||
{{ computed.getMark(date) }}
|
||||
</view>
|
||||
|
||||
<view
|
||||
wx:for="{{ days }}"
|
||||
wx:key="index"
|
||||
style="{{ computed.getDayStyle(item.type, index, date, rowHeight, color) }}"
|
||||
class="{{ utils.bem('calendar__day', [item.type]) }} {{ item.className }}"
|
||||
data-index="{{ index }}"
|
||||
bindtap="onClick"
|
||||
>
|
||||
<view wx:if="{{ item.type === 'selected' }}" class="van-calendar__selected-day" style="background: {{ color }}">
|
||||
<view wx:if="{{ item.topInfo }}" class="van-calendar__top-info">{{ item.topInfo }}</view>
|
||||
{{ item.text }}
|
||||
<view wx:if="{{ item.bottomInfo }}" class="van-calendar__bottom-info">
|
||||
{{ item.bottomInfo }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:else>
|
||||
<view wx:if="{{ item.topInfo }}" class="van-calendar__top-info">{{ item.topInfo }}</view>
|
||||
{{ item.text }}
|
||||
<view wx:if="{{ item.bottomInfo }}" class="van-calendar__bottom-info">
|
||||
{{ item.bottomInfo }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
@ -0,0 +1,67 @@
|
||||
/* eslint-disable */
|
||||
var utils = require('../../utils.wxs');
|
||||
|
||||
function getMark(date) {
|
||||
return getDate(date).getMonth() + 1;
|
||||
}
|
||||
|
||||
var ROW_HEIGHT = 64;
|
||||
|
||||
function getDayStyle(type, index, date, rowHeight, color) {
|
||||
var style = [];
|
||||
var offset = getDate(date).getDay();
|
||||
|
||||
if (index === 0) {
|
||||
style.push(['margin-left', (100 * offset) / 7 + '%']);
|
||||
}
|
||||
|
||||
if (rowHeight !== ROW_HEIGHT) {
|
||||
style.push(['height', rowHeight + 'px']);
|
||||
}
|
||||
|
||||
if (color) {
|
||||
if (
|
||||
type === 'start' ||
|
||||
type === 'end' ||
|
||||
type === 'multiple-selected' ||
|
||||
type === 'multiple-middle'
|
||||
) {
|
||||
style.push(['background', color]);
|
||||
} else if (type === 'middle') {
|
||||
style.push(['color', color]);
|
||||
}
|
||||
}
|
||||
|
||||
return style
|
||||
.map(function(item) {
|
||||
return item.join(':');
|
||||
})
|
||||
.join(';');
|
||||
}
|
||||
|
||||
function formatMonthTitle(date) {
|
||||
date = getDate(date);
|
||||
return date.getFullYear() + '年' + (date.getMonth() + 1) + '月';
|
||||
}
|
||||
|
||||
function getMonthStyle(visible, date, rowHeight) {
|
||||
if (!visible) {
|
||||
date = getDate(date);
|
||||
|
||||
var totalDay = utils.getMonthEndDay(
|
||||
date.getFullYear(),
|
||||
date.getMonth() + 1
|
||||
);
|
||||
var offset = getDate(date).getDay();
|
||||
var padding = Math.ceil((totalDay + offset) / 7) * rowHeight;
|
||||
|
||||
return 'padding-bottom:' + padding + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getMark: getMark,
|
||||
getDayStyle: getDayStyle,
|
||||
formatMonthTitle: formatMonthTitle,
|
||||
getMonthStyle: getMonthStyle
|
||||
};
|
@ -0,0 +1 @@
|
||||
@import '../../../common/index.wxss';.van-calendar{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;height:100%;background-color:#fff;background-color:var(--calendar-background-color,#fff)}.van-calendar__month-title{text-align:center;height:44px;height:var(--calendar-header-title-height,44px);font-weight:500;font-weight:var(--font-weight-bold,500);font-size:14px;font-size:var(--calendar-month-title-font-size,14px);line-height:44px;line-height:var(--calendar-header-title-height,44px)}.van-calendar__days{position:relative;display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap;-webkit-user-select:none;user-select:none}.van-calendar__month-mark{position:absolute;top:50%;left:50%;z-index:0;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);pointer-events:none;color:rgba(242,243,245,.8);color:var(--calendar-month-mark-color,rgba(242,243,245,.8));font-size:160px;font-size:var(--calendar-month-mark-font-size,160px)}.van-calendar__day,.van-calendar__selected-day{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;text-align:center}.van-calendar__day{position:relative;width:14.285%;height:64px;height:var(--calendar-day-height,64px);font-size:16px;font-size:var(--calendar-day-font-size,16px)}.van-calendar__day--end,.van-calendar__day--multiple-middle,.van-calendar__day--multiple-selected,.van-calendar__day--start,.van-calendar__day--start-end{color:#fff;color:var(--calendar-range-edge-color,#fff);background-color:#ee0a24;background-color:var(--calendar-range-edge-background-color,#ee0a24)}.van-calendar__day--start{border-radius:4px 0 0 4px;border-radius:var(--border-radius-md,4px) 0 0 var(--border-radius-md,4px)}.van-calendar__day--end{border-radius:0 4px 4px 0;border-radius:0 var(--border-radius-md,4px) var(--border-radius-md,4px) 0}.van-calendar__day--multiple-selected,.van-calendar__day--start-end{border-radius:4px;border-radius:var(--border-radius-md,4px)}.van-calendar__day--middle{color:#ee0a24;color:var(--calendar-range-middle-color,#ee0a24)}.van-calendar__day--middle:after{position:absolute;top:0;right:0;bottom:0;left:0;background-color:currentColor;content:"";opacity:.1;opacity:var(--calendar-range-middle-background-opacity,.1)}.van-calendar__day--disabled{cursor:default;color:#c8c9cc;color:var(--calendar-day-disabled-color,#c8c9cc)}.van-calendar__bottom-info,.van-calendar__top-info{position:absolute;right:0;left:0;font-size:10px;font-size:var(--calendar-info-font-size,10px);line-height:14px;line-height:var(--calendar-info-line-height,14px)}@media (max-width:350px){.van-calendar__bottom-info,.van-calendar__top-info{font-size:9px}}.van-calendar__top-info{top:6px}.van-calendar__bottom-info{bottom:6px}.van-calendar__selected-day{width:54px;width:var(--calendar-selected-day-size,54px);height:54px;height:var(--calendar-selected-day-size,54px);color:#fff;color:var(--calendar-selected-day-color,#fff);background-color:#ee0a24;background-color:var(--calendar-selected-day-background-color,#ee0a24);border-radius:4px;border-radius:var(--border-radius-md,4px)}
|
@ -0,0 +1,318 @@
|
||||
'use strict';
|
||||
var __spreadArrays =
|
||||
(this && this.__spreadArrays) ||
|
||||
function () {
|
||||
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
||||
s += arguments[i].length;
|
||||
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
||||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
||||
r[k] = a[j];
|
||||
return r;
|
||||
};
|
||||
var __importDefault =
|
||||
(this && this.__importDefault) ||
|
||||
function (mod) {
|
||||
return mod && mod.__esModule ? mod : { default: mod };
|
||||
};
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
var component_1 = require('../common/component');
|
||||
var utils_1 = require('./utils');
|
||||
var toast_1 = __importDefault(require('../toast/toast'));
|
||||
component_1.VantComponent({
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
value: '日期选择',
|
||||
},
|
||||
color: String,
|
||||
show: {
|
||||
type: Boolean,
|
||||
observer: function (val) {
|
||||
if (val) {
|
||||
this.initRect();
|
||||
this.scrollIntoView();
|
||||
}
|
||||
},
|
||||
},
|
||||
formatter: null,
|
||||
confirmText: {
|
||||
type: String,
|
||||
value: '确定',
|
||||
},
|
||||
rangePrompt: String,
|
||||
defaultDate: {
|
||||
type: [Number, Array],
|
||||
observer: function (val) {
|
||||
this.setData({ currentDate: val });
|
||||
this.scrollIntoView();
|
||||
},
|
||||
},
|
||||
allowSameDay: Boolean,
|
||||
confirmDisabledText: String,
|
||||
type: {
|
||||
type: String,
|
||||
value: 'single',
|
||||
observer: 'reset',
|
||||
},
|
||||
minDate: {
|
||||
type: null,
|
||||
value: Date.now(),
|
||||
},
|
||||
maxDate: {
|
||||
type: null,
|
||||
value: new Date(
|
||||
new Date().getFullYear(),
|
||||
new Date().getMonth() + 6,
|
||||
new Date().getDate()
|
||||
).getTime(),
|
||||
},
|
||||
position: {
|
||||
type: String,
|
||||
value: 'bottom',
|
||||
},
|
||||
rowHeight: {
|
||||
type: [Number, String],
|
||||
value: utils_1.ROW_HEIGHT,
|
||||
},
|
||||
round: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
poppable: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
showMark: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
showTitle: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
showConfirm: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
showSubtitle: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
safeAreaInsetBottom: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
closeOnClickOverlay: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
maxRange: {
|
||||
type: [Number, String],
|
||||
value: null,
|
||||
},
|
||||
},
|
||||
data: {
|
||||
subtitle: '',
|
||||
currentDate: null,
|
||||
scrollIntoView: '',
|
||||
},
|
||||
created: function () {
|
||||
this.setData({
|
||||
currentDate: this.getInitialDate(),
|
||||
});
|
||||
},
|
||||
mounted: function () {
|
||||
if (this.data.show || !this.data.poppable) {
|
||||
this.initRect();
|
||||
this.scrollIntoView();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
reset: function () {
|
||||
this.setData({ currentDate: this.getInitialDate() });
|
||||
this.scrollIntoView();
|
||||
},
|
||||
initRect: function () {
|
||||
var _this = this;
|
||||
if (this.contentObserver != null) {
|
||||
this.contentObserver.disconnect();
|
||||
}
|
||||
var contentObserver = this.createIntersectionObserver({
|
||||
thresholds: [0, 0.1, 0.9, 1],
|
||||
observeAll: true,
|
||||
});
|
||||
this.contentObserver = contentObserver;
|
||||
contentObserver.relativeTo('.van-calendar__body');
|
||||
contentObserver.observe('.month', function (res) {
|
||||
if (res.boundingClientRect.top <= res.relativeRect.top) {
|
||||
// @ts-ignore
|
||||
_this.setData({
|
||||
subtitle: utils_1.formatMonthTitle(res.dataset.date),
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
getInitialDate: function () {
|
||||
var _a = this.data,
|
||||
type = _a.type,
|
||||
defaultDate = _a.defaultDate,
|
||||
minDate = _a.minDate;
|
||||
if (type === 'range') {
|
||||
var _b = defaultDate || [],
|
||||
startDay = _b[0],
|
||||
endDay = _b[1];
|
||||
return [
|
||||
startDay || minDate,
|
||||
endDay || utils_1.getNextDay(new Date(minDate)).getTime(),
|
||||
];
|
||||
}
|
||||
if (type === 'multiple') {
|
||||
return defaultDate || [minDate];
|
||||
}
|
||||
return defaultDate || minDate;
|
||||
},
|
||||
scrollIntoView: function () {
|
||||
var _this = this;
|
||||
setTimeout(function () {
|
||||
var _a = _this.data,
|
||||
currentDate = _a.currentDate,
|
||||
type = _a.type,
|
||||
show = _a.show,
|
||||
poppable = _a.poppable,
|
||||
minDate = _a.minDate,
|
||||
maxDate = _a.maxDate;
|
||||
var targetDate = type === 'single' ? currentDate : currentDate[0];
|
||||
var displayed = show || !poppable;
|
||||
if (!targetDate || !displayed) {
|
||||
return;
|
||||
}
|
||||
var months = utils_1.getMonths(minDate, maxDate);
|
||||
months.some(function (month, index) {
|
||||
if (utils_1.compareMonth(month, targetDate) === 0) {
|
||||
_this.setData({ scrollIntoView: 'month' + index });
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}, 100);
|
||||
},
|
||||
onOpen: function () {
|
||||
this.$emit('open');
|
||||
},
|
||||
onOpened: function () {
|
||||
this.$emit('opened');
|
||||
},
|
||||
onClose: function () {
|
||||
this.$emit('close');
|
||||
},
|
||||
onClosed: function () {
|
||||
this.$emit('closed');
|
||||
},
|
||||
onClickDay: function (event) {
|
||||
var date = event.detail.date;
|
||||
var _a = this.data,
|
||||
type = _a.type,
|
||||
currentDate = _a.currentDate,
|
||||
allowSameDay = _a.allowSameDay;
|
||||
if (type === 'range') {
|
||||
var startDay = currentDate[0],
|
||||
endDay = currentDate[1];
|
||||
if (startDay && !endDay) {
|
||||
var compareToStart = utils_1.compareDay(date, startDay);
|
||||
if (compareToStart === 1) {
|
||||
this.select([startDay, date], true);
|
||||
} else if (compareToStart === -1) {
|
||||
this.select([date, null]);
|
||||
} else if (allowSameDay) {
|
||||
this.select([date, date]);
|
||||
}
|
||||
} else {
|
||||
this.select([date, null]);
|
||||
}
|
||||
} else if (type === 'multiple') {
|
||||
var selectedIndex_1;
|
||||
var selected = currentDate.some(function (dateItem, index) {
|
||||
var equal = utils_1.compareDay(dateItem, date) === 0;
|
||||
if (equal) {
|
||||
selectedIndex_1 = index;
|
||||
}
|
||||
return equal;
|
||||
});
|
||||
if (selected) {
|
||||
var cancelDate = currentDate.splice(selectedIndex_1, 1);
|
||||
this.setData({ currentDate: currentDate });
|
||||
this.unselect(cancelDate);
|
||||
} else {
|
||||
this.select(__spreadArrays(currentDate, [date]));
|
||||
}
|
||||
} else {
|
||||
this.select(date, true);
|
||||
}
|
||||
},
|
||||
unselect: function (dateArray) {
|
||||
var date = dateArray[0];
|
||||
if (date) {
|
||||
this.$emit('unselect', utils_1.copyDates(date));
|
||||
}
|
||||
},
|
||||
select: function (date, complete) {
|
||||
if (complete && this.data.type === 'range') {
|
||||
var valid = this.checkRange(date);
|
||||
if (!valid) {
|
||||
// auto selected to max range if showConfirm
|
||||
if (this.data.showConfirm) {
|
||||
this.emit([
|
||||
date[0],
|
||||
utils_1.getDayByOffset(date[0], this.data.maxRange - 1),
|
||||
]);
|
||||
} else {
|
||||
this.emit(date);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.emit(date);
|
||||
if (complete && !this.data.showConfirm) {
|
||||
this.onConfirm();
|
||||
}
|
||||
},
|
||||
emit: function (date) {
|
||||
var getTime = function (date) {
|
||||
return date instanceof Date ? date.getTime() : date;
|
||||
};
|
||||
this.setData({
|
||||
currentDate: Array.isArray(date) ? date.map(getTime) : getTime(date),
|
||||
});
|
||||
this.$emit('select', utils_1.copyDates(date));
|
||||
},
|
||||
checkRange: function (date) {
|
||||
var _a = this.data,
|
||||
maxRange = _a.maxRange,
|
||||
rangePrompt = _a.rangePrompt;
|
||||
if (maxRange && utils_1.calcDateNum(date) > maxRange) {
|
||||
toast_1.default({
|
||||
context: this,
|
||||
message:
|
||||
rangePrompt ||
|
||||
'\u9009\u62E9\u5929\u6570\u4E0D\u80FD\u8D85\u8FC7 ' +
|
||||
maxRange +
|
||||
' \u5929',
|
||||
});
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
onConfirm: function () {
|
||||
var _this = this;
|
||||
if (
|
||||
this.data.type === 'range' &&
|
||||
!this.checkRange(this.data.currentDate)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
wx.nextTick(function () {
|
||||
_this.$emit('confirm', utils_1.copyDates(_this.data.currentDate));
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"header": "./components/header/index",
|
||||
"month": "./components/month/index",
|
||||
"van-button": "../button/index",
|
||||
"van-popup": "../popup/index"
|
||||
}
|
||||
}
|