hy-app 0.4.13 → 0.5.0
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/components/hy-action-sheet/hy-action-sheet.vue +155 -238
- package/components/hy-action-sheet/props.ts +68 -15
- package/components/hy-action-sheet/typing.d.ts +115 -115
- package/components/hy-address-picker/hy-address-picker.vue +185 -289
- package/components/hy-address-picker/props.ts +97 -21
- package/components/hy-address-picker/typing.d.ts +90 -89
- package/components/hy-avatar/hy-avatar.vue +121 -204
- package/components/hy-avatar/props.ts +76 -18
- package/components/hy-avatar/typing.d.ts +63 -62
- package/components/hy-back-top/hy-back-top.vue +65 -120
- package/components/hy-back-top/props.ts +57 -16
- package/components/hy-back-top/typing.d.ts +43 -42
- package/components/hy-badge/hy-badge.vue +66 -138
- package/components/hy-badge/props.ts +73 -17
- package/components/hy-badge/typing.d.ts +59 -58
- package/components/hy-button/hy-button.vue +226 -375
- package/components/hy-button/props.ts +129 -158
- package/components/hy-calendar/header.vue +48 -64
- package/components/hy-calendar/hy-calendar.vue +274 -438
- package/components/hy-calendar/month.vue +508 -516
- package/components/hy-calendar/props.ts +157 -35
- package/components/hy-calendar/typing.d.ts +129 -128
- package/components/hy-card/hy-card.vue +118 -240
- package/components/hy-card/index.scss +1 -2
- package/components/hy-card/props.ts +122 -27
- package/components/hy-card/typing.d.ts +119 -118
- package/components/hy-cell/hy-cell.vue +176 -258
- package/components/hy-cell/props.ts +71 -17
- package/components/hy-cell/typing.d.ts +87 -86
- package/components/hy-check-button/hy-check-button.vue +69 -139
- package/components/hy-check-button/props.ts +72 -18
- package/components/hy-check-button/typing.d.ts +74 -73
- package/components/hy-checkbox/hy-checkbox.vue +170 -263
- package/components/hy-checkbox/props.ts +94 -24
- package/components/hy-checkbox/typing.d.ts +72 -72
- package/components/hy-checkbox-group/hy-checkbox-group.vue +25 -100
- package/components/hy-checkbox-group/props.ts +80 -0
- package/components/hy-checkbox-group/typing.d.ts +65 -65
- package/components/hy-checkbox-item/hy-checkbox-item.vue +140 -177
- package/components/hy-checkbox-item/props.ts +24 -0
- package/components/hy-checkbox-item/typing.d.ts +4 -3
- package/components/hy-code-input/hy-code-input.vue +179 -262
- package/components/hy-code-input/props.ts +84 -18
- package/components/hy-code-input/typing.d.ts +71 -71
- package/components/hy-config-provider/hy-config-provider.vue +28 -50
- package/components/hy-config-provider/props.ts +26 -11
- package/components/hy-config-provider/typing.d.ts +20 -20
- package/components/hy-count-down/hy-count-down.vue +103 -131
- package/components/hy-count-down/props.ts +30 -8
- package/components/hy-count-down/typing.d.ts +25 -25
- package/components/hy-count-to/hy-count-to.vue +148 -213
- package/components/hy-count-to/props.ts +60 -15
- package/components/hy-count-to/typing.d.ts +46 -46
- package/components/hy-coupon/README.md +133 -0
- package/components/hy-coupon/hy-coupon.vue +180 -0
- package/components/hy-coupon/index.scss +553 -0
- package/components/hy-coupon/props.ts +129 -0
- package/components/hy-coupon/typing.d.ts +146 -0
- package/components/hy-datetime-picker/hy-datetime-picker.vue +415 -580
- package/components/hy-datetime-picker/props.ts +142 -32
- package/components/hy-datetime-picker/typing.d.ts +132 -132
- package/components/hy-divider/hy-divider.vue +90 -169
- package/components/hy-divider/props.ts +78 -19
- package/components/hy-divider/typing.d.ts +60 -60
- package/components/hy-dropdown/hy-dropdown.vue +37 -71
- package/components/hy-dropdown/props.ts +38 -15
- package/components/hy-dropdown/typing.d.ts +44 -44
- package/components/hy-dropdown-item/hy-dropdown-item.vue +141 -173
- package/components/hy-dropdown-item/props.ts +19 -8
- package/components/hy-empty/hy-empty.vue +75 -129
- package/components/hy-empty/props.ts +57 -15
- package/components/hy-empty/typing.d.ts +84 -84
- package/components/hy-flex/hy-flex.vue +33 -88
- package/components/hy-flex/props.ts +58 -0
- package/components/hy-flex/typing.d.ts +14 -16
- package/components/hy-float-button/hy-float-button.vue +289 -406
- package/components/hy-float-button/props.ts +109 -25
- package/components/hy-folding-panel/hy-folding-panel.vue +86 -374
- package/components/hy-folding-panel/props.ts +40 -15
- package/components/hy-folding-panel/typing.d.ts +52 -63
- package/components/hy-folding-panel-item/hy-folding-panel-item.vue +186 -228
- package/components/hy-folding-panel-item/index.scss +87 -0
- package/components/hy-folding-panel-item/props.ts +81 -0
- package/components/hy-folding-panel-item/typing.d.ts +23 -0
- package/components/hy-form/hy-form.vue +172 -212
- package/components/hy-form/props.ts +37 -0
- package/components/hy-form/typing.d.ts +68 -61
- package/components/hy-form-group/typing.d.ts +74 -74
- package/components/hy-form-item/hy-form-item.vue +100 -129
- package/components/hy-form-item/props.ts +25 -0
- package/components/hy-form-item/typing.d.ts +40 -37
- package/components/hy-grid/hy-grid.vue +76 -132
- package/components/hy-grid/props.ts +58 -16
- package/components/hy-grid/typing.d.ts +66 -66
- package/components/hy-icon/hy-icon.vue +84 -161
- package/components/hy-icon/props.ts +76 -22
- package/components/hy-icon/typing.d.ts +83 -82
- package/components/hy-image/hy-image.vue +142 -272
- package/components/hy-image/props.ts +105 -23
- package/components/hy-image/typing.d.ts +84 -87
- package/components/hy-input/hy-input.vue +230 -421
- package/components/hy-input/props.ts +183 -35
- package/components/hy-input/typing.d.ts +169 -169
- package/components/hy-line/hy-line.vue +34 -72
- package/components/hy-line/props.ts +41 -10
- package/components/hy-line/typing.d.ts +29 -29
- package/components/hy-line-progress/hy-line-progress.vue +66 -101
- package/components/hy-line-progress/props.ts +31 -10
- package/components/hy-line-progress/typing.d.ts +29 -29
- package/components/hy-list/hy-list.vue +151 -220
- package/components/hy-list/props.ts +67 -16
- package/components/hy-list/typing.d.ts +52 -52
- package/components/hy-loading/hy-loading.vue +63 -119
- package/components/hy-loading/props.ts +63 -15
- package/components/hy-loading/typing.d.ts +49 -49
- package/components/hy-menu/hy-menu.vue +124 -166
- package/components/hy-menu/props.ts +42 -10
- package/components/hy-menu/typing.d.ts +60 -60
- package/components/hy-modal/hy-modal.vue +127 -218
- package/components/hy-modal/props.ts +89 -24
- package/components/hy-navbar/hy-navbar.vue +104 -177
- package/components/hy-navbar/props.ts +76 -22
- package/components/hy-navbar/typing.d.ts +81 -81
- package/components/hy-notice-bar/hy-notice-bar.vue +67 -144
- package/components/hy-notice-bar/props.ts +80 -19
- package/components/hy-notice-bar/typing.d.ts +62 -62
- package/components/hy-notify/hy-notify.vue +128 -177
- package/components/hy-notify/props.ts +49 -12
- package/components/hy-notify/typing.d.ts +45 -41
- package/components/hy-number-step/hy-number-step.vue +281 -394
- package/components/hy-number-step/props.ts +110 -27
- package/components/hy-number-step/typing.d.ts +120 -120
- package/components/hy-overlay/hy-overlay.vue +39 -66
- package/components/hy-overlay/props.ts +31 -8
- package/components/hy-pagination/hy-pagination.vue +100 -155
- package/components/hy-pagination/props.ts +53 -13
- package/components/hy-picker/hy-picker.vue +309 -430
- package/components/hy-picker/index.scss +8 -12
- package/components/hy-picker/props.ts +110 -26
- package/components/hy-popover/hy-popover.vue +190 -252
- package/components/hy-popover/props.ts +48 -10
- package/components/hy-popup/hy-popup.vue +162 -248
- package/components/hy-popup/props.ts +82 -18
- package/components/hy-price/hy-price.vue +45 -104
- package/components/hy-price/props.ts +52 -12
- package/components/hy-price/typing.d.ts +41 -36
- package/components/hy-qrcode/hy-qrcode.vue +115 -185
- package/components/hy-qrcode/props.ts +68 -18
- package/components/hy-qrcode/typing.d.ts +67 -66
- package/components/hy-radio/hy-radio.vue +161 -259
- package/components/hy-radio/props.ts +95 -25
- package/components/hy-radio/typing.d.ts +85 -84
- package/components/hy-rate/hy-rate.vue +185 -270
- package/components/hy-rate/props.ts +76 -18
- package/components/hy-rate/typing.d.ts +61 -60
- package/components/hy-read-more/hy-read-more.vue +93 -136
- package/components/hy-read-more/props.ts +43 -13
- package/components/hy-scroll-list/hy-scroll-list.vue +81 -102
- package/components/hy-scroll-list/props.ts +22 -11
- package/components/hy-search/hy-search.vue +155 -284
- package/components/hy-search/props.ts +130 -25
- package/components/hy-signature/hy-signature.vue +491 -635
- package/components/hy-signature/props.ts +115 -26
- package/components/hy-signature/typing.d.ts +138 -138
- package/components/hy-slider/hy-slider.vue +388 -477
- package/components/hy-slider/props.ts +75 -19
- package/components/hy-steps/hy-steps.vue +212 -279
- package/components/hy-steps/props.ts +47 -13
- package/components/hy-submit-bar/hy-submit-bar.vue +137 -222
- package/components/hy-submit-bar/props.ts +89 -20
- package/components/hy-submit-bar/typing.d.ts +86 -85
- package/components/hy-subsection/hy-subsection.vue +132 -185
- package/components/hy-subsection/props.ts +50 -17
- package/components/hy-subsection/typing.d.ts +52 -52
- package/components/hy-swipe-action/hy-swipe-action.vue +228 -283
- package/components/hy-swipe-action/props.ts +43 -18
- package/components/hy-swipe-action/typing.d.ts +46 -46
- package/components/hy-swiper/hy-swiper.vue +159 -286
- package/components/hy-swiper/props.ts +126 -28
- package/components/hy-swiper/typing.d.ts +115 -115
- package/components/hy-switch/hy-switch.vue +112 -176
- package/components/hy-switch/props.ts +60 -15
- package/components/hy-switch/typing.d.ts +63 -63
- package/components/hy-tabBar/hy-tabBar.vue +64 -60
- package/components/hy-tabs/hy-tabs.vue +277 -380
- package/components/hy-tabs/props.ts +75 -18
- package/components/hy-tag/hy-tag.vue +111 -204
- package/components/hy-tag/props.ts +81 -19
- package/components/hy-text/hy-text.vue +200 -322
- package/components/hy-text/props.ts +107 -28
- package/components/hy-textarea/hy-textarea.vue +147 -256
- package/components/hy-textarea/props.ts +112 -25
- package/components/hy-textarea/typing.d.ts +42 -42
- package/components/hy-toast/hy-toast.vue +135 -143
- package/components/hy-tooltip/hy-tooltip.vue +220 -306
- package/components/hy-tooltip/props.ts +79 -15
- package/components/hy-transition/hy-transition.vue +111 -138
- package/components/hy-transition/props.ts +30 -8
- package/components/hy-upload/hy-upload.vue +320 -469
- package/components/hy-upload/props.ts +130 -27
- package/components/hy-warn/hy-warn.vue +80 -129
- package/components/hy-warn/props.ts +47 -12
- package/components/hy-waterfall/hy-waterfall.vue +139 -163
- package/components/hy-waterfall/props.ts +19 -7
- package/components/hy-watermark/hy-watermark.vue +762 -870
- package/components/hy-watermark/props.ts +103 -22
- package/global.d.ts +2 -0
- package/libs/css/theme.scss +3 -3
- package/package.json +2 -2
- package/web-types.json +1 -1
- package/components/hy-folding-panel/index.scss +0 -9
|
@@ -1,351 +1,224 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
>
|
|
10
|
-
<view class="hy-swiper__loading" v-if="loading">
|
|
11
|
-
<HyIcon :is-rotate="loading" :name="IconConfig.LOADING"></HyIcon>
|
|
12
|
-
</view>
|
|
13
|
-
<swiper
|
|
14
|
-
v-else
|
|
15
|
-
class="hy-swiper__wrapper"
|
|
16
|
-
:style="{
|
|
17
|
-
flex: '1',
|
|
18
|
-
height: addUnit(height),
|
|
19
|
-
}"
|
|
20
|
-
@change="change"
|
|
21
|
-
:circular="circular"
|
|
22
|
-
:interval="interval"
|
|
23
|
-
:duration="duration"
|
|
24
|
-
:autoplay="autoplay"
|
|
25
|
-
:current="current"
|
|
26
|
-
:currentItemId="currentItemId"
|
|
27
|
-
:previousMargin="addUnit(previousMargin)"
|
|
28
|
-
:nextMargin="addUnit(nextMargin)"
|
|
29
|
-
:acceleration="acceleration"
|
|
30
|
-
:displayMultipleItems="list.length > 0 ? displayMultipleItems : 0"
|
|
31
|
-
:easingFunction="easingFunction"
|
|
2
|
+
<view
|
|
3
|
+
class="hy-swiper"
|
|
4
|
+
:style="{
|
|
5
|
+
backgroundColor: bgColor,
|
|
6
|
+
height: addUnit(height),
|
|
7
|
+
borderRadius: addUnit(radius)
|
|
8
|
+
}"
|
|
32
9
|
>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
:src="getSource(item)"
|
|
61
|
-
:poster="getPoster(item)"
|
|
62
|
-
:title="showTitle && hasTitle(item)"
|
|
63
|
-
:style="{
|
|
64
|
-
height: addUnit(height),
|
|
65
|
-
}"
|
|
66
|
-
controls
|
|
67
|
-
@tap="clickHandler(index)"
|
|
68
|
-
></video>
|
|
69
|
-
<view
|
|
70
|
-
v-if="showTitle && hasTitle(item)"
|
|
71
|
-
class="hy-swiper__wrapper--item__wrapper--title"
|
|
10
|
+
<view class="hy-swiper__loading" v-if="loading">
|
|
11
|
+
<hy-loading mode="circle"></hy-loading>
|
|
12
|
+
</view>
|
|
13
|
+
<swiper
|
|
14
|
+
v-else
|
|
15
|
+
class="hy-swiper__wrapper"
|
|
16
|
+
:style="{
|
|
17
|
+
flex: '1',
|
|
18
|
+
height: addUnit(height)
|
|
19
|
+
}"
|
|
20
|
+
@change="change"
|
|
21
|
+
:circular="circular"
|
|
22
|
+
:interval="interval"
|
|
23
|
+
:duration="duration"
|
|
24
|
+
:autoplay="autoplay"
|
|
25
|
+
:current="current"
|
|
26
|
+
:currentItemId="currentItemId"
|
|
27
|
+
:previousMargin="addUnit(previousMargin)"
|
|
28
|
+
:nextMargin="addUnit(nextMargin)"
|
|
29
|
+
:acceleration="acceleration"
|
|
30
|
+
:displayMultipleItems="list.length > 0 ? displayMultipleItems : 0"
|
|
31
|
+
:easingFunction="easingFunction"
|
|
32
|
+
>
|
|
33
|
+
<swiper-item
|
|
34
|
+
class="hy-swiper__wrapper--item"
|
|
35
|
+
v-for="(item, index) in list"
|
|
36
|
+
:key="index"
|
|
72
37
|
>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
38
|
+
<slot :record="item" :index="index">
|
|
39
|
+
<view class="hy-swiper__wrapper--item__wrapper" :style="[itemStyle(index)]">
|
|
40
|
+
<!-- 在nvue中,image图片的宽度默认为屏幕宽度,需要通过flex:1撑开,另外必须设置高度才能显示图片 -->
|
|
41
|
+
<image
|
|
42
|
+
class="hy-swiper__wrapper--item__wrapper--image"
|
|
43
|
+
v-if="getItemType(item) === 'image'"
|
|
44
|
+
:src="getSource(item)"
|
|
45
|
+
:mode="imgMode"
|
|
46
|
+
@tap="clickHandler(index)"
|
|
47
|
+
:style="{
|
|
48
|
+
height: addUnit(height),
|
|
49
|
+
borderRadius: addUnit(radius)
|
|
50
|
+
}"
|
|
51
|
+
></image>
|
|
52
|
+
<video
|
|
53
|
+
class="hy-swiper__wrapper--item__wrapper--video"
|
|
54
|
+
v-if="getItemType(item) === 'video'"
|
|
55
|
+
:id="`video-${index}`"
|
|
56
|
+
:enable-progress-gesture="false"
|
|
57
|
+
:src="getSource(item)"
|
|
58
|
+
:poster="getPoster(item)"
|
|
59
|
+
:title="showTitle && hasTitle(item)"
|
|
60
|
+
:style="{
|
|
61
|
+
height: addUnit(height)
|
|
62
|
+
}"
|
|
63
|
+
controls
|
|
64
|
+
@tap="clickHandler(index)"
|
|
65
|
+
></video>
|
|
66
|
+
<view
|
|
67
|
+
v-if="showTitle && hasTitle(item)"
|
|
68
|
+
class="hy-swiper__wrapper--item__wrapper--title"
|
|
69
|
+
>
|
|
70
|
+
<text class="hy-line-1">{{ hasTitle(item) }}</text>
|
|
71
|
+
</view>
|
|
72
|
+
</view>
|
|
73
|
+
</slot>
|
|
74
|
+
</swiper-item>
|
|
75
|
+
</swiper>
|
|
76
|
+
<view class="hy-swiper__indicator" :style="[indicatorStyle]">
|
|
77
|
+
<slot name="indicator">
|
|
78
|
+
<HySwiperIndicator
|
|
79
|
+
v-if="!loading && indicator && !showTitle"
|
|
80
|
+
:indicatorActiveColor="indicatorActiveColor"
|
|
81
|
+
:indicatorInactiveColor="indicatorInactiveColor"
|
|
82
|
+
:length="list.length"
|
|
83
|
+
:current="currentIndex"
|
|
84
|
+
:indicatorMode="indicatorMode"
|
|
85
|
+
></HySwiperIndicator>
|
|
86
|
+
</slot>
|
|
87
|
+
</view>
|
|
90
88
|
</view>
|
|
91
|
-
</view>
|
|
92
89
|
</template>
|
|
93
90
|
|
|
94
91
|
<script lang="ts">
|
|
95
92
|
export default {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
93
|
+
name: 'hy-swiper',
|
|
94
|
+
options: {
|
|
95
|
+
addGlobalClass: true,
|
|
96
|
+
virtualHost: true,
|
|
97
|
+
styleIsolation: 'shared'
|
|
98
|
+
}
|
|
99
|
+
}
|
|
103
100
|
</script>
|
|
104
101
|
|
|
105
102
|
<script setup lang="ts">
|
|
106
|
-
import { computed, ref, watch, getCurrentInstance } from
|
|
107
|
-
import type { CSSProperties
|
|
108
|
-
import { addUnit, isVideo
|
|
109
|
-
import type { ISwiperEmits, SwiperList, SwiperVo } from
|
|
110
|
-
|
|
103
|
+
import { computed, ref, watch, getCurrentInstance } from 'vue'
|
|
104
|
+
import type { CSSProperties } from 'vue'
|
|
105
|
+
import { addUnit, isVideo } from '../../libs'
|
|
106
|
+
import type { ISwiperEmits, SwiperList, SwiperVo } from './typing'
|
|
107
|
+
import swiperProps from './props'
|
|
111
108
|
// 组件
|
|
112
|
-
import
|
|
113
|
-
import HySwiperIndicator from
|
|
114
|
-
import type { SwiperEasingFunction } from "@uni-helper/uni-types";
|
|
109
|
+
import HyLoading from '../hy-loading/hy-loading.vue'
|
|
110
|
+
import HySwiperIndicator from './hy-swiper-indicator.vue'
|
|
115
111
|
|
|
116
112
|
/**
|
|
117
113
|
* 一般用于导航轮播,广告展示等场景,可开箱即用
|
|
118
114
|
* @displayName hy-swiper
|
|
119
115
|
*/
|
|
120
|
-
defineOptions({})
|
|
116
|
+
defineOptions({})
|
|
121
117
|
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
/** 轮播图数据 */
|
|
125
|
-
list: {
|
|
126
|
-
type: Array as PropType<string[] | SwiperList[]>,
|
|
127
|
-
default: () => [],
|
|
128
|
-
},
|
|
129
|
-
/** list数组中指定对象的目标属性名 */
|
|
130
|
-
keyName: {
|
|
131
|
-
type: String,
|
|
132
|
-
default: "url",
|
|
133
|
-
},
|
|
134
|
-
/** 是否显示面板指示器 */
|
|
135
|
-
indicator: {
|
|
136
|
-
type: Boolean,
|
|
137
|
-
default: false,
|
|
138
|
-
},
|
|
139
|
-
/** 指示器非激活颜色 */
|
|
140
|
-
indicatorActiveColor: {
|
|
141
|
-
type: String,
|
|
142
|
-
default: "#FFFFFF",
|
|
143
|
-
},
|
|
144
|
-
/** 指示器的激活颜色 */
|
|
145
|
-
indicatorInactiveColor: {
|
|
146
|
-
type: String,
|
|
147
|
-
default: "rgba(255, 255, 255, 0.35)",
|
|
148
|
-
},
|
|
149
|
-
/** 指示器样式,可通过bottom,left,right进行定位 */
|
|
150
|
-
indicatorStyle: Object as PropType<CSSProperties>,
|
|
151
|
-
/**
|
|
152
|
-
* 指示器模式
|
|
153
|
-
* @values line,dot
|
|
154
|
-
* */
|
|
155
|
-
indicatorMode: {
|
|
156
|
-
type: String as PropType<HyApp.SwiperIndicatorModeType>,
|
|
157
|
-
default: "line",
|
|
158
|
-
},
|
|
159
|
-
/** 是否自动切换 */
|
|
160
|
-
autoplay: {
|
|
161
|
-
type: Boolean,
|
|
162
|
-
default: true,
|
|
163
|
-
},
|
|
164
|
-
/** 当前所在滑块的 index */
|
|
165
|
-
current: {
|
|
166
|
-
type: Number,
|
|
167
|
-
default: 0,
|
|
168
|
-
},
|
|
169
|
-
/** 当前所在滑块的 item-id ,不能与 current 被同时指定 */
|
|
170
|
-
currentItemId: String,
|
|
171
|
-
/** 滑块自动切换时间间隔(ms) */
|
|
172
|
-
interval: {
|
|
173
|
-
type: Number,
|
|
174
|
-
default: 3000,
|
|
175
|
-
},
|
|
176
|
-
/** 滑块切换过程所需时间(ms) */
|
|
177
|
-
duration: {
|
|
178
|
-
type: Number,
|
|
179
|
-
default: 300,
|
|
180
|
-
},
|
|
181
|
-
/** 播放到末尾后是否重新回到开头 */
|
|
182
|
-
circular: {
|
|
183
|
-
type: Boolean,
|
|
184
|
-
default: false,
|
|
185
|
-
},
|
|
186
|
-
/** 前边距,可用于露出前一项的一小部分,nvue和支付宝不支持 */
|
|
187
|
-
previousMargin: {
|
|
188
|
-
type: [String, Number],
|
|
189
|
-
default: 0,
|
|
190
|
-
},
|
|
191
|
-
/** 后边距,可用于露出后一项的一小部分,nvue和支付宝不支持 */
|
|
192
|
-
nextMargin: {
|
|
193
|
-
type: [String, Number],
|
|
194
|
-
default: 0,
|
|
195
|
-
},
|
|
196
|
-
/** 当开启时,会根据滑动速度,连续滑动多屏,支付宝不支持 */
|
|
197
|
-
acceleration: {
|
|
198
|
-
type: Boolean,
|
|
199
|
-
default: false,
|
|
200
|
-
},
|
|
201
|
-
/** 同时显示的滑块数量,nvue、支付宝小程序不支持 */
|
|
202
|
-
displayMultipleItems: {
|
|
203
|
-
type: Number,
|
|
204
|
-
default: 1,
|
|
205
|
-
},
|
|
206
|
-
/**
|
|
207
|
-
* 指定swiper切换缓动动画类型, 只对微信小程序有效
|
|
208
|
-
* @values default,linear,easeInCubic,easeOutCubic,easeInOutCubic
|
|
209
|
-
* */
|
|
210
|
-
easingFunction: {
|
|
211
|
-
type: String as PropType<SwiperEasingFunction>,
|
|
212
|
-
default: "default",
|
|
213
|
-
},
|
|
214
|
-
/** 图片的裁剪模式 */
|
|
215
|
-
imgMode: {
|
|
216
|
-
type: String,
|
|
217
|
-
default: "aspectFill",
|
|
218
|
-
},
|
|
219
|
-
/** 组件高度 */
|
|
220
|
-
height: {
|
|
221
|
-
type: Number,
|
|
222
|
-
default: 130,
|
|
223
|
-
},
|
|
224
|
-
/** 背景颜色 */
|
|
225
|
-
bgColor: {
|
|
226
|
-
type: String,
|
|
227
|
-
default: "#f3f4f6",
|
|
228
|
-
},
|
|
229
|
-
/** 组件圆角,数值或带单位的字符串 */
|
|
230
|
-
radius: {
|
|
231
|
-
type: [String, Number],
|
|
232
|
-
default: 4,
|
|
233
|
-
},
|
|
234
|
-
/** 轮播图是否加载中数据 */
|
|
235
|
-
loading: {
|
|
236
|
-
type: Boolean,
|
|
237
|
-
default: false,
|
|
238
|
-
},
|
|
239
|
-
/** 是否显示标题,要求数组对象中有title属性 */
|
|
240
|
-
showTitle: {
|
|
241
|
-
type: Boolean,
|
|
242
|
-
default: false,
|
|
243
|
-
},
|
|
244
|
-
});
|
|
245
|
-
const emit = defineEmits<ISwiperEmits>();
|
|
118
|
+
const props = defineProps(swiperProps)
|
|
119
|
+
const emit = defineEmits<ISwiperEmits>()
|
|
246
120
|
|
|
247
|
-
const instance = getCurrentInstance()
|
|
248
|
-
const currentIndex = ref<string | number>(0)
|
|
121
|
+
const instance = getCurrentInstance()
|
|
122
|
+
const currentIndex = ref<string | number>(0)
|
|
249
123
|
|
|
250
124
|
watch(
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
)
|
|
125
|
+
() => props.current,
|
|
126
|
+
(newVal) => {
|
|
127
|
+
currentIndex.value = newVal
|
|
128
|
+
}
|
|
129
|
+
)
|
|
256
130
|
|
|
257
131
|
const hasTitle = computed(() => {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
132
|
+
return (item: string | Record<string, any>) => {
|
|
133
|
+
if (typeof item === 'object') {
|
|
134
|
+
return item.title || ''
|
|
135
|
+
} else {
|
|
136
|
+
return ''
|
|
137
|
+
}
|
|
263
138
|
}
|
|
264
|
-
|
|
265
|
-
});
|
|
139
|
+
})
|
|
266
140
|
|
|
267
141
|
/**
|
|
268
142
|
* @description 轮播图3D效果
|
|
269
143
|
* */
|
|
270
144
|
const itemStyle = computed(() => {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
145
|
+
return (index: number): CSSProperties => {
|
|
146
|
+
const style: CSSProperties = {}
|
|
147
|
+
// #ifndef APP-NVUE || MP-TOUTIAO
|
|
148
|
+
// 左右流出空间的写法不支持nvue和头条
|
|
149
|
+
// 只有配置了此二值,才加上对应的圆角,以及缩放
|
|
150
|
+
if (props.nextMargin && props.previousMargin) {
|
|
151
|
+
style.borderRadius = addUnit(props.radius)
|
|
152
|
+
if (index !== currentIndex.value) style.transform = 'scale(0.92)'
|
|
153
|
+
}
|
|
154
|
+
// #endif
|
|
155
|
+
return style
|
|
279
156
|
}
|
|
280
|
-
|
|
281
|
-
return style;
|
|
282
|
-
};
|
|
283
|
-
});
|
|
157
|
+
})
|
|
284
158
|
|
|
285
159
|
/**
|
|
286
160
|
* @description 获取目标路径,可能数组中为字符串,对象的形式,额外可指定对象的目标属性名keyName
|
|
287
161
|
* */
|
|
288
162
|
const getSource = (item: string | Record<string, any>): string => {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
}
|
|
163
|
+
if (typeof item === 'string') return item
|
|
164
|
+
if (typeof item === 'object' && props.keyName) return item[props.keyName]
|
|
165
|
+
return ''
|
|
166
|
+
}
|
|
293
167
|
|
|
294
168
|
/**
|
|
295
169
|
* @description 轮播切换事件
|
|
296
170
|
*/
|
|
297
171
|
const change = (e: SwiperVo) => {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
172
|
+
// 当前的激活索引
|
|
173
|
+
const { current } = e.detail
|
|
174
|
+
pauseVideo(currentIndex.value)
|
|
175
|
+
currentIndex.value = current
|
|
176
|
+
emit('update:current', currentIndex.value)
|
|
177
|
+
emit('change', e.detail)
|
|
178
|
+
}
|
|
305
179
|
|
|
306
180
|
/**
|
|
307
181
|
* @description 切换轮播时,暂停视频播放
|
|
308
182
|
* */
|
|
309
183
|
const pauseVideo = (index: number | string) => {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
184
|
+
const lastItem = getSource(props.list[Number(index)])
|
|
185
|
+
if (isVideo(lastItem)) {
|
|
186
|
+
// 当视频隐藏时,暂停播放
|
|
187
|
+
const video = uni.createVideoContext(`video-${index}`, instance)
|
|
188
|
+
video.pause()
|
|
189
|
+
}
|
|
190
|
+
}
|
|
317
191
|
|
|
318
192
|
/**
|
|
319
193
|
* @description 当一个轮播item为视频时,获取它的视频海报
|
|
320
194
|
* */
|
|
321
195
|
const getPoster = (item: string | SwiperList): string => {
|
|
322
|
-
|
|
323
|
-
}
|
|
196
|
+
return typeof item === 'object' && item.poster ? item.poster : ''
|
|
197
|
+
}
|
|
324
198
|
|
|
325
199
|
/**
|
|
326
200
|
* @description 点击某个item
|
|
327
201
|
* */
|
|
328
202
|
const clickHandler = (index: number) => {
|
|
329
|
-
|
|
330
|
-
}
|
|
203
|
+
emit('click', index)
|
|
204
|
+
}
|
|
331
205
|
|
|
332
206
|
/**
|
|
333
207
|
* @description 判断链接是视频还是图片
|
|
334
208
|
* */
|
|
335
209
|
const getItemType = computed(() => {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
210
|
+
return (item: string | Record<string, unknown>) => {
|
|
211
|
+
if (typeof item === 'string') return isVideo(item) ? 'video' : 'image'
|
|
212
|
+
if (typeof item === 'object' && props.keyName) {
|
|
213
|
+
if (!item.type) return isVideo(item[props.keyName] as string) ? 'video' : 'image'
|
|
214
|
+
if (item.type === 'image') return 'image'
|
|
215
|
+
if (item.type === 'video') return 'video'
|
|
216
|
+
return 'image'
|
|
217
|
+
}
|
|
344
218
|
}
|
|
345
|
-
|
|
346
|
-
});
|
|
219
|
+
})
|
|
347
220
|
</script>
|
|
348
221
|
|
|
349
222
|
<style lang="scss" scoped>
|
|
350
|
-
@import
|
|
223
|
+
@import './index.scss';
|
|
351
224
|
</style>
|
|
@@ -1,30 +1,128 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { SwiperList } from './typing'
|
|
2
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
3
|
+
import type { SwiperEasingFunction } from '@uni-helper/uni-types'
|
|
2
4
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
5
|
+
const swiperProps = {
|
|
6
|
+
/** 轮播图数据 */
|
|
7
|
+
list: {
|
|
8
|
+
type: Array as PropType<string[] | SwiperList[]>,
|
|
9
|
+
default: () => []
|
|
10
|
+
},
|
|
11
|
+
/** list数组中指定对象的目标属性名 */
|
|
12
|
+
keyName: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: 'url'
|
|
15
|
+
},
|
|
16
|
+
/** 是否显示面板指示器 */
|
|
17
|
+
indicator: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false
|
|
20
|
+
},
|
|
21
|
+
/** 指示器非激活颜色 */
|
|
22
|
+
indicatorActiveColor: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: '#FFFFFF'
|
|
25
|
+
},
|
|
26
|
+
/** 指示器的激活颜色 */
|
|
27
|
+
indicatorInactiveColor: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: 'rgba(255, 255, 255, 0.35)'
|
|
30
|
+
},
|
|
31
|
+
/** 指示器样式,可通过bottom,left,right进行定位 */
|
|
32
|
+
indicatorStyle: Object as PropType<CSSProperties>,
|
|
33
|
+
/**
|
|
34
|
+
* 指示器模式
|
|
35
|
+
* @values line,dot
|
|
36
|
+
* */
|
|
37
|
+
indicatorMode: {
|
|
38
|
+
type: String as PropType<HyApp.SwiperIndicatorModeType>,
|
|
39
|
+
default: 'line'
|
|
40
|
+
},
|
|
41
|
+
/** 是否自动切换 */
|
|
42
|
+
autoplay: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: true
|
|
45
|
+
},
|
|
46
|
+
/** 当前所在滑块的 index */
|
|
47
|
+
current: {
|
|
48
|
+
type: Number,
|
|
49
|
+
default: 0
|
|
50
|
+
},
|
|
51
|
+
/** 当前所在滑块的 item-id ,不能与 current 被同时指定 */
|
|
52
|
+
currentItemId: String,
|
|
53
|
+
/** 滑块自动切换时间间隔(ms) */
|
|
54
|
+
interval: {
|
|
55
|
+
type: Number,
|
|
56
|
+
default: 3000
|
|
57
|
+
},
|
|
58
|
+
/** 滑块切换过程所需时间(ms) */
|
|
59
|
+
duration: {
|
|
60
|
+
type: Number,
|
|
61
|
+
default: 300
|
|
62
|
+
},
|
|
63
|
+
/** 播放到末尾后是否重新回到开头 */
|
|
64
|
+
circular: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: false
|
|
67
|
+
},
|
|
68
|
+
/** 前边距,可用于露出前一项的一小部分,nvue和支付宝不支持 */
|
|
69
|
+
previousMargin: {
|
|
70
|
+
type: [String, Number],
|
|
71
|
+
default: 0
|
|
72
|
+
},
|
|
73
|
+
/** 后边距,可用于露出后一项的一小部分,nvue和支付宝不支持 */
|
|
74
|
+
nextMargin: {
|
|
75
|
+
type: [String, Number],
|
|
76
|
+
default: 0
|
|
77
|
+
},
|
|
78
|
+
/** 当开启时,会根据滑动速度,连续滑动多屏,支付宝不支持 */
|
|
79
|
+
acceleration: {
|
|
80
|
+
type: Boolean,
|
|
81
|
+
default: false
|
|
82
|
+
},
|
|
83
|
+
/** 同时显示的滑块数量,nvue、支付宝小程序不支持 */
|
|
84
|
+
displayMultipleItems: {
|
|
85
|
+
type: Number,
|
|
86
|
+
default: 1
|
|
87
|
+
},
|
|
88
|
+
/**
|
|
89
|
+
* 指定swiper切换缓动动画类型, 只对微信小程序有效
|
|
90
|
+
* @values default,linear,easeInCubic,easeOutCubic,easeInOutCubic
|
|
91
|
+
* */
|
|
92
|
+
easingFunction: {
|
|
93
|
+
type: String as PropType<SwiperEasingFunction>,
|
|
94
|
+
default: 'default'
|
|
95
|
+
},
|
|
96
|
+
/** 图片的裁剪模式 */
|
|
97
|
+
imgMode: {
|
|
98
|
+
type: String,
|
|
99
|
+
default: 'aspectFill'
|
|
100
|
+
},
|
|
101
|
+
/** 组件高度 */
|
|
102
|
+
height: {
|
|
103
|
+
type: Number,
|
|
104
|
+
default: 130
|
|
105
|
+
},
|
|
106
|
+
/** 背景颜色 */
|
|
107
|
+
bgColor: {
|
|
108
|
+
type: String,
|
|
109
|
+
default: '#f3f4f6'
|
|
110
|
+
},
|
|
111
|
+
/** 组件圆角,数值或带单位的字符串 */
|
|
112
|
+
radius: {
|
|
113
|
+
type: [String, Number],
|
|
114
|
+
default: 4
|
|
115
|
+
},
|
|
116
|
+
/** 轮播图是否加载中数据 */
|
|
117
|
+
loading: {
|
|
118
|
+
type: Boolean,
|
|
119
|
+
default: false
|
|
120
|
+
},
|
|
121
|
+
/** 是否显示标题,要求数组对象中有title属性 */
|
|
122
|
+
showTitle: {
|
|
123
|
+
type: Boolean,
|
|
124
|
+
default: false
|
|
125
|
+
}
|
|
126
|
+
}
|
|
29
127
|
|
|
30
|
-
export default
|
|
128
|
+
export default swiperProps
|