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