hy-app 0.1.1 → 0.1.3
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/README.md +1 -1
- package/api/http.ts +8 -8
- package/components/dialog/index.ts +2 -2
- package/components/hy-address-picker/hy-address-picker.vue +14 -42
- package/components/hy-address-picker/index.scss +27 -0
- package/components/hy-address-picker/props.ts +2 -3
- package/components/hy-address-picker/typing.d.ts +1 -2
- package/components/hy-avatar/hy-avatar.vue +10 -54
- package/components/hy-avatar/index.scss +45 -0
- package/components/hy-avatar/props.ts +2 -2
- package/components/hy-avatar/typing.d.ts +2 -2
- package/components/hy-back-top/hy-back-top.vue +7 -22
- package/components/hy-back-top/index.scss +16 -0
- package/components/hy-back-top/props.ts +4 -4
- package/components/hy-back-top/typing.d.ts +2 -3
- package/components/hy-badge/hy-badge.vue +5 -75
- package/components/hy-badge/index.scss +72 -0
- package/components/hy-badge/props.ts +2 -2
- package/components/hy-badge/typing.d.ts +2 -2
- package/components/hy-button/hy-button.vue +22 -134
- package/components/hy-button/index.scss +116 -0
- package/components/hy-button/props.ts +4 -5
- package/components/hy-button/typing.d.ts +3 -3
- package/components/hy-calendar/header.vue +76 -0
- package/components/hy-calendar/hy-calendar.vue +366 -0
- package/components/hy-calendar/index.scss +171 -0
- package/components/hy-calendar/month.vue +524 -0
- package/components/hy-calendar/props.ts +37 -0
- package/components/hy-calendar/typing.d.ts +126 -0
- package/components/hy-card/hy-card.vue +21 -84
- package/components/hy-card/index.scss +57 -0
- package/components/hy-card/props.ts +2 -2
- package/components/hy-card/typing.d.ts +1 -1
- package/components/hy-cell/hy-cell.vue +30 -131
- package/components/hy-cell/index.scss +137 -0
- package/components/hy-cell/props.ts +2 -2
- package/components/hy-cell/typing.d.ts +4 -3
- package/components/hy-check-button/hy-check-button.vue +14 -7
- package/components/hy-check-button/index.scss +5 -0
- package/components/hy-check-button/props.ts +3 -3
- package/components/hy-checkbox/hy-checkbox.vue +24 -107
- package/components/hy-checkbox/index.scss +94 -0
- package/components/hy-checkbox/props.ts +4 -5
- package/components/hy-checkbox/typing.d.ts +3 -7
- package/components/hy-count-down/hy-count-down.vue +150 -0
- package/components/hy-count-down/index.scss +6 -0
- package/components/hy-count-down/index.ts +52 -0
- package/components/hy-count-down/props.ts +10 -0
- package/components/hy-count-down/typing.d.ts +20 -0
- package/components/hy-count-to/hy-count-to.vue +213 -0
- package/components/hy-count-to/index.scss +6 -0
- package/components/hy-count-to/props.ts +17 -0
- package/components/hy-count-to/typing.d.ts +48 -0
- package/components/hy-datetime-picker/hy-datetime-picker.vue +38 -64
- package/components/hy-datetime-picker/index.scss +28 -0
- package/components/hy-datetime-picker/props.ts +2 -2
- package/components/hy-datetime-picker/typing.d.ts +1 -1
- package/components/hy-divider/hy-divider.vue +24 -49
- package/components/hy-divider/index.scss +25 -0
- package/components/hy-divider/props.ts +2 -2
- package/components/hy-divider/typing.d.ts +1 -1
- package/components/hy-dropdown/hy-dropdown.vue +43 -0
- package/components/hy-dropdown/index.scss +17 -0
- package/components/hy-dropdown/props.ts +17 -0
- package/components/hy-dropdown/typing.d.ts +48 -0
- package/components/hy-dropdown-item/hy-dropdown-item.vue +194 -0
- package/components/hy-dropdown-item/index.scss +96 -0
- package/components/hy-dropdown-item/props.ts +10 -0
- package/components/hy-dropdown-item/typing.d.ts +31 -0
- package/components/hy-empty/hy-empty.vue +8 -26
- package/components/hy-empty/index.scss +19 -0
- package/components/hy-empty/props.ts +2 -2
- package/components/hy-empty/typing.d.ts +1 -1
- package/components/hy-float-button/hy-float-button.vue +201 -0
- package/components/hy-float-button/index.scss +69 -0
- package/components/hy-float-button/props.ts +25 -0
- package/components/hy-float-button/typing.d.ts +93 -0
- package/components/hy-folding-panel/hy-folding-panel.vue +9 -12
- package/components/hy-folding-panel/index.scss +6 -0
- package/components/hy-folding-panel/props.ts +2 -2
- package/components/hy-folding-panel/typing.d.ts +2 -2
- package/components/hy-form/hy-form.vue +22 -39
- package/components/hy-form/index.scss +30 -0
- package/components/hy-form/props.ts +4 -2
- package/components/hy-form/typing.d.ts +10 -2
- package/components/hy-grid/hy-grid.vue +4 -45
- package/components/hy-grid/index.scss +40 -0
- package/components/hy-grid/props.ts +5 -5
- package/components/hy-grid/typing.d.ts +2 -2
- package/components/hy-icon/hy-icon.vue +7 -97
- package/components/hy-icon/index.scss +84 -0
- package/components/hy-icon/props.ts +5 -5
- package/components/hy-image/hy-image.vue +212 -0
- package/components/hy-image/index.scss +26 -0
- package/components/hy-image/props.ts +24 -0
- package/components/hy-image/typing.d.ts +76 -0
- package/components/hy-input/hy-input.vue +11 -82
- package/components/hy-input/index.scss +65 -0
- package/components/hy-input/props.ts +2 -2
- package/components/hy-input/typing.d.ts +2 -2
- package/components/hy-line/hy-line.vue +4 -8
- package/components/hy-line/index.scss +5 -0
- package/components/hy-line/props.ts +3 -3
- package/components/hy-line/typing.d.ts +2 -2
- package/components/hy-line-progress/hy-line-progress.vue +15 -44
- package/components/hy-line-progress/index.scss +38 -0
- package/components/hy-line-progress/props.ts +2 -2
- package/components/hy-line-progress/typing.d.ts +1 -1
- package/components/hy-list/hy-list.vue +11 -41
- package/components/hy-list/index.scss +32 -0
- package/components/hy-list/props.ts +2 -2
- package/components/hy-loading/hy-loading.vue +95 -0
- package/components/hy-loading/index.scss +103 -0
- package/components/hy-loading/props.ts +17 -0
- package/components/hy-loading/typing.d.ts +52 -0
- package/components/hy-login/TheUserLogin.vue +16 -16
- package/components/hy-login/hy-login.vue +9 -9
- package/components/hy-login/props.ts +4 -4
- package/components/hy-modal/hy-modal.vue +11 -89
- package/components/hy-modal/index.scss +77 -0
- package/components/hy-modal/props.ts +2 -2
- package/components/hy-modal/typing.d.ts +1 -1
- package/components/hy-navbar/hy-navbar.vue +20 -92
- package/components/hy-navbar/index.scss +67 -0
- package/components/hy-navbar/props.ts +2 -2
- package/components/hy-navbar/typing.d.ts +1 -1
- package/components/hy-notice-bar/hy-column-notice.vue +11 -39
- package/components/hy-notice-bar/hy-notice-bar.vue +10 -12
- package/components/hy-notice-bar/hy-row-notice.vue +5 -56
- package/components/hy-notice-bar/index.scss +93 -0
- package/components/hy-notice-bar/props.ts +4 -2
- package/components/hy-notice-bar/typing.d.ts +13 -3
- package/components/hy-number-step/hy-number-step.vue +55 -105
- package/components/hy-number-step/index.scss +71 -0
- package/components/hy-number-step/props.ts +2 -2
- package/components/hy-number-step/typing.d.ts +1 -1
- package/components/hy-overlay/hy-overlay.vue +5 -17
- package/components/hy-overlay/index.scss +9 -0
- package/components/hy-overlay/props.ts +2 -2
- package/components/hy-overlay/typing.d.ts +1 -1
- package/components/hy-picker/hy-picker.vue +21 -87
- package/components/hy-picker/index.scss +68 -0
- package/components/hy-picker/props.ts +3 -2
- package/components/hy-picker/typing.d.ts +5 -1
- package/components/hy-popup/hy-popup.vue +7 -80
- package/components/hy-popup/index.scss +60 -0
- package/components/hy-popup/props.ts +2 -2
- package/components/hy-popup/typing.d.ts +1 -1
- package/components/hy-price/hy-price.vue +5 -15
- package/components/hy-price/index.scss +11 -0
- package/components/hy-price/props.ts +2 -2
- package/components/hy-price/typing.d.ts +1 -1
- package/components/hy-qrcode/hy-qrcode.vue +15 -37
- package/components/hy-qrcode/index.scss +23 -0
- package/components/hy-qrcode/props.ts +2 -2
- package/components/hy-qrcode/typing.d.ts +2 -2
- package/components/hy-radio/hy-radio.vue +27 -113
- package/components/hy-radio/index.scss +93 -0
- package/components/hy-radio/props.ts +4 -4
- package/components/hy-radio/typing.d.ts +2 -2
- package/components/hy-rate/hy-rate.vue +33 -53
- package/components/hy-rate/index.scss +33 -0
- package/components/hy-rate/props.ts +4 -3
- package/components/hy-rate/typing.d.ts +1 -1
- package/components/hy-read-more/hy-read-more.vue +7 -30
- package/components/hy-read-more/index.scss +25 -0
- package/components/hy-read-more/props.ts +3 -3
- package/components/hy-read-more/typing.d.ts +1 -1
- package/components/hy-safe-bottom/hy-safe-bottom.vue +5 -9
- package/components/hy-safe-bottom/index.scss +5 -0
- package/components/hy-scroll-list/hy-scroll-list.vue +13 -43
- package/components/hy-scroll-list/index.scss +34 -0
- package/components/hy-scroll-list/props.ts +2 -2
- package/components/hy-scroll-list/typing.d.ts +1 -1
- package/components/hy-search/hy-search.vue +12 -94
- package/components/hy-search/index.scss +83 -0
- package/components/hy-search/props.ts +2 -2
- package/components/hy-search/typing.d.ts +1 -2
- package/components/hy-slider/hy-slider.vue +42 -119
- package/components/hy-slider/index.scss +77 -0
- package/components/hy-slider/props.ts +2 -2
- package/components/hy-status-bar/hy-status-bar.vue +41 -0
- package/components/hy-status-bar/index.scss +6 -0
- package/components/hy-status-bar/props.ts +8 -0
- package/components/hy-status-bar/typing.d.ts +12 -0
- package/components/hy-steps/hy-steps.vue +36 -163
- package/components/hy-steps/index.scss +131 -0
- package/components/hy-steps/props.ts +2 -2
- package/components/hy-steps/typing.d.ts +2 -2
- package/components/hy-subsection/hy-subsection.vue +62 -125
- package/components/hy-subsection/index.scss +82 -0
- package/components/hy-subsection/props.ts +7 -3
- package/components/hy-subsection/typing.d.ts +20 -8
- package/components/hy-swipe-action/hy-swipe-action.vue +294 -0
- package/components/hy-swipe-action/index.scss +9 -0
- package/components/hy-swipe-action/index.wxs +235 -0
- package/components/hy-swipe-action/props.ts +16 -0
- package/components/hy-swipe-action/typing.d.ts +55 -0
- package/components/hy-swipe-action/wxs.js +15 -0
- package/components/hy-swiper/hy-swiper-indicator.vue +5 -35
- package/components/hy-swiper/hy-swiper.vue +45 -65
- package/components/hy-swiper/index.scss +82 -0
- package/components/hy-swiper/props.ts +3 -3
- package/components/hy-swiper/typing.d.ts +7 -4
- package/components/hy-switch/hy-switch.vue +65 -68
- package/components/hy-switch/index.scss +46 -0
- package/components/hy-switch/props.ts +6 -3
- package/components/hy-switch/typing.d.ts +14 -1
- package/components/hy-tabs/hy-tabs.vue +22 -81
- package/components/hy-tabs/index.scss +63 -0
- package/components/hy-tabs/props.ts +5 -5
- package/components/hy-tabs/typing.d.ts +1 -1
- package/components/hy-tag/hy-tag.vue +15 -230
- package/components/hy-tag/index.scss +204 -0
- package/components/hy-tag/props.ts +2 -2
- package/components/hy-tag/typing.d.ts +2 -2
- package/components/hy-text/hy-text.vue +238 -0
- package/components/hy-text/index.scss +70 -0
- package/components/hy-text/index.ts +0 -0
- package/components/hy-text/props.ts +30 -0
- package/components/hy-text/typing.d.ts +98 -0
- package/components/hy-textarea/hy-textarea.vue +13 -51
- package/components/hy-textarea/index.scss +40 -0
- package/components/hy-textarea/props.ts +2 -2
- package/components/hy-textarea/typing.d.ts +1 -1
- package/components/hy-tooltip/hy-tooltip.vue +42 -95
- package/components/hy-tooltip/index.scss +64 -0
- package/components/hy-tooltip/props.ts +2 -2
- package/components/hy-tooltip/typing.d.ts +1 -1
- package/components/hy-transition/hy-transition.vue +17 -8
- package/components/hy-transition/props.ts +2 -2
- package/components/hy-transition/typing.d.ts +2 -14
- package/components/hy-upload/hy-upload.vue +37 -182
- package/components/hy-upload/index.scss +147 -0
- package/components/hy-upload/props.ts +2 -2
- package/components/hy-upload/typing.d.ts +11 -11
- package/components/hy-warn/hy-warn.vue +15 -123
- package/components/hy-warn/index.scss +109 -0
- package/components/hy-warn/props.ts +3 -3
- package/components/hy-warn/typing.d.ts +4 -3
- package/components/hy-waterfall/index.scss +82 -0
- package/components/index.ts +25 -1
- package/components/message/index.ts +54 -54
- package/config/color.ts +2 -1
- package/global/index.ts +6 -6
- package/global/register-properties.ts +2 -2
- package/index.scss +2 -0
- package/libs/css/common.scss +16 -0
- package/package.json +4 -4
- package/{libs/css → public/font}/iconfont.css +5 -5
- package/{libs/css → public/font}/iconfont.ttf +0 -0
- package/public/font/iconfont.woff +0 -0
- package/public/font/iconfont.woff2 +0 -0
- package/theme.scss +9 -7
- package/typing/index.ts +0 -1
- package/typing/modules/common.d.ts +66 -1
- package/typing/modules/form.ts +3 -3
- package/utils/calendar.js +1021 -0
- package/utils/colorGradient.ts +112 -0
- package/utils/index.ts +2 -0
- package/utils/inside.ts +80 -34
- package/utils/inspect.ts +66 -0
- package/utils/utils.ts +27 -19
- package/typing/modules/img.ts +0 -15
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<text
|
|
3
|
+
class="hy-count-num"
|
|
4
|
+
:style="{
|
|
5
|
+
fontSize: addUnit(fontSize),
|
|
6
|
+
fontWeight: bold ? 'bold' : 'normal',
|
|
7
|
+
color: color,
|
|
8
|
+
}"
|
|
9
|
+
>{{ displayValue }}</text
|
|
10
|
+
>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup lang="ts">
|
|
14
|
+
import type IProps from "./typing";
|
|
15
|
+
import defaultProps from "./props";
|
|
16
|
+
import { computed, onMounted, onUnmounted, ref, toRefs, watch } from "vue";
|
|
17
|
+
import { addUnit, isNumber } from "../../utils";
|
|
18
|
+
|
|
19
|
+
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
20
|
+
const {
|
|
21
|
+
startVal,
|
|
22
|
+
duration,
|
|
23
|
+
endVal,
|
|
24
|
+
autoplay,
|
|
25
|
+
separator,
|
|
26
|
+
useEasing,
|
|
27
|
+
decimals,
|
|
28
|
+
decimal,
|
|
29
|
+
} = toRefs(props);
|
|
30
|
+
const emit = defineEmits(["end"]);
|
|
31
|
+
|
|
32
|
+
const formatNumber = (num: number): string => {
|
|
33
|
+
let numStr = "";
|
|
34
|
+
// 将num转为Number类型,因为其值可能为字符串数值,调用toFixed会报错
|
|
35
|
+
num = Number(num);
|
|
36
|
+
numStr = num.toFixed(Number(decimals.value));
|
|
37
|
+
numStr += "";
|
|
38
|
+
const x = numStr.split(".");
|
|
39
|
+
let x1 = x[0];
|
|
40
|
+
const x2 = x.length > 1 ? decimal.value + x[1] : "";
|
|
41
|
+
const rgx = /(\d+)(\d{3})/;
|
|
42
|
+
if (separator.value && !isNumber(separator.value)) {
|
|
43
|
+
while (rgx.test(x1)) {
|
|
44
|
+
x1 = x1.replace(rgx, "$1" + separator.value + "$2");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return x1 + x2;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const localStartVal = ref(startVal.value);
|
|
51
|
+
let displayValue = ref(formatNumber(startVal.value));
|
|
52
|
+
const printVal = ref<number | null>(null);
|
|
53
|
+
const paused = ref(false); // 是否暂停
|
|
54
|
+
const localDuration = ref(Number(duration.value));
|
|
55
|
+
const startTime = ref<number | null>(null); // 开始的时间
|
|
56
|
+
const timestamp = ref<number | null>(null); // 时间戳
|
|
57
|
+
const remaining = ref<number | null>(null); // 停留的时间
|
|
58
|
+
const rAF = ref<number>(); // 停留的时间
|
|
59
|
+
const lastTime = ref(0); // 上一次的时间
|
|
60
|
+
|
|
61
|
+
const countDown = computed(() => {
|
|
62
|
+
return startVal.value > endVal.value;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
watch(
|
|
66
|
+
() => startVal.value,
|
|
67
|
+
() => autoplay.value && start(),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
watch(
|
|
71
|
+
() => endVal.value,
|
|
72
|
+
() => autoplay.value && start(),
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
onMounted(() => {
|
|
76
|
+
autoplay.value && start();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const easingFn = (t: number, b: number, c: number, d: number) => {
|
|
80
|
+
return (c * (-Math.pow(2, (-10 * t) / d) + 1) * 1024) / 1023 + b;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const requestAnimationFrame = (callback: Function): number => {
|
|
84
|
+
const currTime = new Date().getTime();
|
|
85
|
+
// 为了使setTimteout的尽可能的接近每秒60帧的效果
|
|
86
|
+
const timeToCall = Math.max(0, 16 - (currTime - lastTime.value));
|
|
87
|
+
const id = setTimeout(() => {
|
|
88
|
+
callback(currTime + timeToCall);
|
|
89
|
+
}, timeToCall) as unknown as number;
|
|
90
|
+
lastTime.value = currTime + timeToCall;
|
|
91
|
+
return id;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const cancelAnimationFrame = (id?: number) => {
|
|
95
|
+
clearTimeout(id);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @description 开始滚动数字
|
|
100
|
+
* */
|
|
101
|
+
const start = () => {
|
|
102
|
+
localStartVal.value = startVal.value;
|
|
103
|
+
startTime.value = null;
|
|
104
|
+
localDuration.value = duration.value;
|
|
105
|
+
paused.value = false;
|
|
106
|
+
rAF.value = requestAnimationFrame(count);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @description 暂定状态,重新再开始滚动;或者滚动状态下,暂停
|
|
111
|
+
* */
|
|
112
|
+
const reStart = () => {
|
|
113
|
+
if (paused.value) {
|
|
114
|
+
resume();
|
|
115
|
+
paused.value = false;
|
|
116
|
+
} else {
|
|
117
|
+
stop();
|
|
118
|
+
paused.value = true;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @description 暂停
|
|
124
|
+
* */
|
|
125
|
+
const stop = () => {
|
|
126
|
+
cancelAnimationFrame(rAF.value);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @description 重新开始(暂停的情况下)
|
|
131
|
+
* */
|
|
132
|
+
const resume = () => {
|
|
133
|
+
if (!remaining.value) return;
|
|
134
|
+
startTime.value = 0;
|
|
135
|
+
localDuration.value = remaining.value;
|
|
136
|
+
if (printVal.value) {
|
|
137
|
+
localStartVal.value = printVal.value;
|
|
138
|
+
}
|
|
139
|
+
requestAnimationFrame(count);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @description 重置
|
|
144
|
+
* */
|
|
145
|
+
const reset = () => {
|
|
146
|
+
startTime.value = null;
|
|
147
|
+
cancelAnimationFrame(rAF.value);
|
|
148
|
+
displayValue.value = formatNumber(startVal.value);
|
|
149
|
+
};
|
|
150
|
+
const count = (time_stamp: number) => {
|
|
151
|
+
if (!startTime.value) startTime.value = time_stamp;
|
|
152
|
+
timestamp.value = time_stamp;
|
|
153
|
+
const progress = time_stamp - startTime.value;
|
|
154
|
+
remaining.value = localDuration.value - progress;
|
|
155
|
+
if (useEasing.value) {
|
|
156
|
+
if (countDown.value) {
|
|
157
|
+
printVal.value =
|
|
158
|
+
localStartVal.value -
|
|
159
|
+
easingFn(
|
|
160
|
+
progress,
|
|
161
|
+
0,
|
|
162
|
+
localStartVal.value - endVal.value,
|
|
163
|
+
localDuration.value,
|
|
164
|
+
);
|
|
165
|
+
} else {
|
|
166
|
+
printVal.value = easingFn(
|
|
167
|
+
progress,
|
|
168
|
+
localStartVal.value,
|
|
169
|
+
endVal.value - localStartVal.value,
|
|
170
|
+
localDuration.value,
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
if (countDown.value) {
|
|
175
|
+
printVal.value =
|
|
176
|
+
localStartVal.value -
|
|
177
|
+
(localStartVal.value - endVal.value) * (progress / localDuration.value);
|
|
178
|
+
} else {
|
|
179
|
+
printVal.value =
|
|
180
|
+
localStartVal.value +
|
|
181
|
+
(endVal.value - localStartVal.value) * (progress / localDuration.value);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (countDown.value) {
|
|
185
|
+
printVal.value =
|
|
186
|
+
printVal.value < endVal.value ? endVal.value : printVal.value;
|
|
187
|
+
} else {
|
|
188
|
+
printVal.value =
|
|
189
|
+
printVal.value > endVal.value ? endVal.value : printVal.value;
|
|
190
|
+
}
|
|
191
|
+
displayValue.value = formatNumber(printVal.value);
|
|
192
|
+
if (progress < localDuration.value) {
|
|
193
|
+
rAF.value = requestAnimationFrame(count);
|
|
194
|
+
} else {
|
|
195
|
+
emit("end");
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const destroyed = () => {
|
|
200
|
+
cancelAnimationFrame(rAF.value);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
defineExpose({
|
|
204
|
+
start,
|
|
205
|
+
stop,
|
|
206
|
+
reStart,
|
|
207
|
+
resume,
|
|
208
|
+
});
|
|
209
|
+
</script>
|
|
210
|
+
|
|
211
|
+
<style scoped lang="scss">
|
|
212
|
+
@import "./index.scss";
|
|
213
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type IProps from "./typing";
|
|
2
|
+
|
|
3
|
+
const defaultProps: IProps = {
|
|
4
|
+
startVal: 0,
|
|
5
|
+
endVal: 0,
|
|
6
|
+
duration: 2000,
|
|
7
|
+
autoplay: true,
|
|
8
|
+
decimals: 0,
|
|
9
|
+
useEasing: true,
|
|
10
|
+
decimal: ".",
|
|
11
|
+
color: "#606266",
|
|
12
|
+
fontSize: 22,
|
|
13
|
+
bold: false,
|
|
14
|
+
separator: "",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default defaultProps;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { CSSProperties } from "vue";
|
|
2
|
+
|
|
3
|
+
export default interface IProps {
|
|
4
|
+
/**
|
|
5
|
+
* @description 开始的数值,默认从0增长到某一个数(默认 0 )
|
|
6
|
+
* */
|
|
7
|
+
startVal?: number;
|
|
8
|
+
/**
|
|
9
|
+
* @description 要滚动的目标数值,必须 (默认 0 )
|
|
10
|
+
* */
|
|
11
|
+
endVal?: number;
|
|
12
|
+
/**
|
|
13
|
+
* @description 滚动到目标数值的动画持续时间,单位为毫秒(ms) (默认
|
|
14
|
+
* */
|
|
15
|
+
duration?: number;
|
|
16
|
+
/**
|
|
17
|
+
* @description 设置数值后是否自动开始滚动 (默认 true )
|
|
18
|
+
* */
|
|
19
|
+
autoplay?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @description 要显示的小数位数,见官网说明(默认 0 )
|
|
22
|
+
* */
|
|
23
|
+
decimals?: number;
|
|
24
|
+
/**
|
|
25
|
+
* @description 滚动结束时,是否缓动结尾,见官网说明(默认 true )
|
|
26
|
+
* */
|
|
27
|
+
useEasing?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* @description 十进制分割 ( 默认 "." )
|
|
30
|
+
* */
|
|
31
|
+
decimal?: string;
|
|
32
|
+
/**
|
|
33
|
+
* @description 字体颜色( 默认 '#606266' )
|
|
34
|
+
* */
|
|
35
|
+
color?: string;
|
|
36
|
+
/**
|
|
37
|
+
* @description 字体大小,单位px( 默认 22 )
|
|
38
|
+
* */
|
|
39
|
+
fontSize?: number | string;
|
|
40
|
+
/**
|
|
41
|
+
* @description 字体是否加粗(默认 false )
|
|
42
|
+
* */
|
|
43
|
+
bold?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* @description 千位分隔符,见官网说明
|
|
46
|
+
* */
|
|
47
|
+
separator?: string;
|
|
48
|
+
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<slot name="trigger" :value="inputValue">
|
|
9
9
|
<HyInput
|
|
10
10
|
:placeholder="placeholder"
|
|
11
|
-
:readonly="
|
|
11
|
+
:readonly="true"
|
|
12
12
|
v-model="inputValue"
|
|
13
13
|
:disabled="disabled"
|
|
14
14
|
:disabledColor="disabledColor"
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
<script setup lang="ts">
|
|
56
56
|
import { computed, onMounted, ref, toRefs, watch } from "vue";
|
|
57
57
|
import defaultProps from "./props";
|
|
58
|
-
import IProps from "./typing";
|
|
58
|
+
import type IProps from "./typing";
|
|
59
59
|
import dayjs from "dayjs/esm";
|
|
60
60
|
import { error, padZero } from "../../utils";
|
|
61
61
|
import { DateModeEnum } from "../../typing";
|
|
@@ -79,14 +79,14 @@ const {
|
|
|
79
79
|
minHour,
|
|
80
80
|
maxHour,
|
|
81
81
|
minMinute,
|
|
82
|
-
maxMinute
|
|
82
|
+
maxMinute,
|
|
83
83
|
} = toRefs(props);
|
|
84
84
|
const emit = defineEmits([
|
|
85
85
|
"close",
|
|
86
86
|
"cancel",
|
|
87
87
|
"confirm",
|
|
88
88
|
"change",
|
|
89
|
-
"update:modelValue"
|
|
89
|
+
"update:modelValue",
|
|
90
90
|
]);
|
|
91
91
|
|
|
92
92
|
// 原来的日期选择器不方便,这里增加一个hasInput选项支持类似element的自带输入框的功能。
|
|
@@ -100,7 +100,7 @@ const validModes = new Set([
|
|
|
100
100
|
DateModeEnum.TIME,
|
|
101
101
|
DateModeEnum.MONTH_DAY,
|
|
102
102
|
DateModeEnum.HOUR_MINUTE,
|
|
103
|
-
DateModeEnum.MINUTE_SECOND
|
|
103
|
+
DateModeEnum.MINUTE_SECOND,
|
|
104
104
|
]);
|
|
105
105
|
|
|
106
106
|
/**
|
|
@@ -110,7 +110,7 @@ const updateColumns = () => {
|
|
|
110
110
|
const formatterFn = formatter.value || innerFormatter;
|
|
111
111
|
// 获取各列的值,并且map后,对各列的具体值进行补0操作
|
|
112
112
|
columns.value = getOriginColumns().map((column) =>
|
|
113
|
-
column.values.map((value) => formatterFn(column.type, value))
|
|
113
|
+
column.values.map((value) => formatterFn(column.type, value)),
|
|
114
114
|
);
|
|
115
115
|
};
|
|
116
116
|
|
|
@@ -122,7 +122,7 @@ const updateColumnValue = (value: string | number) => {
|
|
|
122
122
|
updateColumns();
|
|
123
123
|
// 延迟执行,等待u-picker组件列数据更新完后再设置选中值索引
|
|
124
124
|
setTimeout(() => {
|
|
125
|
-
|
|
125
|
+
updateIndexes(value);
|
|
126
126
|
}, 100);
|
|
127
127
|
};
|
|
128
128
|
|
|
@@ -142,12 +142,12 @@ watch(
|
|
|
142
142
|
if (newValue) {
|
|
143
143
|
updateColumnValue(innerValue.value);
|
|
144
144
|
}
|
|
145
|
-
}
|
|
145
|
+
},
|
|
146
146
|
);
|
|
147
147
|
|
|
148
148
|
watch(
|
|
149
149
|
() => modelValue.value,
|
|
150
|
-
() => init()
|
|
150
|
+
() => init(),
|
|
151
151
|
);
|
|
152
152
|
|
|
153
153
|
const propsChange = computed(() => {
|
|
@@ -159,13 +159,13 @@ const propsChange = computed(() => {
|
|
|
159
159
|
maxHour.value,
|
|
160
160
|
minMinute.value,
|
|
161
161
|
maxMinute.value,
|
|
162
|
-
filter.value
|
|
162
|
+
filter.value,
|
|
163
163
|
];
|
|
164
164
|
});
|
|
165
165
|
|
|
166
166
|
watch(
|
|
167
167
|
() => propsChange.value,
|
|
168
|
-
() => init()
|
|
168
|
+
() => init(),
|
|
169
169
|
);
|
|
170
170
|
|
|
171
171
|
onMounted(() => {
|
|
@@ -254,7 +254,7 @@ const confirm = () => {
|
|
|
254
254
|
}
|
|
255
255
|
emit("confirm", {
|
|
256
256
|
value: innerValue.value,
|
|
257
|
-
mode: mode.value
|
|
257
|
+
mode: mode.value,
|
|
258
258
|
});
|
|
259
259
|
};
|
|
260
260
|
|
|
@@ -287,12 +287,12 @@ const change = (e: any) => {
|
|
|
287
287
|
if (validModes.has(mode.value) && mode.value !== DateModeEnum.MONTH_DAY) {
|
|
288
288
|
// 根据value各列索引,从各列数组中,取出当前时间的选中值
|
|
289
289
|
selectValue = `${intercept(values[0][indexs[0]])}:${intercept(
|
|
290
|
-
values[1][indexs[1]]
|
|
290
|
+
values[1][indexs[1]],
|
|
291
291
|
)}`;
|
|
292
292
|
} else if (mode.value === DateModeEnum.MONTH_DAY) {
|
|
293
293
|
// 根据value各列索引,从各列数组中,取出当前时间的选中值
|
|
294
294
|
selectValue = `${intercept(values[0][indexs[0]])}-${intercept(
|
|
295
|
-
values[1][indexs[1]]
|
|
295
|
+
values[1][indexs[1]],
|
|
296
296
|
)}`;
|
|
297
297
|
} else {
|
|
298
298
|
// 将选择的值转为数值,比如'03'转为数值的3,'2019'转为数值的2019
|
|
@@ -325,15 +325,15 @@ const change = (e: any) => {
|
|
|
325
325
|
// 微信小程序不能传递this实例,会因为循环引用而报错
|
|
326
326
|
// picker: this.$refs.picker,
|
|
327
327
|
// #endif
|
|
328
|
-
mode: mode.value
|
|
328
|
+
mode: mode.value,
|
|
329
329
|
});
|
|
330
330
|
};
|
|
331
331
|
|
|
332
332
|
/**
|
|
333
333
|
* @description 更新索引
|
|
334
334
|
* */
|
|
335
|
-
const
|
|
336
|
-
let values = [];
|
|
335
|
+
const updateIndexes = (value: number | string) => {
|
|
336
|
+
let values: string[] = [];
|
|
337
337
|
let timeArr: string[] = [];
|
|
338
338
|
const formatterFn = formatter.value || innerFormatter;
|
|
339
339
|
|
|
@@ -343,7 +343,7 @@ const updateIndexs = (value: number | string) => {
|
|
|
343
343
|
// 使用formatter格式化方法进行管道处理
|
|
344
344
|
values = [
|
|
345
345
|
formatterFn("hour", timeArr[0]),
|
|
346
|
-
formatterFn("minute", timeArr[1])
|
|
346
|
+
formatterFn("minute", timeArr[1]),
|
|
347
347
|
];
|
|
348
348
|
break;
|
|
349
349
|
case DateModeEnum.MONTH_DAY:
|
|
@@ -351,7 +351,7 @@ const updateIndexs = (value: number | string) => {
|
|
|
351
351
|
// 使用formatter格式化方法进行管道处理
|
|
352
352
|
values = [
|
|
353
353
|
formatterFn("month", timeArr[0]),
|
|
354
|
-
formatterFn("day", timeArr[1])
|
|
354
|
+
formatterFn("day", timeArr[1]),
|
|
355
355
|
];
|
|
356
356
|
break;
|
|
357
357
|
case DateModeEnum.HOUR_MINUTE:
|
|
@@ -359,7 +359,7 @@ const updateIndexs = (value: number | string) => {
|
|
|
359
359
|
// 使用formatter格式化方法进行管道处理
|
|
360
360
|
values = [
|
|
361
361
|
formatterFn("hour", timeArr[0]),
|
|
362
|
-
formatterFn("minute", timeArr[1])
|
|
362
|
+
formatterFn("minute", timeArr[1]),
|
|
363
363
|
];
|
|
364
364
|
break;
|
|
365
365
|
case DateModeEnum.MINUTE_SECOND:
|
|
@@ -367,14 +367,14 @@ const updateIndexs = (value: number | string) => {
|
|
|
367
367
|
// 使用formatter格式化方法进行管道处理
|
|
368
368
|
values = [
|
|
369
369
|
formatterFn("minute", timeArr[0]),
|
|
370
|
-
formatterFn("second", timeArr[1])
|
|
370
|
+
formatterFn("second", timeArr[1]),
|
|
371
371
|
];
|
|
372
372
|
break;
|
|
373
373
|
default:
|
|
374
374
|
values = [
|
|
375
375
|
formatterFn("year", `${dayjs(value).year()}`),
|
|
376
376
|
// 月份补0
|
|
377
|
-
formatterFn("month", padZero(dayjs(value).month() + 1))
|
|
377
|
+
formatterFn("month", padZero(dayjs(value).month() + 1)),
|
|
378
378
|
];
|
|
379
379
|
if (mode.value === DateModeEnum.DATE) {
|
|
380
380
|
// date模式,需要添加天列
|
|
@@ -386,7 +386,7 @@ const updateIndexs = (value: number | string) => {
|
|
|
386
386
|
formatterFn("day", padZero(dayjs(value).date())),
|
|
387
387
|
formatterFn("hour", padZero(dayjs(value).hour())),
|
|
388
388
|
formatterFn("minute", padZero(dayjs(value).minute())),
|
|
389
|
-
formatterFn("second", padZero(dayjs(value).second()))
|
|
389
|
+
formatterFn("second", padZero(dayjs(value).second())),
|
|
390
390
|
);
|
|
391
391
|
}
|
|
392
392
|
break;
|
|
@@ -396,7 +396,7 @@ const updateIndexs = (value: number | string) => {
|
|
|
396
396
|
// 通过取大值,可以保证不会出现找不到索引的"-1"情况
|
|
397
397
|
return Math.max(
|
|
398
398
|
0,
|
|
399
|
-
column.findIndex((item: string) => item === values[index])
|
|
399
|
+
column.findIndex((item: string) => item === values[index]),
|
|
400
400
|
);
|
|
401
401
|
});
|
|
402
402
|
};
|
|
@@ -456,47 +456,47 @@ const getRanges = () => {
|
|
|
456
456
|
return [
|
|
457
457
|
{
|
|
458
458
|
type: "hour",
|
|
459
|
-
range: [props.minHour, props.maxHour]
|
|
459
|
+
range: [props.minHour, props.maxHour],
|
|
460
460
|
},
|
|
461
461
|
{
|
|
462
462
|
type: "minute",
|
|
463
|
-
range: [props.minMinute, props.maxMinute]
|
|
464
|
-
}
|
|
463
|
+
range: [props.minMinute, props.maxMinute],
|
|
464
|
+
},
|
|
465
465
|
];
|
|
466
466
|
}
|
|
467
467
|
const { maxYear, maxDate, maxMonth, maxHour, maxMinute } = getBoundary(
|
|
468
468
|
"max",
|
|
469
|
-
innerValue.value
|
|
469
|
+
innerValue.value,
|
|
470
470
|
);
|
|
471
471
|
const { minYear, minDate, minMonth, minHour, minMinute } = getBoundary(
|
|
472
472
|
"min",
|
|
473
|
-
innerValue.value
|
|
473
|
+
innerValue.value,
|
|
474
474
|
);
|
|
475
475
|
const result = [
|
|
476
476
|
{
|
|
477
477
|
type: "year",
|
|
478
|
-
range: [minYear, maxYear]
|
|
478
|
+
range: [minYear, maxYear],
|
|
479
479
|
},
|
|
480
480
|
{
|
|
481
481
|
type: "month",
|
|
482
|
-
range: [minMonth, maxMonth]
|
|
482
|
+
range: [minMonth, maxMonth],
|
|
483
483
|
},
|
|
484
484
|
{
|
|
485
485
|
type: "day",
|
|
486
|
-
range: [minDate, maxDate]
|
|
486
|
+
range: [minDate, maxDate],
|
|
487
487
|
},
|
|
488
488
|
{
|
|
489
489
|
type: "hour",
|
|
490
|
-
range: [minHour, maxHour]
|
|
490
|
+
range: [minHour, maxHour],
|
|
491
491
|
},
|
|
492
492
|
{
|
|
493
493
|
type: "minute",
|
|
494
|
-
range: [minMinute, maxMinute]
|
|
494
|
+
range: [minMinute, maxMinute],
|
|
495
495
|
},
|
|
496
496
|
{
|
|
497
497
|
type: "second",
|
|
498
|
-
range: [minMinute, maxMinute]
|
|
499
|
-
}
|
|
498
|
+
range: [minMinute, maxMinute],
|
|
499
|
+
},
|
|
500
500
|
];
|
|
501
501
|
let arr = result;
|
|
502
502
|
// 截取对应的列数
|
|
@@ -543,7 +543,7 @@ const getBoundary = (type: string, innerVal: string | number) => {
|
|
|
543
543
|
[`${type}Month`]: month,
|
|
544
544
|
[`${type}Date`]: date,
|
|
545
545
|
[`${type}Hour`]: hour,
|
|
546
|
-
[`${type}Minute`]: minute
|
|
546
|
+
[`${type}Minute`]: minute,
|
|
547
547
|
};
|
|
548
548
|
};
|
|
549
549
|
const onShowByClickInput = () => {
|
|
@@ -554,31 +554,5 @@ const onShowByClickInput = () => {
|
|
|
554
554
|
</script>
|
|
555
555
|
|
|
556
556
|
<style lang="scss" scoped>
|
|
557
|
-
@import "
|
|
558
|
-
.hy-datetime-picker {
|
|
559
|
-
flex: 1;
|
|
560
|
-
&__has-input {
|
|
561
|
-
position: relative;
|
|
562
|
-
display: flex;
|
|
563
|
-
flex-direction: column;
|
|
564
|
-
justify-content: center;
|
|
565
|
-
/* #ifndef APP-NVUE */
|
|
566
|
-
width: 100%;
|
|
567
|
-
/* #endif */
|
|
568
|
-
.input-cover {
|
|
569
|
-
opacity: 0;
|
|
570
|
-
position: absolute;
|
|
571
|
-
top: 0;
|
|
572
|
-
bottom: 0;
|
|
573
|
-
left: 0;
|
|
574
|
-
right: 0;
|
|
575
|
-
display: flex;
|
|
576
|
-
flex-direction: column;
|
|
577
|
-
justify-content: center;
|
|
578
|
-
border-radius: 4px;
|
|
579
|
-
border: 1px solid #eee;
|
|
580
|
-
padding: 0 10px;
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
}
|
|
557
|
+
@import "./index.scss";
|
|
584
558
|
</style>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
@use "../../libs/css/mixin.scss" as *;
|
|
2
|
+
|
|
3
|
+
.hy-datetime-picker {
|
|
4
|
+
flex: 1;
|
|
5
|
+
&__has-input {
|
|
6
|
+
position: relative;
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
/* #ifndef APP-NVUE */
|
|
11
|
+
width: 100%;
|
|
12
|
+
/* #endif */
|
|
13
|
+
.input-cover {
|
|
14
|
+
opacity: 0;
|
|
15
|
+
position: absolute;
|
|
16
|
+
top: 0;
|
|
17
|
+
bottom: 0;
|
|
18
|
+
left: 0;
|
|
19
|
+
right: 0;
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
border-radius: 4px;
|
|
24
|
+
border: 1px solid #eee;
|
|
25
|
+
padding: 0 10px;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import IProps from "./typing";
|
|
1
|
+
import type IProps from "./typing";
|
|
2
2
|
import { DateModeEnum } from "../../typing";
|
|
3
3
|
|
|
4
4
|
const defaultProps: IProps = {
|
|
@@ -30,7 +30,7 @@ const defaultProps: IProps = {
|
|
|
30
30
|
format: "",
|
|
31
31
|
placeholder: "请选择日期",
|
|
32
32
|
disabledColor: "#F5F5F5",
|
|
33
|
-
toolbarRightSlot: false
|
|
33
|
+
toolbarRightSlot: false,
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export default defaultProps;
|