hy-app 0.1.2 → 0.1.4
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 +3 -29
- package/components/hy-address-picker/index.scss +27 -0
- package/components/hy-avatar/hy-avatar.vue +1 -45
- package/components/hy-avatar/index.scss +45 -0
- package/components/hy-avatar/typing.d.ts +1 -1
- 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 +1 -72
- package/components/hy-badge/index.scss +72 -0
- package/components/hy-button/hy-button.vue +17 -128
- package/components/hy-button/index.scss +116 -0
- package/components/hy-button/typing.d.ts +1 -1
- 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 +1 -137
- package/components/hy-cell/index.scss +137 -0
- package/components/hy-check-button/hy-check-button.vue +1 -0
- package/components/hy-check-button/index.scss +5 -0
- package/components/hy-checkbox/hy-checkbox.vue +2 -95
- package/components/hy-checkbox/index.scss +94 -0
- package/components/hy-checkbox/typing.d.ts +1 -2
- 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 +2 -28
- package/components/hy-datetime-picker/index.scss +28 -0
- package/components/hy-divider/hy-divider.vue +24 -49
- package/components/hy-divider/index.scss +26 -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 +217 -0
- package/components/hy-float-button/index.scss +67 -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 +17 -34
- package/components/hy-form/index.scss +30 -0
- package/components/hy-form/props.ts +2 -0
- package/components/hy-form/typing.d.ts +9 -1
- package/components/hy-grid/hy-grid.vue +1 -43
- package/components/hy-grid/index.scss +40 -0
- package/components/hy-icon/hy-icon.vue +1 -93
- package/components/hy-icon/index.scss +84 -0
- package/components/hy-image/hy-image.vue +216 -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 +2 -72
- package/components/hy-input/index.scss +65 -0
- 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 +53 -0
- package/components/hy-login/TheUserLogin.vue +20 -88
- 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 +16 -58
- 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 +1 -70
- package/components/hy-number-step/index.scss +71 -0
- package/components/hy-overlay/hy-overlay.vue +2 -14
- package/components/hy-overlay/index.scss +9 -0
- package/components/hy-parse/hy-parse.vue +499 -0
- package/components/hy-parse/index.scss +9 -0
- package/components/hy-parse/node/node.vue +584 -0
- package/components/hy-parse/parser.js +1337 -0
- package/components/hy-parse/props.ts +19 -0
- package/components/hy-parse/typing.d.ts +68 -0
- package/components/hy-picker/hy-picker.vue +1 -68
- package/components/hy-picker/index.scss +68 -0
- package/components/hy-popup/hy-popup.vue +1 -74
- package/components/hy-popup/index.scss +60 -0
- package/components/hy-price/hy-price.vue +7 -19
- package/components/hy-price/index.scss +11 -0
- package/components/hy-price/props.ts +4 -3
- package/components/hy-price/typing.d.ts +8 -4
- 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 +2 -101
- package/components/hy-radio/index.scss +93 -0
- package/components/hy-radio/typing.d.ts +1 -2
- package/components/hy-rate/hy-rate.vue +1 -33
- package/components/hy-rate/index.scss +33 -0
- 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 +1 -83
- package/components/hy-search/index.scss +83 -0
- package/components/hy-slider/hy-slider.vue +18 -95
- package/components/hy-slider/index.scss +77 -0
- 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-submitBar/Index.vue +17 -0
- package/components/hy-submitBar/hy-submitBar.vue +216 -0
- package/components/hy-submitBar/index.scss +9 -0
- package/components/hy-submitBar/props.ts +22 -0
- package/components/hy-submitBar/typing.d.ts +88 -0
- package/components/hy-subsection/hy-subsection.vue +40 -132
- package/components/hy-subsection/index.scss +82 -0
- package/components/hy-subsection/props.ts +1 -0
- package/components/hy-subsection/typing.d.ts +13 -4
- 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 +1 -54
- package/components/hy-swiper/index.scss +82 -0
- package/components/hy-switch/hy-switch.vue +62 -72
- package/components/hy-switch/index.scss +46 -0
- package/components/hy-switch/props.ts +4 -1
- 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 +25 -220
- package/components/hy-tag/index.scss +205 -0
- 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 +1 -46
- package/components/hy-textarea/index.scss +40 -0
- package/components/hy-toast/hy-toast.vue +175 -0
- package/components/hy-toast/index.scss +77 -0
- package/components/hy-toast/props.ts +3 -0
- package/components/hy-toast/typing.d.ts +38 -0
- 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 +4 -2
- package/components/hy-transition/typing.d.ts +1 -13
- 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 +17 -144
- 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/hy-waterfall.vue +168 -38
- package/components/hy-waterfall/index.scss +16 -0
- package/components/hy-waterfall/props.ts +4 -5
- package/components/hy-waterfall/typing.d.ts +5 -9
- package/components/index.ts +25 -1
- package/components/message/index.ts +54 -54
- package/composables/index.ts +1 -0
- package/composables/useShare.ts +27 -0
- package/config/color.ts +3 -2
- package/config/icon.ts +21 -1
- package/global/index.ts +6 -6
- package/global/register-properties.ts +2 -2
- package/index.scss +2 -1
- package/index.ts +9 -8
- package/libs/css/common.scss +14 -2
- package/package.json +3 -2
- package/{libs/css → public/font}/iconfont.css +4 -4
- package/theme.scss +6 -4
- package/typing/index.ts +1 -1
- package/typing/modules/common.d.ts +36 -1
- 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 +115 -0
- package/utils/utils.ts +20 -19
- package/libs/css/download.zip +0 -0
- /package/{libs/css → public/font}/iconfont.ttf +0 -0
- /package/{libs/css → public/font}/iconfont.woff +0 -0
- /package/{libs/css → public/font}/iconfont.woff2 +0 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
@use "../../libs/css/mixin.scss" as *;
|
|
2
|
+
@use "../../theme.scss" as *;
|
|
3
|
+
|
|
4
|
+
.hy-checkbox {
|
|
5
|
+
&-group {
|
|
6
|
+
&--row {
|
|
7
|
+
/* #ifndef APP-NVUE */
|
|
8
|
+
display: flex;
|
|
9
|
+
/* #endif */
|
|
10
|
+
flex-flow: row wrap;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&--column {
|
|
14
|
+
@include flex(column);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* #ifndef APP-NVUE */
|
|
19
|
+
@include flex(row);
|
|
20
|
+
/* #endif */
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
flex-direction: row;
|
|
23
|
+
align-items: center;
|
|
24
|
+
margin-bottom: 5px;
|
|
25
|
+
margin-top: 5px;
|
|
26
|
+
|
|
27
|
+
&-label--left {
|
|
28
|
+
flex-direction: row;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&-label--right {
|
|
32
|
+
flex-direction: row-reverse;
|
|
33
|
+
justify-content: space-between;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&__icon-wrap {
|
|
37
|
+
/* #ifndef APP-NVUE */
|
|
38
|
+
box-sizing: border-box;
|
|
39
|
+
// nvue下,border-color过渡有问题
|
|
40
|
+
transition-property: border-color, background-color, color;
|
|
41
|
+
transition-duration: 0.2s;
|
|
42
|
+
/* #endif */
|
|
43
|
+
@include flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
color: transparent;
|
|
47
|
+
text-align: center;
|
|
48
|
+
margin-right: $hy-border-margin-padding-sm;
|
|
49
|
+
border: $hy-border-line;
|
|
50
|
+
|
|
51
|
+
/* #ifdef MP-TOUTIAO */
|
|
52
|
+
// 头条小程序兼容性问题,需要设置行高为0,否则图标偏下
|
|
53
|
+
&__icon {
|
|
54
|
+
line-height: 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* #endif */
|
|
58
|
+
|
|
59
|
+
&--circle {
|
|
60
|
+
border-radius: 50%;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&--square {
|
|
64
|
+
border-radius: 3px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&--checked {
|
|
68
|
+
color: $hy-text-color-inverse;
|
|
69
|
+
background-color: $hy-primary;
|
|
70
|
+
border-color: $hy-primary;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&--disabled {
|
|
74
|
+
background-color: $hy-color-disable-bg !important;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&--disabled--checked {
|
|
78
|
+
color: $hy-color-disable-icon !important;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&__label-wrap {
|
|
83
|
+
/* #ifndef APP-NVUE */
|
|
84
|
+
word-wrap: break-word;
|
|
85
|
+
/* #endif */
|
|
86
|
+
color: $hy-text-color;
|
|
87
|
+
font-size: $hy-font-size-base;
|
|
88
|
+
margin-right: $hy-border-margin-padding-sm;
|
|
89
|
+
|
|
90
|
+
&--disabled {
|
|
91
|
+
color: $hy-text-color-disable;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { CSSProperties } from "vue";
|
|
2
2
|
import type { CheckboxColumnsVo, IFieldNames } from "../hy-check-button/typing";
|
|
3
|
-
import { HyApp } from "@/package/typing/modules/common";
|
|
4
3
|
|
|
5
4
|
export default interface IProps {
|
|
6
5
|
/**
|
|
@@ -70,5 +69,5 @@ export default interface IProps {
|
|
|
70
69
|
/**
|
|
71
70
|
* @description 排列方式,row-横向,column-纵向
|
|
72
71
|
* */
|
|
73
|
-
placement?: HyApp.
|
|
72
|
+
placement?: HyApp.DirectionType;
|
|
74
73
|
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="hy-count-down">
|
|
3
|
+
<slot :record="timeData">
|
|
4
|
+
<text class="hy-count-down__text">{{ formattedTime }}</text>
|
|
5
|
+
</slot>
|
|
6
|
+
</view>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import type IProps from "./typing";
|
|
11
|
+
import defaultProps from "./props";
|
|
12
|
+
import { onMounted, onUnmounted, ref, toRefs, watch } from "vue";
|
|
13
|
+
import { isSameSecond, parseFormat, parseTimeData } from "./index";
|
|
14
|
+
|
|
15
|
+
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
16
|
+
const { time, autoStart, millisecond, format } = toRefs(props);
|
|
17
|
+
const emit = defineEmits(["change", "finish"]);
|
|
18
|
+
|
|
19
|
+
let timer: any;
|
|
20
|
+
// 各单位(天,时,分等)剩余时间
|
|
21
|
+
const timeData = ref(parseTimeData(time.value));
|
|
22
|
+
// 格式化后的时间,如"03:23:21"
|
|
23
|
+
const formattedTime = ref("");
|
|
24
|
+
// 倒计时是否正在进行中
|
|
25
|
+
const runing = ref(false);
|
|
26
|
+
// 结束的毫秒时间戳
|
|
27
|
+
const endTime = ref(0);
|
|
28
|
+
// 剩余的毫秒时间
|
|
29
|
+
const remainTime = ref(0);
|
|
30
|
+
|
|
31
|
+
watch(
|
|
32
|
+
() => time.value,
|
|
33
|
+
() => reset(),
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
onMounted(() => {
|
|
37
|
+
reset();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
onUnmounted(() => {
|
|
41
|
+
clearTimeoutFn();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @description 开始倒计时
|
|
46
|
+
*/
|
|
47
|
+
const start = () => {
|
|
48
|
+
if (runing.value) return;
|
|
49
|
+
// 标识为进行中
|
|
50
|
+
runing.value = true;
|
|
51
|
+
// 结束时间戳 = 此刻时间戳 + 剩余的时间
|
|
52
|
+
endTime.value = Date.now() + remainTime.value;
|
|
53
|
+
toTick();
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @description 根据是否展示毫秒,执行不同操作函数
|
|
58
|
+
*/
|
|
59
|
+
const toTick = () => {
|
|
60
|
+
if (millisecond.value) {
|
|
61
|
+
microTick();
|
|
62
|
+
} else {
|
|
63
|
+
macroTick();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const macroTick = () => {
|
|
67
|
+
clearTimeoutFn();
|
|
68
|
+
// 每隔一定时间,更新一遍定时器的值
|
|
69
|
+
// 同时此定时器的作用也能带来毫秒级的更新
|
|
70
|
+
timer = setTimeout(() => {
|
|
71
|
+
// 获取剩余时间
|
|
72
|
+
const remain = getRemainTime();
|
|
73
|
+
// 重设剩余时间
|
|
74
|
+
if (!isSameSecond(remain, remainTime.value) || remain === 0) {
|
|
75
|
+
setRemainTime(remain);
|
|
76
|
+
}
|
|
77
|
+
// 如果剩余时间不为0,则继续检查更新倒计时
|
|
78
|
+
if (remainTime.value !== 0) {
|
|
79
|
+
macroTick();
|
|
80
|
+
}
|
|
81
|
+
}, 30);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const microTick = () => {
|
|
85
|
+
clearTimeoutFn();
|
|
86
|
+
timer = setTimeout(() => {
|
|
87
|
+
setRemainTime(getRemainTime());
|
|
88
|
+
if (remainTime.value !== 0) {
|
|
89
|
+
microTick();
|
|
90
|
+
}
|
|
91
|
+
}, 50);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @description 获取剩余的时间
|
|
96
|
+
*/
|
|
97
|
+
const getRemainTime = () => {
|
|
98
|
+
// 取最大值,防止出现小于0的剩余时间值
|
|
99
|
+
return Math.max(endTime.value - Date.now(), 0);
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* @description 设置剩余的时间
|
|
103
|
+
*/
|
|
104
|
+
const setRemainTime = (remain: number) => {
|
|
105
|
+
remainTime.value = remain;
|
|
106
|
+
// 根据剩余的毫秒时间,得出该有天,小时,分钟等的值,返回一个对象
|
|
107
|
+
timeData.value = parseTimeData(remain);
|
|
108
|
+
emit("change", timeData.value);
|
|
109
|
+
// 得出格式化后的时间
|
|
110
|
+
formattedTime.value = parseFormat(format.value, timeData.value);
|
|
111
|
+
// 如果时间已到,停止倒计时
|
|
112
|
+
if (remain <= 0) {
|
|
113
|
+
pause();
|
|
114
|
+
emit("finish");
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
// 重置倒计时
|
|
118
|
+
const reset = () => {
|
|
119
|
+
pause();
|
|
120
|
+
remainTime.value = time.value;
|
|
121
|
+
setRemainTime(remainTime.value);
|
|
122
|
+
if (autoStart.value) {
|
|
123
|
+
start();
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* @description 暂停倒计时
|
|
128
|
+
* */
|
|
129
|
+
const pause = () => {
|
|
130
|
+
runing.value = false;
|
|
131
|
+
clearTimeoutFn();
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* @description 清空定时器
|
|
135
|
+
* */
|
|
136
|
+
const clearTimeoutFn = () => {
|
|
137
|
+
clearTimeout(timer);
|
|
138
|
+
timer = null;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
defineExpose({
|
|
142
|
+
reset,
|
|
143
|
+
start,
|
|
144
|
+
pause,
|
|
145
|
+
});
|
|
146
|
+
</script>
|
|
147
|
+
|
|
148
|
+
<style scoped lang="scss">
|
|
149
|
+
@import "./index.scss";
|
|
150
|
+
</style>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { padZero } from "../../utils";
|
|
2
|
+
|
|
3
|
+
const SECOND = 1000;
|
|
4
|
+
const MINUTE = 60 * SECOND;
|
|
5
|
+
const HOUR = 60 * MINUTE;
|
|
6
|
+
const DAY = 24 * HOUR;
|
|
7
|
+
export function parseTimeData(time: number) {
|
|
8
|
+
const days = Math.floor(time / DAY);
|
|
9
|
+
const hours = Math.floor((time % DAY) / HOUR);
|
|
10
|
+
const minutes = Math.floor((time % HOUR) / MINUTE);
|
|
11
|
+
const seconds = Math.floor((time % MINUTE) / SECOND);
|
|
12
|
+
const milliseconds = Math.floor(time % SECOND);
|
|
13
|
+
return {
|
|
14
|
+
days,
|
|
15
|
+
hours,
|
|
16
|
+
minutes,
|
|
17
|
+
seconds,
|
|
18
|
+
milliseconds,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function parseFormat(format: string, timeData: AnyObject) {
|
|
23
|
+
let { days, hours, minutes, seconds, milliseconds } = timeData;
|
|
24
|
+
// 如果格式化字符串中不存在DD(天),则将天的时间转为小时中去
|
|
25
|
+
if (format.indexOf("DD") === -1) {
|
|
26
|
+
hours += days * 24;
|
|
27
|
+
} else {
|
|
28
|
+
// 对天补0
|
|
29
|
+
format = format.replace("DD", padZero(days));
|
|
30
|
+
}
|
|
31
|
+
// 其他同理于DD的格式化处理方式
|
|
32
|
+
if (format.indexOf("HH") === -1) {
|
|
33
|
+
minutes += hours * 60;
|
|
34
|
+
} else {
|
|
35
|
+
format = format.replace("HH", padZero(hours));
|
|
36
|
+
}
|
|
37
|
+
if (format.indexOf("mm") === -1) {
|
|
38
|
+
seconds += minutes * 60;
|
|
39
|
+
} else {
|
|
40
|
+
format = format.replace("mm", padZero(minutes));
|
|
41
|
+
}
|
|
42
|
+
if (format.indexOf("ss") === -1) {
|
|
43
|
+
milliseconds += seconds * 1000;
|
|
44
|
+
} else {
|
|
45
|
+
format = format.replace("ss", padZero(seconds));
|
|
46
|
+
}
|
|
47
|
+
return format.replace("SSS", padZero(milliseconds));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function isSameSecond(time1: number, time2: number) {
|
|
51
|
+
return Math.floor(time1 / 1000) === Math.floor(time2 / 1000);
|
|
52
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CSSProperties } from "vue";
|
|
2
|
+
|
|
3
|
+
export default interface IProps {
|
|
4
|
+
/**
|
|
5
|
+
* @description 倒计时时长,单位ms (默认 0 )
|
|
6
|
+
* */
|
|
7
|
+
time: number;
|
|
8
|
+
/**
|
|
9
|
+
* @description 时间格式,DD-日,HH-时,mm-分,ss-秒,SSS-毫秒 (默认 'HH:mm:ss' )
|
|
10
|
+
* */
|
|
11
|
+
format?: string;
|
|
12
|
+
/**
|
|
13
|
+
* @description 是否自动开始倒计时 (默认 true )
|
|
14
|
+
* */
|
|
15
|
+
autoStart?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @description 是否展示毫秒倒计时 (默认 false )
|
|
18
|
+
* */
|
|
19
|
+
millisecond?: boolean;
|
|
20
|
+
}
|
|
@@ -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"
|
|
@@ -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
|
+
}
|