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
|
@@ -6,28 +6,31 @@
|
|
|
6
6
|
>
|
|
7
7
|
<view ref="hy-subsection__bar" :style="barStyle" :class="barClass"></view>
|
|
8
8
|
<view
|
|
9
|
-
:class="wrapperClass"
|
|
9
|
+
:class="wrapperClass(index)"
|
|
10
10
|
:ref="`hy-subsection__item--${index}`"
|
|
11
11
|
:style="itemStyle"
|
|
12
|
-
@tap="clickHandler(index)"
|
|
12
|
+
@tap="clickHandler(item, index)"
|
|
13
13
|
v-for="(item, index) in list"
|
|
14
14
|
:key="index"
|
|
15
15
|
>
|
|
16
16
|
<text class="hy-subsection__item__text" :style="[textStyle(index)]">{{
|
|
17
|
-
|
|
17
|
+
getName(item)
|
|
18
18
|
}}</text>
|
|
19
19
|
</view>
|
|
20
20
|
</view>
|
|
21
21
|
</template>
|
|
22
22
|
|
|
23
23
|
<script setup lang="ts">
|
|
24
|
-
import {
|
|
24
|
+
import {computed, toRefs, ref, onMounted, watch, getCurrentInstance} from "vue";
|
|
25
|
+
import type { CSSProperties } from "vue";
|
|
25
26
|
import defaultProps from "./props";
|
|
26
|
-
import IProps from "./typing";
|
|
27
|
-
import {
|
|
27
|
+
import type IProps from "./typing";
|
|
28
|
+
import type { SubSectionVo } from "./typing";
|
|
29
|
+
import { addUnit, getRect, guid } from "../../utils";
|
|
28
30
|
|
|
29
31
|
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
30
32
|
const {
|
|
33
|
+
modelValue,
|
|
31
34
|
current,
|
|
32
35
|
list,
|
|
33
36
|
mode,
|
|
@@ -36,16 +39,18 @@ const {
|
|
|
36
39
|
bold,
|
|
37
40
|
bgColor,
|
|
38
41
|
inactiveColor,
|
|
39
|
-
|
|
42
|
+
fieldNames,
|
|
40
43
|
} = toRefs(props);
|
|
41
|
-
const emit = defineEmits(["change"]);
|
|
44
|
+
const emit = defineEmits(["change", "update:modelValue"]);
|
|
42
45
|
|
|
46
|
+
const instance = getCurrentInstance();
|
|
43
47
|
// 组件尺寸
|
|
44
48
|
const itemRect = ref<UniApp.NodeInfo>({
|
|
45
49
|
width: 0,
|
|
46
|
-
height: 0
|
|
50
|
+
height: 0,
|
|
47
51
|
});
|
|
48
52
|
const innerCurrent = ref<number>(0);
|
|
53
|
+
const guidClass = guid();
|
|
49
54
|
|
|
50
55
|
/**
|
|
51
56
|
* @description 容器样式
|
|
@@ -62,15 +67,16 @@ const wrapperStyle = computed<CSSProperties>(() => {
|
|
|
62
67
|
* @description 容器类名
|
|
63
68
|
* */
|
|
64
69
|
const wrapperClass = computed(() => {
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"hy-subsection__item--no-border-right",
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
return (index: number) => {
|
|
71
|
+
return [
|
|
72
|
+
"hy-subsection__item",
|
|
73
|
+
"cursor-pointer",
|
|
74
|
+
`hy-subsection__item--${innerCurrent.value}__${guidClass}`,
|
|
75
|
+
index < list.value.length - 1 && "hy-subsection__item--no-border-right",
|
|
76
|
+
index === 0 && "hy-subsection__item--first",
|
|
77
|
+
index === list.value.length - 1 && "hy-subsection__item--last",
|
|
78
|
+
];
|
|
79
|
+
};
|
|
74
80
|
});
|
|
75
81
|
/**
|
|
76
82
|
* @description 滑块的样式
|
|
@@ -105,7 +111,7 @@ const barClass = computed(() => {
|
|
|
105
111
|
"hy-subsection__bar--center",
|
|
106
112
|
innerCurrent.value === list.value.length - 1 &&
|
|
107
113
|
mode.value === "subsection" &&
|
|
108
|
-
"hy-subsection__bar--last"
|
|
114
|
+
"hy-subsection__bar--last",
|
|
109
115
|
].filter(Boolean) as string[];
|
|
110
116
|
className = className.concat(className_2);
|
|
111
117
|
|
|
@@ -114,17 +120,15 @@ const barClass = computed(() => {
|
|
|
114
120
|
/**
|
|
115
121
|
* @description 分段器item的样式
|
|
116
122
|
* */
|
|
117
|
-
const itemStyle = computed(() => {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return style;
|
|
127
|
-
};
|
|
123
|
+
const itemStyle = computed<CSSProperties>(() => {
|
|
124
|
+
const style: CSSProperties = {};
|
|
125
|
+
if (mode.value === "subsection") {
|
|
126
|
+
// 设置border的样式
|
|
127
|
+
style.borderColor = activeColor.value;
|
|
128
|
+
style.borderWidth = "1px";
|
|
129
|
+
style.borderStyle = "solid";
|
|
130
|
+
}
|
|
131
|
+
return style;
|
|
128
132
|
});
|
|
129
133
|
/**
|
|
130
134
|
* @description 分段器文字颜色
|
|
@@ -155,118 +159,51 @@ onMounted(() => {
|
|
|
155
159
|
* @description 初始化
|
|
156
160
|
* */
|
|
157
161
|
const init = () => {
|
|
158
|
-
innerCurrent.value =
|
|
159
|
-
|
|
162
|
+
innerCurrent.value = list.value.findIndex((item: SubSectionVo) => {
|
|
163
|
+
if (typeof item === "string" || typeof item === "number") {
|
|
164
|
+
return item === modelValue.value;
|
|
165
|
+
} else {
|
|
166
|
+
return item[fieldNames.value.value] === modelValue.value;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// 设置默认值当没有找的时候导致样式问题
|
|
171
|
+
innerCurrent.value =
|
|
172
|
+
innerCurrent.value === -1 ? current.value : innerCurrent.value;
|
|
173
|
+
|
|
174
|
+
// TODO: 多个数组在一起计算宽度, 宽度不一样会有问题,所以必须加guidClass随机数
|
|
175
|
+
getRect(`.hy-subsection__item--0__${guidClass}`, false, instance).then((size) => {
|
|
160
176
|
itemRect.value = size as UniApp.NodeInfo;
|
|
161
177
|
});
|
|
162
178
|
};
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* @description 判断值
|
|
182
|
+
* */
|
|
183
|
+
const getValue = (item: SubSectionVo) => {
|
|
184
|
+
return typeof item === "object" ? item[fieldNames.value.value] : item;
|
|
185
|
+
};
|
|
186
|
+
|
|
163
187
|
/**
|
|
164
188
|
* @description 判断展示文本
|
|
165
189
|
* */
|
|
166
|
-
const
|
|
167
|
-
return typeof item === "object" ? item[
|
|
190
|
+
const getName = (item: SubSectionVo) => {
|
|
191
|
+
return typeof item === "object" ? item[fieldNames.value.label] : item;
|
|
168
192
|
};
|
|
193
|
+
|
|
169
194
|
/**
|
|
170
195
|
* @description 点击事件
|
|
171
196
|
* */
|
|
172
|
-
const clickHandler = (index: number) => {
|
|
197
|
+
const clickHandler = (temp: SubSectionVo, index: number) => {
|
|
173
198
|
// 值改变才触发
|
|
174
199
|
if (innerCurrent.value !== index) {
|
|
175
200
|
emit("change", index);
|
|
201
|
+
emit("update:modelValue", getValue(temp));
|
|
176
202
|
}
|
|
177
203
|
innerCurrent.value = index;
|
|
178
204
|
};
|
|
179
205
|
</script>
|
|
180
206
|
|
|
181
207
|
<style lang="scss" scoped>
|
|
182
|
-
@import "
|
|
183
|
-
|
|
184
|
-
.hy-subsection {
|
|
185
|
-
@include flex;
|
|
186
|
-
position: relative;
|
|
187
|
-
overflow: hidden;
|
|
188
|
-
/* #ifndef APP-NVUE */
|
|
189
|
-
width: 100%;
|
|
190
|
-
box-sizing: border-box;
|
|
191
|
-
/* #endif */
|
|
192
|
-
|
|
193
|
-
&--button {
|
|
194
|
-
height: 35px;
|
|
195
|
-
background-color: rgb(238, 238, 239);
|
|
196
|
-
padding: 3px;
|
|
197
|
-
border-radius: 4px;
|
|
198
|
-
align-items: stretch;
|
|
199
|
-
|
|
200
|
-
&__bar {
|
|
201
|
-
background-color: #ffffff;
|
|
202
|
-
border-radius: 4px !important;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
&--subsection {
|
|
207
|
-
height: 32px;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
&__bar {
|
|
211
|
-
position: absolute;
|
|
212
|
-
/* #ifndef APP-NVUE */
|
|
213
|
-
transition-property: transform, color;
|
|
214
|
-
transition-duration: 0.3s;
|
|
215
|
-
transition-timing-function: ease-in-out;
|
|
216
|
-
/* #endif */
|
|
217
|
-
|
|
218
|
-
&--first {
|
|
219
|
-
border-top-left-radius: 4px;
|
|
220
|
-
border-bottom-left-radius: 4px;
|
|
221
|
-
border-top-right-radius: 0px;
|
|
222
|
-
border-bottom-right-radius: 0px;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
&--center {
|
|
226
|
-
border-top-left-radius: 0px;
|
|
227
|
-
border-bottom-left-radius: 0px;
|
|
228
|
-
border-top-right-radius: 0px;
|
|
229
|
-
border-bottom-right-radius: 0px;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
&--last {
|
|
233
|
-
border-top-left-radius: 0px;
|
|
234
|
-
border-bottom-left-radius: 0px;
|
|
235
|
-
border-top-right-radius: 4px;
|
|
236
|
-
border-bottom-right-radius: 4px;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
&__item {
|
|
241
|
-
@include flex;
|
|
242
|
-
flex: 1;
|
|
243
|
-
justify-content: center;
|
|
244
|
-
align-items: center;
|
|
245
|
-
// vue环境下,需要设置相对定位,因为滑块为绝对定位,item需要在滑块的上面
|
|
246
|
-
position: relative;
|
|
247
|
-
|
|
248
|
-
&--no-border-right {
|
|
249
|
-
border-right-width: 0 !important;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
&--first {
|
|
253
|
-
border-top-left-radius: 4px;
|
|
254
|
-
border-bottom-left-radius: 4px;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
&--last {
|
|
258
|
-
border-top-right-radius: 4px;
|
|
259
|
-
border-bottom-right-radius: 4px;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
&__text {
|
|
263
|
-
font-size: 12px;
|
|
264
|
-
line-height: 14px;
|
|
265
|
-
@include flex;
|
|
266
|
-
align-items: center;
|
|
267
|
-
transition-property: color;
|
|
268
|
-
transition-duration: 0.3s;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
208
|
+
@import "./index.scss";
|
|
272
209
|
</style>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
@use "../../theme.scss" as *;
|
|
2
|
+
@use "../../libs/css/mixin.scss" as *;
|
|
3
|
+
|
|
4
|
+
.hy-subsection {
|
|
5
|
+
@include flex;
|
|
6
|
+
position: relative;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
/* #ifndef APP-NVUE */
|
|
9
|
+
width: 100%;
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
/* #endif */
|
|
12
|
+
|
|
13
|
+
&--button {
|
|
14
|
+
height: 35px;
|
|
15
|
+
background-color: rgb(238, 238, 239);
|
|
16
|
+
padding: 3px;
|
|
17
|
+
border-radius: $hy-border-radius-sm;
|
|
18
|
+
align-items: stretch;
|
|
19
|
+
|
|
20
|
+
&__bar {
|
|
21
|
+
background-color: #ffffff;
|
|
22
|
+
border-radius: $hy-border-radius-sm;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&--subsection {
|
|
27
|
+
height: 32px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&__bar {
|
|
31
|
+
position: absolute;
|
|
32
|
+
/* #ifndef APP-NVUE */
|
|
33
|
+
transition-property: transform, color;
|
|
34
|
+
transition-duration: 0.3s;
|
|
35
|
+
transition-timing-function: ease-in-out;
|
|
36
|
+
/* #endif */
|
|
37
|
+
|
|
38
|
+
&--first {
|
|
39
|
+
border-radius: $hy-border-radius-sm 0 0 $hy-border-radius-sm;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&--center {
|
|
43
|
+
border-radius: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&--last {
|
|
47
|
+
border-radius: 0 $hy-border-radius-sm $hy-border-radius-sm 0;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&__item {
|
|
52
|
+
@include flex;
|
|
53
|
+
flex: 1;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
align-items: center;
|
|
56
|
+
// vue环境下,需要设置相对定位,因为滑块为绝对定位,item需要在滑块的上面
|
|
57
|
+
position: relative;
|
|
58
|
+
|
|
59
|
+
&--no-border-right {
|
|
60
|
+
border-right-width: 0 !important;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&--first {
|
|
64
|
+
border-top-left-radius: $hy-border-radius-sm;
|
|
65
|
+
border-bottom-left-radius: $hy-border-radius-sm;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&--last {
|
|
69
|
+
border-top-right-radius: $hy-border-radius-sm;
|
|
70
|
+
border-bottom-right-radius: $hy-border-radius-sm;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&__text {
|
|
74
|
+
font-size: 12px;
|
|
75
|
+
line-height: 14px;
|
|
76
|
+
@include flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
transition-property: color;
|
|
79
|
+
transition-duration: 0.3s;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import IProps from "./typing";
|
|
1
|
+
import type IProps from "./typing";
|
|
2
2
|
import { ColorConfig } from "../../config";
|
|
3
3
|
|
|
4
4
|
const defaultProps: IProps = {
|
|
5
|
-
|
|
5
|
+
modelValue: "",
|
|
6
6
|
current: 0,
|
|
7
|
+
list: [],
|
|
8
|
+
fieldNames: {
|
|
9
|
+
label: "name",
|
|
10
|
+
value: "value",
|
|
11
|
+
},
|
|
7
12
|
activeColor: ColorConfig.success,
|
|
8
13
|
inactiveColor: "#303133",
|
|
9
14
|
mode: "button",
|
|
10
15
|
fontSize: 12,
|
|
11
16
|
bold: true,
|
|
12
17
|
bgColor: "#eeeeef",
|
|
13
|
-
keyName: "name"
|
|
14
18
|
};
|
|
15
19
|
|
|
16
20
|
export default defaultProps;
|
|
@@ -1,14 +1,30 @@
|
|
|
1
|
-
import { CSSProperties } from "vue";
|
|
1
|
+
import type { CSSProperties } from "vue";
|
|
2
|
+
import { HyApp } from "@/package/typing/modules/common";
|
|
3
|
+
|
|
4
|
+
export interface SubSectionItemVo extends HyApp.FieldNamesType {
|
|
5
|
+
name: string;
|
|
6
|
+
value: string | number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type SubSectionVo = string | number | SubSectionItemVo;
|
|
2
10
|
|
|
3
11
|
export default interface IProps {
|
|
4
12
|
/**
|
|
5
|
-
* @description
|
|
13
|
+
* @description 接收值
|
|
6
14
|
* */
|
|
7
|
-
|
|
15
|
+
modelValue: string | number;
|
|
8
16
|
/**
|
|
9
|
-
* @description
|
|
17
|
+
* @description 默认值 (默认0)
|
|
10
18
|
* */
|
|
11
19
|
current?: number;
|
|
20
|
+
/**
|
|
21
|
+
* @description tab的数据
|
|
22
|
+
* */
|
|
23
|
+
list: SubSectionVo[];
|
|
24
|
+
/**
|
|
25
|
+
* @description list的键值
|
|
26
|
+
* */
|
|
27
|
+
fieldNames?: HyApp.IFieldNames;
|
|
12
28
|
/**
|
|
13
29
|
* @description 激活时的颜色(默认 '#3c9cff' )
|
|
14
30
|
* */
|
|
@@ -33,10 +49,6 @@ export default interface IProps {
|
|
|
33
49
|
* @description 组件背景颜色,mode为button时有效(默认 '#eeeeef' )
|
|
34
50
|
* */
|
|
35
51
|
bgColor?: string;
|
|
36
|
-
/**
|
|
37
|
-
* @description 从`list`元素对象中读取的键名(默认 'name' )
|
|
38
|
-
* */
|
|
39
|
-
keyName?: string;
|
|
40
52
|
/**
|
|
41
53
|
* @description 定义需要用到的外部样式
|
|
42
54
|
* */
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="hy-swipe-action" :style="customStyle">
|
|
3
|
+
<template
|
|
4
|
+
v-for="(fatherItem, fatherI) in swipeActionList"
|
|
5
|
+
:key="fatherItem?.[key] || fatherI"
|
|
6
|
+
>
|
|
7
|
+
<view class="u-swipe-action-item" ref="u-swipe-action-item">
|
|
8
|
+
<!-- 右侧操作按钮 -->
|
|
9
|
+
<view class="u-swipe-action-item__right">
|
|
10
|
+
<slot name="button">
|
|
11
|
+
<view
|
|
12
|
+
v-for="(item, index) in options"
|
|
13
|
+
:key="index"
|
|
14
|
+
class="u-swipe-action-item__right__button"
|
|
15
|
+
:ref="`u-swipe-action-item__right__button-${index}`"
|
|
16
|
+
:style="{
|
|
17
|
+
alignItems: item?.style?.borderRadius ? 'center' : 'stretch',
|
|
18
|
+
}"
|
|
19
|
+
@tap="buttonClickHandler(item, index, fatherI)"
|
|
20
|
+
>
|
|
21
|
+
<view
|
|
22
|
+
class="u-swipe-action-item__right__button__wrapper"
|
|
23
|
+
:style="operateItemStyle(item?.style)"
|
|
24
|
+
>
|
|
25
|
+
<u-icon
|
|
26
|
+
v-if="item.icon"
|
|
27
|
+
:name="item.icon"
|
|
28
|
+
:color="item?.style?.color || '#ffffff'"
|
|
29
|
+
:size="
|
|
30
|
+
item.iconSize
|
|
31
|
+
? addUnit(item.iconSize)
|
|
32
|
+
: item.style && item.style.fontSize
|
|
33
|
+
? getPx(item.style.fontSize) * 1.2
|
|
34
|
+
: 17
|
|
35
|
+
"
|
|
36
|
+
:customStyle="{
|
|
37
|
+
marginRight: item.text ? '2px' : 0,
|
|
38
|
+
}"
|
|
39
|
+
></u-icon>
|
|
40
|
+
<text
|
|
41
|
+
v-if="item.text"
|
|
42
|
+
class="u-swipe-action-item__right__button__wrapper__text u-line-1"
|
|
43
|
+
:style="operateTextStyle(item?.style)"
|
|
44
|
+
>{{ item.text }}</text
|
|
45
|
+
>
|
|
46
|
+
</view>
|
|
47
|
+
</view>
|
|
48
|
+
</slot>
|
|
49
|
+
</view>
|
|
50
|
+
<!-- 右侧操作按钮 -->
|
|
51
|
+
|
|
52
|
+
<!-- 左侧内容 -->
|
|
53
|
+
<!-- #ifdef APP-VUE || MP-WEIXIN || MP-QQ || H5 -->
|
|
54
|
+
<view
|
|
55
|
+
class="u-swipe-action-item__content"
|
|
56
|
+
@touchstart="wxs.touchstart"
|
|
57
|
+
@touchmove="wxs.touchmove"
|
|
58
|
+
@touchend="wxs.touchend"
|
|
59
|
+
:status="fatherItem.status"
|
|
60
|
+
:change:status="wxs.statusChange"
|
|
61
|
+
:size="size"
|
|
62
|
+
:change:size="wxs.sizeChange"
|
|
63
|
+
>
|
|
64
|
+
<slot :record="fatherItem"> </slot>
|
|
65
|
+
</view>
|
|
66
|
+
<!-- #endif -->
|
|
67
|
+
<!-- 左侧内容 -->
|
|
68
|
+
</view>
|
|
69
|
+
</template>
|
|
70
|
+
</view>
|
|
71
|
+
</template>
|
|
72
|
+
<!-- #ifdef APP-VUE || MP-WEIXIN || MP-QQ || H5 -->
|
|
73
|
+
<script src="./index.wxs" module="wxs" lang="wxs"></script>
|
|
74
|
+
<!-- #endif -->
|
|
75
|
+
|
|
76
|
+
<script setup lang="ts">
|
|
77
|
+
import type IProps from "./typing";
|
|
78
|
+
import defaultProps from "./props";
|
|
79
|
+
import {
|
|
80
|
+
computed,
|
|
81
|
+
type CSSProperties,
|
|
82
|
+
onMounted,
|
|
83
|
+
ref,
|
|
84
|
+
toRefs,
|
|
85
|
+
watch,
|
|
86
|
+
} from "vue";
|
|
87
|
+
// #ifdef APP-VUE || MP-WEIXIN || MP-QQ || H5
|
|
88
|
+
import { getRect, sleep, addUnit, getPx } from "@/package";
|
|
89
|
+
// #endif
|
|
90
|
+
|
|
91
|
+
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
92
|
+
const {
|
|
93
|
+
list,
|
|
94
|
+
show,
|
|
95
|
+
disabled,
|
|
96
|
+
autoClose,
|
|
97
|
+
threshold,
|
|
98
|
+
options,
|
|
99
|
+
duration,
|
|
100
|
+
closeOnClick,
|
|
101
|
+
} = toRefs(props);
|
|
102
|
+
const emit = defineEmits(["update:show", "click"]);
|
|
103
|
+
|
|
104
|
+
type OpenStatus = "open" | "close" | "";
|
|
105
|
+
|
|
106
|
+
// 按钮的尺寸信息
|
|
107
|
+
const size = ref({});
|
|
108
|
+
const sliderStyle = ref({});
|
|
109
|
+
const swipeActionList = ref<AnyObject[]>([]);
|
|
110
|
+
|
|
111
|
+
watch(
|
|
112
|
+
() => list.value,
|
|
113
|
+
(newValue) => {
|
|
114
|
+
swipeActionList.value = newValue.map((item) => ({
|
|
115
|
+
...item,
|
|
116
|
+
status: "close",
|
|
117
|
+
}));
|
|
118
|
+
},
|
|
119
|
+
{ immediate: true },
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const operateTextStyle = computed(() => {
|
|
123
|
+
return (temp?: CSSProperties): CSSProperties => {
|
|
124
|
+
return {
|
|
125
|
+
color: temp?.color || "#ffffff",
|
|
126
|
+
fontSize: temp?.fontSize || "16px",
|
|
127
|
+
lineHeight: temp?.fontSize || "16px",
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const operateItemStyle = computed(() => {
|
|
133
|
+
return (temp?: CSSProperties): CSSProperties => {
|
|
134
|
+
return {
|
|
135
|
+
backgroundColor: temp?.backgroundColor || "#C7C6CD",
|
|
136
|
+
borderRadius: temp?.borderRadius || "0",
|
|
137
|
+
padding: temp?.borderRadius ? 0 : "0 15px",
|
|
138
|
+
...temp,
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const wxsInit = computed(() => {
|
|
144
|
+
return [
|
|
145
|
+
disabled.value,
|
|
146
|
+
autoClose.value,
|
|
147
|
+
threshold.value,
|
|
148
|
+
options.value,
|
|
149
|
+
duration.value,
|
|
150
|
+
];
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @description 查询节点
|
|
155
|
+
* */
|
|
156
|
+
const queryRect = () => {
|
|
157
|
+
getRect(".u-swipe-action-item__right__button", true).then((buttons) => {
|
|
158
|
+
size.value = {
|
|
159
|
+
buttons,
|
|
160
|
+
show: show.value,
|
|
161
|
+
disabled: disabled.value,
|
|
162
|
+
threshold: threshold.value,
|
|
163
|
+
duration: duration.value,
|
|
164
|
+
};
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
watch(
|
|
169
|
+
() => wxsInit.value,
|
|
170
|
+
() => queryRect(),
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
// watch(
|
|
174
|
+
// () => status.value,
|
|
175
|
+
// (newValue: OpenStatus) => {
|
|
176
|
+
// if (newValue === "open") {
|
|
177
|
+
// emit("update:show", true);
|
|
178
|
+
// } else {
|
|
179
|
+
// emit("update:show", false);
|
|
180
|
+
// }
|
|
181
|
+
// },
|
|
182
|
+
// );
|
|
183
|
+
//
|
|
184
|
+
// watch(
|
|
185
|
+
// () => show.value,
|
|
186
|
+
// (newValue: boolean) => {
|
|
187
|
+
// if (newValue) {
|
|
188
|
+
// status.value = "open";
|
|
189
|
+
// } else {
|
|
190
|
+
// status.value = "close";
|
|
191
|
+
// }
|
|
192
|
+
// },
|
|
193
|
+
// );
|
|
194
|
+
|
|
195
|
+
onMounted(() => {
|
|
196
|
+
init();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
const init = () => {
|
|
200
|
+
// 初始化父组件数据
|
|
201
|
+
updateParentData();
|
|
202
|
+
// #ifndef APP-NVUE
|
|
203
|
+
sleep().then(() => {
|
|
204
|
+
queryRect();
|
|
205
|
+
});
|
|
206
|
+
// #endif
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const updateParentData = () => {
|
|
210
|
+
// 此方法在mixin中
|
|
211
|
+
// getParentData("u-swipe-action");
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* @description 按钮被点击
|
|
216
|
+
*/
|
|
217
|
+
const buttonClickHandler = (
|
|
218
|
+
item: AnyObject,
|
|
219
|
+
index: number,
|
|
220
|
+
fatherI: number,
|
|
221
|
+
) => {
|
|
222
|
+
emit(
|
|
223
|
+
"click",
|
|
224
|
+
{
|
|
225
|
+
item,
|
|
226
|
+
index,
|
|
227
|
+
},
|
|
228
|
+
() => {},
|
|
229
|
+
);
|
|
230
|
+
if (closeOnClick.value) {
|
|
231
|
+
closeHandler(fatherI);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* @description 关闭时执行
|
|
237
|
+
* */
|
|
238
|
+
const closeHandler = (index: number) => {
|
|
239
|
+
swipeActionList.value = swipeActionList.value.map((item, i) => ({
|
|
240
|
+
...item,
|
|
241
|
+
status: i === index ? "close" : "open",
|
|
242
|
+
}));
|
|
243
|
+
console.log(swipeActionList.value);
|
|
244
|
+
};
|
|
245
|
+
</script>
|
|
246
|
+
|
|
247
|
+
<style lang="scss" scoped>
|
|
248
|
+
@import "../../libs/css/mixin.scss";
|
|
249
|
+
|
|
250
|
+
.u-swipe-action-item {
|
|
251
|
+
position: relative;
|
|
252
|
+
overflow: hidden;
|
|
253
|
+
/* #ifndef APP-NVUE || MP-WEIXIN */
|
|
254
|
+
touch-action: pan-y;
|
|
255
|
+
/* #endif */
|
|
256
|
+
|
|
257
|
+
&__content {
|
|
258
|
+
transform: translateX(0px); // 修复某些情况下默认右侧按钮是展开的问题
|
|
259
|
+
background-color: #ffffff;
|
|
260
|
+
z-index: 10;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
&__right {
|
|
264
|
+
position: absolute;
|
|
265
|
+
top: 0;
|
|
266
|
+
bottom: 0;
|
|
267
|
+
right: 0;
|
|
268
|
+
@include flex;
|
|
269
|
+
|
|
270
|
+
&__button {
|
|
271
|
+
@include flex;
|
|
272
|
+
justify-content: center;
|
|
273
|
+
overflow: hidden;
|
|
274
|
+
align-items: center;
|
|
275
|
+
|
|
276
|
+
&__wrapper {
|
|
277
|
+
@include flex;
|
|
278
|
+
align-items: center;
|
|
279
|
+
justify-content: center;
|
|
280
|
+
padding: 0 15px;
|
|
281
|
+
|
|
282
|
+
&__text {
|
|
283
|
+
@include flex;
|
|
284
|
+
align-items: center;
|
|
285
|
+
color: #ffffff;
|
|
286
|
+
font-size: 15px;
|
|
287
|
+
text-align: center;
|
|
288
|
+
justify-content: center;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
</style>
|