uview-plus 3.8.49 → 3.8.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.md +2043 -1827
- package/components/u-action-sheet/props.js +3 -1
- package/components/u-action-sheet/u-action-sheet.vue +1 -0
- package/components/u-album/props.js +3 -1
- package/components/u-alert/props.js +4 -2
- package/components/u-avatar/props.js +4 -1
- package/components/u-avatar-group/props.js +4 -1
- package/components/u-back-top/props.js +4 -1
- package/components/u-badge/props.js +4 -1
- package/components/u-barcode/u-barcode.vue +46 -15
- package/components/u-box/props.js +5 -2
- package/components/u-button/props.js +4 -1
- package/components/u-button/vue.scss +3 -3
- package/components/u-calendar/calendar.js +14 -2
- package/components/u-calendar/month.vue +41 -6
- package/components/u-calendar/props.js +63 -1
- package/components/u-calendar/u-calendar.vue +311 -2
- package/components/u-calendar-strip/props.js +3 -1
- package/components/u-canvas/u-canvas.vue +734 -423
- package/components/u-car-keyboard/props.js +3 -1
- package/components/u-card/props.js +3 -1
- package/components/u-cell/props.js +4 -1
- package/components/u-cell/u-cell.vue +1 -1
- package/components/u-cell-group/props.js +4 -1
- package/components/u-checkbox/props.js +4 -1
- package/components/u-checkbox/u-checkbox.vue +7 -3
- package/components/u-checkbox-group/props.js +3 -1
- package/components/u-circle-progress/props.js +4 -1
- package/components/u-code/props.js +4 -1
- package/components/u-code-input/props.js +4 -1
- package/components/u-col/props.js +4 -1
- package/components/u-collapse/props.js +4 -1
- package/components/u-collapse-item/props.js +4 -1
- package/components/u-color-picker/u-color-picker.vue +1 -0
- package/components/u-column-notice/props.js +4 -1
- package/components/u-count-down/props.js +4 -1
- package/components/u-count-to/props.js +4 -1
- package/components/u-cropper/u-cropper.vue +95 -51
- package/components/u-datetime-picker/props.js +4 -1
- package/components/u-divider/props.js +4 -1
- package/components/u-dragsort/u-dragsort.vue +2 -1
- package/components/u-dropdown/props.js +3 -1
- package/components/u-dropdown-item/props.js +3 -1
- package/components/u-empty/props.js +4 -1
- package/components/u-form/props.js +4 -1
- package/components/u-form-item/props.js +4 -1
- package/components/u-gap/props.js +4 -1
- package/components/u-grid/props.js +4 -1
- package/components/u-grid-item/props.js +4 -1
- package/components/u-guide/props.js +3 -1
- package/components/u-icon/props.js +4 -1
- package/components/u-icon/u-icon.vue +2 -2
- package/components/u-icon/upicon.ttf +0 -0
- package/components/u-icon/util.js +29 -7
- package/components/u-image/props.js +4 -1
- package/components/u-image/u-image.vue +280 -267
- package/components/u-index-anchor/props.js +4 -1
- package/components/u-index-item/props.js +2 -1
- package/components/u-index-list/props.js +4 -1
- package/components/u-input/props.js +3 -1
- package/components/u-input/u-input.vue +10 -1
- package/components/u-keyboard/props.js +4 -1
- package/components/u-line/props.js +4 -1
- package/components/u-line-progress/props.js +6 -3
- package/components/u-link/props.js +4 -1
- package/components/u-list/props.js +4 -1
- package/components/u-list-item/props.js +4 -1
- package/components/u-loading-icon/props.js +4 -1
- package/components/u-loading-page/props.js +3 -1
- package/components/u-loadmore/props.js +4 -1
- package/components/u-markdown/u-markdown.vue +45 -3
- package/components/u-modal/props.js +4 -1
- package/components/u-navbar/props.js +4 -2
- package/components/u-navbar/u-navbar.vue +15 -9
- package/components/u-no-network/props.js +4 -1
- package/components/u-notice-bar/props.js +4 -1
- package/components/u-notify/props.js +4 -1
- package/components/u-number-box/props.js +4 -1
- package/components/u-number-box/u-number-box.vue +2 -2
- package/components/u-number-keyboard/props.js +4 -1
- package/components/u-overlay/props.js +4 -1
- package/components/u-pagination/u-pagination.vue +60 -39
- package/components/u-parse/props.js +4 -1
- package/components/u-picker/props.js +4 -1
- package/components/u-picker/u-picker.vue +15 -0
- package/components/u-picker-column/props.js +3 -1
- package/components/u-popover/props.js +2 -1
- package/components/u-popup/props.js +4 -1
- package/components/u-poster/u-poster.vue +29 -14
- package/components/u-qrcode/qrcode.js +88 -87
- package/components/u-qrcode/u-qrcode.vue +138 -256
- package/components/u-radio/props.js +4 -1
- package/components/u-radio/u-radio.vue +7 -3
- package/components/u-radio-group/props.js +4 -1
- package/components/u-rate/props.js +4 -1
- package/components/u-read-more/props.js +4 -1
- package/components/u-row/props.js +4 -1
- package/components/u-row-notice/props.js +4 -1
- package/components/u-safe-bottom/props.js +2 -1
- package/components/u-scroll-list/props.js +4 -1
- package/components/u-search/props.js +3 -1
- package/components/u-skeleton/props.js +4 -1
- package/components/u-slider/props.js +3 -1
- package/components/u-slider/u-slider.vue +70 -28
- package/components/u-status-bar/props.js +4 -1
- package/components/u-steps/props.js +4 -1
- package/components/u-steps-item/props.js +4 -1
- package/components/u-sticky/props.js +4 -1
- package/components/u-sticky/u-sticky.vue +11 -0
- package/components/u-subsection/props.js +3 -1
- package/components/u-swipe-action/props.js +4 -1
- package/components/u-swipe-action-item/props.js +4 -1
- package/components/u-swipe-action-item/u-swipe-action-item.vue +14 -0
- package/components/u-swiper/props.js +9 -1
- package/components/u-swiper/swiper.js +1 -0
- package/components/u-swiper/u-swiper.vue +2 -0
- package/components/u-swiper-indicator/props.js +4 -1
- package/components/u-switch/props.js +4 -1
- package/components/u-tabbar/props.js +3 -1
- package/components/u-tabbar-item/props.js +4 -1
- package/components/u-table/props.js +3 -1
- package/components/u-table2/tableRow.vue +155 -69
- package/components/u-table2/u-table2.vue +328 -140
- package/components/u-tabs/props.js +4 -1
- package/components/u-tabs-item/props.js +3 -1
- package/components/u-tag/props.js +4 -1
- package/components/u-td/props.js +3 -1
- package/components/u-text/props.js +4 -1
- package/components/u-textarea/props.js +3 -1
- package/components/u-textarea/u-textarea.vue +16 -5
- package/components/u-th/props.js +3 -1
- package/components/u-toolbar/props.js +4 -1
- package/components/u-tooltip/props.js +10 -2
- package/components/u-tooltip/tooltip.js +2 -1
- package/components/u-tooltip/u-tooltip.vue +31 -3
- package/components/u-tr/props.js +3 -1
- package/components/u-transition/nvue-ani-map.js +75 -68
- package/components/u-transition/props.js +4 -1
- package/components/u-transition/transitionMixin.js +164 -163
- package/components/u-upload/props.js +4 -1
- package/components/u-upload/u-upload.vue +47 -40
- package/components/u-waterfall/u-waterfall.vue +50 -51
- package/index.js +65 -8
- package/libs/config/props.js +179 -204
- package/libs/css/components.scss +3 -0
- package/libs/function/uni-api-shims.js +29 -0
- package/libs/i18n/index.js +71 -36
- package/libs/i18n/locale-packs.js +11 -0
- package/libs/i18n/locales/all.js +23 -0
- package/libs/i18n/locales/{de.json → de.js} +1 -1
- package/libs/i18n/locales/{en.json → en.js} +2 -2
- package/libs/i18n/locales/{es.json → es.js} +1 -1
- package/libs/i18n/locales/{fr.json → fr.js} +2 -2
- package/libs/i18n/locales/{ja.json → ja.js} +1 -1
- package/libs/i18n/locales/{ko.json → ko.js} +1 -1
- package/libs/i18n/locales/{ru.json → ru.js} +1 -1
- package/libs/i18n/locales/{th.json → th.js} +1 -1
- package/libs/i18n/locales/{zh-Hans.json → zh-Hans.js} +1 -1
- package/libs/i18n/locales/{zh-Hant.json → zh-Hant.js} +1 -1
- package/libs/mixin/mixin.js +14 -4
- package/libs/util/gcanvas/bridge/bridge-weex.js +10 -5
- package/package.json +4 -5
- package/tsconfig.json +18 -0
- package/types/comps/calendar.d.ts +57 -0
- package/types/comps/checkbox.d.ts +12 -0
- package/types/comps/lineProgress.d.ts +5 -0
- package/types/comps/navbar.d.ts +3 -3
- package/types/comps/swiper.d.ts +5 -0
- package/types/comps/tooltip.d.ts +36 -1
- /package/components/u-markdown/{marked.esm.js → marked.esm.mjs} +0 -0
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
* @FilePath : /uview-plus/libs/config/props/props.js
|
|
8
8
|
*/
|
|
9
9
|
import { defineMixin } from '../../libs/vue'
|
|
10
|
-
import
|
|
10
|
+
import ActionSheetDefaultProps from './actionSheet'
|
|
11
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
11
12
|
|
|
13
|
+
const defProps = registerComponentProps(ActionSheetDefaultProps)
|
|
12
14
|
export const props = defineMixin({
|
|
13
15
|
props: {
|
|
14
16
|
// 操作菜单是否展示 (默认false)
|
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
* @FilePath : /uview-plus/components/u-album/props.js
|
|
8
8
|
*/
|
|
9
9
|
import { defineMixin } from '../../libs/vue'
|
|
10
|
-
import
|
|
10
|
+
import AlbumDefaultProps from './album'
|
|
11
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
11
12
|
|
|
13
|
+
const defProps = registerComponentProps(AlbumDefaultProps)
|
|
12
14
|
export const props = defineMixin({
|
|
13
15
|
props: {
|
|
14
16
|
// 图片地址,Array<String>|Array<Object>形式
|
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
* @FilePath : /uview-plus/libs/config/props/props.js
|
|
8
8
|
*/
|
|
9
9
|
import { defineMixin } from '../../libs/vue'
|
|
10
|
-
import
|
|
11
|
-
|
|
10
|
+
import AlertDefaultProps from './alert'
|
|
11
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
12
|
+
|
|
13
|
+
const defProps = registerComponentProps(AlertDefaultProps)
|
|
12
14
|
export const props = defineMixin({
|
|
13
15
|
props: {
|
|
14
16
|
// 显示文字
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import AvatarDefaultProps from './avatar'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
4
|
+
|
|
5
|
+
const defProps = registerComponentProps(AvatarDefaultProps)
|
|
3
6
|
import test from '../../libs/function/test';
|
|
4
7
|
export const props = defineMixin({
|
|
5
8
|
props: {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import AvatarGroupDefaultProps from './avatarGroup'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
4
|
+
|
|
5
|
+
const defProps = registerComponentProps(AvatarGroupDefaultProps)
|
|
3
6
|
export const props = defineMixin({
|
|
4
7
|
props: {
|
|
5
8
|
// 头像图片组
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import BackTopDefaultProps from './backtop'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
4
|
+
|
|
5
|
+
const defProps = registerComponentProps(BackTopDefaultProps)
|
|
3
6
|
export const props = defineMixin({
|
|
4
7
|
props: {
|
|
5
8
|
// 返回顶部的形状,circle-圆形,square-方形
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import BadgeDefaultProps from './badge'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
4
|
+
|
|
5
|
+
const defProps = registerComponentProps(BadgeDefaultProps)
|
|
3
6
|
export const props = defineMixin({
|
|
4
7
|
props: {
|
|
5
8
|
// 是否显示圆点
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="u-barcode" v-if="calcSizeDone">
|
|
3
|
-
<canvas
|
|
4
|
-
v-if="showCanvas && !error"
|
|
5
|
-
|
|
3
|
+
<up-canvas
|
|
4
|
+
v-if="showCanvas && !error"
|
|
5
|
+
ref="barcodeCanvas"
|
|
6
6
|
:canvas-id="canvasId"
|
|
7
|
+
:width="canvasWidth"
|
|
8
|
+
:height="canvasHeight"
|
|
9
|
+
bg-color="transparent"
|
|
7
10
|
:style="{ width: canvasWidth + 'px', height: canvasHeight + 'px' }"
|
|
8
|
-
></canvas>
|
|
11
|
+
></up-canvas>
|
|
9
12
|
<image
|
|
10
13
|
v-else-if="!showCanvas && !error"
|
|
11
14
|
:src="barcodeImage"
|
|
@@ -19,6 +22,15 @@
|
|
|
19
22
|
>
|
|
20
23
|
<text class="error-text">{{ error }}</text>
|
|
21
24
|
</view>
|
|
25
|
+
<up-canvas
|
|
26
|
+
v-if="!useCanvas && calcSizeDone"
|
|
27
|
+
ref="barcodeImageCanvas"
|
|
28
|
+
class="u-barcode__hidden-canvas"
|
|
29
|
+
:canvas-id="tempCanvasId"
|
|
30
|
+
:width="canvasWidth"
|
|
31
|
+
:height="canvasHeight"
|
|
32
|
+
bg-color="transparent"
|
|
33
|
+
></up-canvas>
|
|
22
34
|
</view>
|
|
23
35
|
</template>
|
|
24
36
|
|
|
@@ -146,6 +158,7 @@ export default {
|
|
|
146
158
|
data() {
|
|
147
159
|
return {
|
|
148
160
|
canvasId: 'barcode-' + Math.random().toString(36).substr(2, 9),
|
|
161
|
+
tempCanvasId: 'barcode-temp-' + Math.random().toString(36).substr(2, 9),
|
|
149
162
|
barcodeImage: '',
|
|
150
163
|
showCanvas: false,
|
|
151
164
|
canvasWidth: 0,
|
|
@@ -269,8 +282,7 @@ export default {
|
|
|
269
282
|
|
|
270
283
|
await nextTick()
|
|
271
284
|
|
|
272
|
-
|
|
273
|
-
const ctx = uni.createCanvasContext(this.canvasId, this)
|
|
285
|
+
const ctx = await this.getCanvasRef('barcodeCanvas')
|
|
274
286
|
|
|
275
287
|
// 清空画布
|
|
276
288
|
ctx.setFillStyle(options.background)
|
|
@@ -301,14 +313,14 @@ export default {
|
|
|
301
313
|
* @author jry <ijry@qq.com>
|
|
302
314
|
* @param {Object} options - 条码配置选项
|
|
303
315
|
*/
|
|
304
|
-
renderToImage(options) {
|
|
316
|
+
async renderToImage(options) {
|
|
305
317
|
try {
|
|
306
318
|
// 计算canvas尺寸
|
|
307
319
|
this.calculateCanvasSize(options)
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
const
|
|
311
|
-
const ctx =
|
|
320
|
+
|
|
321
|
+
await nextTick()
|
|
322
|
+
const canvas = await this.getCanvasRef('barcodeImageCanvas')
|
|
323
|
+
const ctx = canvas
|
|
312
324
|
|
|
313
325
|
// 清空画布
|
|
314
326
|
ctx.setFillStyle(options.background)
|
|
@@ -326,9 +338,11 @@ export default {
|
|
|
326
338
|
ctx.draw(false, () => {
|
|
327
339
|
// 延迟一小段时间确保canvas绘制完成
|
|
328
340
|
setTimeout(() => {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
341
|
+
canvas.toTempFilePath({
|
|
342
|
+
width: this.canvasWidth,
|
|
343
|
+
height: this.canvasHeight,
|
|
344
|
+
destWidth: this.canvasWidth,
|
|
345
|
+
destHeight: this.canvasHeight,
|
|
332
346
|
success: (res) => {
|
|
333
347
|
this.barcodeImage = res.tempFilePath
|
|
334
348
|
this.$emit('rendered', { type: 'image', value: this.value, path: res.tempFilePath })
|
|
@@ -337,7 +351,7 @@ export default {
|
|
|
337
351
|
console.error('生成条码图片失败:', error)
|
|
338
352
|
this.$emit('error', error)
|
|
339
353
|
}
|
|
340
|
-
}
|
|
354
|
+
})
|
|
341
355
|
}, 100)
|
|
342
356
|
})
|
|
343
357
|
} catch (error) {
|
|
@@ -345,6 +359,16 @@ export default {
|
|
|
345
359
|
this.$emit('error', error)
|
|
346
360
|
}
|
|
347
361
|
},
|
|
362
|
+
|
|
363
|
+
async getCanvasRef(refName) {
|
|
364
|
+
await nextTick()
|
|
365
|
+
const canvas = this.$refs[refName]
|
|
366
|
+
if (!canvas) {
|
|
367
|
+
throw new Error(`Canvas ref not found: ${refName}`)
|
|
368
|
+
}
|
|
369
|
+
await canvas.initCanvas(true)
|
|
370
|
+
return canvas
|
|
371
|
+
},
|
|
348
372
|
|
|
349
373
|
/**
|
|
350
374
|
* 计算canvas尺寸
|
|
@@ -986,6 +1010,13 @@ export default {
|
|
|
986
1010
|
align-items: center;
|
|
987
1011
|
}
|
|
988
1012
|
|
|
1013
|
+
.u-barcode__hidden-canvas {
|
|
1014
|
+
position: fixed;
|
|
1015
|
+
top: -10000px;
|
|
1016
|
+
left: -10000px;
|
|
1017
|
+
z-index: -1;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
989
1020
|
.error-container {
|
|
990
1021
|
display: flex;
|
|
991
1022
|
justify-content: center;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue.js'
|
|
2
|
-
import
|
|
2
|
+
import BoxDefaultProps from './box.js'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
4
|
+
|
|
5
|
+
const defProps = registerComponentProps(BoxDefaultProps)
|
|
3
6
|
|
|
4
7
|
export const propsBox = defineMixin({
|
|
5
8
|
props: {
|
|
@@ -54,4 +57,4 @@ export const propsBox = defineMixin({
|
|
|
54
57
|
default: () => defProps.box.rightBottomTitle
|
|
55
58
|
},
|
|
56
59
|
}
|
|
57
|
-
})
|
|
60
|
+
})
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import ButtonDefaultProps from './button'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
4
|
+
|
|
5
|
+
const defProps = registerComponentProps(ButtonDefaultProps)
|
|
3
6
|
export const props = defineMixin({
|
|
4
7
|
props: {
|
|
5
8
|
// 是否细边框
|
|
@@ -14,9 +14,9 @@ $u-button-plain-u-button-success-color:$u-success;
|
|
|
14
14
|
$u-button-plain-u-button-error-color:$u-error;
|
|
15
15
|
$u-button-plain-u-button-warning-color:$u-warning;
|
|
16
16
|
|
|
17
|
-
.u-button {
|
|
18
|
-
width:
|
|
19
|
-
white-space: nowrap;
|
|
17
|
+
.u-button {
|
|
18
|
+
width: auto;
|
|
19
|
+
white-space: nowrap;
|
|
20
20
|
|
|
21
21
|
&__text {
|
|
22
22
|
white-space: nowrap;
|
|
@@ -34,14 +34,26 @@ export default {
|
|
|
34
34
|
readonly: false,
|
|
35
35
|
showConfirm: true,
|
|
36
36
|
maxRange: Number.MAX_SAFE_INTEGER, // Infinity
|
|
37
|
-
rangePrompt: '',
|
|
37
|
+
rangePrompt: '',
|
|
38
38
|
showRangePrompt: true,
|
|
39
39
|
allowSameDay: false,
|
|
40
|
+
rangeResultMode: 'all',
|
|
41
|
+
enableTime: false,
|
|
42
|
+
timePrecision: 'minute',
|
|
43
|
+
defaultTime: '',
|
|
40
44
|
round: 0,
|
|
45
|
+
overlay: true,
|
|
46
|
+
duration: 300,
|
|
47
|
+
overlayStyle: {},
|
|
48
|
+
overlayOpacity: 0.5,
|
|
49
|
+
zIndex: 10075,
|
|
50
|
+
safeAreaInsetBottom: true,
|
|
51
|
+
safeAreaInsetTop: false,
|
|
52
|
+
bgColor: '',
|
|
41
53
|
monthNum: 3,
|
|
42
54
|
monthSwitch: false,
|
|
43
55
|
showToday: true,
|
|
44
|
-
|
|
56
|
+
todayColor: '',
|
|
45
57
|
weekText: [t("up.week.one"), t("up.week.two"), t("up.week.three"), t("up.week.four"), t("up.week.five"), t("up.week.six"), t("up.week.seven")],
|
|
46
58
|
forbidDays: [],
|
|
47
59
|
forbidDaysToast: t("up.calendar.disabled"),
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
// #endif
|
|
34
34
|
import { mpMixin } from '../../libs/mixin/mpMixin';
|
|
35
35
|
import { mixin } from '../../libs/mixin/mixin';
|
|
36
|
-
import { addUnit, deepClone, toast, sleep } from '../../libs/function/index';
|
|
36
|
+
import { addUnit, deepClone, toast, sleep, getWindowInfo } from '../../libs/function/index';
|
|
37
37
|
import { colorGradient } from '../../libs/function/colorGradient';
|
|
38
38
|
import test from '../../libs/function/test';
|
|
39
39
|
import defProps from '../../libs/config/props';
|
|
@@ -140,6 +140,11 @@
|
|
|
140
140
|
todayDate: {
|
|
141
141
|
type: String,
|
|
142
142
|
default: ''
|
|
143
|
+
},
|
|
144
|
+
// 今天日期的独立高亮颜色
|
|
145
|
+
todayColor: {
|
|
146
|
+
type: String,
|
|
147
|
+
default: ''
|
|
143
148
|
}
|
|
144
149
|
},
|
|
145
150
|
data() {
|
|
@@ -168,8 +173,10 @@
|
|
|
168
173
|
return (index1, index2, item) => {
|
|
169
174
|
const style = {}
|
|
170
175
|
let week = item.week
|
|
176
|
+
// 隐藏挂载场景下节点宽度可能拿到0,兜底使用窗口宽度避免首日偏移归零
|
|
177
|
+
const wrapperWidth = this.width > 0 ? this.width : (getWindowInfo().windowWidth || 0)
|
|
171
178
|
// 不进行四舍五入的形式保留2位小数
|
|
172
|
-
const dayWidth = Number(parseFloat(
|
|
179
|
+
const dayWidth = Number(parseFloat(wrapperWidth / 7).toFixed(3).slice(0, -1))
|
|
173
180
|
// 得出每个日期的宽度
|
|
174
181
|
// #ifdef APP-NVUE
|
|
175
182
|
style.width = addUnit(dayWidth, 'px')
|
|
@@ -178,7 +185,12 @@
|
|
|
178
185
|
if (index2 === 0) {
|
|
179
186
|
// 获取当前为星期几,如果为0,则为星期天,减一为每月第一天时,需要向左偏移的item个数
|
|
180
187
|
week = (week === 0 ? 7 : week) - 1
|
|
188
|
+
// #ifdef APP-NVUE
|
|
181
189
|
style.marginLeft = addUnit(week * dayWidth, 'px')
|
|
190
|
+
// #endif
|
|
191
|
+
// #ifndef APP-NVUE
|
|
192
|
+
style.marginLeft = `${(week / 7) * 100}%`
|
|
193
|
+
// #endif
|
|
182
194
|
}
|
|
183
195
|
if (this.mode === 'range') {
|
|
184
196
|
// 之所以需要这么写,是因为DCloud公司的iOS客户端导致的bug
|
|
@@ -198,8 +210,8 @@
|
|
|
198
210
|
if (this.selected.some(item => this.dateSame(item, date))) {
|
|
199
211
|
style.backgroundColor = this.color
|
|
200
212
|
}
|
|
201
|
-
if (this.todayDate && this.dateSame(date, this.todayDate)
|
|
202
|
-
style.border = `1px solid ${this.
|
|
213
|
+
if (this.todayDate && this.dateSame(date, this.todayDate)) {
|
|
214
|
+
style.border = `1px solid ${this.resolvedTodayColor}`
|
|
203
215
|
style.boxSizing = 'border-box'
|
|
204
216
|
}
|
|
205
217
|
if (this.mode === 'single') {
|
|
@@ -248,6 +260,9 @@
|
|
|
248
260
|
return style
|
|
249
261
|
}
|
|
250
262
|
},
|
|
263
|
+
resolvedTodayColor() {
|
|
264
|
+
return this.todayColor || this.color
|
|
265
|
+
},
|
|
251
266
|
// 某个日期是否被选中
|
|
252
267
|
textStyle() {
|
|
253
268
|
return (item) => {
|
|
@@ -265,6 +280,9 @@
|
|
|
265
280
|
style.color = this.color
|
|
266
281
|
}
|
|
267
282
|
}
|
|
283
|
+
if (this.todayDate && this.dateSame(date, this.todayDate) && !this.isSelectedDate(date)) {
|
|
284
|
+
style.color = this.resolvedTodayColor
|
|
285
|
+
}
|
|
268
286
|
return style
|
|
269
287
|
}
|
|
270
288
|
},
|
|
@@ -335,16 +353,21 @@
|
|
|
335
353
|
dateSame(date1, date2) {
|
|
336
354
|
return dayjs(date1).isSame(dayjs(date2))
|
|
337
355
|
},
|
|
356
|
+
isSelectedDate(date) {
|
|
357
|
+
return this.selected.some(item => this.dateSame(item, date))
|
|
358
|
+
},
|
|
338
359
|
// 获取月份数据区域的宽度,因为nvue不支持百分比,所以无法通过css设置每个日期item的宽度
|
|
339
360
|
getWrapperWidth() {
|
|
340
361
|
// #ifdef APP-NVUE
|
|
341
362
|
dom.getComponentRect(this.$refs['u-calendar-month-wrapper'], res => {
|
|
342
|
-
|
|
363
|
+
const width = res && res.size ? Number(res.size.width) : 0
|
|
364
|
+
this.width = width > 0 ? width : (getWindowInfo().windowWidth || 0)
|
|
343
365
|
})
|
|
344
366
|
// #endif
|
|
345
367
|
// #ifndef APP-NVUE
|
|
346
368
|
this.$uGetRect('.u-calendar-month-wrapper').then(size => {
|
|
347
|
-
|
|
369
|
+
const width = size ? Number(size.width) : 0
|
|
370
|
+
this.width = width > 0 ? width : (getWindowInfo().windowWidth || 0)
|
|
348
371
|
})
|
|
349
372
|
// #endif
|
|
350
373
|
},
|
|
@@ -493,6 +516,18 @@
|
|
|
493
516
|
setSelected(selected, event = true) {
|
|
494
517
|
this.selected = selected
|
|
495
518
|
event && this.$emit('monthSelected', this.selected,'tap')
|
|
519
|
+
},
|
|
520
|
+
selectDate(date) {
|
|
521
|
+
const targetDate = dayjs(date).format("YYYY-MM-DD")
|
|
522
|
+
for (let monthIndex = 0; monthIndex < this.months.length; monthIndex++) {
|
|
523
|
+
const dayIndex = this.months[monthIndex].date.findIndex(item => {
|
|
524
|
+
return this.dateSame(item.date, targetDate)
|
|
525
|
+
})
|
|
526
|
+
if (dayIndex !== -1) {
|
|
527
|
+
this.clickHandler(monthIndex, dayIndex, this.months[monthIndex].date[dayIndex])
|
|
528
|
+
return
|
|
529
|
+
}
|
|
530
|
+
}
|
|
496
531
|
}
|
|
497
532
|
}
|
|
498
533
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import CalendarDefaultProps from './calendar'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
3
4
|
|
|
5
|
+
const defProps = registerComponentProps(CalendarDefaultProps)
|
|
4
6
|
export const props = defineMixin({
|
|
5
7
|
props: {
|
|
6
8
|
// 日历顶部标题
|
|
@@ -98,6 +100,46 @@ export const props = defineMixin({
|
|
|
98
100
|
type: Boolean,
|
|
99
101
|
default: () => defProps.calendar.show
|
|
100
102
|
},
|
|
103
|
+
// 是否显示遮罩
|
|
104
|
+
overlay: {
|
|
105
|
+
type: Boolean,
|
|
106
|
+
default: () => defProps.calendar.overlay
|
|
107
|
+
},
|
|
108
|
+
// 动画时长,单位ms
|
|
109
|
+
duration: {
|
|
110
|
+
type: [String, Number],
|
|
111
|
+
default: () => defProps.calendar.duration
|
|
112
|
+
},
|
|
113
|
+
// 自定义遮罩的样式
|
|
114
|
+
overlayStyle: {
|
|
115
|
+
type: [Object, String],
|
|
116
|
+
default: () => defProps.calendar.overlayStyle
|
|
117
|
+
},
|
|
118
|
+
// 遮罩的透明度,0-1之间
|
|
119
|
+
overlayOpacity: {
|
|
120
|
+
type: [Number, String],
|
|
121
|
+
default: () => defProps.calendar.overlayOpacity
|
|
122
|
+
},
|
|
123
|
+
// 层级
|
|
124
|
+
zIndex: {
|
|
125
|
+
type: [String, Number],
|
|
126
|
+
default: () => defProps.calendar.zIndex
|
|
127
|
+
},
|
|
128
|
+
// 是否为iPhoneX留出底部安全距离
|
|
129
|
+
safeAreaInsetBottom: {
|
|
130
|
+
type: Boolean,
|
|
131
|
+
default: () => defProps.calendar.safeAreaInsetBottom
|
|
132
|
+
},
|
|
133
|
+
// 是否留出顶部安全距离(状态栏高度)
|
|
134
|
+
safeAreaInsetTop: {
|
|
135
|
+
type: Boolean,
|
|
136
|
+
default: () => defProps.calendar.safeAreaInsetTop
|
|
137
|
+
},
|
|
138
|
+
// 弹窗背景色,设置为transparent可去除白色背景
|
|
139
|
+
bgColor: {
|
|
140
|
+
type: String,
|
|
141
|
+
default: () => defProps.calendar.bgColor
|
|
142
|
+
},
|
|
101
143
|
// 是否允许点击遮罩关闭日历
|
|
102
144
|
closeOnClickOverlay: {
|
|
103
145
|
type: Boolean,
|
|
@@ -137,6 +179,21 @@ export const props = defineMixin({
|
|
|
137
179
|
rangeResultMode: {
|
|
138
180
|
type: String,
|
|
139
181
|
default: () => defProps.calendar.rangeResultMode
|
|
182
|
+
},
|
|
183
|
+
// 是否开启时分秒选择
|
|
184
|
+
enableTime: {
|
|
185
|
+
type: Boolean,
|
|
186
|
+
default: () => defProps.calendar.enableTime
|
|
187
|
+
},
|
|
188
|
+
// 时间精度:hour-仅时,minute-时分,second-时分秒
|
|
189
|
+
timePrecision: {
|
|
190
|
+
type: String,
|
|
191
|
+
default: () => defProps.calendar.timePrecision
|
|
192
|
+
},
|
|
193
|
+
// 默认时间,格式支持 HH / HH:mm / HH:mm:ss
|
|
194
|
+
defaultTime: {
|
|
195
|
+
type: String,
|
|
196
|
+
default: () => defProps.calendar.defaultTime
|
|
140
197
|
},
|
|
141
198
|
// 圆角值
|
|
142
199
|
round: {
|
|
@@ -158,6 +215,11 @@ export const props = defineMixin({
|
|
|
158
215
|
type: Boolean,
|
|
159
216
|
default: () => defProps.calendar.showToday
|
|
160
217
|
},
|
|
218
|
+
// 今天日期的独立高亮颜色,默认跟随主题色
|
|
219
|
+
todayColor: {
|
|
220
|
+
type: String,
|
|
221
|
+
default: () => defProps.calendar.todayColor
|
|
222
|
+
},
|
|
161
223
|
// 星期文案
|
|
162
224
|
weekText: {
|
|
163
225
|
type: Array,
|