hy-app 0.1.1
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 +42 -0
- package/api/http.ts +138 -0
- package/api/index.ts +1 -0
- package/common/index.ts +1 -0
- package/common/versionControl.ts +102 -0
- package/components/dialog/TheDialog.vue +128 -0
- package/components/dialog/index.ts +38 -0
- package/components/hy-address-picker/hy-address-picker.vue +262 -0
- package/components/hy-address-picker/props.ts +27 -0
- package/components/hy-address-picker/typing.d.ts +98 -0
- package/components/hy-avatar/hy-avatar.vue +217 -0
- package/components/hy-avatar/props.ts +20 -0
- package/components/hy-avatar/typing.d.ts +64 -0
- package/components/hy-back-top/hy-back-top.vue +71 -0
- package/components/hy-back-top/props.ts +23 -0
- package/components/hy-back-top/typing.d.ts +49 -0
- package/components/hy-badge/hy-badge.vue +155 -0
- package/components/hy-badge/props.ts +19 -0
- package/components/hy-badge/typing.d.ts +60 -0
- package/components/hy-button/hy-button.vue +394 -0
- package/components/hy-button/props.ts +36 -0
- package/components/hy-button/typing.d.ts +125 -0
- package/components/hy-card/hy-card.vue +198 -0
- package/components/hy-card/props.ts +29 -0
- package/components/hy-card/typing.d.ts +112 -0
- package/components/hy-cell/hy-cell.vue +268 -0
- package/components/hy-cell/props.ts +20 -0
- package/components/hy-cell/typing.d.ts +98 -0
- package/components/hy-check-button/hy-check-button.vue +71 -0
- package/components/hy-check-button/props.ts +20 -0
- package/components/hy-check-button/typing.d.ts +79 -0
- package/components/hy-checkbox/hy-checkbox.vue +299 -0
- package/components/hy-checkbox/props.ts +28 -0
- package/components/hy-checkbox/typing.d.ts +77 -0
- package/components/hy-datetime-picker/hy-datetime-picker.vue +584 -0
- package/components/hy-datetime-picker/props.ts +36 -0
- package/components/hy-datetime-picker/typing.d.ts +135 -0
- package/components/hy-divider/hy-divider.vue +164 -0
- package/components/hy-divider/props.ts +21 -0
- package/components/hy-divider/typing.d.ts +64 -0
- package/components/hy-empty/hy-empty.vue +122 -0
- package/components/hy-empty/props.ts +21 -0
- package/components/hy-empty/typing.d.ts +68 -0
- package/components/hy-folding-panel/hy-folding-panel.vue +94 -0
- package/components/hy-folding-panel/props.ts +17 -0
- package/components/hy-folding-panel/typing.d.ts +59 -0
- package/components/hy-form/hy-form.vue +372 -0
- package/components/hy-form/props.ts +15 -0
- package/components/hy-form/typing.d.ts +51 -0
- package/components/hy-grid/hy-grid.vue +126 -0
- package/components/hy-grid/props.ts +16 -0
- package/components/hy-grid/typing.d.ts +62 -0
- package/components/hy-icon/hy-icon.vue +207 -0
- package/components/hy-icon/props.ts +24 -0
- package/components/hy-icon/typing.d.ts +80 -0
- package/components/hy-input/hy-input.vue +402 -0
- package/components/hy-input/props.ts +41 -0
- package/components/hy-input/typing.d.ts +148 -0
- package/components/hy-line/hy-line.vue +44 -0
- package/components/hy-line/props.ts +12 -0
- package/components/hy-line/typing.d.ts +32 -0
- package/components/hy-line-progress/hy-line-progress.vue +118 -0
- package/components/hy-line-progress/props.ts +12 -0
- package/components/hy-line-progress/typing.d.ts +28 -0
- package/components/hy-list/hy-list.vue +250 -0
- package/components/hy-list/props.ts +18 -0
- package/components/hy-list/typing.d.ts +50 -0
- package/components/hy-login/ThePhoneLogin.vue +106 -0
- package/components/hy-login/TheUserLogin.vue +391 -0
- package/components/hy-login/hy-login.vue +283 -0
- package/components/hy-login/props.ts +32 -0
- package/components/hy-login/typing.d.ts +60 -0
- package/components/hy-modal/hy-modal.vue +240 -0
- package/components/hy-modal/props.ts +24 -0
- package/components/hy-modal/typing.d.ts +70 -0
- package/components/hy-navbar/hy-navbar.vue +194 -0
- package/components/hy-navbar/props.ts +24 -0
- package/components/hy-navbar/typing.d.ts +81 -0
- package/components/hy-notice-bar/hy-column-notice.vue +130 -0
- package/components/hy-notice-bar/hy-notice-bar.vue +82 -0
- package/components/hy-notice-bar/hy-row-notice.vue +182 -0
- package/components/hy-notice-bar/props.ts +19 -0
- package/components/hy-notice-bar/typing.d.ts +56 -0
- package/components/hy-number-step/hy-number-step.vue +428 -0
- package/components/hy-number-step/props.ts +29 -0
- package/components/hy-number-step/typing.d.ts +104 -0
- package/components/hy-overlay/hy-overlay.vue +54 -0
- package/components/hy-overlay/props.ts +10 -0
- package/components/hy-overlay/typing.d.ts +24 -0
- package/components/hy-picker/hy-picker.vue +499 -0
- package/components/hy-picker/props.ts +30 -0
- package/components/hy-picker/typing.d.ts +115 -0
- package/components/hy-popup/hy-popup.vue +269 -0
- package/components/hy-popup/props.ts +21 -0
- package/components/hy-popup/typing.d.ts +68 -0
- package/components/hy-price/hy-price.vue +86 -0
- package/components/hy-price/props.ts +13 -0
- package/components/hy-price/typing.d.ts +36 -0
- package/components/hy-qrcode/hy-qrcode.vue +153 -0
- package/components/hy-qrcode/props.ts +20 -0
- package/components/hy-qrcode/qrcode.js +1364 -0
- package/components/hy-qrcode/typing.d.ts +64 -0
- package/components/hy-radio/hy-radio.vue +319 -0
- package/components/hy-radio/props.ts +28 -0
- package/components/hy-radio/typing.d.ts +85 -0
- package/components/hy-rate/hy-rate.vue +261 -0
- package/components/hy-rate/props.ts +18 -0
- package/components/hy-rate/typing.d.ts +60 -0
- package/components/hy-read-more/hy-read-more.vue +134 -0
- package/components/hy-read-more/props.ts +20 -0
- package/components/hy-read-more/typing.d.ts +44 -0
- package/components/hy-safe-bottom/hy-safe-bottom.vue +64 -0
- package/components/hy-scroll-list/hy-scroll-list.vue +146 -0
- package/components/hy-scroll-list/props.ts +12 -0
- package/components/hy-scroll-list/typing.d.ts +28 -0
- package/components/hy-search/hy-search.vue +294 -0
- package/components/hy-search/props.ts +29 -0
- package/components/hy-search/typing.d.ts +109 -0
- package/components/hy-slider/hy-slider.vue +511 -0
- package/components/hy-slider/props.ts +21 -0
- package/components/hy-slider/typing.d.ts +68 -0
- package/components/hy-steps/hy-steps.vue +352 -0
- package/components/hy-steps/props.ts +15 -0
- package/components/hy-steps/typing.d.ts +58 -0
- package/components/hy-subsection/hy-subsection.vue +272 -0
- package/components/hy-subsection/props.ts +16 -0
- package/components/hy-subsection/typing.d.ts +44 -0
- package/components/hy-swiper/hy-swiper-indicator.vue +105 -0
- package/components/hy-swiper/hy-swiper.vue +242 -0
- package/components/hy-swiper/props.ts +30 -0
- package/components/hy-swiper/typing.d.ts +107 -0
- package/components/hy-switch/hy-switch.vue +168 -0
- package/components/hy-switch/props.ts +16 -0
- package/components/hy-switch/typing.d.ts +48 -0
- package/components/hy-tabs/hy-tabs.vue +416 -0
- package/components/hy-tabs/props.ts +26 -0
- package/components/hy-tabs/typing.d.ts +86 -0
- package/components/hy-tag/hy-tag.vue +374 -0
- package/components/hy-tag/props.ts +22 -0
- package/components/hy-tag/typing.d.ts +76 -0
- package/components/hy-textarea/hy-textarea.vue +229 -0
- package/components/hy-textarea/props.ts +26 -0
- package/components/hy-textarea/typing.d.ts +27 -0
- package/components/hy-tooltip/hy-tooltip.vue +332 -0
- package/components/hy-tooltip/props.ts +17 -0
- package/components/hy-tooltip/typing.d.ts +52 -0
- package/components/hy-transition/hy-transition.vue +150 -0
- package/components/hy-transition/index.scss +113 -0
- package/components/hy-transition/props.ts +10 -0
- package/components/hy-transition/typing.d.ts +36 -0
- package/components/hy-upload/hy-upload.vue +557 -0
- package/components/hy-upload/props.ts +29 -0
- package/components/hy-upload/typing.d.ts +147 -0
- package/components/hy-warn/hy-warn.vue +228 -0
- package/components/hy-warn/props.ts +14 -0
- package/components/hy-warn/typing.d.ts +40 -0
- package/components/hy-waterfall/hy-waterfall.vue +51 -0
- package/components/hy-waterfall/props.ts +10 -0
- package/components/hy-waterfall/typing.d.ts +20 -0
- package/components/index.ts +162 -0
- package/components/message/TheMessage.vue +169 -0
- package/components/message/index.ts +54 -0
- package/components/u-form/form.js +22 -0
- package/components/u-form/hy-form.vue +324 -0
- package/components/u-form/props.js +49 -0
- package/components/u-form/schema.js +1451 -0
- package/components/u-form/u-form.vue +267 -0
- package/components/u-form/utils.js +65 -0
- package/components/u-form-item/formItem.js +24 -0
- package/components/u-form-item/hy-form-item.vue +360 -0
- package/components/u-form-item/props.js +57 -0
- package/components/u-form-item/u-form-item.vue +294 -0
- package/components/yk-dialog/yk-dialog.vue +129 -0
- package/components/yk-tabbar/props.ts +49 -0
- package/components/yk-tabbar/yk-tabbar.vue +224 -0
- package/config/color.ts +6 -0
- package/config/icon.ts +366 -0
- package/config/index.ts +2 -0
- package/global/index.ts +6 -0
- package/global/register-properties.ts +37 -0
- package/index.ts +8 -0
- package/libs/css/common.scss +0 -0
- package/libs/css/iconfont.css +379 -0
- package/libs/css/iconfont.ttf +0 -0
- package/libs/css/mixin.scss +15 -0
- package/package.json +42 -0
- package/public/icons/error.png +0 -0
- package/public/icons/success.png +0 -0
- package/public/icons/warning.png +0 -0
- package/store/index.ts +1 -0
- package/store/userInfo.ts +25 -0
- package/theme.scss +94 -0
- package/typing/index.ts +7 -0
- package/typing/modules/common.d.ts +50 -0
- package/typing/modules/dialog.ts +17 -0
- package/typing/modules/enum.ts +67 -0
- package/typing/modules/form.ts +161 -0
- package/typing/modules/http.ts +68 -0
- package/typing/modules/icon.d.ts +366 -0
- package/typing/modules/img.ts +15 -0
- package/typing/modules/rect.ts +10 -0
- package/utils/address.json +5890 -0
- package/utils/base64.ts +119 -0
- package/utils/index.ts +3 -0
- package/utils/inside.ts +310 -0
- package/utils/utils.ts +446 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="u-scroll-list" ref="u-scroll-list">
|
|
3
|
+
<!-- #ifdef MP-WEIXIN || APP-VUE || H5 || MP-QQ -->
|
|
4
|
+
<!-- 以上平台,支持wxs -->
|
|
5
|
+
<scroll-view
|
|
6
|
+
class="u-scroll-list__scroll-view scroll-view-native"
|
|
7
|
+
scroll-x
|
|
8
|
+
enable-flex
|
|
9
|
+
@scroll="onScroll"
|
|
10
|
+
@scrolltoupper="onScrollToUpper"
|
|
11
|
+
@scrolltolower="onScrollToLower"
|
|
12
|
+
:data-scrollWidth="scrollWidth"
|
|
13
|
+
:data-barWidth="indicatorBarWidth"
|
|
14
|
+
:data-indicatorWidth="indicatorWidth"
|
|
15
|
+
:show-scrollbar="false"
|
|
16
|
+
:upper-threshold="0"
|
|
17
|
+
:lower-threshold="0"
|
|
18
|
+
>
|
|
19
|
+
<slot></slot>
|
|
20
|
+
</scroll-view>
|
|
21
|
+
<!-- #endif -->
|
|
22
|
+
<view
|
|
23
|
+
class="u-scroll-list__indicator"
|
|
24
|
+
v-if="indicator"
|
|
25
|
+
:style="indicatorStyle"
|
|
26
|
+
>
|
|
27
|
+
<view class="u-scroll-list__indicator__line" :style="lineStyle">
|
|
28
|
+
<view
|
|
29
|
+
class="u-scroll-list__indicator__line__bar"
|
|
30
|
+
:style="barStyle"
|
|
31
|
+
ref="u-scroll-list__indicator__line__bar"
|
|
32
|
+
>
|
|
33
|
+
</view>
|
|
34
|
+
</view>
|
|
35
|
+
</view>
|
|
36
|
+
</view>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<script setup lang="ts">
|
|
40
|
+
import { computed, CSSProperties, reactive, toRefs, ref, onMounted } from "vue";
|
|
41
|
+
import defaultProps from "./props";
|
|
42
|
+
import IProps from "./typing";
|
|
43
|
+
import { addUnit, getRect, sleep } from "../../utils";
|
|
44
|
+
|
|
45
|
+
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
46
|
+
const {
|
|
47
|
+
indicatorWidth,
|
|
48
|
+
indicatorColor,
|
|
49
|
+
indicatorBarWidth,
|
|
50
|
+
indicatorActiveColor
|
|
51
|
+
} = toRefs(props);
|
|
52
|
+
const emit = defineEmits(["click", "left", "right"]);
|
|
53
|
+
|
|
54
|
+
const scrollInfo = ref({
|
|
55
|
+
scrollLeft: 0,
|
|
56
|
+
scrollWidth: 0
|
|
57
|
+
});
|
|
58
|
+
const scrollWidth = ref(0);
|
|
59
|
+
const barLeft = ref(0);
|
|
60
|
+
|
|
61
|
+
const barStyle = computed<CSSProperties>(() => {
|
|
62
|
+
const style: CSSProperties = {};
|
|
63
|
+
style.transform = `translateX(${barLeft.value}px)`;
|
|
64
|
+
// 设置滑块的宽度和背景色,是每个平台都需要的
|
|
65
|
+
style.width = addUnit(indicatorBarWidth.value);
|
|
66
|
+
style.backgroundColor = indicatorActiveColor.value;
|
|
67
|
+
return style;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const lineStyle = computed<CSSProperties>(() => {
|
|
71
|
+
const style: CSSProperties = {};
|
|
72
|
+
// 指示器整体的样式,需要设置其宽度和背景色
|
|
73
|
+
style.width = addUnit(indicatorWidth.value);
|
|
74
|
+
style.backgroundColor = indicatorColor.value;
|
|
75
|
+
return style;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
onMounted(() => {
|
|
79
|
+
initWidth();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @description 初始化宽度
|
|
84
|
+
* */
|
|
85
|
+
const initWidth = async () => {
|
|
86
|
+
// 延时一定时间,以获取dom尺寸
|
|
87
|
+
await sleep(30);
|
|
88
|
+
// #ifndef APP-NVUE
|
|
89
|
+
getRect(".u-scroll-list").then((size) => {
|
|
90
|
+
scrollWidth.value = (size as UniApp.NodeInfo).width!;
|
|
91
|
+
});
|
|
92
|
+
// #endif
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const onScroll = (event: any) => {
|
|
96
|
+
const { scrollLeft, scrollWidth: totalWidth } = event.detail;
|
|
97
|
+
const targetWidth = totalWidth - scrollWidth.value;
|
|
98
|
+
const targetBarWidth = indicatorWidth.value - indicatorBarWidth.value;
|
|
99
|
+
barLeft.value = (scrollLeft / targetWidth) * targetBarWidth;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const onScrollToLower = () => {
|
|
103
|
+
barLeft.value = indicatorWidth.value - indicatorBarWidth.value;
|
|
104
|
+
emit("right");
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const onScrollToUpper = () => {
|
|
108
|
+
barLeft.value = 0;
|
|
109
|
+
emit("left");
|
|
110
|
+
};
|
|
111
|
+
</script>
|
|
112
|
+
|
|
113
|
+
<style lang="scss" scoped>
|
|
114
|
+
@import "../../libs/css/mixin.scss";
|
|
115
|
+
.u-scroll-list {
|
|
116
|
+
padding-bottom: 10px;
|
|
117
|
+
|
|
118
|
+
&__scroll-view {
|
|
119
|
+
@include flex;
|
|
120
|
+
// 缺少会在enable-flex模式下高度异常
|
|
121
|
+
align-items: flex-start;
|
|
122
|
+
:deep(.uni-scroll-view-content) {
|
|
123
|
+
@include flex;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&__indicator {
|
|
128
|
+
@include flex;
|
|
129
|
+
justify-content: center;
|
|
130
|
+
margin-top: 15px;
|
|
131
|
+
|
|
132
|
+
&__line {
|
|
133
|
+
width: 60px;
|
|
134
|
+
height: 4px;
|
|
135
|
+
border-radius: 100px;
|
|
136
|
+
overflow: hidden;
|
|
137
|
+
|
|
138
|
+
&__bar {
|
|
139
|
+
width: 20px;
|
|
140
|
+
height: 4px;
|
|
141
|
+
border-radius: 100px;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import IProps from "./typing";
|
|
2
|
+
import { ColorConfig } from "../../config";
|
|
3
|
+
|
|
4
|
+
const defaultProps: IProps = {
|
|
5
|
+
indicatorWidth: 50,
|
|
6
|
+
indicatorBarWidth: 20,
|
|
7
|
+
indicator: true,
|
|
8
|
+
indicatorColor: "#f2f2f2",
|
|
9
|
+
indicatorActiveColor: ColorConfig.primary
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default defaultProps;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CSSProperties } from "vue";
|
|
2
|
+
|
|
3
|
+
export default interface IProps {
|
|
4
|
+
/**
|
|
5
|
+
* @description 指示器的整体宽度 (默认 50 )
|
|
6
|
+
* */
|
|
7
|
+
indicatorWidth?: number;
|
|
8
|
+
/**
|
|
9
|
+
* @description 滑块的宽度 (默认 20 )
|
|
10
|
+
* */
|
|
11
|
+
indicatorBarWidth?: number;
|
|
12
|
+
/**
|
|
13
|
+
* @description 是否显示面板指示器 (默认 true )
|
|
14
|
+
* */
|
|
15
|
+
indicator?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @description 指示器非激活颜色 (默认 '#f2f2f2' )
|
|
18
|
+
* */
|
|
19
|
+
indicatorColor?: string;
|
|
20
|
+
/**
|
|
21
|
+
* @description 指示器的激活颜色 (默认 '#3c9cff' )
|
|
22
|
+
* */
|
|
23
|
+
indicatorActiveColor?: string;
|
|
24
|
+
/**
|
|
25
|
+
* @description 指示器样式,可通过bottom,left,right进行定位
|
|
26
|
+
* */
|
|
27
|
+
indicatorStyle?: CSSProperties;
|
|
28
|
+
}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="hy-search"
|
|
4
|
+
@tap="clickHandler"
|
|
5
|
+
:style="[
|
|
6
|
+
{
|
|
7
|
+
margin: margin
|
|
8
|
+
},
|
|
9
|
+
customStyle
|
|
10
|
+
]"
|
|
11
|
+
>
|
|
12
|
+
<view
|
|
13
|
+
class="hy-search__content"
|
|
14
|
+
:style="{
|
|
15
|
+
backgroundColor: bgColor,
|
|
16
|
+
borderRadius: shape == 'circle' ? '100px' : '4px',
|
|
17
|
+
borderColor: borderColor
|
|
18
|
+
}"
|
|
19
|
+
>
|
|
20
|
+
<template v-if="$slots.label || label !== null">
|
|
21
|
+
<slot name="label">
|
|
22
|
+
<text class="hy-search__content__label">{{ label }}</text>
|
|
23
|
+
</slot>
|
|
24
|
+
</template>
|
|
25
|
+
<view class="hy-search__content__icon">
|
|
26
|
+
<HyIcon
|
|
27
|
+
@tap="clickIcon"
|
|
28
|
+
:size="searchIconSize"
|
|
29
|
+
:name="IconConfig.SEARCH"
|
|
30
|
+
:color="searchIconColor ? searchIconColor : color"
|
|
31
|
+
></HyIcon>
|
|
32
|
+
</view>
|
|
33
|
+
<input
|
|
34
|
+
confirm-type="search"
|
|
35
|
+
@blur="blur"
|
|
36
|
+
:value="keyword"
|
|
37
|
+
@confirm="search"
|
|
38
|
+
@input="inputChange"
|
|
39
|
+
:disabled="disabled"
|
|
40
|
+
@focus="getFocus"
|
|
41
|
+
:focus="focus"
|
|
42
|
+
:maxlength="maxlength"
|
|
43
|
+
:adjust-position="adjustPosition"
|
|
44
|
+
:auto-blur="autoBlur"
|
|
45
|
+
placeholder-class="hy-search__content__input--placeholder"
|
|
46
|
+
:placeholder="placeholder"
|
|
47
|
+
:placeholder-style="`color: ${placeholderColor}`"
|
|
48
|
+
class="hy-search__content__input"
|
|
49
|
+
type="text"
|
|
50
|
+
:style="[
|
|
51
|
+
{
|
|
52
|
+
pointerEvents: disabled ? 'none' : 'auto',
|
|
53
|
+
textAlign: inputAlign,
|
|
54
|
+
color: color,
|
|
55
|
+
backgroundColor: bgColor,
|
|
56
|
+
height: addUnit(height)
|
|
57
|
+
},
|
|
58
|
+
inputStyle
|
|
59
|
+
]"
|
|
60
|
+
/>
|
|
61
|
+
<view
|
|
62
|
+
class="hy-search__content__icon hy-search__content__close"
|
|
63
|
+
v-if="keyword && clear && focused"
|
|
64
|
+
@click="clear"
|
|
65
|
+
>
|
|
66
|
+
<HyIcon
|
|
67
|
+
:name="IconConfig.CLOSE"
|
|
68
|
+
size="11"
|
|
69
|
+
color="#ffffff"
|
|
70
|
+
:customStyle="{
|
|
71
|
+
lineHeight: '12px'
|
|
72
|
+
}"
|
|
73
|
+
></HyIcon>
|
|
74
|
+
</view>
|
|
75
|
+
</view>
|
|
76
|
+
<text
|
|
77
|
+
:style="[actionStyle]"
|
|
78
|
+
class="hy-search__action"
|
|
79
|
+
:class="[(showActionBtn || show) && 'hy-search__action--active']"
|
|
80
|
+
@tap.stop.prevent="confirm"
|
|
81
|
+
>{{ actionText }}</text
|
|
82
|
+
>
|
|
83
|
+
</view>
|
|
84
|
+
</template>
|
|
85
|
+
|
|
86
|
+
<script setup lang="ts">
|
|
87
|
+
import { computed, nextTick, toRefs, ref, watch } from "vue";
|
|
88
|
+
import defaultProps from "./props";
|
|
89
|
+
import IProps from "./typing";
|
|
90
|
+
import { addUnit, sleep } from "../../utils";
|
|
91
|
+
import { IconConfig } from "../../config";
|
|
92
|
+
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
93
|
+
|
|
94
|
+
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
95
|
+
const { focus, modelValue, showAction, animation, disabled } = toRefs(props);
|
|
96
|
+
const emit = defineEmits([
|
|
97
|
+
"click",
|
|
98
|
+
"change",
|
|
99
|
+
"update:modelValue",
|
|
100
|
+
"clickIcon",
|
|
101
|
+
"search",
|
|
102
|
+
"clear",
|
|
103
|
+
"confirm",
|
|
104
|
+
"change",
|
|
105
|
+
"focus",
|
|
106
|
+
"blur"
|
|
107
|
+
]);
|
|
108
|
+
|
|
109
|
+
const keyword = ref<string>("");
|
|
110
|
+
// 是否显示右边的清除图标
|
|
111
|
+
const showClear = ref<boolean>(false);
|
|
112
|
+
const show = ref<boolean>(false);
|
|
113
|
+
// 标记input当前状态是否处于聚焦中,如果是,才会显示右侧的清除控件
|
|
114
|
+
const focused = ref(focus.value);
|
|
115
|
+
|
|
116
|
+
watch(
|
|
117
|
+
() => keyword.value,
|
|
118
|
+
(newValue: string) => {
|
|
119
|
+
emit("update:modelValue", newValue);
|
|
120
|
+
emit("change", newValue);
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
watch(
|
|
125
|
+
() => modelValue.value,
|
|
126
|
+
(newValue: string) => {
|
|
127
|
+
keyword.value = newValue;
|
|
128
|
+
},
|
|
129
|
+
{ immediate: true }
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
const showActionBtn = computed<boolean>(() => {
|
|
133
|
+
return !animation.value && showAction.value;
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @description
|
|
138
|
+
* */
|
|
139
|
+
const inputChange = (e: Event) => {
|
|
140
|
+
keyword.value = e.detail.value;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* @description 清空输入
|
|
144
|
+
* */
|
|
145
|
+
const clear = () => {
|
|
146
|
+
keyword.value = "";
|
|
147
|
+
// 延后发出事件,避免在父组件监听clear事件时,value为更新前的值(不为空)
|
|
148
|
+
nextTick(() => {
|
|
149
|
+
emit("clear");
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* @description 确定搜索
|
|
154
|
+
* */
|
|
155
|
+
const search = (e: InputEvent) => {
|
|
156
|
+
emit("search", e.detail.value);
|
|
157
|
+
try {
|
|
158
|
+
// 收起键盘
|
|
159
|
+
uni.hideKeyboard();
|
|
160
|
+
} catch (e) {}
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* @description 点击右边自定义按钮的事件
|
|
164
|
+
*/
|
|
165
|
+
const confirm = () => {
|
|
166
|
+
emit("confirm", keyword.value);
|
|
167
|
+
try {
|
|
168
|
+
// 收起键盘
|
|
169
|
+
uni.hideKeyboard();
|
|
170
|
+
} catch (e) {}
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* @description 获取焦点
|
|
174
|
+
* */
|
|
175
|
+
const getFocus = () => {
|
|
176
|
+
focused.value = true;
|
|
177
|
+
// 开启右侧搜索按钮展开的动画效果
|
|
178
|
+
if (animation.value && showAction.value) show.value = true;
|
|
179
|
+
emit("focus", keyword.value);
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* @description 失去焦点
|
|
183
|
+
*/
|
|
184
|
+
const blur = async () => {
|
|
185
|
+
// 最开始使用的是监听图标@touchstart事件,自从hx2.8.4后,此方法在微信小程序出错
|
|
186
|
+
// 这里改为监听点击事件,手点击清除图标时,同时也发生了@blur事件,导致图标消失而无法点击,这里做一个延时
|
|
187
|
+
show.value = false;
|
|
188
|
+
emit("blur", keyword.value);
|
|
189
|
+
await sleep(100);
|
|
190
|
+
focused.value = false;
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* @description 点击搜索框,只有disabled=true时才发出事件,因为禁止了输入,意味着是想跳转真正的搜索页
|
|
194
|
+
* */
|
|
195
|
+
const clickHandler = () => {
|
|
196
|
+
if (disabled.value) emit("click");
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* @description 点击左边图标
|
|
200
|
+
* */
|
|
201
|
+
const clickIcon = () => {
|
|
202
|
+
emit("clickIcon", keyword.value);
|
|
203
|
+
try {
|
|
204
|
+
// 收起键盘
|
|
205
|
+
uni.hideKeyboard();
|
|
206
|
+
} catch (e) {}
|
|
207
|
+
};
|
|
208
|
+
</script>
|
|
209
|
+
|
|
210
|
+
<style lang="scss" scoped>
|
|
211
|
+
@import "../../libs/css/mixin.scss";
|
|
212
|
+
@import "../../theme.scss";
|
|
213
|
+
|
|
214
|
+
$u-search-close-size: 20px !default;
|
|
215
|
+
|
|
216
|
+
/* #ifdef H5 */
|
|
217
|
+
// iOS15在H5下,hx的某些版本,input type=search时,会多了一个搜索图标,进行移除
|
|
218
|
+
[type="search"]::-webkit-search-decoration {
|
|
219
|
+
display: none;
|
|
220
|
+
}
|
|
221
|
+
/* #endif */
|
|
222
|
+
|
|
223
|
+
.hy-search {
|
|
224
|
+
@include flex(row);
|
|
225
|
+
align-items: center;
|
|
226
|
+
flex: 1;
|
|
227
|
+
|
|
228
|
+
&__content {
|
|
229
|
+
@include flex;
|
|
230
|
+
align-items: center;
|
|
231
|
+
padding: 0 $hy-border-margin-padding-lg;
|
|
232
|
+
flex: 1;
|
|
233
|
+
justify-content: space-between;
|
|
234
|
+
border-width: 1px;
|
|
235
|
+
border-color: transparent;
|
|
236
|
+
border-style: solid;
|
|
237
|
+
overflow: hidden;
|
|
238
|
+
|
|
239
|
+
&__icon {
|
|
240
|
+
@include flex;
|
|
241
|
+
align-items: center;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
&__label {
|
|
245
|
+
color: $hy-text-color;
|
|
246
|
+
font-size: $hy-font-size-base;
|
|
247
|
+
margin: 0 4px;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/*清除icon样式*/
|
|
251
|
+
&__close {
|
|
252
|
+
width: $u-search-close-size;
|
|
253
|
+
height: $u-search-close-size;
|
|
254
|
+
border-radius: 50%;
|
|
255
|
+
background-color: #c6c7cb;
|
|
256
|
+
@include flex(row);
|
|
257
|
+
align-items: center;
|
|
258
|
+
justify-content: center;
|
|
259
|
+
transform: scale(0.82);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/*输入框样式*/
|
|
263
|
+
&__input {
|
|
264
|
+
flex: 1;
|
|
265
|
+
font-size: $hy-font-size-base;
|
|
266
|
+
line-height: 1;
|
|
267
|
+
margin: 0 $hy-border-margin-padding-sm;
|
|
268
|
+
color: $hy-text-color;
|
|
269
|
+
|
|
270
|
+
&--placeholder {
|
|
271
|
+
color: $hy-text-color-grey;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
&__action {
|
|
277
|
+
font-size: $hy-font-size-base;
|
|
278
|
+
color: $hy-text-color;
|
|
279
|
+
width: 0;
|
|
280
|
+
overflow: hidden;
|
|
281
|
+
transition-property: width;
|
|
282
|
+
transition-duration: 0.3s;
|
|
283
|
+
/* #ifndef APP-NVUE */
|
|
284
|
+
white-space: nowrap;
|
|
285
|
+
/* #endif */
|
|
286
|
+
text-align: center;
|
|
287
|
+
|
|
288
|
+
&--active {
|
|
289
|
+
width: 40px;
|
|
290
|
+
margin-left: $hy-border-margin-padding-sm;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
</style>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import IProps from "./typing";
|
|
2
|
+
|
|
3
|
+
const defaultProps: IProps = {
|
|
4
|
+
modelValue: "",
|
|
5
|
+
shape: "circle",
|
|
6
|
+
bgColor: "#f2f2f2",
|
|
7
|
+
placeholder: "请输入关键字",
|
|
8
|
+
clear: true,
|
|
9
|
+
focus: false,
|
|
10
|
+
showAction: true,
|
|
11
|
+
actionText: "搜索",
|
|
12
|
+
inputAlign: "left",
|
|
13
|
+
disabled: false,
|
|
14
|
+
borderColor: "transparent",
|
|
15
|
+
searchIconColor: "#909399",
|
|
16
|
+
searchIconSize: 18,
|
|
17
|
+
color: "#606266",
|
|
18
|
+
placeholderColor: "#909399",
|
|
19
|
+
searchIcon: "search",
|
|
20
|
+
margin: "0",
|
|
21
|
+
animation: false,
|
|
22
|
+
maxlength: "-1",
|
|
23
|
+
height: 32,
|
|
24
|
+
label: null,
|
|
25
|
+
adjustPosition: true,
|
|
26
|
+
autoBlur: true
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default defaultProps;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { CSSProperties } from "vue";
|
|
2
|
+
import { b } from "vite/dist/node/types.d-aGj9QkWt";
|
|
3
|
+
|
|
4
|
+
export default interface IProps {
|
|
5
|
+
/**
|
|
6
|
+
* @description 输入框初始值
|
|
7
|
+
* */
|
|
8
|
+
modelValue: string;
|
|
9
|
+
/**
|
|
10
|
+
* @description 搜索框形状,circle-圆形,square-方形(默认 'circle' )
|
|
11
|
+
* */
|
|
12
|
+
shape?: HyApp.ShapeType;
|
|
13
|
+
/**
|
|
14
|
+
* @description 搜索框背景颜色(默认 '#f2f2f2' )
|
|
15
|
+
* */
|
|
16
|
+
bgColor?: string;
|
|
17
|
+
/**
|
|
18
|
+
* @description 占位文字内容(默认 '请输入关键字' )
|
|
19
|
+
* */
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
/**
|
|
22
|
+
* @description 是否启用清除控件(默认 true )
|
|
23
|
+
* */
|
|
24
|
+
clear?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @description 是否自动获得焦点(默认 false )
|
|
27
|
+
* */
|
|
28
|
+
focus?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* @description 是否显示右侧控件(默认 true )
|
|
31
|
+
* */
|
|
32
|
+
showAction?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* @description 右侧控件的样式,对象形式
|
|
35
|
+
* */
|
|
36
|
+
actionStyle?: CSSProperties;
|
|
37
|
+
/**
|
|
38
|
+
* @description 右侧控件文字(默认 '搜索' )
|
|
39
|
+
* */
|
|
40
|
+
actionText?: string;
|
|
41
|
+
/**
|
|
42
|
+
* @description 输入框内容水平对齐方式 (默认 'left' )
|
|
43
|
+
* */
|
|
44
|
+
inputAlign?: "center" | HyApp.LeftRightType;
|
|
45
|
+
/**
|
|
46
|
+
* @description 自定义输入框样式,对象形式
|
|
47
|
+
* */
|
|
48
|
+
inputStyle?: Record<string, any>;
|
|
49
|
+
/**
|
|
50
|
+
* @description 是否启用输入框(默认 false )
|
|
51
|
+
* */
|
|
52
|
+
disabled?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* @description 边框颜色,配置了颜色,才会有边框 (默认 'transparent' )
|
|
55
|
+
* */
|
|
56
|
+
borderColor?: string;
|
|
57
|
+
/**
|
|
58
|
+
* @description 搜索图标的颜色,默认同输入框字体颜色 (默认 '#909399' )
|
|
59
|
+
* */
|
|
60
|
+
searchIconColor?: string;
|
|
61
|
+
/**
|
|
62
|
+
* @description 搜索图标的字体,默认18
|
|
63
|
+
* */
|
|
64
|
+
searchIconSize?: number;
|
|
65
|
+
/**
|
|
66
|
+
* @description 输入框字体颜色(默认 '#606266' )
|
|
67
|
+
* */
|
|
68
|
+
color?: string;
|
|
69
|
+
/**
|
|
70
|
+
* @description placeholder的颜色(默认 '#909399' )
|
|
71
|
+
* */
|
|
72
|
+
placeholderColor?: string;
|
|
73
|
+
/**
|
|
74
|
+
* @description 输入框左边的图标,可以为图标名称或图片路径 (默认 'search' )
|
|
75
|
+
* */
|
|
76
|
+
searchIcon?: string;
|
|
77
|
+
/**
|
|
78
|
+
* @description 组件与其他上下左右之间的距离,带单位的字符串形式,如"30px" (默认 '0' )
|
|
79
|
+
* */
|
|
80
|
+
margin?: string;
|
|
81
|
+
/**
|
|
82
|
+
* @description 是否开启动画,见上方说明(默认 false )
|
|
83
|
+
* */
|
|
84
|
+
animation?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* @description 输入框最大能输入的长度,-1为不限制长度 (默认 '-1' )
|
|
87
|
+
* */
|
|
88
|
+
maxlength?: string | number;
|
|
89
|
+
/**
|
|
90
|
+
* @description 输入框高度,单位px(默认 64 )
|
|
91
|
+
* */
|
|
92
|
+
height?: number;
|
|
93
|
+
/**
|
|
94
|
+
* @description 搜索框左边显示内容
|
|
95
|
+
* */
|
|
96
|
+
label?: string | null;
|
|
97
|
+
/**
|
|
98
|
+
* @description 键盘弹起时,是否自动上推页面
|
|
99
|
+
* */
|
|
100
|
+
adjustPosition?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* @description 键盘收起时,是否自动失去焦点
|
|
103
|
+
* */
|
|
104
|
+
autoBlur?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* @description 定义需要用到的外部样式
|
|
107
|
+
* */
|
|
108
|
+
customStyle?: CSSProperties;
|
|
109
|
+
}
|