hy-app 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/api/http.ts +8 -8
- package/components/dialog/index.ts +2 -2
- package/components/hy-address-picker/hy-address-picker.vue +3 -29
- package/components/hy-address-picker/index.scss +27 -0
- package/components/hy-avatar/hy-avatar.vue +1 -45
- package/components/hy-avatar/index.scss +45 -0
- package/components/hy-avatar/typing.d.ts +1 -1
- package/components/hy-back-top/hy-back-top.vue +7 -22
- package/components/hy-back-top/index.scss +16 -0
- package/components/hy-back-top/props.ts +4 -4
- package/components/hy-back-top/typing.d.ts +2 -3
- package/components/hy-badge/hy-badge.vue +1 -72
- package/components/hy-badge/index.scss +72 -0
- package/components/hy-button/hy-button.vue +17 -128
- package/components/hy-button/index.scss +116 -0
- package/components/hy-button/typing.d.ts +1 -1
- package/components/hy-calendar/header.vue +76 -0
- package/components/hy-calendar/hy-calendar.vue +366 -0
- package/components/hy-calendar/index.scss +171 -0
- package/components/hy-calendar/month.vue +524 -0
- package/components/hy-calendar/props.ts +37 -0
- package/components/hy-calendar/typing.d.ts +126 -0
- package/components/hy-card/hy-card.vue +21 -84
- package/components/hy-card/index.scss +57 -0
- package/components/hy-card/props.ts +2 -2
- package/components/hy-card/typing.d.ts +1 -1
- package/components/hy-cell/hy-cell.vue +1 -137
- package/components/hy-cell/index.scss +137 -0
- package/components/hy-check-button/hy-check-button.vue +1 -0
- package/components/hy-check-button/index.scss +5 -0
- package/components/hy-checkbox/hy-checkbox.vue +2 -95
- package/components/hy-checkbox/index.scss +94 -0
- package/components/hy-checkbox/typing.d.ts +1 -2
- package/components/hy-count-down/hy-count-down.vue +150 -0
- package/components/hy-count-down/index.scss +6 -0
- package/components/hy-count-down/index.ts +52 -0
- package/components/hy-count-down/props.ts +10 -0
- package/components/hy-count-down/typing.d.ts +20 -0
- package/components/hy-count-to/hy-count-to.vue +213 -0
- package/components/hy-count-to/index.scss +6 -0
- package/components/hy-count-to/props.ts +17 -0
- package/components/hy-count-to/typing.d.ts +48 -0
- package/components/hy-datetime-picker/hy-datetime-picker.vue +2 -28
- package/components/hy-datetime-picker/index.scss +28 -0
- package/components/hy-divider/hy-divider.vue +24 -49
- package/components/hy-divider/index.scss +26 -0
- package/components/hy-divider/props.ts +2 -2
- package/components/hy-divider/typing.d.ts +1 -1
- package/components/hy-dropdown/hy-dropdown.vue +43 -0
- package/components/hy-dropdown/index.scss +17 -0
- package/components/hy-dropdown/props.ts +17 -0
- package/components/hy-dropdown/typing.d.ts +48 -0
- package/components/hy-dropdown-item/hy-dropdown-item.vue +194 -0
- package/components/hy-dropdown-item/index.scss +96 -0
- package/components/hy-dropdown-item/props.ts +10 -0
- package/components/hy-dropdown-item/typing.d.ts +31 -0
- package/components/hy-empty/hy-empty.vue +8 -26
- package/components/hy-empty/index.scss +19 -0
- package/components/hy-empty/props.ts +2 -2
- package/components/hy-empty/typing.d.ts +1 -1
- package/components/hy-float-button/hy-float-button.vue +217 -0
- package/components/hy-float-button/index.scss +67 -0
- package/components/hy-float-button/props.ts +25 -0
- package/components/hy-float-button/typing.d.ts +93 -0
- package/components/hy-folding-panel/hy-folding-panel.vue +9 -12
- package/components/hy-folding-panel/index.scss +6 -0
- package/components/hy-folding-panel/props.ts +2 -2
- package/components/hy-folding-panel/typing.d.ts +2 -2
- package/components/hy-form/hy-form.vue +17 -34
- package/components/hy-form/index.scss +30 -0
- package/components/hy-form/props.ts +2 -0
- package/components/hy-form/typing.d.ts +9 -1
- package/components/hy-grid/hy-grid.vue +1 -43
- package/components/hy-grid/index.scss +40 -0
- package/components/hy-icon/hy-icon.vue +1 -93
- package/components/hy-icon/index.scss +84 -0
- package/components/hy-image/hy-image.vue +216 -0
- package/components/hy-image/index.scss +26 -0
- package/components/hy-image/props.ts +24 -0
- package/components/hy-image/typing.d.ts +76 -0
- package/components/hy-input/hy-input.vue +2 -72
- package/components/hy-input/index.scss +65 -0
- package/components/hy-line/hy-line.vue +4 -8
- package/components/hy-line/index.scss +5 -0
- package/components/hy-line/props.ts +3 -3
- package/components/hy-line/typing.d.ts +2 -2
- package/components/hy-line-progress/hy-line-progress.vue +15 -44
- package/components/hy-line-progress/index.scss +38 -0
- package/components/hy-line-progress/props.ts +2 -2
- package/components/hy-line-progress/typing.d.ts +1 -1
- package/components/hy-list/hy-list.vue +11 -41
- package/components/hy-list/index.scss +32 -0
- package/components/hy-list/props.ts +2 -2
- package/components/hy-loading/hy-loading.vue +95 -0
- package/components/hy-loading/index.scss +103 -0
- package/components/hy-loading/props.ts +17 -0
- package/components/hy-loading/typing.d.ts +53 -0
- package/components/hy-login/TheUserLogin.vue +20 -88
- package/components/hy-login/hy-login.vue +9 -9
- package/components/hy-login/props.ts +4 -4
- package/components/hy-modal/hy-modal.vue +11 -89
- package/components/hy-modal/index.scss +77 -0
- package/components/hy-modal/props.ts +2 -2
- package/components/hy-modal/typing.d.ts +1 -1
- package/components/hy-navbar/hy-navbar.vue +20 -92
- package/components/hy-navbar/index.scss +67 -0
- package/components/hy-navbar/props.ts +2 -2
- package/components/hy-navbar/typing.d.ts +1 -1
- package/components/hy-notice-bar/hy-column-notice.vue +11 -39
- package/components/hy-notice-bar/hy-notice-bar.vue +10 -12
- package/components/hy-notice-bar/hy-row-notice.vue +16 -58
- package/components/hy-notice-bar/index.scss +93 -0
- package/components/hy-notice-bar/props.ts +4 -2
- package/components/hy-notice-bar/typing.d.ts +13 -3
- package/components/hy-number-step/hy-number-step.vue +1 -70
- package/components/hy-number-step/index.scss +71 -0
- package/components/hy-overlay/hy-overlay.vue +2 -14
- package/components/hy-overlay/index.scss +9 -0
- package/components/hy-parse/hy-parse.vue +499 -0
- package/components/hy-parse/index.scss +9 -0
- package/components/hy-parse/node/node.vue +584 -0
- package/components/hy-parse/parser.js +1337 -0
- package/components/hy-parse/props.ts +19 -0
- package/components/hy-parse/typing.d.ts +68 -0
- package/components/hy-picker/hy-picker.vue +1 -68
- package/components/hy-picker/index.scss +68 -0
- package/components/hy-popup/hy-popup.vue +1 -74
- package/components/hy-popup/index.scss +60 -0
- package/components/hy-price/hy-price.vue +7 -19
- package/components/hy-price/index.scss +11 -0
- package/components/hy-price/props.ts +4 -3
- package/components/hy-price/typing.d.ts +8 -4
- package/components/hy-qrcode/hy-qrcode.vue +15 -37
- package/components/hy-qrcode/index.scss +23 -0
- package/components/hy-qrcode/props.ts +2 -2
- package/components/hy-qrcode/typing.d.ts +2 -2
- package/components/hy-radio/hy-radio.vue +2 -101
- package/components/hy-radio/index.scss +93 -0
- package/components/hy-radio/typing.d.ts +1 -2
- package/components/hy-rate/hy-rate.vue +1 -33
- package/components/hy-rate/index.scss +33 -0
- package/components/hy-read-more/hy-read-more.vue +7 -30
- package/components/hy-read-more/index.scss +25 -0
- package/components/hy-read-more/props.ts +3 -3
- package/components/hy-read-more/typing.d.ts +1 -1
- package/components/hy-safe-bottom/hy-safe-bottom.vue +5 -9
- package/components/hy-safe-bottom/index.scss +5 -0
- package/components/hy-scroll-list/hy-scroll-list.vue +13 -43
- package/components/hy-scroll-list/index.scss +34 -0
- package/components/hy-scroll-list/props.ts +2 -2
- package/components/hy-scroll-list/typing.d.ts +1 -1
- package/components/hy-search/hy-search.vue +1 -83
- package/components/hy-search/index.scss +83 -0
- package/components/hy-slider/hy-slider.vue +18 -95
- package/components/hy-slider/index.scss +77 -0
- package/components/hy-status-bar/hy-status-bar.vue +41 -0
- package/components/hy-status-bar/index.scss +6 -0
- package/components/hy-status-bar/props.ts +8 -0
- package/components/hy-status-bar/typing.d.ts +12 -0
- package/components/hy-steps/hy-steps.vue +36 -163
- package/components/hy-steps/index.scss +131 -0
- package/components/hy-steps/props.ts +2 -2
- package/components/hy-steps/typing.d.ts +2 -2
- package/components/hy-submitBar/Index.vue +17 -0
- package/components/hy-submitBar/hy-submitBar.vue +216 -0
- package/components/hy-submitBar/index.scss +9 -0
- package/components/hy-submitBar/props.ts +22 -0
- package/components/hy-submitBar/typing.d.ts +88 -0
- package/components/hy-subsection/hy-subsection.vue +40 -132
- package/components/hy-subsection/index.scss +82 -0
- package/components/hy-subsection/props.ts +1 -0
- package/components/hy-subsection/typing.d.ts +13 -4
- package/components/hy-swipe-action/hy-swipe-action.vue +294 -0
- package/components/hy-swipe-action/index.scss +9 -0
- package/components/hy-swipe-action/index.wxs +235 -0
- package/components/hy-swipe-action/props.ts +16 -0
- package/components/hy-swipe-action/typing.d.ts +55 -0
- package/components/hy-swipe-action/wxs.js +15 -0
- package/components/hy-swiper/hy-swiper-indicator.vue +5 -35
- package/components/hy-swiper/hy-swiper.vue +1 -54
- package/components/hy-swiper/index.scss +82 -0
- package/components/hy-switch/hy-switch.vue +62 -72
- package/components/hy-switch/index.scss +46 -0
- package/components/hy-switch/props.ts +4 -1
- package/components/hy-switch/typing.d.ts +14 -1
- package/components/hy-tabs/hy-tabs.vue +22 -81
- package/components/hy-tabs/index.scss +63 -0
- package/components/hy-tabs/props.ts +5 -5
- package/components/hy-tabs/typing.d.ts +1 -1
- package/components/hy-tag/hy-tag.vue +25 -220
- package/components/hy-tag/index.scss +205 -0
- package/components/hy-text/hy-text.vue +238 -0
- package/components/hy-text/index.scss +70 -0
- package/components/hy-text/index.ts +0 -0
- package/components/hy-text/props.ts +30 -0
- package/components/hy-text/typing.d.ts +98 -0
- package/components/hy-textarea/hy-textarea.vue +1 -46
- package/components/hy-textarea/index.scss +40 -0
- package/components/hy-toast/hy-toast.vue +175 -0
- package/components/hy-toast/index.scss +77 -0
- package/components/hy-toast/props.ts +3 -0
- package/components/hy-toast/typing.d.ts +38 -0
- package/components/hy-tooltip/hy-tooltip.vue +42 -95
- package/components/hy-tooltip/index.scss +64 -0
- package/components/hy-tooltip/props.ts +2 -2
- package/components/hy-tooltip/typing.d.ts +1 -1
- package/components/hy-transition/hy-transition.vue +4 -2
- package/components/hy-transition/typing.d.ts +1 -13
- package/components/hy-upload/hy-upload.vue +37 -182
- package/components/hy-upload/index.scss +147 -0
- package/components/hy-upload/props.ts +2 -2
- package/components/hy-upload/typing.d.ts +11 -11
- package/components/hy-warn/hy-warn.vue +17 -144
- package/components/hy-warn/index.scss +109 -0
- package/components/hy-warn/props.ts +3 -3
- package/components/hy-warn/typing.d.ts +4 -3
- package/components/hy-waterfall/hy-waterfall.vue +168 -38
- package/components/hy-waterfall/index.scss +16 -0
- package/components/hy-waterfall/props.ts +4 -5
- package/components/hy-waterfall/typing.d.ts +5 -9
- package/components/index.ts +25 -1
- package/components/message/index.ts +54 -54
- package/composables/index.ts +1 -0
- package/composables/useShare.ts +27 -0
- package/config/color.ts +3 -2
- package/config/icon.ts +21 -1
- package/global/index.ts +6 -6
- package/global/register-properties.ts +2 -2
- package/index.scss +2 -1
- package/index.ts +9 -8
- package/libs/css/common.scss +14 -2
- package/package.json +3 -2
- package/{libs/css → public/font}/iconfont.css +4 -4
- package/theme.scss +6 -4
- package/typing/index.ts +1 -1
- package/typing/modules/common.d.ts +36 -1
- package/utils/calendar.js +1021 -0
- package/utils/colorGradient.ts +112 -0
- package/utils/index.ts +2 -0
- package/utils/inside.ts +80 -34
- package/utils/inspect.ts +115 -0
- package/utils/utils.ts +20 -19
- package/libs/css/download.zip +0 -0
- /package/{libs/css → public/font}/iconfont.ttf +0 -0
- /package/{libs/css → public/font}/iconfont.woff +0 -0
- /package/{libs/css → public/font}/iconfont.woff2 +0 -0
|
@@ -0,0 +1,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>
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 此为wxs模块,只支持APP-VUE,微信和QQ小程序以及H5平台
|
|
3
|
+
* wxs内部不支持es6语法,变量只能使用var定义,无法使用解构,箭头函数等特性
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
// 开始触摸
|
|
8
|
+
function touchstart(event, ownerInstance) {
|
|
9
|
+
// 触发事件的组件的ComponentDescriptor实例
|
|
10
|
+
var instance = event.instance
|
|
11
|
+
// wxs内的局部变量快照,此快照是属于整个组件的,在touchstart和touchmove事件中都能获取到相同的结果
|
|
12
|
+
var state = instance.getState()
|
|
13
|
+
if (state.disabled) return
|
|
14
|
+
var touches = event.touches
|
|
15
|
+
// 如果进行的是多指触控,不允许进行操作
|
|
16
|
+
if (touches && touches.length > 1) return
|
|
17
|
+
// 标识当前为滑动中状态
|
|
18
|
+
state.moving = true
|
|
19
|
+
// 记录触摸开始点的坐标值
|
|
20
|
+
state.startX = touches[0].pageX
|
|
21
|
+
state.startY = touches[0].pageY
|
|
22
|
+
|
|
23
|
+
ownerInstance.callMethod('closeOther')
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 触摸滑动
|
|
27
|
+
function touchmove(event, ownerInstance) {
|
|
28
|
+
// 触发事件的组件的ComponentDescriptor实例
|
|
29
|
+
var instance = event.instance
|
|
30
|
+
// wxs内的局部变量快照
|
|
31
|
+
var state = instance.getState()
|
|
32
|
+
if (state.disabled || !state.moving) return
|
|
33
|
+
var touches = event.touches
|
|
34
|
+
var pageX = touches[0].pageX
|
|
35
|
+
var pageY = touches[0].pageY
|
|
36
|
+
var moveX = pageX - state.startX
|
|
37
|
+
var moveY = pageY - state.startY
|
|
38
|
+
var buttonsWidth = state.buttonsWidth
|
|
39
|
+
|
|
40
|
+
// 移动的X轴距离大于Y轴距离,也即终点与起点位置连线,与X轴夹角小于45度时,禁止页面滚动
|
|
41
|
+
if (Math.abs(moveX) > Math.abs(moveY) || Math.abs(moveX) > state.threshold) {
|
|
42
|
+
event.preventDefault && event.preventDefault()
|
|
43
|
+
event.stopPropagation && event.stopPropagation()
|
|
44
|
+
}
|
|
45
|
+
// 如果移动的X轴距离小于Y轴距离,也即终点位置与起点位置连线,与Y轴夹角小于45度时,认为是页面上下滑动,而不是左右滑动单元格
|
|
46
|
+
if (Math.abs(moveX) < Math.abs(moveY)) return
|
|
47
|
+
|
|
48
|
+
// 限制右滑的距离,不允许内容部分往右偏移,右滑会导致X轴偏移值大于0,以此做判断
|
|
49
|
+
// 此处不能直接return,因为滑动过程中会缺失某些关键点坐标,会导致错乱,最好的办法就是
|
|
50
|
+
// 在超出后,设置为0
|
|
51
|
+
if (state.status === 'open') {
|
|
52
|
+
// 在开启状态下,向左滑动,需忽略
|
|
53
|
+
if (moveX < 0) moveX = 0
|
|
54
|
+
// 想要收起菜单,最大能移动的距离为按钮的总宽度
|
|
55
|
+
if (moveX > buttonsWidth) moveX = buttonsWidth
|
|
56
|
+
// 如果是已经打开了的状态,向左滑动时,移动收起菜单
|
|
57
|
+
moveSwipeAction(-buttonsWidth + moveX, instance, ownerInstance)
|
|
58
|
+
} else {
|
|
59
|
+
// 关闭状态下,右滑动需忽略
|
|
60
|
+
if (moveX > 0) moveX = 0
|
|
61
|
+
// 滑动的距离不允许超过所有按钮的总宽度,此时只能是左滑,最终设置按钮的总宽度,同时为负数
|
|
62
|
+
if (Math.abs(moveX) > buttonsWidth) moveX = -buttonsWidth
|
|
63
|
+
// 只要是在滑过程中,就不断移动单元格内容部分,从而使隐藏的菜单显示出来
|
|
64
|
+
moveSwipeAction(moveX, instance, ownerInstance)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// 触摸结束
|
|
69
|
+
function touchend(event, ownerInstance) {
|
|
70
|
+
// 触发事件的组件的ComponentDescriptor实例
|
|
71
|
+
var instance = event.instance
|
|
72
|
+
// wxs内的局部变量快照
|
|
73
|
+
var state = instance.getState()
|
|
74
|
+
if (!state.moving || state.disabled) return
|
|
75
|
+
var touches = event.changedTouches ? event.changedTouches[0] : {}
|
|
76
|
+
var pageX = touches.pageX
|
|
77
|
+
var pageY = touches.pageY
|
|
78
|
+
var moveX = pageX - state.startX
|
|
79
|
+
if (state.status === 'open') {
|
|
80
|
+
// 在展开的状态下,继续左滑,无需操作
|
|
81
|
+
if (moveX < 0) return
|
|
82
|
+
// 在开启状态下,点击一下内容区域,moveX为0,也即没有进行移动,这时执行收起菜单逻辑
|
|
83
|
+
if (moveX === 0) {
|
|
84
|
+
return closeSwipeAction(instance, ownerInstance)
|
|
85
|
+
}
|
|
86
|
+
// 在开启状态下,滑动距离小于阈值,则默认为不关闭,同时恢复原来的打开状态
|
|
87
|
+
if (Math.abs(moveX) < state.threshold) {
|
|
88
|
+
openSwipeAction(instance, ownerInstance)
|
|
89
|
+
} else {
|
|
90
|
+
// 如果滑动距离大于阈值,则执行收起逻辑
|
|
91
|
+
closeSwipeAction(instance, ownerInstance)
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
// 在关闭的状态下,右滑,无需操作
|
|
95
|
+
if (moveX > 0) return
|
|
96
|
+
// 理由同上
|
|
97
|
+
if (Math.abs(moveX) < state.threshold) {
|
|
98
|
+
closeSwipeAction(instance, ownerInstance)
|
|
99
|
+
} else {
|
|
100
|
+
openSwipeAction(instance, ownerInstance)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// 获取过渡时间
|
|
106
|
+
function getDuration(value) {
|
|
107
|
+
if (value.toString().indexOf('s') >= 0) return value
|
|
108
|
+
return value > 30 ? value + 'ms' : value + 's'
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// 滑动结束时判断滑动的方向
|
|
112
|
+
function getMoveDirection(instance, ownerInstance) {
|
|
113
|
+
var state = instance.getState()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// 移动滑动选择器内容区域,同时显示出其隐藏的菜单
|
|
117
|
+
function moveSwipeAction(moveX, instance, ownerInstance) {
|
|
118
|
+
var state = instance.getState()
|
|
119
|
+
// 获取所有按钮的实例,需要通过它去设置按钮的位移
|
|
120
|
+
var buttons = ownerInstance.selectAllComponents('.hy-swipe-action-item__right__button')
|
|
121
|
+
|
|
122
|
+
// 设置菜单内容部分的偏移
|
|
123
|
+
instance.requestAnimationFrame(function() {
|
|
124
|
+
instance.setStyle({
|
|
125
|
+
// 设置translateX的值
|
|
126
|
+
'transition': 'none',
|
|
127
|
+
transform: 'translateX(' + moveX + 'px)',
|
|
128
|
+
'-webkit-transform': 'translateX(' + moveX + 'px)'
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// 一次性展开滑动菜单
|
|
134
|
+
function openSwipeAction(instance, ownerInstance) {
|
|
135
|
+
var state = instance.getState()
|
|
136
|
+
// 获取所有按钮的实例,需要通过它去设置按钮的位移
|
|
137
|
+
var buttons = ownerInstance.selectAllComponents('.hy-swipe-action-item__right__button')
|
|
138
|
+
// 处理duration单位问题
|
|
139
|
+
var duration = getDuration(state.duration)
|
|
140
|
+
// 展开过程中,是向左移动,所以X的偏移应该为负值
|
|
141
|
+
var buttonsWidth = -state.buttonsWidth
|
|
142
|
+
instance.requestAnimationFrame(function() {
|
|
143
|
+
// 设置菜单主体内容
|
|
144
|
+
instance.setStyle({
|
|
145
|
+
'transition': 'transform ' + duration,
|
|
146
|
+
'transform': 'translateX(' + buttonsWidth + 'px)',
|
|
147
|
+
'-webkit-transform': 'translateX(' + buttonsWidth + 'px)',
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
setStatus('open', instance, ownerInstance)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// 标记菜单的当前状态,open-已经打开,close-已经关闭
|
|
154
|
+
function setStatus(status, instance, ownerInstance) {
|
|
155
|
+
var state = instance.getState()
|
|
156
|
+
state.status = status
|
|
157
|
+
ownerInstance.callMethod('setState', status)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// 一次性收起滑动菜单
|
|
161
|
+
function closeSwipeAction(instance, ownerInstance) {
|
|
162
|
+
var state = instance.getState()
|
|
163
|
+
// 获取所有按钮的实例,需要通过它去设置按钮的位移
|
|
164
|
+
var buttons = ownerInstance.selectAllComponents('.hy-swipe-action-item__right__button')
|
|
165
|
+
var len = buttons.length
|
|
166
|
+
// 处理duration单位问题
|
|
167
|
+
var duration = getDuration(state.duration)
|
|
168
|
+
instance.requestAnimationFrame(function() {
|
|
169
|
+
// 设置菜单主体内容
|
|
170
|
+
instance.setStyle({
|
|
171
|
+
'transition': 'transform ' + duration,
|
|
172
|
+
'transform': 'translateX(0px)',
|
|
173
|
+
'-webkit-transform': 'translateX(0px)'
|
|
174
|
+
})
|
|
175
|
+
// 设置各个隐藏的按钮为收起的状态
|
|
176
|
+
for (var i = len - 1; i >= 0; i--) {
|
|
177
|
+
buttons[i].setStyle({
|
|
178
|
+
'transition': 'transform ' + duration,
|
|
179
|
+
'transform': 'translateX(0px)',
|
|
180
|
+
'-webkit-transform': 'translateX(0px)'
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
setStatus('close', instance, ownerInstance)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// status的状态发生变化
|
|
188
|
+
function statusChange(newValue, oldValue, ownerInstance, instance) {
|
|
189
|
+
var state = instance.getState()
|
|
190
|
+
if (state.disabled) return
|
|
191
|
+
// 打开或关闭单元格
|
|
192
|
+
if (newValue === 'close' && state.status === 'open') {
|
|
193
|
+
closeSwipeAction(instance, ownerInstance)
|
|
194
|
+
} else if(newValue === 'open' && state.status === 'close') {
|
|
195
|
+
openSwipeAction(instance, ownerInstance)
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// 菜单尺寸发生变化
|
|
200
|
+
function sizeChange(newValue, oldValue, ownerInstance, instance) {
|
|
201
|
+
// wxs内的局部变量快照
|
|
202
|
+
var state = instance.getState()
|
|
203
|
+
// 临时防止nv_disabled报错
|
|
204
|
+
if (!state || !newValue) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
state.disabled = newValue.disabled
|
|
208
|
+
state.duration = newValue.duration
|
|
209
|
+
state.show = newValue.show
|
|
210
|
+
state.threshold = newValue.threshold
|
|
211
|
+
state.buttons = newValue.buttons
|
|
212
|
+
|
|
213
|
+
if (state.buttons) {
|
|
214
|
+
var len = state.buttons.length
|
|
215
|
+
var buttonsWidth = 0
|
|
216
|
+
var buttons = newValue.buttons
|
|
217
|
+
for (var i = 0; i < len; i++) {
|
|
218
|
+
buttonsWidth += buttons[i].width
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
state.buttonsWidth = buttonsWidth
|
|
222
|
+
|
|
223
|
+
// 支持默认打开
|
|
224
|
+
if (state.show) {
|
|
225
|
+
openSwipeAction(instance, ownerInstance)
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
module.exports = {
|
|
230
|
+
touchstart: touchstart,
|
|
231
|
+
touchmove: touchmove,
|
|
232
|
+
touchend: touchend,
|
|
233
|
+
sizeChange: sizeChange,
|
|
234
|
+
statusChange: statusChange
|
|
235
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type IProps from "./typing";
|
|
2
|
+
|
|
3
|
+
const defaultProps: IProps = {
|
|
4
|
+
list: [],
|
|
5
|
+
show: false,
|
|
6
|
+
name: "",
|
|
7
|
+
key: "id",
|
|
8
|
+
disabled: false,
|
|
9
|
+
threshold: 20,
|
|
10
|
+
autoClose: true,
|
|
11
|
+
options: [{ text: "删除" }],
|
|
12
|
+
duration: 300,
|
|
13
|
+
closeOnClick: true,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default defaultProps;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { CSSProperties } from "vue";
|
|
2
|
+
|
|
3
|
+
interface SwipeActionOptionsVo {
|
|
4
|
+
text: string;
|
|
5
|
+
style?: CSSProperties;
|
|
6
|
+
icon?: string;
|
|
7
|
+
iconSize?: string | number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default interface IProps {
|
|
11
|
+
/**
|
|
12
|
+
* @description 数据列表
|
|
13
|
+
* */
|
|
14
|
+
list: Record<string, any>[];
|
|
15
|
+
/**
|
|
16
|
+
* @description 控制打开或者关闭(默认 false )
|
|
17
|
+
* */
|
|
18
|
+
show?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* @description 标识符,如果是v-for,可用index索引值
|
|
21
|
+
* */
|
|
22
|
+
name?: string;
|
|
23
|
+
/**
|
|
24
|
+
* @description 唯一键值
|
|
25
|
+
* */
|
|
26
|
+
key?: string;
|
|
27
|
+
/**
|
|
28
|
+
* @description 是否禁用(默认 false )
|
|
29
|
+
* */
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* @description 滑动距离阈值,只有大于此值,才被认为是要打开菜单(默认 30 )
|
|
33
|
+
* */
|
|
34
|
+
threshold?: number;
|
|
35
|
+
/**
|
|
36
|
+
* @description 是否自动关闭其他swipe按钮组(默认 true )
|
|
37
|
+
* */
|
|
38
|
+
autoClose?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* @description 右侧按钮内容
|
|
41
|
+
* */
|
|
42
|
+
options?: SwipeActionOptionsVo[];
|
|
43
|
+
/**
|
|
44
|
+
* @description 动画过渡时间,单位ms(默认 350 )
|
|
45
|
+
* */
|
|
46
|
+
duration?: number;
|
|
47
|
+
/**
|
|
48
|
+
* @description 是否关闭
|
|
49
|
+
* */
|
|
50
|
+
closeOnClick: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* @description 定义需要用到的外部样式
|
|
53
|
+
* */
|
|
54
|
+
customStyle?: CSSProperties;
|
|
55
|
+
}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
v-if="indicatorMode === 'line'"
|
|
5
5
|
:class="[
|
|
6
6
|
'hy-swiper-indicator__wrapper',
|
|
7
|
-
`hy-swiper-indicator__wrapper--${indicatorMode}
|
|
7
|
+
`hy-swiper-indicator__wrapper--${indicatorMode}`,
|
|
8
8
|
]"
|
|
9
9
|
:style="{
|
|
10
10
|
width: addUnit(lineWidth * length),
|
|
11
|
-
backgroundColor: indicatorInactiveColor
|
|
11
|
+
backgroundColor: indicatorInactiveColor,
|
|
12
12
|
}"
|
|
13
13
|
>
|
|
14
14
|
<view
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
v-for="(item, index) in length"
|
|
23
23
|
:key="index"
|
|
24
24
|
:class="[
|
|
25
|
-
index === current && 'hy-swiper-indicator__wrapper__dot--active'
|
|
25
|
+
index === current && 'hy-swiper-indicator__wrapper__dot--active',
|
|
26
26
|
]"
|
|
27
27
|
:style="[dotStyle(index)]"
|
|
28
28
|
>
|
|
@@ -52,7 +52,7 @@ const lineStyle = computed<CSSProperties>(() => {
|
|
|
52
52
|
let style: CSSProperties = {};
|
|
53
53
|
style.width = addUnit(lineWidth.value);
|
|
54
54
|
style.transform = `translateX(${addUnit(
|
|
55
|
-
Number(current.value) * lineWidth.value
|
|
55
|
+
Number(current.value) * lineWidth.value,
|
|
56
56
|
)})`;
|
|
57
57
|
style.backgroundColor = indicatorActiveColor.value;
|
|
58
58
|
return style;
|
|
@@ -71,35 +71,5 @@ const dotStyle = computed(() => {
|
|
|
71
71
|
</script>
|
|
72
72
|
|
|
73
73
|
<style lang="scss" scoped>
|
|
74
|
-
@import "
|
|
75
|
-
|
|
76
|
-
.hy-swiper-indicator {
|
|
77
|
-
&__wrapper {
|
|
78
|
-
@include flex;
|
|
79
|
-
|
|
80
|
-
&--line {
|
|
81
|
-
border-radius: 100px;
|
|
82
|
-
height: 4px;
|
|
83
|
-
|
|
84
|
-
&__bar {
|
|
85
|
-
width: 22px;
|
|
86
|
-
height: 4px;
|
|
87
|
-
border-radius: 100px;
|
|
88
|
-
background-color: #ffffff;
|
|
89
|
-
transition: transform 0.3s;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
&__dot {
|
|
94
|
-
width: 5px;
|
|
95
|
-
height: 5px;
|
|
96
|
-
border-radius: 100px;
|
|
97
|
-
margin: 0 4px;
|
|
98
|
-
|
|
99
|
-
&--active {
|
|
100
|
-
width: 12px;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
74
|
+
@import "./index.scss";
|
|
105
75
|
</style>
|