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
|
@@ -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>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
:style="{
|
|
5
5
|
backgroundColor: bgColor,
|
|
6
6
|
height: addUnit(height),
|
|
7
|
-
borderRadius: addUnit(radius)
|
|
7
|
+
borderRadius: addUnit(radius),
|
|
8
8
|
}"
|
|
9
9
|
>
|
|
10
10
|
<view class="hy-swiper__loading" v-if="loading">
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
class="hy-swiper__wrapper"
|
|
16
16
|
:style="{
|
|
17
17
|
flex: '1',
|
|
18
|
-
height: addUnit(height)
|
|
18
|
+
height: addUnit(height),
|
|
19
19
|
}"
|
|
20
20
|
@change="change"
|
|
21
21
|
:circular="circular"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
:previousMargin="addUnit(previousMargin)"
|
|
28
28
|
:nextMargin="addUnit(nextMargin)"
|
|
29
29
|
:acceleration="acceleration"
|
|
30
|
-
:displayMultipleItems="displayMultipleItems"
|
|
30
|
+
:displayMultipleItems="list.length > 0 ? displayMultipleItems : 0"
|
|
31
31
|
:easingFunction="easingFunction"
|
|
32
32
|
>
|
|
33
33
|
<swiper-item
|
|
@@ -36,7 +36,10 @@
|
|
|
36
36
|
:key="index"
|
|
37
37
|
>
|
|
38
38
|
<slot :record="item" :index="index">
|
|
39
|
-
<view
|
|
39
|
+
<view
|
|
40
|
+
class="hy-swiper__wrapper__item__wrapper"
|
|
41
|
+
:style="[itemStyle(index)]"
|
|
42
|
+
>
|
|
40
43
|
<!-- 在nvue中,image图片的宽度默认为屏幕宽度,需要通过flex:1撑开,另外必须设置高度才能显示图片 -->
|
|
41
44
|
<image
|
|
42
45
|
class="hy-swiper__wrapper__item__wrapper__image"
|
|
@@ -46,7 +49,7 @@
|
|
|
46
49
|
@tap="clickHandler(index)"
|
|
47
50
|
:style="{
|
|
48
51
|
height: addUnit(height),
|
|
49
|
-
borderRadius: addUnit(radius)
|
|
52
|
+
borderRadius: addUnit(radius),
|
|
50
53
|
}"
|
|
51
54
|
></image>
|
|
52
55
|
<video
|
|
@@ -58,7 +61,7 @@
|
|
|
58
61
|
:poster="getPoster(item)"
|
|
59
62
|
:title="showTitle && hasTitle(item)"
|
|
60
63
|
:style="{
|
|
61
|
-
height: addUnit(height)
|
|
64
|
+
height: addUnit(height),
|
|
62
65
|
}"
|
|
63
66
|
controls
|
|
64
67
|
@tap="clickHandler(index)"
|
|
@@ -89,16 +92,27 @@
|
|
|
89
92
|
</template>
|
|
90
93
|
|
|
91
94
|
<script setup lang="ts">
|
|
92
|
-
import {
|
|
95
|
+
import {
|
|
96
|
+
computed,
|
|
97
|
+
toRefs,
|
|
98
|
+
ref,
|
|
99
|
+
watch,
|
|
100
|
+
getCurrentInstance,
|
|
101
|
+
type CSSProperties,
|
|
102
|
+
} from "vue";
|
|
93
103
|
import { addUnit, isVideo } from "../../utils";
|
|
94
104
|
import defaultProps from "./props";
|
|
95
|
-
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
96
105
|
import { IconConfig } from "../../config";
|
|
97
|
-
import IProps
|
|
106
|
+
import type IProps from "./typing";
|
|
107
|
+
import type { SwiperVo } from "./typing";
|
|
108
|
+
|
|
109
|
+
// 组件
|
|
110
|
+
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
98
111
|
import HySwiperIndicator from "./hy-swiper-indicator.vue";
|
|
99
112
|
|
|
100
113
|
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
101
|
-
const { keyName, list, current } =
|
|
114
|
+
const { keyName, list, current, nextMargin, previousMargin, radius } =
|
|
115
|
+
toRefs(props);
|
|
102
116
|
const emit = defineEmits(["click", "update:current", "change"]);
|
|
103
117
|
|
|
104
118
|
const instance = getCurrentInstance();
|
|
@@ -108,7 +122,7 @@ watch(
|
|
|
108
122
|
() => current.value,
|
|
109
123
|
(newVal) => {
|
|
110
124
|
currentIndex.value = newVal;
|
|
111
|
-
}
|
|
125
|
+
},
|
|
112
126
|
);
|
|
113
127
|
|
|
114
128
|
const hasTitle = computed(() => {
|
|
@@ -120,6 +134,25 @@ const hasTitle = computed(() => {
|
|
|
120
134
|
}
|
|
121
135
|
};
|
|
122
136
|
});
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @description 轮播图3D效果
|
|
140
|
+
* */
|
|
141
|
+
const itemStyle = computed(() => {
|
|
142
|
+
return (index: number): CSSProperties => {
|
|
143
|
+
const style: CSSProperties = {};
|
|
144
|
+
// #ifndef APP-NVUE || MP-TOUTIAO
|
|
145
|
+
// 左右流出空间的写法不支持nvue和头条
|
|
146
|
+
// 只有配置了此二值,才加上对应的圆角,以及缩放
|
|
147
|
+
if (nextMargin.value && previousMargin.value) {
|
|
148
|
+
style.borderRadius = addUnit(radius.value);
|
|
149
|
+
if (index !== currentIndex.value) style.transform = "scale(0.92)";
|
|
150
|
+
}
|
|
151
|
+
// #endif
|
|
152
|
+
return style;
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
|
|
123
156
|
/**
|
|
124
157
|
* @description 获取目标路径,可能数组中为字符串,对象的形式,额外可指定对象的目标属性名keyName
|
|
125
158
|
* */
|
|
@@ -185,58 +218,5 @@ const getItemType = computed(() => {
|
|
|
185
218
|
</script>
|
|
186
219
|
|
|
187
220
|
<style lang="scss" scoped>
|
|
188
|
-
@import "
|
|
189
|
-
@import "../../theme.scss";
|
|
190
|
-
|
|
191
|
-
.hy-swiper__wrapper {
|
|
192
|
-
flex: 1;
|
|
193
|
-
}
|
|
194
|
-
.hy-swiper {
|
|
195
|
-
@include flex;
|
|
196
|
-
justify-content: center;
|
|
197
|
-
align-items: center;
|
|
198
|
-
position: relative;
|
|
199
|
-
overflow: hidden;
|
|
200
|
-
|
|
201
|
-
&__wrapper {
|
|
202
|
-
flex: 1;
|
|
203
|
-
|
|
204
|
-
&__item {
|
|
205
|
-
flex: 1;
|
|
206
|
-
|
|
207
|
-
&__wrapper {
|
|
208
|
-
@include flex;
|
|
209
|
-
position: relative;
|
|
210
|
-
overflow: hidden;
|
|
211
|
-
transition: transform 0.3s;
|
|
212
|
-
flex: 1;
|
|
213
|
-
|
|
214
|
-
&__image {
|
|
215
|
-
flex: 1;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
&__video {
|
|
219
|
-
flex: 1;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
&__title {
|
|
223
|
-
position: absolute;
|
|
224
|
-
background-color: rgba(0, 0, 0, 0.3);
|
|
225
|
-
bottom: 0;
|
|
226
|
-
left: 0;
|
|
227
|
-
right: 0;
|
|
228
|
-
font-size: 28rpx;
|
|
229
|
-
padding: $hy-border-margin-padding-sm $hy-border-margin-padding-lg;
|
|
230
|
-
color: #ffffff;
|
|
231
|
-
flex: 1;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
&__indicator {
|
|
238
|
-
position: absolute;
|
|
239
|
-
bottom: $hy-border-margin-padding-sm;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
221
|
+
@import "./index.scss";
|
|
242
222
|
</style>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
@use "../../theme.scss" as *;
|
|
2
|
+
@use "../../libs/css/mixin.scss" as *;
|
|
3
|
+
|
|
4
|
+
.hy-swiper {
|
|
5
|
+
@include flex;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
align-items: center;
|
|
8
|
+
position: relative;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
|
|
11
|
+
&__wrapper {
|
|
12
|
+
flex: 1;
|
|
13
|
+
|
|
14
|
+
&__item {
|
|
15
|
+
flex: 1;
|
|
16
|
+
|
|
17
|
+
&__wrapper {
|
|
18
|
+
@include flex;
|
|
19
|
+
position: relative;
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
transition: transform 0.3s;
|
|
22
|
+
flex: 1;
|
|
23
|
+
|
|
24
|
+
&__image {
|
|
25
|
+
flex: 1;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&__video {
|
|
29
|
+
flex: 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&__title {
|
|
33
|
+
position: absolute;
|
|
34
|
+
background-color: rgba(0, 0, 0, 0.3);
|
|
35
|
+
bottom: 0;
|
|
36
|
+
left: 0;
|
|
37
|
+
right: 0;
|
|
38
|
+
font-size: 28rpx;
|
|
39
|
+
padding: $hy-border-margin-padding-sm $hy-border-margin-padding-lg;
|
|
40
|
+
color: #ffffff;
|
|
41
|
+
flex: 1;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&__indicator {
|
|
48
|
+
position: absolute;
|
|
49
|
+
bottom: $hy-border-margin-padding-sm;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
.hy-swiper-indicator {
|
|
55
|
+
&__wrapper {
|
|
56
|
+
@include flex;
|
|
57
|
+
|
|
58
|
+
&--line {
|
|
59
|
+
border-radius: 100px;
|
|
60
|
+
height: 4px;
|
|
61
|
+
|
|
62
|
+
&__bar {
|
|
63
|
+
width: 22px;
|
|
64
|
+
height: 4px;
|
|
65
|
+
border-radius: $hy-border-radius-semicircle;
|
|
66
|
+
background-color: #ffffff;
|
|
67
|
+
transition: transform 0.3s;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&__dot {
|
|
72
|
+
width: 5px;
|
|
73
|
+
height: 5px;
|
|
74
|
+
border-radius: $hy-border-radius-semicircle;
|
|
75
|
+
margin: 0 $hy-border-margin-padding-sm;
|
|
76
|
+
|
|
77
|
+
&--active {
|
|
78
|
+
width: 12px;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import IProps from "./typing";
|
|
1
|
+
import type IProps from "./typing";
|
|
2
2
|
|
|
3
3
|
const defaultProps: IProps = {
|
|
4
|
-
list:
|
|
4
|
+
list: [],
|
|
5
5
|
indicator: false,
|
|
6
6
|
indicatorActiveColor: "#FFFFFF",
|
|
7
7
|
indicatorInactiveColor: "rgba(255, 255, 255, 0.35)",
|
|
@@ -24,7 +24,7 @@ const defaultProps: IProps = {
|
|
|
24
24
|
bgColor: "#f3f4f6",
|
|
25
25
|
radius: 4,
|
|
26
26
|
loading: false,
|
|
27
|
-
showTitle: false
|
|
27
|
+
showTitle: false,
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
export default defaultProps;
|