正在显示
100 个修改的文件
包含
2617 行增加
和
75 行删除
1 | { | 1 | { |
2 | - "pages": [ | ||
3 | - "pages/start/start", | ||
4 | - "pages/index/index", | ||
5 | - "pages/my/my", | ||
6 | - "pages/mydetail/mydetail", | ||
7 | - "pages/more/more", | ||
8 | - "pages/more_other/more_other", | ||
9 | - "pages/admin/admin", | ||
10 | - "pages/apply/apply", | ||
11 | - "pages/img_txt/img_txt", | ||
12 | - "pages/result/result", | ||
13 | - "pages/close_apply/close_apply", | ||
14 | - "pages/my/my_active/my_active", | ||
15 | - "pages/index/active/active", | ||
16 | - "pages/word_report/word_report", | ||
17 | - "pages/enroll/enroll", | ||
18 | - | ||
19 | - | ||
20 | - "pages/Volunteer_dynamic/Volunteer_dynamic", | ||
21 | - "pages/getNewsInfo/getNewsInfo", | ||
22 | - "pages/Volunteer_group/Volunteer_group", | ||
23 | - "pages/Volunteer_group/active/active", | ||
24 | - "pages/Volunteer_detail/Volunteer_detail", | ||
25 | - "pages/Online_regulations/Online_regulations", | ||
26 | - "pages/getStudycontent/getStudycontent", | ||
27 | - "pages/getStudycontent/answer/answer", | ||
28 | - "pages/guanlitiaoli/guanlitiaoli", | ||
29 | - "pages/guangrongpaihang/guangrongpaihang", | ||
30 | - | ||
31 | - | ||
32 | - "pages/myactivity/myactivity", | ||
33 | - "pages/myactivity/myactivity_active/myactivity_active", | ||
34 | - "pages/myactivity/myactivity_report/myactivity_report", | ||
35 | - "pages/myteam/myteam", | ||
36 | - "pages/mytrain/mytrain", | ||
37 | - "pages/myfeedback/myfeedback", | ||
38 | - "pages/myfeedback/myfeedback_active/myfeedback_active", | ||
39 | - "pages/myfeedback/myfeedback_duihuan/myfeedback_duihuan", | ||
40 | - "pages/myfeedback/myfeedback_list/myfeedback_list", | ||
41 | - "pages/myfeedback/myfeedback_detail/myfeedback_detail", | ||
42 | - "pages/myfeedback_lists/myfeedback_lists", | ||
43 | - "pages/mycertificate/mycertificate", | ||
44 | - "pages/myaddress/myaddress", | ||
45 | - "pages/myaddcompile/myaddcompile" | ||
46 | - | ||
47 | - | ||
48 | - ], | ||
49 | - | ||
50 | - "permission": { | ||
51 | - "scope.userLocation": { | ||
52 | - "desc": "你的位置信息将用于小程序位置接口的效果展示" | ||
53 | - } | ||
54 | - }, | ||
55 | - "window": { | ||
56 | - "backgroundTextStyle": "light", | ||
57 | - "navigationBarBackgroundColor": "#21AE59", | ||
58 | - "navigationBarTitleText": "白求恩志愿者中心", | ||
59 | - "navigationBarTextStyle": "white" | ||
60 | - }, | ||
61 | - "tabBar": { | ||
62 | - "color":"#999999", | ||
63 | - "list": [{ | ||
64 | - "pagePath": "pages/index/index", | ||
65 | - "text": "首页", | ||
66 | - "iconPath": "imgs/shouye_02@2x.png", | ||
67 | - "selectedIconPath": "imgs/shouye_01@2x.png" | ||
68 | - }, | ||
69 | - { | ||
70 | - "pagePath": "pages/my/my", | ||
71 | - "text": "个人中心", | ||
72 | - "iconPath": "imgs/wode_01@2x.png", | ||
73 | - "selectedIconPath": "imgs/wode_02@2x.png" | 2 | + "pages": [ |
3 | + "pages/start/start", | ||
4 | + "pages/index/index", | ||
5 | + "pages/my/my", | ||
6 | + "pages/mydetail/mydetail", | ||
7 | + "pages/more/more", | ||
8 | + "pages/more_other/more_other", | ||
9 | + "pages/admin/admin", | ||
10 | + "pages/apply/apply", | ||
11 | + "pages/img_txt/img_txt", | ||
12 | + "pages/result/result", | ||
13 | + "pages/close_apply/close_apply", | ||
14 | + "pages/my/my_active/my_active", | ||
15 | + "pages/index/active/active", | ||
16 | + "pages/word_report/word_report", | ||
17 | + "pages/enroll/enroll", | ||
18 | + "pages/Volunteer_dynamic/Volunteer_dynamic", | ||
19 | + "pages/getNewsInfo/getNewsInfo", | ||
20 | + "pages/Volunteer_group/Volunteer_group", | ||
21 | + "pages/Volunteer_group/active/active", | ||
22 | + "pages/Volunteer_detail/Volunteer_detail", | ||
23 | + "pages/Online_regulations/Online_regulations", | ||
24 | + "pages/getStudycontent/getStudycontent", | ||
25 | + "pages/getStudycontent/answer/answer", | ||
26 | + "pages/guanlitiaoli/guanlitiaoli", | ||
27 | + "pages/guangrongpaihang/guangrongpaihang", | ||
28 | + "pages/myactivity/myactivity", | ||
29 | + "pages/myactivity/myactivity_active/myactivity_active", | ||
30 | + "pages/myactivity/myactivity_report/myactivity_report", | ||
31 | + "pages/myteam/myteam", | ||
32 | + "pages/mytrain/mytrain", | ||
33 | + "pages/myfeedback/myfeedback", | ||
34 | + "pages/myfeedback/myfeedback_active/myfeedback_active", | ||
35 | + "pages/myfeedback/myfeedback_duihuan/myfeedback_duihuan", | ||
36 | + "pages/myfeedback/myfeedback_list/myfeedback_list", | ||
37 | + "pages/myfeedback/myfeedback_detail/myfeedback_detail", | ||
38 | + "pages/myfeedback_lists/myfeedback_lists", | ||
39 | + "pages/mycertificate/mycertificate", | ||
40 | + "pages/myaddress/myaddress", | ||
41 | + "pages/myaddcompile/myaddcompile", | ||
42 | + "pages/1/1" | ||
43 | + ], | ||
44 | + "permission": { | ||
45 | + "scope.userLocation": { | ||
46 | + "desc": "你的位置信息将用于小程序位置接口的效果展示" | ||
47 | + } | ||
48 | + }, | ||
49 | + "window": { | ||
50 | + "backgroundTextStyle": "light", | ||
51 | + "navigationBarBackgroundColor": "#21AE59", | ||
52 | + "navigationBarTitleText": "白求恩志愿者中心", | ||
53 | + "navigationBarTextStyle": "white" | ||
54 | + }, | ||
55 | + "tabBar": { | ||
56 | + "color": "#999999", | ||
57 | + "list": [ | ||
58 | + { | ||
59 | + "pagePath": "pages/index/index", | ||
60 | + "text": "首页", | ||
61 | + "iconPath": "imgs/shouye_02@2x.png", | ||
62 | + "selectedIconPath": "imgs/shouye_01@2x.png" | ||
63 | + }, | ||
64 | + { | ||
65 | + "pagePath": "pages/my/my", | ||
66 | + "text": "个人中心", | ||
67 | + "iconPath": "imgs/wode_01@2x.png", | ||
68 | + "selectedIconPath": "imgs/wode_02@2x.png" | ||
69 | + } | ||
70 | + ] | ||
71 | + }, | ||
72 | + "sitemapLocation": "sitemap.json", | ||
73 | + "usingComponents": { | ||
74 | + "van-button": "@vant/weapp/button/index", | ||
75 | + "van-calendar": "@vant/weapp/calendar/index" | ||
74 | } | 76 | } |
75 | - ] | ||
76 | - }, | ||
77 | - "sitemapLocation": "sitemap.json" | ||
78 | } | 77 | } |
zhiyuanzhe/imgs/ac1.png
已删除
100644 → 0
5.0 KB
zhiyuanzhe/imgs/ac2.png
已删除
100644 → 0
5.4 KB
zhiyuanzhe/imgs/ac3.png
已删除
100644 → 0
4.4 KB
zhiyuanzhe/imgs/ac4.png
已删除
100644 → 0
4.7 KB
zhiyuanzhe/imgs/card.png
已删除
100644 → 0
39.8 KB
zhiyuanzhe/imgs/dianzizhengjian.png
已删除
100644 → 0
29.6 KB
zhiyuanzhe/imgs/dianzizhengjian1.png
已删除
100644 → 0
41.6 KB
zhiyuanzhe/imgs/dingdanliebaio.png
已删除
100644 → 0
33.2 KB
zhiyuanzhe/imgs/menu1.png
已删除
100644 → 0
6.4 KB
zhiyuanzhe/imgs/menu2.png
已删除
100644 → 0
6.6 KB
zhiyuanzhe/imgs/menu3.png
已删除
100644 → 0
6.2 KB
zhiyuanzhe/imgs/menu4.png
已删除
100644 → 0
6.1 KB
zhiyuanzhe/imgs/menu5.png
已删除
100644 → 0
7.1 KB
zhiyuanzhe/imgs/menu6.png
已删除
100644 → 0
6.5 KB
zhiyuanzhe/imgs/menu7.png
已删除
100644 → 0
6.4 KB
zhiyuanzhe/imgs/menu8.png
已删除
100644 → 0
6.6 KB
zhiyuanzhe/imgs/myfeedback.png
已删除
100644 → 0
36.9 KB
zhiyuanzhe/imgs/mytrain.png
已删除
100644 → 0
19.5 KB
zhiyuanzhe/imgs/renwu@2x.png
已删除
100644 → 0
62.4 KB
zhiyuanzhe/imgs/shaixuan-1.png
已删除
100644 → 0
258 字节
zhiyuanzhe/imgs/shaixuan-2.png
已删除
100644 → 0
351 字节
zhiyuanzhe/imgs/wancheng.png
已删除
100644 → 0
37.3 KB
1 | +'use strict'; | ||
2 | +Object.defineProperty(exports, '__esModule', { value: true }); | ||
3 | +var component_1 = require('../common/component'); | ||
4 | +var button_1 = require('../mixins/button'); | ||
5 | +var open_type_1 = require('../mixins/open-type'); | ||
6 | +component_1.VantComponent({ | ||
7 | + mixins: [button_1.button, open_type_1.openType], | ||
8 | + props: { | ||
9 | + show: Boolean, | ||
10 | + title: String, | ||
11 | + cancelText: String, | ||
12 | + description: String, | ||
13 | + round: { | ||
14 | + type: Boolean, | ||
15 | + value: true, | ||
16 | + }, | ||
17 | + zIndex: { | ||
18 | + type: Number, | ||
19 | + value: 100, | ||
20 | + }, | ||
21 | + actions: { | ||
22 | + type: Array, | ||
23 | + value: [], | ||
24 | + }, | ||
25 | + overlay: { | ||
26 | + type: Boolean, | ||
27 | + value: true, | ||
28 | + }, | ||
29 | + closeOnClickOverlay: { | ||
30 | + type: Boolean, | ||
31 | + value: true, | ||
32 | + }, | ||
33 | + closeOnClickAction: { | ||
34 | + type: Boolean, | ||
35 | + value: true, | ||
36 | + }, | ||
37 | + safeAreaInsetBottom: { | ||
38 | + type: Boolean, | ||
39 | + value: true, | ||
40 | + }, | ||
41 | + }, | ||
42 | + methods: { | ||
43 | + onSelect: function (event) { | ||
44 | + var index = event.currentTarget.dataset.index; | ||
45 | + var item = this.data.actions[index]; | ||
46 | + if (item && !item.disabled && !item.loading) { | ||
47 | + this.$emit('select', item); | ||
48 | + if (this.data.closeOnClickAction) { | ||
49 | + this.onClose(); | ||
50 | + } | ||
51 | + } | ||
52 | + }, | ||
53 | + onCancel: function () { | ||
54 | + this.$emit('cancel'); | ||
55 | + }, | ||
56 | + onClose: function () { | ||
57 | + this.$emit('close'); | ||
58 | + }, | ||
59 | + onClickOverlay: function () { | ||
60 | + this.$emit('click-overlay'); | ||
61 | + this.onClose(); | ||
62 | + }, | ||
63 | + }, | ||
64 | +}); |
1 | +<wxs src="../wxs/utils.wxs" module="utils" /> | ||
2 | + | ||
3 | +<van-popup | ||
4 | + show="{{ show }}" | ||
5 | + position="bottom" | ||
6 | + round="{{ round }}" | ||
7 | + z-index="{{ zIndex }}" | ||
8 | + overlay="{{ overlay }}" | ||
9 | + custom-class="van-action-sheet" | ||
10 | + safe-area-inset-bottom="{{ safeAreaInsetBottom }}" | ||
11 | + close-on-click-overlay="{{ closeOnClickOverlay }}" | ||
12 | + bind:close="onClickOverlay" | ||
13 | +> | ||
14 | + <view wx:if="{{ title }}" class="van-hairline--bottom van-action-sheet__header"> | ||
15 | + {{ title }} | ||
16 | + <van-icon | ||
17 | + name="close" | ||
18 | + custom-class="van-action-sheet__close" | ||
19 | + bind:click="onClose" | ||
20 | + /> | ||
21 | + </view> | ||
22 | + <view wx:if="{{ description }}" class="van-action-sheet__description"> | ||
23 | + {{ description }} | ||
24 | + </view> | ||
25 | + <view wx:if="{{ actions && actions.length }}"> | ||
26 | + <!-- button外包一层view,防止actions动态变化,导致渲染时button被打散 --> | ||
27 | + <button | ||
28 | + wx:for="{{ actions }}" | ||
29 | + wx:key="index" | ||
30 | + open-type="{{ item.openType }}" | ||
31 | + style="{{ item.color ? 'color: ' + item.color : '' }}" | ||
32 | + class="{{ utils.bem('action-sheet__item', { disabled: item.disabled || item.loading }) }} van-hairline--top {{ item.className || '' }}" | ||
33 | + hover-class="van-action-sheet__item--hover" | ||
34 | + data-index="{{ index }}" | ||
35 | + bind:tap="onSelect" | ||
36 | + bindgetuserinfo="bindGetUserInfo" | ||
37 | + bindcontact="bindContact" | ||
38 | + bindgetphonenumber="bindGetPhoneNumber" | ||
39 | + binderror="bindError" | ||
40 | + bindlaunchapp="bindLaunchApp" | ||
41 | + bindopensetting="bindOpenSetting" | ||
42 | + lang="{{ lang }}" | ||
43 | + session-from="{{ sessionFrom }}" | ||
44 | + send-message-title="{{ sendMessageTitle }}" | ||
45 | + send-message-path="{{ sendMessagePath }}" | ||
46 | + send-message-img="{{ sendMessageImg }}" | ||
47 | + show-message-card="{{ showMessageCard }}" | ||
48 | + app-parameter="{{ appParameter }}" | ||
49 | + > | ||
50 | + <block wx:if="{{ !item.loading }}"> | ||
51 | + {{ item.name }} | ||
52 | + <text wx:if="{{ item.subname }}" class="van-action-sheet__subname" >{{ item.subname }}</text> | ||
53 | + </block> | ||
54 | + <van-loading wx:else custom-class="van-action-sheet__loading" size="20px" /> | ||
55 | + </button> | ||
56 | + </view> | ||
57 | + <slot /> | ||
58 | + <view | ||
59 | + wx:if="{{ cancelText }}" | ||
60 | + class="van-action-sheet__cancel" | ||
61 | + hover-class="van-action-sheet__cancel--hover" | ||
62 | + hover-stay-time="70" | ||
63 | + bind:tap="onCancel" | ||
64 | + > | ||
65 | + {{ cancelText }} | ||
66 | + </view> | ||
67 | +</van-popup> |
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)} |
1 | +'use strict'; | ||
2 | +var __assign = | ||
3 | + (this && this.__assign) || | ||
4 | + function () { | ||
5 | + __assign = | ||
6 | + Object.assign || | ||
7 | + function (t) { | ||
8 | + for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
9 | + s = arguments[i]; | ||
10 | + for (var p in s) | ||
11 | + if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
12 | + } | ||
13 | + return t; | ||
14 | + }; | ||
15 | + return __assign.apply(this, arguments); | ||
16 | + }; | ||
17 | +Object.defineProperty(exports, '__esModule', { value: true }); | ||
18 | +var component_1 = require('../common/component'); | ||
19 | +var shared_1 = require('../picker/shared'); | ||
20 | +var utils_1 = require('../common/utils'); | ||
21 | +var COLUMNSPLACEHOLDERCODE = '000000'; | ||
22 | +component_1.VantComponent({ | ||
23 | + classes: ['active-class', 'toolbar-class', 'column-class'], | ||
24 | + props: __assign(__assign({}, shared_1.pickerProps), { | ||
25 | + value: { | ||
26 | + type: String, | ||
27 | + observer: function (value) { | ||
28 | + this.code = value; | ||
29 | + this.setValues(); | ||
30 | + }, | ||
31 | + }, | ||
32 | + areaList: { | ||
33 | + type: Object, | ||
34 | + value: {}, | ||
35 | + observer: 'setValues', | ||
36 | + }, | ||
37 | + columnsNum: { | ||
38 | + type: null, | ||
39 | + value: 3, | ||
40 | + observer: function (value) { | ||
41 | + this.setData({ | ||
42 | + displayColumns: this.data.columns.slice(0, +value), | ||
43 | + }); | ||
44 | + }, | ||
45 | + }, | ||
46 | + columnsPlaceholder: { | ||
47 | + type: Array, | ||
48 | + observer: function (val) { | ||
49 | + this.setData({ | ||
50 | + typeToColumnsPlaceholder: { | ||
51 | + province: val[0] || '', | ||
52 | + city: val[1] || '', | ||
53 | + county: val[2] || '', | ||
54 | + }, | ||
55 | + }); | ||
56 | + }, | ||
57 | + }, | ||
58 | + }), | ||
59 | + data: { | ||
60 | + columns: [{ values: [] }, { values: [] }, { values: [] }], | ||
61 | + displayColumns: [{ values: [] }, { values: [] }, { values: [] }], | ||
62 | + typeToColumnsPlaceholder: {}, | ||
63 | + }, | ||
64 | + mounted: function () { | ||
65 | + var _this = this; | ||
66 | + utils_1.requestAnimationFrame(function () { | ||
67 | + _this.setValues(); | ||
68 | + }); | ||
69 | + }, | ||
70 | + methods: { | ||
71 | + getPicker: function () { | ||
72 | + if (this.picker == null) { | ||
73 | + this.picker = this.selectComponent('.van-area__picker'); | ||
74 | + } | ||
75 | + return this.picker; | ||
76 | + }, | ||
77 | + onCancel: function (event) { | ||
78 | + this.emit('cancel', event.detail); | ||
79 | + }, | ||
80 | + onConfirm: function (event) { | ||
81 | + var index = event.detail.index; | ||
82 | + var value = event.detail.value; | ||
83 | + value = this.parseOutputValues(value); | ||
84 | + this.emit('confirm', { value: value, index: index }); | ||
85 | + }, | ||
86 | + emit: function (type, detail) { | ||
87 | + detail.values = detail.value; | ||
88 | + delete detail.value; | ||
89 | + this.$emit(type, detail); | ||
90 | + }, | ||
91 | + // parse output columns data | ||
92 | + parseOutputValues: function (values) { | ||
93 | + var columnsPlaceholder = this.data.columnsPlaceholder; | ||
94 | + return values.map(function (value, index) { | ||
95 | + // save undefined value | ||
96 | + if (!value) return value; | ||
97 | + value = JSON.parse(JSON.stringify(value)); | ||
98 | + if (!value.code || value.name === columnsPlaceholder[index]) { | ||
99 | + value.code = ''; | ||
100 | + value.name = ''; | ||
101 | + } | ||
102 | + return value; | ||
103 | + }); | ||
104 | + }, | ||
105 | + onChange: function (event) { | ||
106 | + var _this = this; | ||
107 | + var _a = event.detail, | ||
108 | + index = _a.index, | ||
109 | + picker = _a.picker, | ||
110 | + value = _a.value; | ||
111 | + this.code = value[index].code; | ||
112 | + this.setValues().then(function () { | ||
113 | + _this.$emit('change', { | ||
114 | + picker: picker, | ||
115 | + values: _this.parseOutputValues(picker.getValues()), | ||
116 | + index: index, | ||
117 | + }); | ||
118 | + }); | ||
119 | + }, | ||
120 | + getConfig: function (type) { | ||
121 | + var areaList = this.data.areaList; | ||
122 | + return (areaList && areaList[type + '_list']) || {}; | ||
123 | + }, | ||
124 | + getList: function (type, code) { | ||
125 | + var typeToColumnsPlaceholder = this.data.typeToColumnsPlaceholder; | ||
126 | + var result = []; | ||
127 | + if (type !== 'province' && !code) { | ||
128 | + return result; | ||
129 | + } | ||
130 | + var list = this.getConfig(type); | ||
131 | + result = Object.keys(list).map(function (code) { | ||
132 | + return { | ||
133 | + code: code, | ||
134 | + name: list[code], | ||
135 | + }; | ||
136 | + }); | ||
137 | + if (code) { | ||
138 | + // oversea code | ||
139 | + if (code[0] === '9' && type === 'city') { | ||
140 | + code = '9'; | ||
141 | + } | ||
142 | + result = result.filter(function (item) { | ||
143 | + return item.code.indexOf(code) === 0; | ||
144 | + }); | ||
145 | + } | ||
146 | + if (typeToColumnsPlaceholder[type] && result.length) { | ||
147 | + // set columns placeholder | ||
148 | + var codeFill = | ||
149 | + type === 'province' | ||
150 | + ? '' | ||
151 | + : type === 'city' | ||
152 | + ? COLUMNSPLACEHOLDERCODE.slice(2, 4) | ||
153 | + : COLUMNSPLACEHOLDERCODE.slice(4, 6); | ||
154 | + result.unshift({ | ||
155 | + code: '' + code + codeFill, | ||
156 | + name: typeToColumnsPlaceholder[type], | ||
157 | + }); | ||
158 | + } | ||
159 | + return result; | ||
160 | + }, | ||
161 | + getIndex: function (type, code) { | ||
162 | + var compareNum = type === 'province' ? 2 : type === 'city' ? 4 : 6; | ||
163 | + var list = this.getList(type, code.slice(0, compareNum - 2)); | ||
164 | + // oversea code | ||
165 | + if (code[0] === '9' && type === 'province') { | ||
166 | + compareNum = 1; | ||
167 | + } | ||
168 | + code = code.slice(0, compareNum); | ||
169 | + for (var i = 0; i < list.length; i++) { | ||
170 | + if (list[i].code.slice(0, compareNum) === code) { | ||
171 | + return i; | ||
172 | + } | ||
173 | + } | ||
174 | + return 0; | ||
175 | + }, | ||
176 | + setValues: function () { | ||
177 | + var county = this.getConfig('county'); | ||
178 | + var code = this.code; | ||
179 | + if (!code) { | ||
180 | + if (this.data.columnsPlaceholder.length) { | ||
181 | + code = COLUMNSPLACEHOLDERCODE; | ||
182 | + } else if (Object.keys(county)[0]) { | ||
183 | + code = Object.keys(county)[0]; | ||
184 | + } else { | ||
185 | + code = ''; | ||
186 | + } | ||
187 | + } | ||
188 | + var province = this.getList('province'); | ||
189 | + var city = this.getList('city', code.slice(0, 2)); | ||
190 | + var picker = this.getPicker(); | ||
191 | + if (!picker) { | ||
192 | + return; | ||
193 | + } | ||
194 | + var stack = []; | ||
195 | + var indexes = []; | ||
196 | + var columnsNum = this.data.columnsNum; | ||
197 | + if (columnsNum >= 1) { | ||
198 | + stack.push(picker.setColumnValues(0, province, false)); | ||
199 | + indexes.push(this.getIndex('province', code)); | ||
200 | + } | ||
201 | + if (columnsNum >= 2) { | ||
202 | + stack.push(picker.setColumnValues(1, city, false)); | ||
203 | + indexes.push(this.getIndex('city', code)); | ||
204 | + if (city.length && code.slice(2, 4) === '00') { | ||
205 | + code = city[0].code; | ||
206 | + } | ||
207 | + } | ||
208 | + if (columnsNum === 3) { | ||
209 | + stack.push( | ||
210 | + picker.setColumnValues( | ||
211 | + 2, | ||
212 | + this.getList('county', code.slice(0, 4)), | ||
213 | + false | ||
214 | + ) | ||
215 | + ); | ||
216 | + indexes.push(this.getIndex('county', code)); | ||
217 | + } | ||
218 | + return Promise.all(stack) | ||
219 | + .catch(function () {}) | ||
220 | + .then(function () { | ||
221 | + return picker.setIndexes(indexes); | ||
222 | + }) | ||
223 | + .catch(function () {}); | ||
224 | + }, | ||
225 | + getValues: function () { | ||
226 | + var picker = this.getPicker(); | ||
227 | + return picker | ||
228 | + ? picker.getValues().filter(function (value) { | ||
229 | + return !!value; | ||
230 | + }) | ||
231 | + : []; | ||
232 | + }, | ||
233 | + getDetail: function () { | ||
234 | + var values = this.getValues(); | ||
235 | + var area = { | ||
236 | + code: '', | ||
237 | + country: '', | ||
238 | + province: '', | ||
239 | + city: '', | ||
240 | + county: '', | ||
241 | + }; | ||
242 | + if (!values.length) { | ||
243 | + return area; | ||
244 | + } | ||
245 | + var names = values.map(function (item) { | ||
246 | + return item.name; | ||
247 | + }); | ||
248 | + area.code = values[values.length - 1].code; | ||
249 | + if (area.code[0] === '9') { | ||
250 | + area.country = names[1] || ''; | ||
251 | + area.province = names[2] || ''; | ||
252 | + } else { | ||
253 | + area.province = names[0] || ''; | ||
254 | + area.city = names[1] || ''; | ||
255 | + area.county = names[2] || ''; | ||
256 | + } | ||
257 | + return area; | ||
258 | + }, | ||
259 | + reset: function (code) { | ||
260 | + this.code = code || ''; | ||
261 | + return this.setValues(); | ||
262 | + }, | ||
263 | + }, | ||
264 | +}); |
1 | +<van-picker | ||
2 | + class="van-area__picker" | ||
3 | + active-class="active-class" | ||
4 | + toolbar-class="toolbar-class" | ||
5 | + column-class="column-class" | ||
6 | + show-toolbar | ||
7 | + value-key="name" | ||
8 | + title="{{ title }}" | ||
9 | + loading="{{ loading }}" | ||
10 | + columns="{{ displayColumns }}" | ||
11 | + item-height="{{ itemHeight }}" | ||
12 | + visible-item-count="{{ visibleItemCount }}" | ||
13 | + cancel-button-text="{{ cancelButtonText }}" | ||
14 | + confirm-button-text="{{ confirmButtonText }}" | ||
15 | + bind:change="onChange" | ||
16 | + bind:confirm="onConfirm" | ||
17 | + bind:cancel="onCancel" | ||
18 | +/> |
1 | +@import '../common/index.wxss'; |
1 | +'use strict'; | ||
2 | +Object.defineProperty(exports, '__esModule', { value: true }); | ||
3 | +var component_1 = require('../common/component'); | ||
4 | +var button_1 = require('../mixins/button'); | ||
5 | +var open_type_1 = require('../mixins/open-type'); | ||
6 | +var version_1 = require('../common/version'); | ||
7 | +var mixins = [button_1.button, open_type_1.openType]; | ||
8 | +if (version_1.canIUseFormFieldButton()) { | ||
9 | + mixins.push('wx://form-field-button'); | ||
10 | +} | ||
11 | +component_1.VantComponent({ | ||
12 | + mixins: mixins, | ||
13 | + classes: ['hover-class', 'loading-class'], | ||
14 | + data: { | ||
15 | + baseStyle: '', | ||
16 | + }, | ||
17 | + props: { | ||
18 | + formType: String, | ||
19 | + icon: String, | ||
20 | + classPrefix: { | ||
21 | + type: String, | ||
22 | + value: 'van-icon', | ||
23 | + }, | ||
24 | + plain: Boolean, | ||
25 | + block: Boolean, | ||
26 | + round: Boolean, | ||
27 | + square: Boolean, | ||
28 | + loading: Boolean, | ||
29 | + hairline: Boolean, | ||
30 | + disabled: Boolean, | ||
31 | + loadingText: String, | ||
32 | + customStyle: String, | ||
33 | + loadingType: { | ||
34 | + type: String, | ||
35 | + value: 'circular', | ||
36 | + }, | ||
37 | + type: { | ||
38 | + type: String, | ||
39 | + value: 'default', | ||
40 | + }, | ||
41 | + dataset: null, | ||
42 | + size: { | ||
43 | + type: String, | ||
44 | + value: 'normal', | ||
45 | + }, | ||
46 | + loadingSize: { | ||
47 | + type: String, | ||
48 | + value: '20px', | ||
49 | + }, | ||
50 | + color: { | ||
51 | + type: String, | ||
52 | + observer: function (color) { | ||
53 | + var style = ''; | ||
54 | + if (color) { | ||
55 | + style += 'color: ' + (this.data.plain ? color : 'white') + ';'; | ||
56 | + if (!this.data.plain) { | ||
57 | + // Use background instead of backgroundColor to make linear-gradient work | ||
58 | + style += 'background: ' + color + ';'; | ||
59 | + } | ||
60 | + // hide border when color is linear-gradient | ||
61 | + if (color.indexOf('gradient') !== -1) { | ||
62 | + style += 'border: 0;'; | ||
63 | + } else { | ||
64 | + style += 'border-color: ' + color + ';'; | ||
65 | + } | ||
66 | + } | ||
67 | + if (style !== this.data.baseStyle) { | ||
68 | + this.setData({ baseStyle: style }); | ||
69 | + } | ||
70 | + }, | ||
71 | + }, | ||
72 | + }, | ||
73 | + methods: { | ||
74 | + onClick: function () { | ||
75 | + if (!this.data.loading) { | ||
76 | + this.$emit('click'); | ||
77 | + } | ||
78 | + }, | ||
79 | + noop: function () {}, | ||
80 | + }, | ||
81 | +}); |
1 | +<wxs src="../wxs/utils.wxs" module="utils" /> | ||
2 | + | ||
3 | +<button | ||
4 | + id="{{ id }}" | ||
5 | + data-detail="{{ dataset }}" | ||
6 | + class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, hairline, unclickable: disabled || loading }]) }} {{ hairline ? 'van-hairline--surround' : '' }}" | ||
7 | + hover-class="van-button--active hover-class" | ||
8 | + lang="{{ lang }}" | ||
9 | + form-type="{{ formType }}" | ||
10 | + style="{{ baseStyle }} {{ customStyle }}" | ||
11 | + open-type="{{ disabled ? '' : openType }}" | ||
12 | + business-id="{{ businessId }}" | ||
13 | + session-from="{{ sessionFrom }}" | ||
14 | + send-message-title="{{ sendMessageTitle }}" | ||
15 | + send-message-path="{{ sendMessagePath }}" | ||
16 | + send-message-img="{{ sendMessageImg }}" | ||
17 | + show-message-card="{{ showMessageCard }}" | ||
18 | + app-parameter="{{ appParameter }}" | ||
19 | + aria-label="{{ ariaLabel }}" | ||
20 | + bindtap="{{ !disabled ? 'onClick' : 'noop' }}" | ||
21 | + bindgetuserinfo="bindGetUserInfo" | ||
22 | + bindcontact="bindContact" | ||
23 | + bindgetphonenumber="bindGetPhoneNumber" | ||
24 | + binderror="bindError" | ||
25 | + bindlaunchapp="bindLaunchApp" | ||
26 | + bindopensetting="bindOpenSetting" | ||
27 | +> | ||
28 | + <block wx:if="{{ loading }}"> | ||
29 | + <van-loading | ||
30 | + custom-class="loading-class" | ||
31 | + size="{{ loadingSize }}" | ||
32 | + type="{{ loadingType }}" | ||
33 | + color="{{ loadingColor(type,color,plain) }}" | ||
34 | + /> | ||
35 | + <view wx:if="{{ loadingText }}" class="van-button__loading-text"> | ||
36 | + {{ loadingText }} | ||
37 | + </view> | ||
38 | + </block> | ||
39 | + <block wx:else> | ||
40 | + <van-icon | ||
41 | + wx:if="{{ icon }}" | ||
42 | + size="1.2em" | ||
43 | + name="{{ icon }}" | ||
44 | + class-prefix="{{ classPrefix }}" | ||
45 | + class="van-button__icon" | ||
46 | + custom-style="line-height: inherit;" | ||
47 | + /> | ||
48 | + <view class="van-button__text"> | ||
49 | + <slot /> | ||
50 | + </view> | ||
51 | + </block> | ||
52 | +</button> | ||
53 | + | ||
54 | + | ||
55 | +<wxs module="loadingColor"> | ||
56 | +function get(type, color,plain) { | ||
57 | + if(plain) { | ||
58 | + return color ? color: '#c9c9c9'; | ||
59 | + } | ||
60 | + | ||
61 | + if(type === 'default') { | ||
62 | + return '#c9c9c9'; | ||
63 | + } | ||
64 | + return 'white'; | ||
65 | +} | ||
66 | + | ||
67 | +module.exports = get; | ||
68 | +</wxs> |
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} |
1 | +<wxs src="./index.wxs" module="computed"></wxs> | ||
2 | + | ||
3 | +<template name="calendar"> | ||
4 | + <view class="van-calendar"> | ||
5 | + <header | ||
6 | + title="{{ title }}" | ||
7 | + showTitle="{{ showTitle }}" | ||
8 | + subtitle="{{ subtitle }}" | ||
9 | + showSubtitle="{{ showSubtitle }}" | ||
10 | + > | ||
11 | + <slot name="title" slot="title"></slot> | ||
12 | + </header> | ||
13 | + | ||
14 | + <scroll-view class="van-calendar__body" scroll-y scroll-into-view="{{ scrollIntoView }}"> | ||
15 | + <month | ||
16 | + wx:for="{{ computed.getMonths(minDate, maxDate) }}" | ||
17 | + wx:key="index" | ||
18 | + id="month{{ index }}" | ||
19 | + class="month" | ||
20 | + data-date="{{ item }}" | ||
21 | + date="{{ item }}" | ||
22 | + type="{{ type }}" | ||
23 | + color="{{ color }}" | ||
24 | + minDate="{{ minDate }}" | ||
25 | + maxDate="{{ maxDate }}" | ||
26 | + showMark="{{ showMark }}" | ||
27 | + formatter="{{ formatter }}" | ||
28 | + rowHeight="{{ rowHeight }}" | ||
29 | + currentDate="{{ currentDate }}" | ||
30 | + showSubtitle="{{ showSubtitle }}" | ||
31 | + allowSameDay="{{ allowSameDay }}" | ||
32 | + showMonthTitle="{{ index !== 0 || !showSubtitle }}" | ||
33 | + bind:click="onClickDay" | ||
34 | + /> | ||
35 | + </scroll-view> | ||
36 | + | ||
37 | + <view class="van-calendar__footer {{ safeAreaInsetBottom ? 'van-calendar__footer--safe-area-inset-bottom' : '' }}"> | ||
38 | + <slot name="footer"></slot> | ||
39 | + </view> | ||
40 | + | ||
41 | + <view class="van-calendar__footer {{ safeAreaInsetBottom ? 'van-calendar__footer--safe-area-inset-bottom' : '' }}"> | ||
42 | + <van-button | ||
43 | + wx:if="{{ showConfirm }}" | ||
44 | + round | ||
45 | + block | ||
46 | + type="danger" | ||
47 | + color="{{ color }}" | ||
48 | + custom-class="van-calendar__confirm" | ||
49 | + disabled="{{ computed.getButtonDisabled(type, currentDate) }}" | ||
50 | + nativeType="text" | ||
51 | + bind:click="onConfirm" | ||
52 | + > | ||
53 | + {{ computed.getButtonDisabled(type, currentDate) ? confirmDisabledText : confirmText }} | ||
54 | + </van-button> | ||
55 | + </view> | ||
56 | + </view> | ||
57 | +</template> |
1 | +'use strict'; | ||
2 | +Object.defineProperty(exports, '__esModule', { value: true }); | ||
3 | +var component_1 = require('../../../common/component'); | ||
4 | +component_1.VantComponent({ | ||
5 | + props: { | ||
6 | + title: { | ||
7 | + type: String, | ||
8 | + value: '日期选择', | ||
9 | + }, | ||
10 | + subtitle: String, | ||
11 | + showTitle: Boolean, | ||
12 | + showSubtitle: Boolean, | ||
13 | + }, | ||
14 | + data: { | ||
15 | + weekdays: ['日', '一', '二', '三', '四', '五', '六'], | ||
16 | + }, | ||
17 | + methods: {}, | ||
18 | +}); |
1 | +<view class="van-calendar__header"> | ||
2 | + <block wx:if="{{ showTitle }}"> | ||
3 | + <view class="van-calendar__header-title"><slot name="title"></slot></view> | ||
4 | + <view class="van-calendar__header-title">{{ title }}</view> | ||
5 | + </block> | ||
6 | + | ||
7 | + <view wx:if="{{ showSubtitle }}" class="van-calendar__header-subtitle"> | ||
8 | + {{ subtitle }} | ||
9 | + </view> | ||
10 | + | ||
11 | + <view class="van-calendar__weekdays"> | ||
12 | + <view wx:for="{{ weekdays }}" wx:key="index" class="van-calendar__weekday"> | ||
13 | + {{ item }} | ||
14 | + </view> | ||
15 | + </view> | ||
16 | +</view> |
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)} |
1 | +'use strict'; | ||
2 | +Object.defineProperty(exports, '__esModule', { value: true }); | ||
3 | +var component_1 = require('../../../common/component'); | ||
4 | +var utils_1 = require('../../utils'); | ||
5 | +component_1.VantComponent({ | ||
6 | + props: { | ||
7 | + date: { | ||
8 | + type: null, | ||
9 | + observer: 'setDays', | ||
10 | + }, | ||
11 | + type: { | ||
12 | + type: String, | ||
13 | + observer: 'setDays', | ||
14 | + }, | ||
15 | + color: String, | ||
16 | + minDate: { | ||
17 | + type: null, | ||
18 | + observer: 'setDays', | ||
19 | + }, | ||
20 | + maxDate: { | ||
21 | + type: null, | ||
22 | + observer: 'setDays', | ||
23 | + }, | ||
24 | + showMark: Boolean, | ||
25 | + rowHeight: [Number, String], | ||
26 | + formatter: { | ||
27 | + type: null, | ||
28 | + observer: 'setDays', | ||
29 | + }, | ||
30 | + currentDate: { | ||
31 | + type: [null, Array], | ||
32 | + observer: 'setDays', | ||
33 | + }, | ||
34 | + allowSameDay: Boolean, | ||
35 | + showSubtitle: Boolean, | ||
36 | + showMonthTitle: Boolean, | ||
37 | + }, | ||
38 | + data: { | ||
39 | + visible: true, | ||
40 | + days: [], | ||
41 | + }, | ||
42 | + methods: { | ||
43 | + onClick: function (event) { | ||
44 | + var index = event.currentTarget.dataset.index; | ||
45 | + var item = this.data.days[index]; | ||
46 | + if (item.type !== 'disabled') { | ||
47 | + this.$emit('click', item); | ||
48 | + } | ||
49 | + }, | ||
50 | + setDays: function () { | ||
51 | + var days = []; | ||
52 | + var startDate = new Date(this.data.date); | ||
53 | + var year = startDate.getFullYear(); | ||
54 | + var month = startDate.getMonth(); | ||
55 | + var totalDay = utils_1.getMonthEndDay( | ||
56 | + startDate.getFullYear(), | ||
57 | + startDate.getMonth() + 1 | ||
58 | + ); | ||
59 | + for (var day = 1; day <= totalDay; day++) { | ||
60 | + var date = new Date(year, month, day); | ||
61 | + var type = this.getDayType(date); | ||
62 | + var config = { | ||
63 | + date: date, | ||
64 | + type: type, | ||
65 | + text: day, | ||
66 | + bottomInfo: this.getBottomInfo(type), | ||
67 | + }; | ||
68 | + if (this.data.formatter) { | ||
69 | + config = this.data.formatter(config); | ||
70 | + } | ||
71 | + days.push(config); | ||
72 | + } | ||
73 | + this.setData({ days: days }); | ||
74 | + }, | ||
75 | + getMultipleDayType: function (day) { | ||
76 | + var currentDate = this.data.currentDate; | ||
77 | + if (!Array.isArray(currentDate)) { | ||
78 | + return ''; | ||
79 | + } | ||
80 | + var isSelected = function (date) { | ||
81 | + return currentDate.some(function (item) { | ||
82 | + return utils_1.compareDay(item, date) === 0; | ||
83 | + }); | ||
84 | + }; | ||
85 | + if (isSelected(day)) { | ||
86 | + var prevDay = utils_1.getPrevDay(day); | ||
87 | + var nextDay = utils_1.getNextDay(day); | ||
88 | + var prevSelected = isSelected(prevDay); | ||
89 | + var nextSelected = isSelected(nextDay); | ||
90 | + if (prevSelected && nextSelected) { | ||
91 | + return 'multiple-middle'; | ||
92 | + } | ||
93 | + if (prevSelected) { | ||
94 | + return 'end'; | ||
95 | + } | ||
96 | + return nextSelected ? 'start' : 'multiple-selected'; | ||
97 | + } | ||
98 | + return ''; | ||
99 | + }, | ||
100 | + getRangeDayType: function (day) { | ||
101 | + var _a = this.data, | ||
102 | + currentDate = _a.currentDate, | ||
103 | + allowSameDay = _a.allowSameDay; | ||
104 | + if (!Array.isArray(currentDate)) { | ||
105 | + return; | ||
106 | + } | ||
107 | + var startDay = currentDate[0], | ||
108 | + endDay = currentDate[1]; | ||
109 | + if (!startDay) { | ||
110 | + return; | ||
111 | + } | ||
112 | + var compareToStart = utils_1.compareDay(day, startDay); | ||
113 | + if (!endDay) { | ||
114 | + return compareToStart === 0 ? 'start' : ''; | ||
115 | + } | ||
116 | + var compareToEnd = utils_1.compareDay(day, endDay); | ||
117 | + if (compareToStart === 0 && compareToEnd === 0 && allowSameDay) { | ||
118 | + return 'start-end'; | ||
119 | + } | ||
120 | + if (compareToStart === 0) { | ||
121 | + return 'start'; | ||
122 | + } | ||
123 | + if (compareToEnd === 0) { | ||
124 | + return 'end'; | ||
125 | + } | ||
126 | + if (compareToStart > 0 && compareToEnd < 0) { | ||
127 | + return 'middle'; | ||
128 | + } | ||
129 | + }, | ||
130 | + getDayType: function (day) { | ||
131 | + var _a = this.data, | ||
132 | + type = _a.type, | ||
133 | + minDate = _a.minDate, | ||
134 | + maxDate = _a.maxDate, | ||
135 | + currentDate = _a.currentDate; | ||
136 | + if ( | ||
137 | + utils_1.compareDay(day, minDate) < 0 || | ||
138 | + utils_1.compareDay(day, maxDate) > 0 | ||
139 | + ) { | ||
140 | + return 'disabled'; | ||
141 | + } | ||
142 | + if (type === 'single') { | ||
143 | + return utils_1.compareDay(day, currentDate) === 0 ? 'selected' : ''; | ||
144 | + } | ||
145 | + if (type === 'multiple') { | ||
146 | + return this.getMultipleDayType(day); | ||
147 | + } | ||
148 | + /* istanbul ignore else */ | ||
149 | + if (type === 'range') { | ||
150 | + return this.getRangeDayType(day); | ||
151 | + } | ||
152 | + }, | ||
153 | + getBottomInfo: function (type) { | ||
154 | + if (this.data.type === 'range') { | ||
155 | + if (type === 'start') { | ||
156 | + return '开始'; | ||
157 | + } | ||
158 | + if (type === 'end') { | ||
159 | + return '结束'; | ||
160 | + } | ||
161 | + if (type === 'start-end') { | ||
162 | + return '开始/结束'; | ||
163 | + } | ||
164 | + } | ||
165 | + }, | ||
166 | + }, | ||
167 | +}); |
1 | +<wxs src="./index.wxs" module="computed"></wxs> | ||
2 | +<wxs src="../../../wxs/utils.wxs" module="utils" /> | ||
3 | + | ||
4 | +<view class="van-calendar__month" style="{{ computed.getMonthStyle(visible, date, rowHeight) }}"> | ||
5 | + <view wx:if="{{ showMonthTitle }}" class="van-calendar__month-title"> | ||
6 | + {{ computed.formatMonthTitle(date) }} | ||
7 | + </view> | ||
8 | + | ||
9 | + <view wx:if="{{ visible }}" class="van-calendar__days"> | ||
10 | + <view wx:if="{{ showMark }}" class="van-calendar__month-mark"> | ||
11 | + {{ computed.getMark(date) }} | ||
12 | + </view> | ||
13 | + | ||
14 | + <view | ||
15 | + wx:for="{{ days }}" | ||
16 | + wx:key="index" | ||
17 | + style="{{ computed.getDayStyle(item.type, index, date, rowHeight, color) }}" | ||
18 | + class="{{ utils.bem('calendar__day', [item.type]) }} {{ item.className }}" | ||
19 | + data-index="{{ index }}" | ||
20 | + bindtap="onClick" | ||
21 | + > | ||
22 | + <view wx:if="{{ item.type === 'selected' }}" class="van-calendar__selected-day" style="background: {{ color }}"> | ||
23 | + <view wx:if="{{ item.topInfo }}" class="van-calendar__top-info">{{ item.topInfo }}</view> | ||
24 | + {{ item.text }} | ||
25 | + <view wx:if="{{ item.bottomInfo }}" class="van-calendar__bottom-info"> | ||
26 | + {{ item.bottomInfo }} | ||
27 | + </view> | ||
28 | + </view> | ||
29 | + | ||
30 | + <view wx:else> | ||
31 | + <view wx:if="{{ item.topInfo }}" class="van-calendar__top-info">{{ item.topInfo }}</view> | ||
32 | + {{ item.text }} | ||
33 | + <view wx:if="{{ item.bottomInfo }}" class="van-calendar__bottom-info"> | ||
34 | + {{ item.bottomInfo }} | ||
35 | + </view> | ||
36 | + </view> | ||
37 | + </view> | ||
38 | + </view> | ||
39 | +</view> |
1 | +/* eslint-disable */ | ||
2 | +var utils = require('../../utils.wxs'); | ||
3 | + | ||
4 | +function getMark(date) { | ||
5 | + return getDate(date).getMonth() + 1; | ||
6 | +} | ||
7 | + | ||
8 | +var ROW_HEIGHT = 64; | ||
9 | + | ||
10 | +function getDayStyle(type, index, date, rowHeight, color) { | ||
11 | + var style = []; | ||
12 | + var offset = getDate(date).getDay(); | ||
13 | + | ||
14 | + if (index === 0) { | ||
15 | + style.push(['margin-left', (100 * offset) / 7 + '%']); | ||
16 | + } | ||
17 | + | ||
18 | + if (rowHeight !== ROW_HEIGHT) { | ||
19 | + style.push(['height', rowHeight + 'px']); | ||
20 | + } | ||
21 | + | ||
22 | + if (color) { | ||
23 | + if ( | ||
24 | + type === 'start' || | ||
25 | + type === 'end' || | ||
26 | + type === 'multiple-selected' || | ||
27 | + type === 'multiple-middle' | ||
28 | + ) { | ||
29 | + style.push(['background', color]); | ||
30 | + } else if (type === 'middle') { | ||
31 | + style.push(['color', color]); | ||
32 | + } | ||
33 | + } | ||
34 | + | ||
35 | + return style | ||
36 | + .map(function(item) { | ||
37 | + return item.join(':'); | ||
38 | + }) | ||
39 | + .join(';'); | ||
40 | +} | ||
41 | + | ||
42 | +function formatMonthTitle(date) { | ||
43 | + date = getDate(date); | ||
44 | + return date.getFullYear() + '年' + (date.getMonth() + 1) + '月'; | ||
45 | +} | ||
46 | + | ||
47 | +function getMonthStyle(visible, date, rowHeight) { | ||
48 | + if (!visible) { | ||
49 | + date = getDate(date); | ||
50 | + | ||
51 | + var totalDay = utils.getMonthEndDay( | ||
52 | + date.getFullYear(), | ||
53 | + date.getMonth() + 1 | ||
54 | + ); | ||
55 | + var offset = getDate(date).getDay(); | ||
56 | + var padding = Math.ceil((totalDay + offset) / 7) * rowHeight; | ||
57 | + | ||
58 | + return 'padding-bottom:' + padding + 'px'; | ||
59 | + } | ||
60 | +} | ||
61 | + | ||
62 | +module.exports = { | ||
63 | + getMark: getMark, | ||
64 | + getDayStyle: getDayStyle, | ||
65 | + formatMonthTitle: formatMonthTitle, | ||
66 | + getMonthStyle: getMonthStyle | ||
67 | +}; |
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)} |
1 | +'use strict'; | ||
2 | +var __spreadArrays = | ||
3 | + (this && this.__spreadArrays) || | ||
4 | + function () { | ||
5 | + for (var s = 0, i = 0, il = arguments.length; i < il; i++) | ||
6 | + s += arguments[i].length; | ||
7 | + for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
8 | + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
9 | + r[k] = a[j]; | ||
10 | + return r; | ||
11 | + }; | ||
12 | +var __importDefault = | ||
13 | + (this && this.__importDefault) || | ||
14 | + function (mod) { | ||
15 | + return mod && mod.__esModule ? mod : { default: mod }; | ||
16 | + }; | ||
17 | +Object.defineProperty(exports, '__esModule', { value: true }); | ||
18 | +var component_1 = require('../common/component'); | ||
19 | +var utils_1 = require('./utils'); | ||
20 | +var toast_1 = __importDefault(require('../toast/toast')); | ||
21 | +var utils_2 = require('../common/utils'); | ||
22 | +component_1.VantComponent({ | ||
23 | + props: { | ||
24 | + title: { | ||
25 | + type: String, | ||
26 | + value: '日期选择', | ||
27 | + }, | ||
28 | + color: String, | ||
29 | + show: { | ||
30 | + type: Boolean, | ||
31 | + observer: function (val) { | ||
32 | + if (val) { | ||
33 | + this.initRect(); | ||
34 | + this.scrollIntoView(); | ||
35 | + } | ||
36 | + }, | ||
37 | + }, | ||
38 | + formatter: null, | ||
39 | + confirmText: { | ||
40 | + type: String, | ||
41 | + value: '确定', | ||
42 | + }, | ||
43 | + rangePrompt: String, | ||
44 | + defaultDate: { | ||
45 | + type: [Number, Array], | ||
46 | + observer: function (val) { | ||
47 | + this.setData({ currentDate: val }); | ||
48 | + this.scrollIntoView(); | ||
49 | + }, | ||
50 | + }, | ||
51 | + allowSameDay: Boolean, | ||
52 | + confirmDisabledText: String, | ||
53 | + type: { | ||
54 | + type: String, | ||
55 | + value: 'single', | ||
56 | + observer: 'reset', | ||
57 | + }, | ||
58 | + minDate: { | ||
59 | + type: null, | ||
60 | + value: Date.now(), | ||
61 | + }, | ||
62 | + maxDate: { | ||
63 | + type: null, | ||
64 | + value: new Date( | ||
65 | + new Date().getFullYear(), | ||
66 | + new Date().getMonth() + 6, | ||
67 | + new Date().getDate() | ||
68 | + ).getTime(), | ||
69 | + }, | ||
70 | + position: { | ||
71 | + type: String, | ||
72 | + value: 'bottom', | ||
73 | + }, | ||
74 | + rowHeight: { | ||
75 | + type: [Number, String], | ||
76 | + value: utils_1.ROW_HEIGHT, | ||
77 | + }, | ||
78 | + round: { | ||
79 | + type: Boolean, | ||
80 | + value: true, | ||
81 | + }, | ||
82 | + poppable: { | ||
83 | + type: Boolean, | ||
84 | + value: true, | ||
85 | + }, | ||
86 | + showMark: { | ||
87 | + type: Boolean, | ||
88 | + value: true, | ||
89 | + }, | ||
90 | + showTitle: { | ||
91 | + type: Boolean, | ||
92 | + value: true, | ||
93 | + }, | ||
94 | + showConfirm: { | ||
95 | + type: Boolean, | ||
96 | + value: true, | ||
97 | + }, | ||
98 | + showSubtitle: { | ||
99 | + type: Boolean, | ||
100 | + value: true, | ||
101 | + }, | ||
102 | + safeAreaInsetBottom: { | ||
103 | + type: Boolean, | ||
104 | + value: true, | ||
105 | + }, | ||
106 | + closeOnClickOverlay: { | ||
107 | + type: Boolean, | ||
108 | + value: true, | ||
109 | + }, | ||
110 | + maxRange: { | ||
111 | + type: [Number, String], | ||
112 | + value: null, | ||
113 | + }, | ||
114 | + }, | ||
115 | + data: { | ||
116 | + subtitle: '', | ||
117 | + currentDate: null, | ||
118 | + scrollIntoView: '', | ||
119 | + }, | ||
120 | + created: function () { | ||
121 | + this.setData({ | ||
122 | + currentDate: this.getInitialDate(), | ||
123 | + }); | ||
124 | + }, | ||
125 | + mounted: function () { | ||
126 | + if (this.data.show || !this.data.poppable) { | ||
127 | + this.initRect(); | ||
128 | + this.scrollIntoView(); | ||
129 | + } | ||
130 | + }, | ||
131 | + methods: { | ||
132 | + reset: function () { | ||
133 | + this.setData({ currentDate: this.getInitialDate() }); | ||
134 | + this.scrollIntoView(); | ||
135 | + }, | ||
136 | + initRect: function () { | ||
137 | + var _this = this; | ||
138 | + if (this.contentObserver != null) { | ||
139 | + this.contentObserver.disconnect(); | ||
140 | + } | ||
141 | + var contentObserver = this.createIntersectionObserver({ | ||
142 | + thresholds: [0, 0.1, 0.9, 1], | ||
143 | + observeAll: true, | ||
144 | + }); | ||
145 | + this.contentObserver = contentObserver; | ||
146 | + contentObserver.relativeTo('.van-calendar__body'); | ||
147 | + contentObserver.observe('.month', function (res) { | ||
148 | + if (res.boundingClientRect.top <= res.relativeRect.top) { | ||
149 | + // @ts-ignore | ||
150 | + _this.setData({ | ||
151 | + subtitle: utils_1.formatMonthTitle(res.dataset.date), | ||
152 | + }); | ||
153 | + } | ||
154 | + }); | ||
155 | + }, | ||
156 | + getInitialDate: function () { | ||
157 | + var _a = this.data, | ||
158 | + type = _a.type, | ||
159 | + defaultDate = _a.defaultDate, | ||
160 | + minDate = _a.minDate; | ||
161 | + if (type === 'range') { | ||
162 | + var _b = defaultDate || [], | ||
163 | + startDay = _b[0], | ||
164 | + endDay = _b[1]; | ||
165 | + return [ | ||
166 | + startDay || minDate, | ||
167 | + endDay || utils_1.getNextDay(new Date(minDate)).getTime(), | ||
168 | + ]; | ||
169 | + } | ||
170 | + if (type === 'multiple') { | ||
171 | + return defaultDate || [minDate]; | ||
172 | + } | ||
173 | + return defaultDate || minDate; | ||
174 | + }, | ||
175 | + scrollIntoView: function () { | ||
176 | + var _this = this; | ||
177 | + utils_2.requestAnimationFrame(function () { | ||
178 | + var _a = _this.data, | ||
179 | + currentDate = _a.currentDate, | ||
180 | + type = _a.type, | ||
181 | + show = _a.show, | ||
182 | + poppable = _a.poppable, | ||
183 | + minDate = _a.minDate, | ||
184 | + maxDate = _a.maxDate; | ||
185 | + var targetDate = type === 'single' ? currentDate : currentDate[0]; | ||
186 | + var displayed = show || !poppable; | ||
187 | + if (!targetDate || !displayed) { | ||
188 | + return; | ||
189 | + } | ||
190 | + var months = utils_1.getMonths(minDate, maxDate); | ||
191 | + months.some(function (month, index) { | ||
192 | + if (utils_1.compareMonth(month, targetDate) === 0) { | ||
193 | + _this.setData({ scrollIntoView: 'month' + index }); | ||
194 | + return true; | ||
195 | + } | ||
196 | + return false; | ||
197 | + }); | ||
198 | + }); | ||
199 | + }, | ||
200 | + onOpen: function () { | ||
201 | + this.$emit('open'); | ||
202 | + }, | ||
203 | + onOpened: function () { | ||
204 | + this.$emit('opened'); | ||
205 | + }, | ||
206 | + onClose: function () { | ||
207 | + this.$emit('close'); | ||
208 | + }, | ||
209 | + onClosed: function () { | ||
210 | + this.$emit('closed'); | ||
211 | + }, | ||
212 | + onClickDay: function (event) { | ||
213 | + var date = event.detail.date; | ||
214 | + var _a = this.data, | ||
215 | + type = _a.type, | ||
216 | + currentDate = _a.currentDate, | ||
217 | + allowSameDay = _a.allowSameDay; | ||
218 | + if (type === 'range') { | ||
219 | + var startDay = currentDate[0], | ||
220 | + endDay = currentDate[1]; | ||
221 | + if (startDay && !endDay) { | ||
222 | + var compareToStart = utils_1.compareDay(date, startDay); | ||
223 | + if (compareToStart === 1) { | ||
224 | + this.select([startDay, date], true); | ||
225 | + } else if (compareToStart === -1) { | ||
226 | + this.select([date, null]); | ||
227 | + } else if (allowSameDay) { | ||
228 | + this.select([date, date]); | ||
229 | + } | ||
230 | + } else { | ||
231 | + this.select([date, null]); | ||
232 | + } | ||
233 | + } else if (type === 'multiple') { | ||
234 | + var selectedIndex_1; | ||
235 | + var selected = currentDate.some(function (dateItem, index) { | ||
236 | + var equal = utils_1.compareDay(dateItem, date) === 0; | ||
237 | + if (equal) { | ||
238 | + selectedIndex_1 = index; | ||
239 | + } | ||
240 | + return equal; | ||
241 | + }); | ||
242 | + if (selected) { | ||
243 | + var cancelDate = currentDate.splice(selectedIndex_1, 1); | ||
244 | + this.setData({ currentDate: currentDate }); | ||
245 | + this.unselect(cancelDate); | ||
246 | + } else { | ||
247 | + this.select(__spreadArrays(currentDate, [date])); | ||
248 | + } | ||
249 | + } else { | ||
250 | + this.select(date, true); | ||
251 | + } | ||
252 | + }, | ||
253 | + unselect: function (dateArray) { | ||
254 | + var date = dateArray[0]; | ||
255 | + if (date) { | ||
256 | + this.$emit('unselect', utils_1.copyDates(date)); | ||
257 | + } | ||
258 | + }, | ||
259 | + select: function (date, complete) { | ||
260 | + if (complete && this.data.type === 'range') { | ||
261 | + var valid = this.checkRange(date); | ||
262 | + if (!valid) { | ||
263 | + // auto selected to max range if showConfirm | ||
264 | + if (this.data.showConfirm) { | ||
265 | + this.emit([ | ||
266 | + date[0], | ||
267 | + utils_1.getDayByOffset(date[0], this.data.maxRange - 1), | ||
268 | + ]); | ||
269 | + } else { | ||
270 | + this.emit(date); | ||
271 | + } | ||
272 | + return; | ||
273 | + } | ||
274 | + } | ||
275 | + this.emit(date); | ||
276 | + if (complete && !this.data.showConfirm) { | ||
277 | + this.onConfirm(); | ||
278 | + } | ||
279 | + }, | ||
280 | + emit: function (date) { | ||
281 | + var getTime = function (date) { | ||
282 | + return date instanceof Date ? date.getTime() : date; | ||
283 | + }; | ||
284 | + this.setData({ | ||
285 | + currentDate: Array.isArray(date) ? date.map(getTime) : getTime(date), | ||
286 | + }); | ||
287 | + this.$emit('select', utils_1.copyDates(date)); | ||
288 | + }, | ||
289 | + checkRange: function (date) { | ||
290 | + var _a = this.data, | ||
291 | + maxRange = _a.maxRange, | ||
292 | + rangePrompt = _a.rangePrompt; | ||
293 | + if (maxRange && utils_1.calcDateNum(date) > maxRange) { | ||
294 | + toast_1.default({ | ||
295 | + context: this, | ||
296 | + message: | ||
297 | + rangePrompt || | ||
298 | + '\u9009\u62E9\u5929\u6570\u4E0D\u80FD\u8D85\u8FC7 ' + | ||
299 | + maxRange + | ||
300 | + ' \u5929', | ||
301 | + }); | ||
302 | + return false; | ||
303 | + } | ||
304 | + return true; | ||
305 | + }, | ||
306 | + onConfirm: function () { | ||
307 | + var _this = this; | ||
308 | + if ( | ||
309 | + this.data.type === 'range' && | ||
310 | + !this.checkRange(this.data.currentDate) | ||
311 | + ) { | ||
312 | + return; | ||
313 | + } | ||
314 | + wx.nextTick(function () { | ||
315 | + _this.$emit('confirm', utils_1.copyDates(_this.data.currentDate)); | ||
316 | + }); | ||
317 | + }, | ||
318 | + }, | ||
319 | +}); |
1 | +<wxs src="./index.wxs" module="computed" /> | ||
2 | + | ||
3 | +<import src="./calendar.wxml" /> | ||
4 | + | ||
5 | +<van-popup | ||
6 | + wx:if="{{ poppable }}" | ||
7 | + custom-class="van-calendar__popup--{{ position }}" | ||
8 | + close-icon-class="van-calendar__close-icon" | ||
9 | + show="{{ show }}" | ||
10 | + round="{{ round }}" | ||
11 | + position="{{ position }}" | ||
12 | + closeable="{{ showTitle || showSubtitle }}" | ||
13 | + close-on-click-overlay="{{ closeOnClickOverlay }}" | ||
14 | + bind:enter="onOpen" | ||
15 | + bind:close="onClose" | ||
16 | + bind:after-enter="onOpened" | ||
17 | + bind:after-leave="onClosed" | ||
18 | +> | ||
19 | + <template | ||
20 | + is="calendar" | ||
21 | + data="{{ title, subtitle, showTitle, showSubtitle, minDate, maxDate, type, color, showMark, formatter, rowHeight, currentDate, safeAreaInsetBottom, showConfirm, confirmDisabledText, confirmText, scrollIntoView, allowSameDay }}" | ||
22 | + /> | ||
23 | +</van-popup> | ||
24 | + | ||
25 | +<template | ||
26 | + wx:else | ||
27 | + is="calendar" | ||
28 | + data="{{ title, subtitle, showTitle, showSubtitle, minDate, maxDate, type, color, showMark, formatter, rowHeight, currentDate, safeAreaInsetBottom, showConfirm, confirmDisabledText, confirmText, scrollIntoView, allowSameDay }}" | ||
29 | +/> | ||
30 | + | ||
31 | +<van-toast id="van-toast" /> |
1 | +/* eslint-disable */ | ||
2 | +var utils = require('./utils.wxs'); | ||
3 | + | ||
4 | +function getMonths(minDate, maxDate) { | ||
5 | + var months = []; | ||
6 | + var cursor = getDate(minDate); | ||
7 | + | ||
8 | + cursor.setDate(1); | ||
9 | + | ||
10 | + do { | ||
11 | + months.push(cursor.getTime()); | ||
12 | + cursor.setMonth(cursor.getMonth() + 1); | ||
13 | + } while (utils.compareMonth(cursor, getDate(maxDate)) !== 1); | ||
14 | + | ||
15 | + return months; | ||
16 | +} | ||
17 | + | ||
18 | +function getButtonDisabled(type, currentDate) { | ||
19 | + if (currentDate == null) { | ||
20 | + return true; | ||
21 | + } | ||
22 | + | ||
23 | + if (type === 'range') { | ||
24 | + return !currentDate[0] || !currentDate[1]; | ||
25 | + } | ||
26 | + | ||
27 | + if (type === 'multiple') { | ||
28 | + return !currentDate.length; | ||
29 | + } | ||
30 | + | ||
31 | + return !currentDate; | ||
32 | +} | ||
33 | + | ||
34 | +module.exports = { | ||
35 | + getMonths: getMonths, | ||
36 | + getButtonDisabled: getButtonDisabled | ||
37 | +}; |
1 | +@import '../common/index.wxss';.van-calendar{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;height:100%;height:var(--calendar-height,100%);background-color:#fff;background-color:var(--calendar-background-color,#fff)}.van-calendar__close-icon{top:11px}.van-calendar__popup--bottom,.van-calendar__popup--top{height:80%;height:var(--calendar-popup-height,80%)}.van-calendar__popup--left,.van-calendar__popup--right{height:100%}.van-calendar__body{-webkit-flex:1;flex:1;overflow:auto;-webkit-overflow-scrolling:touch}.van-calendar__footer{-webkit-flex-shrink:0;flex-shrink:0;padding:0 16px;padding:0 var(--padding-md,16px)}.van-calendar__footer--safe-area-inset-bottom{padding-bottom:env(safe-area-inset-bottom)}.van-calendar__footer+.van-calendar__footer,.van-calendar__footer:empty{display:none}.van-calendar__footer:empty+.van-calendar__footer{display:block!important}.van-calendar__confirm{height:36px!important;height:var(--calendar-confirm-button-height,36px)!important;margin:7px 0!important;margin:var(--calendar-confirm-button-margin,7px 0)!important;line-height:34px!important;line-height:var(--calendar-confirm-button-line-height,34px)!important} |
1 | +'use strict'; | ||
2 | +Object.defineProperty(exports, '__esModule', { value: true }); | ||
3 | +exports.getMonths = exports.getMonthEndDay = exports.copyDates = exports.calcDateNum = exports.getNextDay = exports.getPrevDay = exports.getDayByOffset = exports.compareDay = exports.compareMonth = exports.formatMonthTitle = exports.ROW_HEIGHT = void 0; | ||
4 | +exports.ROW_HEIGHT = 64; | ||
5 | +function formatMonthTitle(date) { | ||
6 | + if (!(date instanceof Date)) { | ||
7 | + date = new Date(date); | ||
8 | + } | ||
9 | + return date.getFullYear() + '\u5E74' + (date.getMonth() + 1) + '\u6708'; | ||
10 | +} | ||
11 | +exports.formatMonthTitle = formatMonthTitle; | ||
12 | +function compareMonth(date1, date2) { | ||
13 | + if (!(date1 instanceof Date)) { | ||
14 | + date1 = new Date(date1); | ||
15 | + } | ||
16 | + if (!(date2 instanceof Date)) { | ||
17 | + date2 = new Date(date2); | ||
18 | + } | ||
19 | + var year1 = date1.getFullYear(); | ||
20 | + var year2 = date2.getFullYear(); | ||
21 | + var month1 = date1.getMonth(); | ||
22 | + var month2 = date2.getMonth(); | ||
23 | + if (year1 === year2) { | ||
24 | + return month1 === month2 ? 0 : month1 > month2 ? 1 : -1; | ||
25 | + } | ||
26 | + return year1 > year2 ? 1 : -1; | ||
27 | +} | ||
28 | +exports.compareMonth = compareMonth; | ||
29 | +function compareDay(day1, day2) { | ||
30 | + if (!(day1 instanceof Date)) { | ||
31 | + day1 = new Date(day1); | ||
32 | + } | ||
33 | + if (!(day2 instanceof Date)) { | ||
34 | + day2 = new Date(day2); | ||
35 | + } | ||
36 | + var compareMonthResult = compareMonth(day1, day2); | ||
37 | + if (compareMonthResult === 0) { | ||
38 | + var date1 = day1.getDate(); | ||
39 | + var date2 = day2.getDate(); | ||
40 | + return date1 === date2 ? 0 : date1 > date2 ? 1 : -1; | ||
41 | + } | ||
42 | + return compareMonthResult; | ||
43 | +} | ||
44 | +exports.compareDay = compareDay; | ||
45 | +function getDayByOffset(date, offset) { | ||
46 | + date = new Date(date); | ||
47 | + date.setDate(date.getDate() + offset); | ||
48 | + return date; | ||
49 | +} | ||
50 | +exports.getDayByOffset = getDayByOffset; | ||
51 | +function getPrevDay(date) { | ||
52 | + return getDayByOffset(date, -1); | ||
53 | +} | ||
54 | +exports.getPrevDay = getPrevDay; | ||
55 | +function getNextDay(date) { | ||
56 | + return getDayByOffset(date, 1); | ||
57 | +} | ||
58 | +exports.getNextDay = getNextDay; | ||
59 | +function calcDateNum(date) { | ||
60 | + var day1 = new Date(date[0]).getTime(); | ||
61 | + var day2 = new Date(date[1]).getTime(); | ||
62 | + return (day2 - day1) / (1000 * 60 * 60 * 24) + 1; | ||
63 | +} | ||
64 | +exports.calcDateNum = calcDateNum; | ||
65 | +function copyDates(dates) { | ||
66 | + if (Array.isArray(dates)) { | ||
67 | + return dates.map(function (date) { | ||
68 | + if (date === null) { | ||
69 | + return date; | ||
70 | + } | ||
71 | + return new Date(date); | ||
72 | + }); | ||
73 | + } | ||
74 | + return new Date(dates); | ||
75 | +} | ||
76 | +exports.copyDates = copyDates; | ||
77 | +function getMonthEndDay(year, month) { | ||
78 | + return 32 - new Date(year, month - 1, 32).getDate(); | ||
79 | +} | ||
80 | +exports.getMonthEndDay = getMonthEndDay; | ||
81 | +function getMonths(minDate, maxDate) { | ||
82 | + var months = []; | ||
83 | + var cursor = new Date(minDate); | ||
84 | + cursor.setDate(1); | ||
85 | + do { | ||
86 | + months.push(cursor.getTime()); | ||
87 | + cursor.setMonth(cursor.getMonth() + 1); | ||
88 | + } while (compareMonth(cursor, maxDate) !== 1); | ||
89 | + return months; | ||
90 | +} | ||
91 | +exports.getMonths = getMonths; |
1 | +/* eslint-disable */ | ||
2 | +function getMonthEndDay(year, month) { | ||
3 | + return 32 - getDate(year, month - 1, 32).getDate(); | ||
4 | +} | ||
5 | + | ||
6 | +function compareMonth(date1, date2) { | ||
7 | + date1 = getDate(date1); | ||
8 | + date2 = getDate(date2); | ||
9 | + | ||
10 | + var year1 = date1.getFullYear(); | ||
11 | + var year2 = date2.getFullYear(); | ||
12 | + var month1 = date1.getMonth(); | ||
13 | + var month2 = date2.getMonth(); | ||
14 | + | ||
15 | + if (year1 === year2) { | ||
16 | + return month1 === month2 ? 0 : month1 > month2 ? 1 : -1; | ||
17 | + } | ||
18 | + | ||
19 | + return year1 > year2 ? 1 : -1; | ||
20 | +} | ||
21 | + | ||
22 | +module.exports = { | ||
23 | + getMonthEndDay: getMonthEndDay, | ||
24 | + compareMonth: compareMonth | ||
25 | +}; |
1 | +'use strict'; | ||
2 | +Object.defineProperty(exports, '__esModule', { value: true }); | ||
3 | +var link_1 = require('../mixins/link'); | ||
4 | +var component_1 = require('../common/component'); | ||
5 | +component_1.VantComponent({ | ||
6 | + classes: [ | ||
7 | + 'num-class', | ||
8 | + 'desc-class', | ||
9 | + 'thumb-class', | ||
10 | + 'title-class', | ||
11 | + 'price-class', | ||
12 | + 'origin-price-class', | ||
13 | + ], | ||
14 | + mixins: [link_1.link], | ||
15 | + props: { | ||
16 | + tag: String, | ||
17 | + num: String, | ||
18 | + desc: String, | ||
19 | + thumb: String, | ||
20 | + title: String, | ||
21 | + price: { | ||
22 | + type: String, | ||
23 | + observer: 'updatePrice', | ||
24 | + }, | ||
25 | + centered: Boolean, | ||
26 | + lazyLoad: Boolean, | ||
27 | + thumbLink: String, | ||
28 | + originPrice: String, | ||
29 | + thumbMode: { | ||
30 | + type: String, | ||
31 | + value: 'aspectFit', | ||
32 | + }, | ||
33 | + currency: { | ||
34 | + type: String, | ||
35 | + value: '¥', | ||
36 | + }, | ||
37 | + }, | ||
38 | + methods: { | ||
39 | + updatePrice: function () { | ||
40 | + var price = this.data.price; | ||
41 | + var priceArr = price.toString().split('.'); | ||
42 | + this.setData({ | ||
43 | + integerStr: priceArr[0], | ||
44 | + decimalStr: priceArr[1] ? '.' + priceArr[1] : '', | ||
45 | + }); | ||
46 | + }, | ||
47 | + onClickThumb: function () { | ||
48 | + this.jumpLink('thumbLink'); | ||
49 | + }, | ||
50 | + }, | ||
51 | +}); |
1 | +<wxs src="../wxs/utils.wxs" module="utils" /> | ||
2 | + | ||
3 | +<view class="custom-class van-card"> | ||
4 | + <view class="{{ utils.bem('card__header', { center: centered }) }}"> | ||
5 | + <view class="van-card__thumb" bind:tap="onClickThumb"> | ||
6 | + <image | ||
7 | + wx:if="{{ thumb }}" | ||
8 | + src="{{ thumb }}" | ||
9 | + mode="{{ thumbMode }}" | ||
10 | + lazy-load="{{ lazyLoad }}" | ||
11 | + class="van-card__img thumb-class" | ||
12 | + /> | ||
13 | + <slot wx:else name="thumb" /> | ||
14 | + <van-tag | ||
15 | + wx:if="{{ tag }}" | ||
16 | + mark | ||
17 | + type="danger" | ||
18 | + custom-class="van-card__tag" | ||
19 | + > | ||
20 | + {{ tag }} | ||
21 | + </van-tag> | ||
22 | + <slot wx:else name="tag" /> | ||
23 | + </view> | ||
24 | + | ||
25 | + <view class="van-card__content {{ utils.bem('card__content', { center: centered }) }}"> | ||
26 | + <view> | ||
27 | + <view wx:if="{{ title }}" class="van-card__title title-class">{{ title }}</view> | ||
28 | + <slot wx:else name="title" /> | ||
29 | + | ||
30 | + <view wx:if="{{ desc }}" class="van-card__desc desc-class">{{ desc }}</view> | ||
31 | + <slot wx:else name="desc" /> | ||
32 | + | ||
33 | + <slot name="tags" /> | ||
34 | + </view> | ||
35 | + | ||
36 | + <view class="van-card__bottom"> | ||
37 | + <slot name="price-top" /> | ||
38 | + <view wx:if="{{ price || price === 0 }}" class="van-card__price price-class"> | ||
39 | + <text>{{ currency }}</text> | ||
40 | + <text class="van-card__price-integer">{{ integerStr }}</text> | ||
41 | + <text class="van-card__price-decimal">{{ decimalStr }}</text> | ||
42 | + </view> | ||
43 | + <slot wx:else name="price" /> | ||
44 | + <view wx:if="{{ originPrice || originPrice === 0 }}" class="van-card__origin-price origin-price-class">{{ currency }} {{ originPrice }}</view> | ||
45 | + <slot wx:else name="origin-price" /> | ||
46 | + <view wx:if="{{ num }}" class="van-card__num num-class">x {{ num }}</view> | ||
47 | + <slot wx:else name="num" /> | ||
48 | + <slot name="bottom" /> | ||
49 | + </view> | ||
50 | + </view> | ||
51 | + </view> | ||
52 | + | ||
53 | + <view class="van-card__footer"> | ||
54 | + <slot name="footer" /> | ||
55 | + </view> | ||
56 | +</view> |
1 | +@import '../common/index.wxss';.van-card{position:relative;box-sizing:border-box;padding:8px 16px;padding:var(--card-padding,8px 16px);font-size:12px;font-size:var(--card-font-size,12px);color:#323233;color:var(--card-text-color,#323233);background-color:#fafafa;background-color:var(--card-background-color,#fafafa)}.van-card__header{display:-webkit-flex;display:flex}.van-card__header--center{-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-card__thumb{position:relative;-webkit-flex:none;flex:none;width:88px;width:var(--card-thumb-size,88px);height:88px;height:var(--card-thumb-size,88px);margin-right:8px;margin-right:var(--padding-xs,8px)}.van-card__thumb:empty{display:none}.van-card__img{width:100%;height:100%;border-radius:8px;border-radius:var(--border-radius-lg,8px)}.van-card__content{position:relative;display:-webkit-flex;display:flex;-webkit-flex:1;flex:1;-webkit-flex-direction:column;flex-direction:column;-webkit-justify-content:space-between;justify-content:space-between;min-width:0;min-height:88px;min-height:var(--card-thumb-size,88px)}.van-card__content--center{-webkit-justify-content:center;justify-content:center}.van-card__desc,.van-card__title{word-wrap:break-word}.van-card__title{font-weight:700;line-height:16px;line-height:var(--card-title-line-height,16px)}.van-card__desc{line-height:20px;line-height:var(--card-desc-line-height,20px);color:#646566;color:var(--card-desc-color,#646566)}.van-card__bottom{line-height:20px}.van-card__price{display:inline-block;font-weight:700;color:#ee0a24;color:var(--card-price-color,#ee0a24);font-size:12px;font-size:var(--card-price-font-size,12px)}.van-card__price-integer{font-size:16px;font-size:var(--card-price-integer-font-size,16px)}.van-card__price-decimal,.van-card__price-integer{font-family:Avenir-Heavy,PingFang SC,Helvetica Neue,Arial,sans-serif;font-family:var(--card-price-font-family,Avenir-Heavy,PingFang SC,Helvetica Neue,Arial,sans-serif)}.van-card__origin-price{display:inline-block;margin-left:5px;text-decoration:line-through;font-size:10px;font-size:var(--card-origin-price-font-size,10px);color:#646566;color:var(--card-origin-price-color,#646566)}.van-card__num{float:right}.van-card__tag{position:absolute!important;top:2px;left:0}.van-card__footer{-webkit-flex:none;flex:none;width:100%;text-align:right} |
1 | +@import '../common/index.wxss';.van-cell-group__title{padding:16px 16px 8px;padding:var(--cell-group-title-padding,16px 16px 8px);font-size:14px;font-size:var(--cell-group-title-font-size,14px);line-height:16px;line-height:var(--cell-group-title-line-height,16px);color:#969799;color:var(--cell-group-title-color,#969799)} |
1 | +'use strict'; | ||
2 | +Object.defineProperty(exports, '__esModule', { value: true }); | ||
3 | +var link_1 = require('../mixins/link'); | ||
4 | +var component_1 = require('../common/component'); | ||
5 | +component_1.VantComponent({ | ||
6 | + classes: [ | ||
7 | + 'title-class', | ||
8 | + 'label-class', | ||
9 | + 'value-class', | ||
10 | + 'right-icon-class', | ||
11 | + 'hover-class', | ||
12 | + ], | ||
13 | + mixins: [link_1.link], | ||
14 | + props: { | ||
15 | + title: null, | ||
16 | + value: null, | ||
17 | + icon: String, | ||
18 | + size: String, | ||
19 | + label: String, | ||
20 | + center: Boolean, | ||
21 | + isLink: Boolean, | ||
22 | + required: Boolean, | ||
23 | + clickable: Boolean, | ||
24 | + titleWidth: String, | ||
25 | + customStyle: String, | ||
26 | + arrowDirection: String, | ||
27 | + useLabelSlot: Boolean, | ||
28 | + border: { | ||
29 | + type: Boolean, | ||
30 | + value: true, | ||
31 | + }, | ||
32 | + titleStyle: String, | ||
33 | + }, | ||
34 | + methods: { | ||
35 | + onClick: function (event) { | ||
36 | + this.$emit('click', event.detail); | ||
37 | + this.jumpLink(); | ||
38 | + }, | ||
39 | + }, | ||
40 | +}); |
1 | +<wxs src="../wxs/utils.wxs" module="utils" /> | ||
2 | + | ||
3 | +<view | ||
4 | + class="custom-class {{ utils.bem('cell', [size, { center, required, borderless: !border, clickable: isLink || clickable }]) }}" | ||
5 | + hover-class="van-cell--hover hover-class" | ||
6 | + hover-stay-time="70" | ||
7 | + style="{{ customStyle }}" | ||
8 | + bind:tap="onClick" | ||
9 | +> | ||
10 | + <van-icon | ||
11 | + wx:if="{{ icon }}" | ||
12 | + name="{{ icon }}" | ||
13 | + class="van-cell__left-icon-wrap" | ||
14 | + custom-class="van-cell__left-icon" | ||
15 | + /> | ||
16 | + <slot wx:else name="icon" /> | ||
17 | + | ||
18 | + <view | ||
19 | + style="{{ (titleWidth ? 'max-width:' + titleWidth + ';min-width:' + titleWidth + ';' : '') + titleStyle }}" | ||
20 | + class="van-cell__title title-class" | ||
21 | + > | ||
22 | + <block wx:if="{{ title }}">{{ title }}</block> | ||
23 | + <slot wx:else name="title" /> | ||
24 | + | ||
25 | + <view wx:if="{{ label || useLabelSlot }}" class="van-cell__label label-class"> | ||
26 | + <slot wx:if="{{ useLabelSlot }}" name="label" /> | ||
27 | + <block wx:elif="{{ label }}">{{ label }}</block> | ||
28 | + </view> | ||
29 | + </view> | ||
30 | + | ||
31 | + <view class="van-cell__value value-class"> | ||
32 | + <block wx:if="{{ value || value === 0 }}">{{ value }}</block> | ||
33 | + <slot wx:else /> | ||
34 | + </view> | ||
35 | + | ||
36 | + <van-icon | ||
37 | + wx:if="{{ isLink }}" | ||
38 | + name="{{ arrowDirection ? 'arrow' + '-' + arrowDirection : 'arrow' }}" | ||
39 | + class="van-cell__right-icon-wrap right-icon-class" | ||
40 | + custom-class="van-cell__right-icon" | ||
41 | + /> | ||
42 | + <slot wx:else name="right-icon" /> | ||
43 | + | ||
44 | + <slot name="extra" /> | ||
45 | +</view> |
1 | +@import '../common/index.wxss';.van-cell{position:relative;display:-webkit-flex;display:flex;box-sizing:border-box;width:100%;padding:10px 16px;padding:var(--cell-vertical-padding,10px) var(--cell-horizontal-padding,16px);font-size:14px;font-size:var(--cell-font-size,14px);line-height:24px;line-height:var(--cell-line-height,24px);color:#323233;color:var(--cell-text-color,#323233);background-color:#fff;background-color:var(--cell-background-color,#fff)}.van-cell:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;right:16px;bottom:0;left:16px;border-bottom:1px solid #ebedf0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.van-cell--borderless:after{display:none}.van-cell-group{background-color:#fff;background-color:var(--cell-background-color,#fff)}.van-cell__label{margin-top:3px;margin-top:var(--cell-label-margin-top,3px);font-size:12px;font-size:var(--cell-label-font-size,12px);line-height:18px;line-height:var(--cell-label-line-height,18px);color:#969799;color:var(--cell-label-color,#969799)}.van-cell__value{overflow:hidden;text-align:right;vertical-align:middle;color:#969799;color:var(--cell-value-color,#969799)}.van-cell__title,.van-cell__value{-webkit-flex:1;flex:1}.van-cell__title:empty,.van-cell__value:empty{display:none}.van-cell__left-icon-wrap,.van-cell__right-icon-wrap{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;height:24px;height:var(--cell-line-height,24px);font-size:16px;font-size:var(--cell-icon-size,16px)}.van-cell__left-icon-wrap{margin-right:5px}.van-cell__right-icon-wrap{margin-left:5px;color:#969799;color:var(--cell-right-icon-color,#969799)}.van-cell__left-icon{vertical-align:middle}.van-cell__left-icon,.van-cell__right-icon{line-height:24px;line-height:var(--cell-line-height,24px)}.van-cell--clickable.van-cell--hover{background-color:#f2f3f5;background-color:var(--cell-active-color,#f2f3f5)}.van-cell--required{overflow:visible}.van-cell--required:before{position:absolute;content:"*";left:8px;left:var(--padding-xs,8px);font-size:14px;font-size:var(--cell-font-size,14px);color:#ee0a24;color:var(--cell-required-color,#ee0a24)}.van-cell--center{-webkit-align-items:center;align-items:center}.van-cell--large{padding-top:12px;padding-top:var(--cell-large-vertical-padding,12px);padding-bottom:12px;padding-bottom:var(--cell-large-vertical-padding,12px)}.van-cell--large .van-cell__title{font-size:16px;font-size:var(--cell-large-title-font-size,16px)}.van-cell--large .van-cell__value{font-size:16px;font-size:var(--cell-large-value-font-size,16px)}.van-cell--large .van-cell__label{font-size:14px;font-size:var(--cell-large-label-font-size,14px)} |
1 | +'use strict'; | ||
2 | +Object.defineProperty(exports, '__esModule', { value: true }); | ||
3 | +var component_1 = require('../common/component'); | ||
4 | +component_1.VantComponent({ | ||
5 | + field: true, | ||
6 | + relation: { | ||
7 | + name: 'checkbox', | ||
8 | + type: 'descendant', | ||
9 | + current: 'checkbox-group', | ||
10 | + linked: function (target) { | ||
11 | + this.updateChild(target); | ||
12 | + }, | ||
13 | + }, | ||
14 | + props: { | ||
15 | + max: Number, | ||
16 | + value: { | ||
17 | + type: Array, | ||
18 | + observer: 'updateChildren', | ||
19 | + }, | ||
20 | + disabled: { | ||
21 | + type: Boolean, | ||
22 | + observer: 'updateChildren', | ||
23 | + }, | ||
24 | + }, | ||
25 | + methods: { | ||
26 | + updateChildren: function () { | ||
27 | + var _this = this; | ||
28 | + (this.children || []).forEach(function (child) { | ||
29 | + return _this.updateChild(child); | ||
30 | + }); | ||
31 | + }, | ||
32 | + updateChild: function (child) { | ||
33 | + var _a = this.data, | ||
34 | + value = _a.value, | ||
35 | + disabled = _a.disabled; | ||
36 | + child.setData({ | ||
37 | + value: value.indexOf(child.data.name) !== -1, | ||
38 | + parentDisabled: disabled, | ||
39 | + }); | ||
40 | + }, | ||
41 | + }, | ||
42 | +}); |
1 | +<slot /> |
1 | +@import '../common/index.wxss'; |
1 | +'use strict'; | ||
2 | +Object.defineProperty(exports, '__esModule', { value: true }); | ||
3 | +var component_1 = require('../common/component'); | ||
4 | +function emit(target, value) { | ||
5 | + target.$emit('input', value); | ||
6 | + target.$emit('change', value); | ||
7 | +} | ||
8 | +component_1.VantComponent({ | ||
9 | + field: true, | ||
10 | + relation: { | ||
11 | + name: 'checkbox-group', | ||
12 | + type: 'ancestor', | ||
13 | + current: 'checkbox', | ||
14 | + }, | ||
15 | + classes: ['icon-class', 'label-class'], | ||
16 | + props: { | ||
17 | + value: Boolean, | ||
18 | + disabled: Boolean, | ||
19 | + useIconSlot: Boolean, | ||
20 | + checkedColor: String, | ||
21 | + labelPosition: String, | ||
22 | + labelDisabled: Boolean, | ||
23 | + shape: { | ||
24 | + type: String, | ||
25 | + value: 'round', | ||
26 | + }, | ||
27 | + iconSize: { | ||
28 | + type: null, | ||
29 | + value: 20, | ||
30 | + }, | ||
31 | + }, | ||
32 | + data: { | ||
33 | + parentDisabled: false, | ||
34 | + }, | ||
35 | + methods: { | ||
36 | + emitChange: function (value) { | ||
37 | + if (this.parent) { | ||
38 | + this.setParentValue(this.parent, value); | ||
39 | + } else { | ||
40 | + emit(this, value); | ||
41 | + } | ||
42 | + }, | ||
43 | + toggle: function () { | ||
44 | + var _a = this.data, | ||
45 | + parentDisabled = _a.parentDisabled, | ||
46 | + disabled = _a.disabled, | ||
47 | + value = _a.value; | ||
48 | + if (!disabled && !parentDisabled) { | ||
49 | + this.emitChange(!value); | ||
50 | + } | ||
51 | + }, | ||
52 | + onClickLabel: function () { | ||
53 | + var _a = this.data, | ||
54 | + labelDisabled = _a.labelDisabled, | ||
55 | + parentDisabled = _a.parentDisabled, | ||
56 | + disabled = _a.disabled, | ||
57 | + value = _a.value; | ||
58 | + if (!disabled && !labelDisabled && !parentDisabled) { | ||
59 | + this.emitChange(!value); | ||
60 | + } | ||
61 | + }, | ||
62 | + setParentValue: function (parent, value) { | ||
63 | + var parentValue = parent.data.value.slice(); | ||
64 | + var name = this.data.name; | ||
65 | + var max = parent.data.max; | ||
66 | + if (value) { | ||
67 | + if (max && parentValue.length >= max) { | ||
68 | + return; | ||
69 | + } | ||
70 | + if (parentValue.indexOf(name) === -1) { | ||
71 | + parentValue.push(name); | ||
72 | + emit(parent, parentValue); | ||
73 | + } | ||
74 | + } else { | ||
75 | + var index = parentValue.indexOf(name); | ||
76 | + if (index !== -1) { | ||
77 | + parentValue.splice(index, 1); | ||
78 | + emit(parent, parentValue); | ||
79 | + } | ||
80 | + } | ||
81 | + }, | ||
82 | + }, | ||
83 | +}); |
1 | +<wxs src="../wxs/utils.wxs" module="utils" /> | ||
2 | +<wxs src="./index.wxs" module="computed" /> | ||
3 | + | ||
4 | +<view class="van-checkbox custom-class"> | ||
5 | + <view class="van-checkbox__icon-wrap" bindtap="toggle"> | ||
6 | + <slot wx:if="{{ useIconSlot }}" name="icon" /> | ||
7 | + <van-icon | ||
8 | + wx:else | ||
9 | + name="success" | ||
10 | + size="0.8em" | ||
11 | + class="{{ utils.bem('checkbox__icon', [shape, { disabled: disabled || parentDisabled, checked: value }]) }}" | ||
12 | + style="{{ computed.iconStyle(checkedColor, value, disabled, parentDisabled, iconSize) }}" | ||
13 | + custom-class="icon-class" | ||
14 | + custom-style="line-height: 1.25em;" | ||
15 | + /> | ||
16 | + </view> | ||
17 | + <view class="label-class {{ utils.bem('checkbox__label', [labelPosition, { disabled: disabled || parentDisabled }]) }}" bindtap="onClickLabel"> | ||
18 | + <slot /> | ||
19 | + </view> | ||
20 | +</view> |
1 | +/* eslint-disable */ | ||
2 | +var utils = require('../wxs/utils.wxs'); | ||
3 | + | ||
4 | +function iconStyle(checkedColor, value, disabled, parentDisabled, iconSize) { | ||
5 | + var styles = [['font-size', utils.addUnit(iconSize)]]; | ||
6 | + if (checkedColor && value && !disabled && !parentDisabled) { | ||
7 | + styles.push(['border-color', checkedColor]); | ||
8 | + styles.push(['background-color', checkedColor]); | ||
9 | + } | ||
10 | + | ||
11 | + return styles | ||
12 | + .map(function(item) { | ||
13 | + return item.join(':'); | ||
14 | + }) | ||
15 | + .join(';'); | ||
16 | +} | ||
17 | + | ||
18 | +module.exports = { | ||
19 | + iconStyle: iconStyle | ||
20 | +}; |
1 | +@import '../common/index.wxss';.van-checkbox{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;overflow:hidden;-webkit-user-select:none;user-select:none}.van-checkbox__icon-wrap,.van-checkbox__label{line-height:20px;line-height:var(--checkbox-size,20px)}.van-checkbox__icon-wrap{-webkit-flex:none;flex:none}.van-checkbox__icon{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;width:1em;height:1em;color:transparent;text-align:center;transition-property:color,border-color,background-color;font-size:20px;font-size:var(--checkbox-size,20px);border:1px solid #c8c9cc;border:1px solid var(--checkbox-border-color,#c8c9cc);transition-duration:.2s;transition-duration:var(--checkbox-transition-duration,.2s)}.van-checkbox__icon--round{border-radius:100%}.van-checkbox__icon--checked{color:#fff;color:var(--white,#fff);background-color:#1989fa;background-color:var(--checkbox-checked-icon-color,#1989fa);border-color:#1989fa;border-color:var(--checkbox-checked-icon-color,#1989fa)}.van-checkbox__icon--disabled{background-color:#ebedf0;background-color:var(--checkbox-disabled-background-color,#ebedf0);border-color:#c8c9cc;border-color:var(--checkbox-disabled-icon-color,#c8c9cc)}.van-checkbox__icon--disabled.van-checkbox__icon--checked{color:#c8c9cc;color:var(--checkbox-disabled-icon-color,#c8c9cc)}.van-checkbox__label{word-wrap:break-word;margin-left:10px;margin-left:var(--checkbox-label-margin,10px);color:#323233;color:var(--checkbox-label-color,#323233)}.van-checkbox__label--left{float:left;margin:0 10px 0 0;margin:0 var(--checkbox-label-margin,10px) 0 0}.van-checkbox__label--disabled{color:#c8c9cc;color:var(--checkbox-disabled-label-color,#c8c9cc)}.van-checkbox__label:empty{margin:0} |
1 | +'use strict'; | ||
2 | +Object.defineProperty(exports, '__esModule', { value: true }); | ||
3 | +exports.adaptor = void 0; | ||
4 | +function adaptor(ctx) { | ||
5 | + // @ts-ignore | ||
6 | + return Object.assign(ctx, { | ||
7 | + setStrokeStyle: function (val) { | ||
8 | + ctx.strokeStyle = val; | ||
9 | + }, | ||
10 | + setLineWidth: function (val) { | ||
11 | + ctx.lineWidth = val; | ||
12 | + }, | ||
13 | + setLineCap: function (val) { | ||
14 | + ctx.lineCap = val; | ||
15 | + }, | ||
16 | + setFillStyle: function (val) { | ||
17 | + ctx.fillStyle = val; | ||
18 | + }, | ||
19 | + setFontSize: function (val) { | ||
20 | + ctx.font = String(val); | ||
21 | + }, | ||
22 | + setGlobalAlpha: function (val) { | ||
23 | + ctx.globalAlpha = val; | ||
24 | + }, | ||
25 | + setLineJoin: function (val) { | ||
26 | + ctx.lineJoin = val; | ||
27 | + }, | ||
28 | + setTextAlign: function (val) { | ||
29 | + ctx.textAlign = val; | ||
30 | + }, | ||
31 | + setMiterLimit: function (val) { | ||
32 | + ctx.miterLimit = val; | ||
33 | + }, | ||
34 | + setShadow: function (offsetX, offsetY, blur, color) { | ||
35 | + ctx.shadowOffsetX = offsetX; | ||
36 | + ctx.shadowOffsetY = offsetY; | ||
37 | + ctx.shadowBlur = blur; | ||
38 | + ctx.shadowColor = color; | ||
39 | + }, | ||
40 | + setTextBaseline: function (val) { | ||
41 | + ctx.textBaseline = val; | ||
42 | + }, | ||
43 | + createCircularGradient: function () {}, | ||
44 | + draw: function () {}, | ||
45 | + }); | ||
46 | +} | ||
47 | +exports.adaptor = adaptor; |
1 | +'use strict'; | ||
2 | +Object.defineProperty(exports, '__esModule', { value: true }); | ||
3 | +var component_1 = require('../common/component'); | ||
4 | +var utils_1 = require('../common/utils'); | ||
5 | +var color_1 = require('../common/color'); | ||
6 | +var canvas_1 = require('./canvas'); | ||
7 | +function format(rate) { | ||
8 | + return Math.min(Math.max(rate, 0), 100); | ||
9 | +} | ||
10 | +var PERIMETER = 2 * Math.PI; | ||
11 | +var BEGIN_ANGLE = -Math.PI / 2; | ||
12 | +var STEP = 1; | ||
13 | +component_1.VantComponent({ | ||
14 | + props: { | ||
15 | + text: String, | ||
16 | + lineCap: { | ||
17 | + type: String, | ||
18 | + value: 'round', | ||
19 | + }, | ||
20 | + value: { | ||
21 | + type: Number, | ||
22 | + value: 0, | ||
23 | + observer: 'reRender', | ||
24 | + }, | ||
25 | + speed: { | ||
26 | + type: Number, | ||
27 | + value: 50, | ||
28 | + }, | ||
29 | + size: { | ||
30 | + type: Number, | ||
31 | + value: 100, | ||
32 | + observer: function () { | ||
33 | + this.drawCircle(this.currentValue); | ||
34 | + }, | ||
35 | + }, | ||
36 | + fill: String, | ||
37 | + layerColor: { | ||
38 | + type: String, | ||
39 | + value: color_1.WHITE, | ||
40 | + }, | ||
41 | + color: { | ||
42 | + type: [String, Object], | ||
43 | + value: color_1.BLUE, | ||
44 | + observer: function () { | ||
45 | + var _this = this; | ||
46 | + this.setHoverColor().then(function () { | ||
47 | + _this.drawCircle(_this.currentValue); | ||
48 | + }); | ||
49 | + }, | ||
50 | + }, | ||
51 | + type: { | ||
52 | + type: String, | ||
53 | + value: '', | ||
54 | + }, | ||
55 | + strokeWidth: { | ||
56 | + type: Number, | ||
57 | + value: 4, | ||
58 | + }, | ||
59 | + clockwise: { | ||
60 | + type: Boolean, | ||
61 | + value: true, | ||
62 | + }, | ||
63 | + }, | ||
64 | + data: { | ||
65 | + hoverColor: color_1.BLUE, | ||
66 | + }, | ||
67 | + methods: { | ||
68 | + getContext: function () { | ||
69 | + var _this = this; | ||
70 | + var _a = this.data, | ||
71 | + type = _a.type, | ||
72 | + size = _a.size; | ||
73 | + if (type === '') { | ||
74 | + var ctx = wx.createCanvasContext('van-circle', this); | ||
75 | + return Promise.resolve(ctx); | ||
76 | + } | ||
77 | + var dpr = wx.getSystemInfoSync().pixelRatio; | ||
78 | + return new Promise(function (resolve) { | ||
79 | + wx.createSelectorQuery() | ||
80 | + .in(_this) | ||
81 | + .select('#van-circle') | ||
82 | + .node() | ||
83 | + .exec(function (res) { | ||
84 | + var canvas = res[0].node; | ||
85 | + var ctx = canvas.getContext(type); | ||
86 | + if (!_this.inited) { | ||
87 | + _this.inited = true; | ||
88 | + canvas.width = size * dpr; | ||
89 | + canvas.height = size * dpr; | ||
90 | + ctx.scale(dpr, dpr); | ||
91 | + } | ||
92 | + resolve(canvas_1.adaptor(ctx)); | ||
93 | + }); | ||
94 | + }); | ||
95 | + }, | ||
96 | + setHoverColor: function () { | ||
97 | + var _this = this; | ||
98 | + var _a = this.data, | ||
99 | + color = _a.color, | ||
100 | + size = _a.size; | ||
101 | + if (utils_1.isObj(color)) { | ||
102 | + return this.getContext().then(function (context) { | ||
103 | + var LinearColor = context.createLinearGradient(size, 0, 0, 0); | ||
104 | + Object.keys(color) | ||
105 | + .sort(function (a, b) { | ||
106 | + return parseFloat(a) - parseFloat(b); | ||
107 | + }) | ||
108 | + .map(function (key) { | ||
109 | + return LinearColor.addColorStop( | ||
110 | + parseFloat(key) / 100, | ||
111 | + color[key] | ||
112 | + ); | ||
113 | + }); | ||
114 | + _this.hoverColor = LinearColor; | ||
115 | + }); | ||
116 | + } | ||
117 | + this.hoverColor = color; | ||
118 | + return Promise.resolve(); | ||
119 | + }, | ||
120 | + presetCanvas: function (context, strokeStyle, beginAngle, endAngle, fill) { | ||
121 | + var _a = this.data, | ||
122 | + strokeWidth = _a.strokeWidth, | ||
123 | + lineCap = _a.lineCap, | ||
124 | + clockwise = _a.clockwise, | ||
125 | + size = _a.size; | ||
126 | + var position = size / 2; | ||
127 | + var radius = position - strokeWidth / 2; | ||
128 | + context.setStrokeStyle(strokeStyle); | ||
129 | + context.setLineWidth(strokeWidth); | ||
130 | + context.setLineCap(lineCap); | ||
131 | + context.beginPath(); | ||
132 | + context.arc(position, position, radius, beginAngle, endAngle, !clockwise); | ||
133 | + context.stroke(); | ||
134 | + if (fill) { | ||
135 | + context.setFillStyle(fill); | ||
136 | + context.fill(); | ||
137 | + } | ||
138 | + }, | ||
139 | + renderLayerCircle: function (context) { | ||
140 | + var _a = this.data, | ||
141 | + layerColor = _a.layerColor, | ||
142 | + fill = _a.fill; | ||
143 | + this.presetCanvas(context, layerColor, 0, PERIMETER, fill); | ||
144 | + }, | ||
145 | + renderHoverCircle: function (context, formatValue) { | ||
146 | + var clockwise = this.data.clockwise; | ||
147 | + // 结束角度 | ||
148 | + var progress = PERIMETER * (formatValue / 100); | ||
149 | + var endAngle = clockwise | ||
150 | + ? BEGIN_ANGLE + progress | ||
151 | + : 3 * Math.PI - (BEGIN_ANGLE + progress); | ||
152 | + this.presetCanvas(context, this.hoverColor, BEGIN_ANGLE, endAngle); | ||
153 | + }, | ||
154 | + drawCircle: function (currentValue) { | ||
155 | + var _this = this; | ||
156 | + var size = this.data.size; | ||
157 | + this.getContext().then(function (context) { | ||
158 | + context.clearRect(0, 0, size, size); | ||
159 | + _this.renderLayerCircle(context); | ||
160 | + var formatValue = format(currentValue); | ||
161 | + if (formatValue !== 0) { | ||
162 | + _this.renderHoverCircle(context, formatValue); | ||
163 | + } | ||
164 | + context.draw(); | ||
165 | + }); | ||
166 | + }, | ||
167 | + reRender: function () { | ||
168 | + var _this = this; | ||
169 | + // tofector 动画暂时没有想到好的解决方案 | ||
170 | + var _a = this.data, | ||
171 | + value = _a.value, | ||
172 | + speed = _a.speed; | ||
173 | + if (speed <= 0 || speed > 1000) { | ||
174 | + this.drawCircle(value); | ||
175 | + return; | ||
176 | + } | ||
177 | + this.clearInterval(); | ||
178 | + this.currentValue = this.currentValue || 0; | ||
179 | + this.interval = setInterval(function () { | ||
180 | + if (_this.currentValue !== value) { | ||
181 | + if (_this.currentValue < value) { | ||
182 | + _this.currentValue += STEP; | ||
183 | + } else { | ||
184 | + _this.currentValue -= STEP; | ||
185 | + } | ||
186 | + _this.drawCircle(_this.currentValue); | ||
187 | + } else { | ||
188 | + _this.clearInterval(); | ||
189 | + } | ||
190 | + }, 1000 / speed); | ||
191 | + }, | ||
192 | + clearInterval: function () { | ||
193 | + if (this.interval) { | ||
194 | + clearInterval(this.interval); | ||
195 | + this.interval = null; | ||
196 | + } | ||
197 | + }, | ||
198 | + }, | ||
199 | + mounted: function () { | ||
200 | + var _this = this; | ||
201 | + this.currentValue = this.data.value; | ||
202 | + this.setHoverColor().then(function () { | ||
203 | + _this.drawCircle(_this.currentValue); | ||
204 | + }); | ||
205 | + }, | ||
206 | + destroyed: function () { | ||
207 | + this.clearInterval(); | ||
208 | + }, | ||
209 | +}); |
1 | +<wxs src="../wxs/utils.wxs" module="utils" /> | ||
2 | + | ||
3 | +<view class="van-circle"> | ||
4 | + <canvas class="van-circle__canvas" type="{{ type }}" style="width: {{ utils.addUnit(size) }};height:{{ utils.addUnit(size) }}" id="van-circle" canvas-id="van-circle"></canvas> | ||
5 | + <view wx:if="{{ !text }}" class="van-circle__text"> | ||
6 | + <slot></slot> | ||
7 | + </view> | ||
8 | + <cover-view wx:else class="van-circle__text">{{ text }}</cover-view> | ||
9 | +</view> |
1 | +@import '../common/index.wxss';.van-circle{position:relative;display:inline-block;text-align:center}.van-circle__text{position:absolute;top:50%;left:0;width:100%;-webkit-transform:translateY(-50%);transform:translateY(-50%);color:#323233;color:var(--circle-text-color,#323233)} |
1 | +'use strict'; | ||
2 | +Object.defineProperty(exports, '__esModule', { value: true }); | ||
3 | +var component_1 = require('../common/component'); | ||
4 | +component_1.VantComponent({ | ||
5 | + relation: { | ||
6 | + name: 'row', | ||
7 | + type: 'ancestor', | ||
8 | + current: 'col', | ||
9 | + }, | ||
10 | + props: { | ||
11 | + span: Number, | ||
12 | + offset: Number, | ||
13 | + }, | ||
14 | + data: { | ||
15 | + viewStyle: '', | ||
16 | + }, | ||
17 | + methods: { | ||
18 | + setGutter: function (gutter) { | ||
19 | + var padding = gutter / 2 + 'px'; | ||
20 | + var viewStyle = gutter | ||
21 | + ? 'padding-left: ' + padding + '; padding-right: ' + padding + ';' | ||
22 | + : ''; | ||
23 | + if (viewStyle !== this.data.viewStyle) { | ||
24 | + this.setData({ viewStyle: viewStyle }); | ||
25 | + } | ||
26 | + }, | ||
27 | + }, | ||
28 | +}); |
1 | +@import '../common/index.wxss';.van-col{float:left;box-sizing:border-box}.van-col--1{width:4.16666667%}.van-col--offset-1{margin-left:4.16666667%}.van-col--2{width:8.33333333%}.van-col--offset-2{margin-left:8.33333333%}.van-col--3{width:12.5%}.van-col--offset-3{margin-left:12.5%}.van-col--4{width:16.66666667%}.van-col--offset-4{margin-left:16.66666667%}.van-col--5{width:20.83333333%}.van-col--offset-5{margin-left:20.83333333%}.van-col--6{width:25%}.van-col--offset-6{margin-left:25%}.van-col--7{width:29.16666667%}.van-col--offset-7{margin-left:29.16666667%}.van-col--8{width:33.33333333%}.van-col--offset-8{margin-left:33.33333333%}.van-col--9{width:37.5%}.van-col--offset-9{margin-left:37.5%}.van-col--10{width:41.66666667%}.van-col--offset-10{margin-left:41.66666667%}.van-col--11{width:45.83333333%}.van-col--offset-11{margin-left:45.83333333%}.van-col--12{width:50%}.van-col--offset-12{margin-left:50%}.van-col--13{width:54.16666667%}.van-col--offset-13{margin-left:54.16666667%}.van-col--14{width:58.33333333%}.van-col--offset-14{margin-left:58.33333333%}.van-col--15{width:62.5%}.van-col--offset-15{margin-left:62.5%}.van-col--16{width:66.66666667%}.van-col--offset-16{margin-left:66.66666667%}.van-col--17{width:70.83333333%}.van-col--offset-17{margin-left:70.83333333%}.van-col--18{width:75%}.van-col--offset-18{margin-left:75%}.van-col--19{width:79.16666667%}.van-col--offset-19{margin-left:79.16666667%}.van-col--20{width:83.33333333%}.van-col--offset-20{margin-left:83.33333333%}.van-col--21{width:87.5%}.van-col--offset-21{margin-left:87.5%}.van-col--22{width:91.66666667%}.van-col--offset-22{margin-left:91.66666667%}.van-col--23{width:95.83333333%}.van-col--offset-23{margin-left:95.83333333%}.van-col--24{width:100%}.van-col--offset-24{margin-left:100%} |
1 | +'use strict'; | ||
2 | +Object.defineProperty(exports, '__esModule', { value: true }); | ||
3 | +var component_1 = require('../common/component'); | ||
4 | +component_1.VantComponent({ | ||
5 | + classes: ['title-class', 'content-class'], | ||
6 | + relation: { | ||
7 | + name: 'collapse', | ||
8 | + type: 'ancestor', | ||
9 | + current: 'collapse-item', | ||
10 | + }, | ||
11 | + props: { | ||
12 | + name: null, | ||
13 | + title: null, | ||
14 | + value: null, | ||
15 | + icon: String, | ||
16 | + label: String, | ||
17 | + disabled: Boolean, | ||
18 | + clickable: Boolean, | ||
19 | + border: { | ||
20 | + type: Boolean, | ||
21 | + value: true, | ||
22 | + }, | ||
23 | + isLink: { | ||
24 | + type: Boolean, | ||
25 | + value: true, | ||
26 | + }, | ||
27 | + }, | ||
28 | + data: { | ||
29 | + expanded: false, | ||
30 | + }, | ||
31 | + created: function () { | ||
32 | + this.animation = wx.createAnimation({ | ||
33 | + duration: 0, | ||
34 | + timingFunction: 'ease-in-out', | ||
35 | + }); | ||
36 | + }, | ||
37 | + mounted: function () { | ||
38 | + this.updateExpanded(); | ||
39 | + this.inited = true; | ||
40 | + }, | ||
41 | + methods: { | ||
42 | + updateExpanded: function () { | ||
43 | + if (!this.parent) { | ||
44 | + return Promise.resolve(); | ||
45 | + } | ||
46 | + var _a = this.parent.data, | ||
47 | + value = _a.value, | ||
48 | + accordion = _a.accordion; | ||
49 | + var _b = this.parent.children, | ||
50 | + children = _b === void 0 ? [] : _b; | ||
51 | + var name = this.data.name; | ||
52 | + var index = children.indexOf(this); | ||
53 | + var currentName = name == null ? index : name; | ||
54 | + var expanded = accordion | ||
55 | + ? value === currentName | ||
56 | + : (value || []).some(function (name) { | ||
57 | + return name === currentName; | ||
58 | + }); | ||
59 | + if (expanded !== this.data.expanded) { | ||
60 | + this.updateStyle(expanded); | ||
61 | + } | ||
62 | + this.setData({ index: index, expanded: expanded }); | ||
63 | + }, | ||
64 | + updateStyle: function (expanded) { | ||
65 | + var _this = this; | ||
66 | + var inited = this.inited; | ||
67 | + this.getRect('.van-collapse-item__content') | ||
68 | + .then(function (rect) { | ||
69 | + return rect.height; | ||
70 | + }) | ||
71 | + .then(function (height) { | ||
72 | + var animation = _this.animation; | ||
73 | + if (expanded) { | ||
74 | + if (height === 0) { | ||
75 | + animation.height('auto').top(1).step(); | ||
76 | + } else { | ||
77 | + animation | ||
78 | + .height(height) | ||
79 | + .top(1) | ||
80 | + .step({ | ||
81 | + duration: inited ? 300 : 1, | ||
82 | + }) | ||
83 | + .height('auto') | ||
84 | + .step(); | ||
85 | + } | ||
86 | + _this.setData({ | ||
87 | + animation: animation.export(), | ||
88 | + }); | ||
89 | + return; | ||
90 | + } | ||
91 | + animation.height(height).top(0).step({ duration: 1 }).height(0).step({ | ||
92 | + duration: 300, | ||
93 | + }); | ||
94 | + _this.setData({ | ||
95 | + animation: animation.export(), | ||
96 | + }); | ||
97 | + }); | ||
98 | + }, | ||
99 | + onClick: function () { | ||
100 | + if (this.data.disabled) { | ||
101 | + return; | ||
102 | + } | ||
103 | + var _a = this.data, | ||
104 | + name = _a.name, | ||
105 | + expanded = _a.expanded; | ||
106 | + var index = this.parent.children.indexOf(this); | ||
107 | + var currentName = name == null ? index : name; | ||
108 | + this.parent.switch(currentName, !expanded); | ||
109 | + }, | ||
110 | + }, | ||
111 | +}); |
1 | +<wxs src="../wxs/utils.wxs" module="utils" /> | ||
2 | + | ||
3 | +<view class="van-collapse-item custom-class {{ index !== 0 ? 'van-hairline--top' : '' }}"> | ||
4 | + <van-cell | ||
5 | + title="{{ title }}" | ||
6 | + title-class="title-class" | ||
7 | + icon="{{ icon }}" | ||
8 | + value="{{ value }}" | ||
9 | + label="{{ label }}" | ||
10 | + is-link="{{ isLink }}" | ||
11 | + clickable="{{ clickable }}" | ||
12 | + border="{{ border && expanded }}" | ||
13 | + class="{{ utils.bem('collapse-item__title', { disabled, expanded }) }}" | ||
14 | + right-icon-class="van-cell__right-icon" | ||
15 | + custom-class="van-cell" | ||
16 | + hover-class="van-cell--hover" | ||
17 | + bind:click="onClick" | ||
18 | + > | ||
19 | + <slot | ||
20 | + name="title" | ||
21 | + slot="title" | ||
22 | + /> | ||
23 | + <slot | ||
24 | + name="icon" | ||
25 | + slot="icon" | ||
26 | + /> | ||
27 | + <slot name="value" /> | ||
28 | + <slot | ||
29 | + name="right-icon" | ||
30 | + slot="right-icon" | ||
31 | + /> | ||
32 | + </van-cell> | ||
33 | + <view | ||
34 | + class="{{ utils.bem('collapse-item__wrapper') }}" | ||
35 | + style="height: 0;" | ||
36 | + animation="{{ animation }}" | ||
37 | + > | ||
38 | + <view | ||
39 | + class="van-collapse-item__content content-class" | ||
40 | + > | ||
41 | + <slot /> | ||
42 | + </view> | ||
43 | + </view> | ||
44 | +</view> |
1 | +@import '../common/index.wxss';.van-collapse-item__title .van-cell__right-icon{-webkit-transform:rotate(90deg);transform:rotate(90deg);transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s;transition:-webkit-transform var(--collapse-item-transition-duration,.3s);transition:transform var(--collapse-item-transition-duration,.3s);transition:transform var(--collapse-item-transition-duration,.3s),-webkit-transform var(--collapse-item-transition-duration,.3s)}.van-collapse-item__title--expanded .van-cell__right-icon{-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.van-collapse-item__title--disabled .van-cell,.van-collapse-item__title--disabled .van-cell__right-icon{color:#c8c9cc!important;color:var(--collapse-item-title-disabled-color,#c8c9cc)!important}.van-collapse-item__title--disabled .van-cell--hover{background-color:#fff!important;background-color:var(--white,#fff)!important}.van-collapse-item__wrapper{overflow:hidden}.van-collapse-item__content{padding:15px;padding:var(--collapse-item-content-padding,15px);color:#969799;color:var(--collapse-item-content-text-color,#969799);font-size:13px;font-size:var(--collapse-item-content-font-size,13px);line-height:1.5;line-height:var(--collapse-item-content-line-height,1.5);background-color:#fff;background-color:var(--collapse-item-content-background-color,#fff)} |
1 | +'use strict'; | ||
2 | +Object.defineProperty(exports, '__esModule', { value: true }); | ||
3 | +var component_1 = require('../common/component'); | ||
4 | +component_1.VantComponent({ | ||
5 | + relation: { | ||
6 | + name: 'collapse-item', | ||
7 | + type: 'descendant', | ||
8 | + current: 'collapse', | ||
9 | + }, | ||
10 | + props: { | ||
11 | + value: { | ||
12 | + type: null, | ||
13 | + observer: 'updateExpanded', | ||
14 | + }, | ||
15 | + accordion: { | ||
16 | + type: Boolean, | ||
17 | + observer: 'updateExpanded', | ||
18 | + }, | ||
19 | + border: { | ||
20 | + type: Boolean, | ||
21 | + value: true, | ||
22 | + }, | ||
23 | + }, | ||
24 | + methods: { | ||
25 | + updateExpanded: function () { | ||
26 | + this.children.forEach(function (child) { | ||
27 | + child.updateExpanded(); | ||
28 | + }); | ||
29 | + }, | ||
30 | + switch: function (name, expanded) { | ||
31 | + var _a = this.data, | ||
32 | + accordion = _a.accordion, | ||
33 | + value = _a.value; | ||
34 | + var changeItem = name; | ||
35 | + if (!accordion) { | ||
36 | + name = expanded | ||
37 | + ? (value || []).concat(name) | ||
38 | + : (value || []).filter(function (activeName) { | ||
39 | + return activeName !== name; | ||
40 | + }); | ||
41 | + } else { | ||
42 | + name = expanded ? name : ''; | ||
43 | + } | ||
44 | + if (expanded) { | ||
45 | + this.$emit('open', changeItem); | ||
46 | + } else { | ||
47 | + this.$emit('close', changeItem); | ||
48 | + } | ||
49 | + this.$emit('change', name); | ||
50 | + this.$emit('input', name); | ||
51 | + }, | ||
52 | + }, | ||
53 | +}); |
1 | +@import '../common/index.wxss'; |
1 | +'use strict'; | ||
2 | +Object.defineProperty(exports, '__esModule', { value: true }); | ||
3 | +exports.GRAY_DARK = exports.GRAY = exports.ORANGE = exports.GREEN = exports.WHITE = exports.BLUE = exports.RED = void 0; | ||
4 | +exports.RED = '#ee0a24'; | ||
5 | +exports.BLUE = '#1989fa'; | ||
6 | +exports.WHITE = '#fff'; | ||
7 | +exports.GREEN = '#07c160'; | ||
8 | +exports.ORANGE = '#ff976a'; | ||
9 | +exports.GRAY = '#323233'; | ||
10 | +exports.GRAY_DARK = '#969799'; |
1 | +'use strict'; | ||
2 | +Object.defineProperty(exports, '__esModule', { value: true }); | ||
3 | +exports.VantComponent = void 0; | ||
4 | +var basic_1 = require('../mixins/basic'); | ||
5 | +var relationFunctions = { | ||
6 | + ancestor: { | ||
7 | + linked: function (parent) { | ||
8 | + this.parent = parent; | ||
9 | + }, | ||
10 | + unlinked: function () { | ||
11 | + this.parent = null; | ||
12 | + }, | ||
13 | + }, | ||
14 | + descendant: { | ||
15 | + linked: function (child) { | ||
16 | + this.children = this.children || []; | ||
17 | + this.children.push(child); | ||
18 | + }, | ||
19 | + unlinked: function (child) { | ||
20 | + this.children = (this.children || []).filter(function (it) { | ||
21 | + return it !== child; | ||
22 | + }); | ||
23 | + }, | ||
24 | + }, | ||
25 | +}; | ||
26 | +function mapKeys(source, target, map) { | ||
27 | + Object.keys(map).forEach(function (key) { | ||
28 | + if (source[key]) { | ||
29 | + target[map[key]] = source[key]; | ||
30 | + } | ||
31 | + }); | ||
32 | +} | ||
33 | +function makeRelation(options, vantOptions, relation) { | ||
34 | + var _a; | ||
35 | + var type = relation.type, | ||
36 | + name = relation.name, | ||
37 | + linked = relation.linked, | ||
38 | + unlinked = relation.unlinked, | ||
39 | + linkChanged = relation.linkChanged; | ||
40 | + var beforeCreate = vantOptions.beforeCreate, | ||
41 | + destroyed = vantOptions.destroyed; | ||
42 | + if (type === 'descendant') { | ||
43 | + options.created = function () { | ||
44 | + beforeCreate && beforeCreate.bind(this)(); | ||
45 | + this.children = this.children || []; | ||
46 | + }; | ||
47 | + options.detached = function () { | ||
48 | + this.children = []; | ||
49 | + destroyed && destroyed.bind(this)(); | ||
50 | + }; | ||
51 | + } | ||
52 | + options.relations = Object.assign( | ||
53 | + options.relations || {}, | ||
54 | + ((_a = {}), | ||
55 | + (_a['../' + name + '/index'] = { | ||
56 | + type: type, | ||
57 | + linked: function (node) { | ||
58 | + relationFunctions[type].linked.bind(this)(node); | ||
59 | + linked && linked.bind(this)(node); | ||
60 | + }, | ||
61 | + linkChanged: function (node) { | ||
62 | + linkChanged && linkChanged.bind(this)(node); | ||
63 | + }, | ||
64 | + unlinked: function (node) { | ||
65 | + relationFunctions[type].unlinked.bind(this)(node); | ||
66 | + unlinked && unlinked.bind(this)(node); | ||
67 | + }, | ||
68 | + }), | ||
69 | + _a) | ||
70 | + ); | ||
71 | +} | ||
72 | +function VantComponent(vantOptions) { | ||
73 | + if (vantOptions === void 0) { | ||
74 | + vantOptions = {}; | ||
75 | + } | ||
76 | + var options = {}; | ||
77 | + mapKeys(vantOptions, options, { | ||
78 | + data: 'data', | ||
79 | + props: 'properties', | ||
80 | + mixins: 'behaviors', | ||
81 | + methods: 'methods', | ||
82 | + beforeCreate: 'created', | ||
83 | + created: 'attached', | ||
84 | + mounted: 'ready', | ||
85 | + relations: 'relations', | ||
86 | + destroyed: 'detached', | ||
87 | + classes: 'externalClasses', | ||
88 | + }); | ||
89 | + var relation = vantOptions.relation; | ||
90 | + if (relation) { | ||
91 | + makeRelation(options, vantOptions, relation); | ||
92 | + } | ||
93 | + // add default externalClasses | ||
94 | + options.externalClasses = options.externalClasses || []; | ||
95 | + options.externalClasses.push('custom-class'); | ||
96 | + // add default behaviors | ||
97 | + options.behaviors = options.behaviors || []; | ||
98 | + options.behaviors.push(basic_1.basic); | ||
99 | + // map field to form-field behavior | ||
100 | + if (vantOptions.field) { | ||
101 | + options.behaviors.push('wx://form-field'); | ||
102 | + } | ||
103 | + if (options.properties) { | ||
104 | + Object.keys(options.properties).forEach(function (name) { | ||
105 | + if (Array.isArray(options.properties[name])) { | ||
106 | + // miniprogram do not allow multi type | ||
107 | + options.properties[name] = null; | ||
108 | + } | ||
109 | + }); | ||
110 | + } | ||
111 | + // add default options | ||
112 | + options.options = { | ||
113 | + multipleSlots: true, | ||
114 | + addGlobalClass: true, | ||
115 | + }; | ||
116 | + Component(options); | ||
117 | +} | ||
118 | +exports.VantComponent = VantComponent; |
1 | +.van-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{display:-webkit-box;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3}.van-clearfix:after{display:table;clear:both;content:""}.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:-50%;right:-50%;bottom:-50%;left:-50%;border:0 solid #ebedf0;-webkit-transform:scale(.5);transform:scale(.5)}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px} |
1 | +.van-clearfix:after{display:table;clear:both;content:""} |
1 | +.van-ellipsis{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.van-multi-ellipsis--l2{-webkit-line-clamp:2}.van-multi-ellipsis--l2,.van-multi-ellipsis--l3{display:-webkit-box;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical}.van-multi-ellipsis--l3{-webkit-line-clamp:3} |
1 | +.van-hairline,.van-hairline--bottom,.van-hairline--left,.van-hairline--right,.van-hairline--surround,.van-hairline--top,.van-hairline--top-bottom{position:relative}.van-hairline--bottom:after,.van-hairline--left:after,.van-hairline--right:after,.van-hairline--surround:after,.van-hairline--top-bottom:after,.van-hairline--top:after,.van-hairline:after{position:absolute;box-sizing:border-box;-webkit-transform-origin:center;transform-origin:center;content:" ";pointer-events:none;top:-50%;right:-50%;bottom:-50%;left:-50%;border:0 solid #ebedf0;-webkit-transform:scale(.5);transform:scale(.5)}.van-hairline--top:after{border-top-width:1px}.van-hairline--left:after{border-left-width:1px}.van-hairline--right:after{border-right-width:1px}.van-hairline--bottom:after{border-bottom-width:1px}.van-hairline--top-bottom:after{border-width:1px 0}.van-hairline--surround:after{border-width:1px} |
-
请 注册 或 登录 后发表评论