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.
Files changed (206) hide show
  1. package/README.md +42 -0
  2. package/api/http.ts +138 -0
  3. package/api/index.ts +1 -0
  4. package/common/index.ts +1 -0
  5. package/common/versionControl.ts +102 -0
  6. package/components/dialog/TheDialog.vue +128 -0
  7. package/components/dialog/index.ts +38 -0
  8. package/components/hy-address-picker/hy-address-picker.vue +262 -0
  9. package/components/hy-address-picker/props.ts +27 -0
  10. package/components/hy-address-picker/typing.d.ts +98 -0
  11. package/components/hy-avatar/hy-avatar.vue +217 -0
  12. package/components/hy-avatar/props.ts +20 -0
  13. package/components/hy-avatar/typing.d.ts +64 -0
  14. package/components/hy-back-top/hy-back-top.vue +71 -0
  15. package/components/hy-back-top/props.ts +23 -0
  16. package/components/hy-back-top/typing.d.ts +49 -0
  17. package/components/hy-badge/hy-badge.vue +155 -0
  18. package/components/hy-badge/props.ts +19 -0
  19. package/components/hy-badge/typing.d.ts +60 -0
  20. package/components/hy-button/hy-button.vue +394 -0
  21. package/components/hy-button/props.ts +36 -0
  22. package/components/hy-button/typing.d.ts +125 -0
  23. package/components/hy-card/hy-card.vue +198 -0
  24. package/components/hy-card/props.ts +29 -0
  25. package/components/hy-card/typing.d.ts +112 -0
  26. package/components/hy-cell/hy-cell.vue +268 -0
  27. package/components/hy-cell/props.ts +20 -0
  28. package/components/hy-cell/typing.d.ts +98 -0
  29. package/components/hy-check-button/hy-check-button.vue +71 -0
  30. package/components/hy-check-button/props.ts +20 -0
  31. package/components/hy-check-button/typing.d.ts +79 -0
  32. package/components/hy-checkbox/hy-checkbox.vue +299 -0
  33. package/components/hy-checkbox/props.ts +28 -0
  34. package/components/hy-checkbox/typing.d.ts +77 -0
  35. package/components/hy-datetime-picker/hy-datetime-picker.vue +584 -0
  36. package/components/hy-datetime-picker/props.ts +36 -0
  37. package/components/hy-datetime-picker/typing.d.ts +135 -0
  38. package/components/hy-divider/hy-divider.vue +164 -0
  39. package/components/hy-divider/props.ts +21 -0
  40. package/components/hy-divider/typing.d.ts +64 -0
  41. package/components/hy-empty/hy-empty.vue +122 -0
  42. package/components/hy-empty/props.ts +21 -0
  43. package/components/hy-empty/typing.d.ts +68 -0
  44. package/components/hy-folding-panel/hy-folding-panel.vue +94 -0
  45. package/components/hy-folding-panel/props.ts +17 -0
  46. package/components/hy-folding-panel/typing.d.ts +59 -0
  47. package/components/hy-form/hy-form.vue +372 -0
  48. package/components/hy-form/props.ts +15 -0
  49. package/components/hy-form/typing.d.ts +51 -0
  50. package/components/hy-grid/hy-grid.vue +126 -0
  51. package/components/hy-grid/props.ts +16 -0
  52. package/components/hy-grid/typing.d.ts +62 -0
  53. package/components/hy-icon/hy-icon.vue +207 -0
  54. package/components/hy-icon/props.ts +24 -0
  55. package/components/hy-icon/typing.d.ts +80 -0
  56. package/components/hy-input/hy-input.vue +402 -0
  57. package/components/hy-input/props.ts +41 -0
  58. package/components/hy-input/typing.d.ts +148 -0
  59. package/components/hy-line/hy-line.vue +44 -0
  60. package/components/hy-line/props.ts +12 -0
  61. package/components/hy-line/typing.d.ts +32 -0
  62. package/components/hy-line-progress/hy-line-progress.vue +118 -0
  63. package/components/hy-line-progress/props.ts +12 -0
  64. package/components/hy-line-progress/typing.d.ts +28 -0
  65. package/components/hy-list/hy-list.vue +250 -0
  66. package/components/hy-list/props.ts +18 -0
  67. package/components/hy-list/typing.d.ts +50 -0
  68. package/components/hy-login/ThePhoneLogin.vue +106 -0
  69. package/components/hy-login/TheUserLogin.vue +391 -0
  70. package/components/hy-login/hy-login.vue +283 -0
  71. package/components/hy-login/props.ts +32 -0
  72. package/components/hy-login/typing.d.ts +60 -0
  73. package/components/hy-modal/hy-modal.vue +240 -0
  74. package/components/hy-modal/props.ts +24 -0
  75. package/components/hy-modal/typing.d.ts +70 -0
  76. package/components/hy-navbar/hy-navbar.vue +194 -0
  77. package/components/hy-navbar/props.ts +24 -0
  78. package/components/hy-navbar/typing.d.ts +81 -0
  79. package/components/hy-notice-bar/hy-column-notice.vue +130 -0
  80. package/components/hy-notice-bar/hy-notice-bar.vue +82 -0
  81. package/components/hy-notice-bar/hy-row-notice.vue +182 -0
  82. package/components/hy-notice-bar/props.ts +19 -0
  83. package/components/hy-notice-bar/typing.d.ts +56 -0
  84. package/components/hy-number-step/hy-number-step.vue +428 -0
  85. package/components/hy-number-step/props.ts +29 -0
  86. package/components/hy-number-step/typing.d.ts +104 -0
  87. package/components/hy-overlay/hy-overlay.vue +54 -0
  88. package/components/hy-overlay/props.ts +10 -0
  89. package/components/hy-overlay/typing.d.ts +24 -0
  90. package/components/hy-picker/hy-picker.vue +499 -0
  91. package/components/hy-picker/props.ts +30 -0
  92. package/components/hy-picker/typing.d.ts +115 -0
  93. package/components/hy-popup/hy-popup.vue +269 -0
  94. package/components/hy-popup/props.ts +21 -0
  95. package/components/hy-popup/typing.d.ts +68 -0
  96. package/components/hy-price/hy-price.vue +86 -0
  97. package/components/hy-price/props.ts +13 -0
  98. package/components/hy-price/typing.d.ts +36 -0
  99. package/components/hy-qrcode/hy-qrcode.vue +153 -0
  100. package/components/hy-qrcode/props.ts +20 -0
  101. package/components/hy-qrcode/qrcode.js +1364 -0
  102. package/components/hy-qrcode/typing.d.ts +64 -0
  103. package/components/hy-radio/hy-radio.vue +319 -0
  104. package/components/hy-radio/props.ts +28 -0
  105. package/components/hy-radio/typing.d.ts +85 -0
  106. package/components/hy-rate/hy-rate.vue +261 -0
  107. package/components/hy-rate/props.ts +18 -0
  108. package/components/hy-rate/typing.d.ts +60 -0
  109. package/components/hy-read-more/hy-read-more.vue +134 -0
  110. package/components/hy-read-more/props.ts +20 -0
  111. package/components/hy-read-more/typing.d.ts +44 -0
  112. package/components/hy-safe-bottom/hy-safe-bottom.vue +64 -0
  113. package/components/hy-scroll-list/hy-scroll-list.vue +146 -0
  114. package/components/hy-scroll-list/props.ts +12 -0
  115. package/components/hy-scroll-list/typing.d.ts +28 -0
  116. package/components/hy-search/hy-search.vue +294 -0
  117. package/components/hy-search/props.ts +29 -0
  118. package/components/hy-search/typing.d.ts +109 -0
  119. package/components/hy-slider/hy-slider.vue +511 -0
  120. package/components/hy-slider/props.ts +21 -0
  121. package/components/hy-slider/typing.d.ts +68 -0
  122. package/components/hy-steps/hy-steps.vue +352 -0
  123. package/components/hy-steps/props.ts +15 -0
  124. package/components/hy-steps/typing.d.ts +58 -0
  125. package/components/hy-subsection/hy-subsection.vue +272 -0
  126. package/components/hy-subsection/props.ts +16 -0
  127. package/components/hy-subsection/typing.d.ts +44 -0
  128. package/components/hy-swiper/hy-swiper-indicator.vue +105 -0
  129. package/components/hy-swiper/hy-swiper.vue +242 -0
  130. package/components/hy-swiper/props.ts +30 -0
  131. package/components/hy-swiper/typing.d.ts +107 -0
  132. package/components/hy-switch/hy-switch.vue +168 -0
  133. package/components/hy-switch/props.ts +16 -0
  134. package/components/hy-switch/typing.d.ts +48 -0
  135. package/components/hy-tabs/hy-tabs.vue +416 -0
  136. package/components/hy-tabs/props.ts +26 -0
  137. package/components/hy-tabs/typing.d.ts +86 -0
  138. package/components/hy-tag/hy-tag.vue +374 -0
  139. package/components/hy-tag/props.ts +22 -0
  140. package/components/hy-tag/typing.d.ts +76 -0
  141. package/components/hy-textarea/hy-textarea.vue +229 -0
  142. package/components/hy-textarea/props.ts +26 -0
  143. package/components/hy-textarea/typing.d.ts +27 -0
  144. package/components/hy-tooltip/hy-tooltip.vue +332 -0
  145. package/components/hy-tooltip/props.ts +17 -0
  146. package/components/hy-tooltip/typing.d.ts +52 -0
  147. package/components/hy-transition/hy-transition.vue +150 -0
  148. package/components/hy-transition/index.scss +113 -0
  149. package/components/hy-transition/props.ts +10 -0
  150. package/components/hy-transition/typing.d.ts +36 -0
  151. package/components/hy-upload/hy-upload.vue +557 -0
  152. package/components/hy-upload/props.ts +29 -0
  153. package/components/hy-upload/typing.d.ts +147 -0
  154. package/components/hy-warn/hy-warn.vue +228 -0
  155. package/components/hy-warn/props.ts +14 -0
  156. package/components/hy-warn/typing.d.ts +40 -0
  157. package/components/hy-waterfall/hy-waterfall.vue +51 -0
  158. package/components/hy-waterfall/props.ts +10 -0
  159. package/components/hy-waterfall/typing.d.ts +20 -0
  160. package/components/index.ts +162 -0
  161. package/components/message/TheMessage.vue +169 -0
  162. package/components/message/index.ts +54 -0
  163. package/components/u-form/form.js +22 -0
  164. package/components/u-form/hy-form.vue +324 -0
  165. package/components/u-form/props.js +49 -0
  166. package/components/u-form/schema.js +1451 -0
  167. package/components/u-form/u-form.vue +267 -0
  168. package/components/u-form/utils.js +65 -0
  169. package/components/u-form-item/formItem.js +24 -0
  170. package/components/u-form-item/hy-form-item.vue +360 -0
  171. package/components/u-form-item/props.js +57 -0
  172. package/components/u-form-item/u-form-item.vue +294 -0
  173. package/components/yk-dialog/yk-dialog.vue +129 -0
  174. package/components/yk-tabbar/props.ts +49 -0
  175. package/components/yk-tabbar/yk-tabbar.vue +224 -0
  176. package/config/color.ts +6 -0
  177. package/config/icon.ts +366 -0
  178. package/config/index.ts +2 -0
  179. package/global/index.ts +6 -0
  180. package/global/register-properties.ts +37 -0
  181. package/index.ts +8 -0
  182. package/libs/css/common.scss +0 -0
  183. package/libs/css/iconfont.css +379 -0
  184. package/libs/css/iconfont.ttf +0 -0
  185. package/libs/css/mixin.scss +15 -0
  186. package/package.json +42 -0
  187. package/public/icons/error.png +0 -0
  188. package/public/icons/success.png +0 -0
  189. package/public/icons/warning.png +0 -0
  190. package/store/index.ts +1 -0
  191. package/store/userInfo.ts +25 -0
  192. package/theme.scss +94 -0
  193. package/typing/index.ts +7 -0
  194. package/typing/modules/common.d.ts +50 -0
  195. package/typing/modules/dialog.ts +17 -0
  196. package/typing/modules/enum.ts +67 -0
  197. package/typing/modules/form.ts +161 -0
  198. package/typing/modules/http.ts +68 -0
  199. package/typing/modules/icon.d.ts +366 -0
  200. package/typing/modules/img.ts +15 -0
  201. package/typing/modules/rect.ts +10 -0
  202. package/utils/address.json +5890 -0
  203. package/utils/base64.ts +119 -0
  204. package/utils/index.ts +3 -0
  205. package/utils/inside.ts +310 -0
  206. package/utils/utils.ts +446 -0
@@ -0,0 +1,56 @@
1
+ import { CSSProperties } from "vue";
2
+
3
+ export default interface IProps {
4
+ /**
5
+ * @description 显示的内容,数组
6
+ * */
7
+ text: string[] | string;
8
+ /**
9
+ * @description 通告滚动模式,row-横向滚动,column-竖向滚动 ( 默认 'row' )
10
+ * */
11
+ direction?: HyApp.PermutationType;
12
+ /**
13
+ * @description direction = row时,是否使用步进形式滚动 ( 默认 false )
14
+ * */
15
+ step?: boolean;
16
+ /**
17
+ * @description 是否显示左侧的音量图标 ( 默认 'volume' )
18
+ * */
19
+ icon?: string | HyIconConfig;
20
+ /**
21
+ * @description 通告模式,link-显示右箭头,closable-显示右侧关闭图标
22
+ * */
23
+ mode?: "closable" | "link" | "";
24
+ /**
25
+ * @description 文字颜色,各图标也会使用文字颜色 ( 默认 '#f9ae3d' )
26
+ * */
27
+ color?: string;
28
+ /**
29
+ * @description 背景颜色 ( 默认 '#fdf6ec' )
30
+ * */
31
+ bgColor?: string;
32
+ /**
33
+ * @description 水平滚动时的滚动速度,即每秒滚动多少px(px),这有利于控制文字无论多少时,都能有一个恒定的速度 ( 默认 80 )
34
+ * */
35
+ speed?: number;
36
+ /**
37
+ * @description 字体大小 ( 默认 14 )
38
+ * */
39
+ fontSize?: number | string;
40
+ /**
41
+ * @description 滚动一个周期的时间长,单位ms ( 默认 2000 )
42
+ * */
43
+ duration?: number;
44
+ /**
45
+ * @description 是否禁止用手滑动切换 目前HX2.6.11,只支持App 2.5.5+、H5 2.5.5+、支付宝小程序、字节跳动小程序(默认34) ( 默认 true )
46
+ * */
47
+ disableTouch?: boolean;
48
+ /**
49
+ * @description 分布
50
+ * */
51
+ justifyContent?: HyApp.JustifyContentType;
52
+ /**
53
+ * @description 定义需要用到的外部样式
54
+ * */
55
+ customStyle?: CSSProperties;
56
+ }
@@ -0,0 +1,428 @@
1
+ <template>
2
+ <view class="hy-number-box">
3
+ <view
4
+ v-if="showMinus && !hideMinus"
5
+ @tap.stop="clickHandler('minus')"
6
+ @touchstart="onTouchStart('minus')"
7
+ @touchend.stop="onClearTimeout"
8
+ hover-class="hy-number-box__minus--hover"
9
+ hover-stay-time="150"
10
+ :class="[
11
+ { 'hy-number-box__minus--disabled': isDisabled('minus') },
12
+ 'hy-number-box__minus',
13
+ 'cursor-pointer'
14
+ ]"
15
+ :style="buttonStyle('minus')"
16
+ >
17
+ <slot name="minus">
18
+ <HyICon
19
+ :name="IconConfig.MINUS"
20
+ :color="isDisabled('minus') ? '#c8c9cc' : '#323233'"
21
+ size="15"
22
+ bold
23
+ :customStyle="iconStyle"
24
+ ></HyICon>
25
+ </slot>
26
+ </view>
27
+
28
+ <template v-if="!hideMinus">
29
+ <slot name="input" :record="currentValue">
30
+ <!-- #ifdef MP-WEIXIN -->
31
+ <input
32
+ :disabled="disabledInput || disabled"
33
+ :cursor-spacing="getCursorSpacing"
34
+ :class="[
35
+ {
36
+ 'hy-number-box__input--disabled': disabled || disabledInput
37
+ },
38
+ 'hy-number-box__input'
39
+ ]"
40
+ :value="currentValue"
41
+ @blur="onBlur"
42
+ @focus="onFocus"
43
+ @input="onInput"
44
+ type="number"
45
+ :style="[inputStyle]"
46
+ />
47
+ <!-- #endif -->
48
+ <!-- #ifndef MP-WEIXIN -->
49
+ <input
50
+ :disabled="disabledInput || disabled"
51
+ :cursor-spacing="getCursorSpacing"
52
+ :class="[
53
+ {
54
+ 'hy-number-box__input--disabled': disabled || disabledInput
55
+ },
56
+ 'hy-number-box__input'
57
+ ]"
58
+ v-model="currentValue"
59
+ @blur="onBlur"
60
+ @focus="onFocus"
61
+ @input="onInput"
62
+ type="number"
63
+ :style="[inputStyle]"
64
+ />
65
+ <!-- #endif -->
66
+ </slot>
67
+ </template>
68
+ <view
69
+ v-if="showPlus"
70
+ @tap.stop="clickHandler('plus')"
71
+ @touchstart="onTouchStart('plus')"
72
+ @touchend.stop="onClearTimeout"
73
+ hover-class="hy-number-box__plus--hover"
74
+ hover-stay-time="150"
75
+ :class="[
76
+ { 'hy-number-box__minus--disabled': isDisabled('plus') },
77
+ 'hy-number-box__plus',
78
+ 'cursor-pointer'
79
+ ]"
80
+ :style="[buttonStyle('plus')]"
81
+ >
82
+ <slot name="plus">
83
+ <HyICon
84
+ :name="IconConfig.PLUS"
85
+ :color="isDisabled('plus') ? '#c8c9cc' : '#323233'"
86
+ size="15"
87
+ bold
88
+ :customStyle="iconStyle"
89
+ ></HyICon>
90
+ </slot>
91
+ </view>
92
+ </view>
93
+ </template>
94
+
95
+ <script setup lang="ts">
96
+ import {
97
+ computed,
98
+ CSSProperties,
99
+ toRefs,
100
+ ref,
101
+ watch,
102
+ onMounted,
103
+ nextTick
104
+ } from "vue";
105
+ import defaultProps from "./props";
106
+ import IProps from "./typing";
107
+ import { addUnit } from "../../utils";
108
+ import { IconConfig } from "../../config";
109
+ import HyICon from "../hy-icon/hy-icon.vue";
110
+
111
+ const props = withDefaults(defineProps<IProps>(), defaultProps);
112
+ const {
113
+ modelValue,
114
+ miniMode,
115
+ cursorSpacing,
116
+ inputBgColor,
117
+ inputWidth,
118
+ buttonSize,
119
+ buttonWidth,
120
+ bgColor,
121
+ color,
122
+ buttonRadius,
123
+ disabledInput,
124
+ disabled,
125
+ integer,
126
+ max,
127
+ min,
128
+ decimalLength,
129
+ disablePlus,
130
+ disableMinus,
131
+ longPress,
132
+ asyncChange,
133
+ step
134
+ } = toRefs(props);
135
+ const emit = defineEmits([
136
+ "update:modelValue",
137
+ "focus",
138
+ "blur",
139
+ "overLimit",
140
+ "change",
141
+ "plus",
142
+ "minus"
143
+ ]);
144
+ type StepType = "plus" | "minus";
145
+
146
+ // 输入框实际操作的值
147
+ const currentValue = ref<number>(0);
148
+ // 定时器
149
+ const longPressTimer = ref<null | number | NodeJS.Timeout>(null);
150
+
151
+ const stepType = ref<StepType>("plus");
152
+
153
+ /**
154
+ * @description 格式化整理数据,限制范围
155
+ * @param value 处理值
156
+ * */
157
+ const format = (value: number): number => {
158
+ // 如果为空字符串,那么设置为0,同时将值转为Number类型
159
+ value = !value ? 0 : +value;
160
+ // 对比最大最小值,取在min和max之间的值
161
+ value = Math.max(Math.min(max.value, value), min.value);
162
+ // 如果设定了最大的小数位数,使用toFixed去进行格式化
163
+ if (decimalLength.value !== null) {
164
+ value = parseFloat(value.toFixed(decimalLength.value));
165
+ }
166
+ return value;
167
+ };
168
+
169
+ // 用于监听多个值发生变化
170
+ const watchChange = computed(() => {
171
+ return [integer.value, decimalLength.value, min.value, max.value];
172
+ });
173
+
174
+ watch(
175
+ () => watchChange.value,
176
+ () => check()
177
+ );
178
+ watch(
179
+ () => modelValue.value,
180
+ (newValue: number) => {
181
+ if (newValue !== currentValue.value) {
182
+ currentValue.value = format(modelValue.value);
183
+ }
184
+ },
185
+ { immediate: true }
186
+ );
187
+
188
+ const hideMinus = computed(() => {
189
+ return currentValue.value == 0 && miniMode.value;
190
+ });
191
+ const getCursorSpacing = computed(() => {
192
+ // 判断传入的单位,如果为px单位,需要转成px
193
+ return cursorSpacing.value;
194
+ });
195
+ // 按钮的样式
196
+ const buttonStyle = computed(() => {
197
+ return (type: string) => {
198
+ const style: CSSProperties = {
199
+ backgroundColor: bgColor.value,
200
+ width: addUnit(buttonWidth.value),
201
+ height: addUnit(buttonSize.value),
202
+ color: color.value,
203
+ borderRadius: buttonRadius.value
204
+ };
205
+ if (isDisabled.value(type)) {
206
+ style.backgroundColor = "#f7f8fa";
207
+ }
208
+ return style;
209
+ };
210
+ });
211
+ // 输入框的样式
212
+ const inputStyle = computed<CSSProperties>(() => {
213
+ // const disabled_1 = disabled.value || disabledInput.value;
214
+ return {
215
+ color: color.value,
216
+ backgroundColor: inputBgColor.value || bgColor.value,
217
+ height: addUnit(buttonSize.value),
218
+ width: addUnit(inputWidth.value)
219
+ };
220
+ });
221
+
222
+ const isDisabled = computed(() => {
223
+ return (type: string) => {
224
+ if (type === "plus") {
225
+ // 在点击增加按钮情况下,判断整体的disabled,是否单独禁用增加按钮,以及当前值是否大于最大的允许值
226
+ return (
227
+ disabled.value || disablePlus.value || currentValue.value >= max.value
228
+ );
229
+ }
230
+ // 点击减少按钮同理
231
+ return (
232
+ disabled.value || disableMinus.value || currentValue.value <= min.value
233
+ );
234
+ };
235
+ });
236
+
237
+ onMounted(() => {
238
+ init();
239
+ });
240
+
241
+ const init = () => {
242
+ currentValue.value = format(modelValue.value);
243
+ };
244
+ const check = () => {
245
+ // 格式化了之后,如果前后的值不相等,那么设置为格式化后的值
246
+ const val = format(currentValue.value);
247
+ if (val !== currentValue.value) {
248
+ currentValue.value = val;
249
+ emitChange(val);
250
+ }
251
+ };
252
+
253
+ /**
254
+ * @description 输入框活动焦点
255
+ */
256
+ const onFocus = (event: Event) => {
257
+ emit("focus", event.detail);
258
+ };
259
+ /**
260
+ * @description 输入框失去焦点
261
+ */
262
+ const onBlur = (event: Event) => {
263
+ // 对输入值进行格式化
264
+ format(event.detail.value);
265
+ // 发出blur事件
266
+ emit("blur", event.detail);
267
+ };
268
+ /**
269
+ * @description 输入框值发生变化
270
+ */
271
+ const onInput = (e: Event) => {
272
+ const { value = "" } = e.detail || {};
273
+ // 为空返回
274
+ if (value === "") return;
275
+ let formatted = value;
276
+ // https://github.com/ijry/uview-plus/issues/613
277
+ emitChange(value);
278
+ // 最大允许的小数长度
279
+ if (decimalLength.value !== null && formatted.indexOf(".") !== -1) {
280
+ const pair = formatted.split(".");
281
+ formatted = `${pair[0]}.${pair[1].slice(0, decimalLength.value)}`;
282
+ }
283
+ formatted = format(formatted);
284
+ emitChange(formatted);
285
+ // #ifdef MP-WEIXIN
286
+ return formatted;
287
+ // #endif
288
+ };
289
+ /**
290
+ * @description 发出change事件
291
+ * @param value 值
292
+ */
293
+ const emitChange = (value: number) => {
294
+ // 如果开启了异步变更值,则不修改内部的值,需要用户手动在外部通过v-model变更
295
+ if (!asyncChange.value) {
296
+ nextTick(() => {
297
+ emit("update:modelValue", value);
298
+ currentValue.value = value;
299
+ // this.$forceUpdate()
300
+ });
301
+ }
302
+ emit("change", value);
303
+ };
304
+ const onChange = () => {
305
+ if (isDisabled.value(stepType.value)) {
306
+ return emit("overLimit", stepType.value);
307
+ }
308
+ const diff = stepType.value === "minus" ? -step.value : +step.value;
309
+ const value = format(add(+currentValue.value, diff));
310
+ emitChange(value);
311
+ emit(stepType.value, value);
312
+ };
313
+ /**
314
+ * @description 对值扩大后进行四舍五入,再除以扩大因子,避免出现浮点数操作的精度问题
315
+ * @param num1
316
+ * @param num2
317
+ * */
318
+ const add = (num1: number, num2: number) => {
319
+ const cardinal = Math.pow(10, 10);
320
+ return Math.round((num1 + num2) * cardinal) / cardinal;
321
+ };
322
+ // 点击加减按钮
323
+ const clickHandler = (type: StepType) => {
324
+ stepType.value = type;
325
+ onChange();
326
+ };
327
+ const longPressStep = () => {
328
+ // 每隔一段时间,重新调用longPressStep方法,实现长按加减
329
+ onClearTimeout();
330
+ longPressTimer.value = setTimeout(() => {
331
+ onChange();
332
+ longPressStep();
333
+ }, 250) as NodeJS.Timeout;
334
+ };
335
+ const onTouchStart = (type: StepType) => {
336
+ if (!longPress.value) return;
337
+ onClearTimeout();
338
+ stepType.value = type;
339
+ // 一定时间后,默认达到长按状态
340
+ longPressTimer.value = setTimeout(() => {
341
+ onChange();
342
+ longPressStep();
343
+ }, 600);
344
+ };
345
+ // 触摸结束,清除定时器,停止长按加减
346
+ const onTouchEnd = () => {
347
+ if (!longPress.value) return;
348
+ onClearTimeout();
349
+ };
350
+ // 清除定时器
351
+ const onClearTimeout = () => {
352
+ clearTimeout(longPressTimer.value as number);
353
+ longPressTimer.value = null;
354
+ };
355
+ </script>
356
+
357
+ <style lang="scss" scoped>
358
+ @import "../../libs/css/mixin.scss";
359
+
360
+ $u-numberBox-hover-bgColor: #e6e6e6 !default;
361
+ $u-numberBox-disabled-color: #c8c9cc !default;
362
+ $u-numberBox-disabled-bgColor: #f7f8fa !default;
363
+ $u-numberBox-plus-radius: 4px !default;
364
+ $u-numberBox-minus-radius: 4px !default;
365
+ $u-numberBox-input-text-align: center !default;
366
+ $u-numberBox-input-font-size: 15px !default;
367
+ $u-numberBox-input-padding: 0 !default;
368
+ $u-numberBox-input-margin: 0 2px !default;
369
+ $u-numberBox-input-disabled-color: #c8c9cc !default;
370
+ $u-numberBox-input-disabled-bgColor: #f2f3f5 !default;
371
+
372
+ .hy-number-box {
373
+ @include flex(row);
374
+ align-items: center;
375
+
376
+ &__slot {
377
+ /* #ifndef APP-NVUE */
378
+ touch-action: none;
379
+ /* #endif */
380
+ }
381
+
382
+ &__plus,
383
+ &__minus {
384
+ width: 35px;
385
+ @include flex;
386
+ justify-content: center;
387
+ align-items: center;
388
+ /* #ifndef APP-NVUE */
389
+ touch-action: none;
390
+ /* #endif */
391
+
392
+ &--hover {
393
+ background-color: $u-numberBox-hover-bgColor !important;
394
+ }
395
+
396
+ &--disabled {
397
+ color: $u-numberBox-disabled-color;
398
+ background-color: $u-numberBox-disabled-bgColor;
399
+ }
400
+ }
401
+
402
+ &__plus {
403
+ border-top-right-radius: $u-numberBox-plus-radius;
404
+ border-bottom-right-radius: $u-numberBox-plus-radius;
405
+ }
406
+
407
+ &__minus {
408
+ border-top-left-radius: $u-numberBox-minus-radius;
409
+ border-bottom-left-radius: $u-numberBox-minus-radius;
410
+ }
411
+
412
+ &__input {
413
+ position: relative;
414
+ text-align: $u-numberBox-input-text-align;
415
+ font-size: $u-numberBox-input-font-size;
416
+ padding: $u-numberBox-input-padding;
417
+ margin: $u-numberBox-input-margin;
418
+ @include flex;
419
+ align-items: center;
420
+ justify-content: center;
421
+
422
+ &--disabled {
423
+ color: $u-numberBox-input-disabled-color;
424
+ background-color: $u-numberBox-input-disabled-bgColor;
425
+ }
426
+ }
427
+ }
428
+ </style>
@@ -0,0 +1,29 @@
1
+ import IProps from "./typing";
2
+
3
+ const defaultProps: IProps = {
4
+ modelValue: 0,
5
+ min: 1,
6
+ max: Number.MAX_SAFE_INTEGER,
7
+ step: 1,
8
+ integer: false,
9
+ disabled: false,
10
+ disabledInput: false,
11
+ asyncChange: false,
12
+ inputWidth: 35,
13
+ showMinus: true,
14
+ showPlus: true,
15
+ decimalLength: null,
16
+ longPress: true,
17
+ color: "#323233",
18
+ buttonWidth: 30,
19
+ buttonSize: 30,
20
+ buttonRadius: "0px",
21
+ bgColor: "#EBECEE",
22
+ inputBgColor: "#EBECEE",
23
+ cursorSpacing: 100,
24
+ disableMinus: false,
25
+ disablePlus: false,
26
+ miniMode: false
27
+ };
28
+
29
+ export default defaultProps;
@@ -0,0 +1,104 @@
1
+ import { CSSProperties } from "vue";
2
+
3
+ export default interface IProps {
4
+ /**
5
+ * @description 用于双向绑定的值,初始化时设置设为默认min值(最小值) (默认 0 )
6
+ * */
7
+ modelValue: number;
8
+ /**
9
+ * @description 最小值 (默认 1 )
10
+ * */
11
+ min?: number;
12
+ /**
13
+ * @description 最大值 (默认 Number.MAX_SAFE_INTEGER )
14
+ * */
15
+ max?: number;
16
+ /**
17
+ * @description 加减的步长,可为小数 (默认 1 )
18
+ * */
19
+ step?: number;
20
+ /**
21
+ * @description 是否只允许输入整数 (默认 false )
22
+ * */
23
+ integer?: boolean;
24
+ /**
25
+ * @description 是否禁用,包括输入框,加减按钮 (默认 false )
26
+ * */
27
+ disabled?: boolean;
28
+ /**
29
+ * @description 是否禁用输入框 (默认 false )
30
+ * */
31
+ disabledInput?: boolean;
32
+ /**
33
+ * @description 是否开启异步变更,开启后需要手动控制输入值 (默认 false )
34
+ * */
35
+ asyncChange?: boolean;
36
+ /**
37
+ * @description 输入框宽度,单位为px (默认 35 )
38
+ * */
39
+ inputWidth?: number;
40
+ /**
41
+ * @description 是否显示减少按钮 (默认 true )
42
+ * */
43
+ showMinus?: boolean;
44
+ /**
45
+ * @description 是否显示增加按钮 (默认 true )
46
+ * */
47
+ showPlus?: boolean;
48
+ /**
49
+ * @description 显示的小数位数
50
+ * */
51
+ decimalLength?: number | null;
52
+ /**
53
+ * @description 是否开启长按加减手势 (默认 true )
54
+ * */
55
+ longPress?: boolean;
56
+ /**
57
+ * @description 输入框文字和加减按钮图标的颜色 (默认 '#323233' )
58
+ * */
59
+ color?: string;
60
+ /**
61
+ * @description 按钮宽度(默认 '30' )
62
+ * */
63
+ buttonWidth?: number | string;
64
+ /**
65
+ * @description 按钮大小,宽高等于此值,单位px,输入框高度和此值保持一致 (默认 30 )
66
+ * */
67
+ buttonSize?: number | string;
68
+ /**
69
+ * @description 按钮圆角 (默认 '0px' )
70
+ * */
71
+ buttonRadius?: number | string;
72
+ /**
73
+ * @description 输入框和按钮的背景颜色 (默认 '#EBECEE' )
74
+ * */
75
+ bgColor?: string;
76
+ /**
77
+ * @description 输入框背景颜色 (默认 '#EBECEE' )
78
+ * */
79
+ inputBgColor?: string;
80
+ /**
81
+ * @description 指定光标于键盘的距离,避免键盘遮挡输入框,单位px (默认 100 )
82
+ * */
83
+ cursorSpacing?: number;
84
+ /**
85
+ * @description 是否禁用减少按钮 (默认 false )
86
+ * */
87
+ disableMinus?: boolean;
88
+ /**
89
+ * @description 是否禁用增加按钮 (默认 false )
90
+ * */
91
+ disablePlus?: boolean;
92
+ /**
93
+ * @description 加减按钮图标的样式
94
+ * */
95
+ iconStyle?: CSSProperties;
96
+ /**
97
+ * @description 迷你模式(默认 false )
98
+ * */
99
+ miniMode?: boolean;
100
+ /**
101
+ * @description 定义需要用到的外部样式
102
+ * */
103
+ customStyle?: CSSProperties;
104
+ }
@@ -0,0 +1,54 @@
1
+ <template>
2
+ <HyTransition
3
+ :show="show"
4
+ custom-class="u-overlay"
5
+ :duration="duration"
6
+ :custom-style="overlayStyle"
7
+ @click="clickHandler"
8
+ >
9
+ <slot />
10
+ </HyTransition>
11
+ </template>
12
+
13
+ <script setup lang="ts">
14
+ import { computed, CSSProperties, toRefs } from "vue";
15
+ import defaultProps from "./props";
16
+ import IProps from "./typing";
17
+ import HyTransition from "../hy-transition/hy-transition.vue";
18
+
19
+ const props = withDefaults(defineProps<IProps>(), defaultProps);
20
+ const { customStyle, opacity, zIndex } = toRefs(props);
21
+ const emit = defineEmits(["click"]);
22
+
23
+ const overlayStyle = computed<CSSProperties>(() => {
24
+ const style: CSSProperties = {
25
+ position: "fixed",
26
+ top: 0,
27
+ left: 0,
28
+ right: 0,
29
+ zIndex: zIndex?.value,
30
+ bottom: 0,
31
+ "background-color": `rgba(0, 0, 0, ${opacity.value})`
32
+ };
33
+ return Object.assign(style, customStyle.value || {});
34
+ });
35
+ const clickHandler = () => {
36
+ emit("click");
37
+ };
38
+ </script>
39
+
40
+ <style lang="scss" scoped>
41
+ $u-overlay-top: 0 !default;
42
+ $u-overlay-left: 0 !default;
43
+ $u-overlay-width: 100% !default;
44
+ $u-overlay-height: 100% !default;
45
+ $u-overlay-background-color: rgba(0, 0, 0, 0.7) !default;
46
+ .u-overlay {
47
+ position: fixed;
48
+ top: $u-overlay-top;
49
+ left: $u-overlay-left;
50
+ width: $u-overlay-width;
51
+ height: $u-overlay-height;
52
+ background-color: $u-overlay-background-color;
53
+ }
54
+ </style>
@@ -0,0 +1,10 @@
1
+ import IProps from "./typing";
2
+
3
+ const defaultProps: IProps = {
4
+ show: false,
5
+ zIndex: 10070,
6
+ duration: 300,
7
+ opacity: 0.5
8
+ };
9
+
10
+ export default defaultProps;
@@ -0,0 +1,24 @@
1
+ import { CSSProperties } from "vue";
2
+
3
+ export default interface IProps {
4
+ /**
5
+ * @description 是否显示遮罩(默认 false )
6
+ * */
7
+ show: boolean;
8
+ /**
9
+ * @description zIndex 层级(默认 10070 )
10
+ * */
11
+ zIndex?: number;
12
+ /**
13
+ * @description 动画时长,单位毫秒(默认 300 )
14
+ * */
15
+ duration?: number;
16
+ /**
17
+ * @description 不透明度值,当做rgba的第四个参数 (默认 0.5 )
18
+ * */
19
+ opacity?: number;
20
+ /**
21
+ * @description 定义需要用到的外部样式
22
+ * */
23
+ customStyle?: CSSProperties;
24
+ }