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.
Files changed (211) hide show
  1. package/components/hy-action-sheet/hy-action-sheet.vue +155 -238
  2. package/components/hy-action-sheet/props.ts +68 -15
  3. package/components/hy-action-sheet/typing.d.ts +115 -115
  4. package/components/hy-address-picker/hy-address-picker.vue +185 -289
  5. package/components/hy-address-picker/props.ts +97 -21
  6. package/components/hy-address-picker/typing.d.ts +90 -89
  7. package/components/hy-avatar/hy-avatar.vue +121 -204
  8. package/components/hy-avatar/props.ts +76 -18
  9. package/components/hy-avatar/typing.d.ts +63 -62
  10. package/components/hy-back-top/hy-back-top.vue +65 -120
  11. package/components/hy-back-top/props.ts +57 -16
  12. package/components/hy-back-top/typing.d.ts +43 -42
  13. package/components/hy-badge/hy-badge.vue +66 -138
  14. package/components/hy-badge/props.ts +73 -17
  15. package/components/hy-badge/typing.d.ts +59 -58
  16. package/components/hy-button/hy-button.vue +226 -375
  17. package/components/hy-button/props.ts +129 -158
  18. package/components/hy-calendar/header.vue +48 -64
  19. package/components/hy-calendar/hy-calendar.vue +274 -438
  20. package/components/hy-calendar/month.vue +508 -516
  21. package/components/hy-calendar/props.ts +157 -35
  22. package/components/hy-calendar/typing.d.ts +129 -128
  23. package/components/hy-card/hy-card.vue +118 -240
  24. package/components/hy-card/index.scss +1 -2
  25. package/components/hy-card/props.ts +122 -27
  26. package/components/hy-card/typing.d.ts +119 -118
  27. package/components/hy-cell/hy-cell.vue +176 -258
  28. package/components/hy-cell/props.ts +71 -17
  29. package/components/hy-cell/typing.d.ts +87 -86
  30. package/components/hy-check-button/hy-check-button.vue +69 -139
  31. package/components/hy-check-button/props.ts +72 -18
  32. package/components/hy-check-button/typing.d.ts +74 -73
  33. package/components/hy-checkbox/hy-checkbox.vue +170 -263
  34. package/components/hy-checkbox/props.ts +94 -24
  35. package/components/hy-checkbox/typing.d.ts +72 -72
  36. package/components/hy-checkbox-group/hy-checkbox-group.vue +25 -100
  37. package/components/hy-checkbox-group/props.ts +80 -0
  38. package/components/hy-checkbox-group/typing.d.ts +65 -65
  39. package/components/hy-checkbox-item/hy-checkbox-item.vue +140 -177
  40. package/components/hy-checkbox-item/props.ts +24 -0
  41. package/components/hy-checkbox-item/typing.d.ts +4 -3
  42. package/components/hy-code-input/hy-code-input.vue +179 -262
  43. package/components/hy-code-input/props.ts +84 -18
  44. package/components/hy-code-input/typing.d.ts +71 -71
  45. package/components/hy-config-provider/hy-config-provider.vue +28 -50
  46. package/components/hy-config-provider/props.ts +26 -11
  47. package/components/hy-config-provider/typing.d.ts +20 -20
  48. package/components/hy-count-down/hy-count-down.vue +103 -131
  49. package/components/hy-count-down/props.ts +30 -8
  50. package/components/hy-count-down/typing.d.ts +25 -25
  51. package/components/hy-count-to/hy-count-to.vue +148 -213
  52. package/components/hy-count-to/props.ts +60 -15
  53. package/components/hy-count-to/typing.d.ts +46 -46
  54. package/components/hy-coupon/README.md +133 -0
  55. package/components/hy-coupon/hy-coupon.vue +180 -0
  56. package/components/hy-coupon/index.scss +553 -0
  57. package/components/hy-coupon/props.ts +129 -0
  58. package/components/hy-coupon/typing.d.ts +146 -0
  59. package/components/hy-datetime-picker/hy-datetime-picker.vue +415 -580
  60. package/components/hy-datetime-picker/props.ts +142 -32
  61. package/components/hy-datetime-picker/typing.d.ts +132 -132
  62. package/components/hy-divider/hy-divider.vue +90 -169
  63. package/components/hy-divider/props.ts +78 -19
  64. package/components/hy-divider/typing.d.ts +60 -60
  65. package/components/hy-dropdown/hy-dropdown.vue +37 -71
  66. package/components/hy-dropdown/props.ts +38 -15
  67. package/components/hy-dropdown/typing.d.ts +44 -44
  68. package/components/hy-dropdown-item/hy-dropdown-item.vue +141 -173
  69. package/components/hy-dropdown-item/props.ts +19 -8
  70. package/components/hy-empty/hy-empty.vue +75 -129
  71. package/components/hy-empty/props.ts +57 -15
  72. package/components/hy-empty/typing.d.ts +84 -84
  73. package/components/hy-flex/hy-flex.vue +33 -88
  74. package/components/hy-flex/props.ts +58 -0
  75. package/components/hy-flex/typing.d.ts +14 -16
  76. package/components/hy-float-button/hy-float-button.vue +289 -406
  77. package/components/hy-float-button/props.ts +109 -25
  78. package/components/hy-folding-panel/hy-folding-panel.vue +86 -374
  79. package/components/hy-folding-panel/props.ts +40 -15
  80. package/components/hy-folding-panel/typing.d.ts +52 -63
  81. package/components/hy-folding-panel-item/hy-folding-panel-item.vue +186 -228
  82. package/components/hy-folding-panel-item/index.scss +87 -0
  83. package/components/hy-folding-panel-item/props.ts +81 -0
  84. package/components/hy-folding-panel-item/typing.d.ts +23 -0
  85. package/components/hy-form/hy-form.vue +172 -212
  86. package/components/hy-form/props.ts +37 -0
  87. package/components/hy-form/typing.d.ts +68 -61
  88. package/components/hy-form-group/typing.d.ts +74 -74
  89. package/components/hy-form-item/hy-form-item.vue +100 -129
  90. package/components/hy-form-item/props.ts +25 -0
  91. package/components/hy-form-item/typing.d.ts +40 -37
  92. package/components/hy-grid/hy-grid.vue +76 -132
  93. package/components/hy-grid/props.ts +58 -16
  94. package/components/hy-grid/typing.d.ts +66 -66
  95. package/components/hy-icon/hy-icon.vue +84 -161
  96. package/components/hy-icon/props.ts +76 -22
  97. package/components/hy-icon/typing.d.ts +83 -82
  98. package/components/hy-image/hy-image.vue +142 -272
  99. package/components/hy-image/props.ts +105 -23
  100. package/components/hy-image/typing.d.ts +84 -87
  101. package/components/hy-input/hy-input.vue +230 -421
  102. package/components/hy-input/props.ts +183 -35
  103. package/components/hy-input/typing.d.ts +169 -169
  104. package/components/hy-line/hy-line.vue +34 -72
  105. package/components/hy-line/props.ts +41 -10
  106. package/components/hy-line/typing.d.ts +29 -29
  107. package/components/hy-line-progress/hy-line-progress.vue +66 -101
  108. package/components/hy-line-progress/props.ts +31 -10
  109. package/components/hy-line-progress/typing.d.ts +29 -29
  110. package/components/hy-list/hy-list.vue +151 -220
  111. package/components/hy-list/props.ts +67 -16
  112. package/components/hy-list/typing.d.ts +52 -52
  113. package/components/hy-loading/hy-loading.vue +63 -119
  114. package/components/hy-loading/props.ts +63 -15
  115. package/components/hy-loading/typing.d.ts +49 -49
  116. package/components/hy-menu/hy-menu.vue +124 -166
  117. package/components/hy-menu/props.ts +42 -10
  118. package/components/hy-menu/typing.d.ts +60 -60
  119. package/components/hy-modal/hy-modal.vue +127 -218
  120. package/components/hy-modal/props.ts +89 -24
  121. package/components/hy-navbar/hy-navbar.vue +104 -177
  122. package/components/hy-navbar/props.ts +76 -22
  123. package/components/hy-navbar/typing.d.ts +81 -81
  124. package/components/hy-notice-bar/hy-notice-bar.vue +67 -144
  125. package/components/hy-notice-bar/props.ts +80 -19
  126. package/components/hy-notice-bar/typing.d.ts +62 -62
  127. package/components/hy-notify/hy-notify.vue +128 -177
  128. package/components/hy-notify/props.ts +49 -12
  129. package/components/hy-notify/typing.d.ts +45 -41
  130. package/components/hy-number-step/hy-number-step.vue +281 -394
  131. package/components/hy-number-step/props.ts +110 -27
  132. package/components/hy-number-step/typing.d.ts +120 -120
  133. package/components/hy-overlay/hy-overlay.vue +39 -66
  134. package/components/hy-overlay/props.ts +31 -8
  135. package/components/hy-pagination/hy-pagination.vue +100 -155
  136. package/components/hy-pagination/props.ts +53 -13
  137. package/components/hy-picker/hy-picker.vue +309 -430
  138. package/components/hy-picker/index.scss +8 -12
  139. package/components/hy-picker/props.ts +110 -26
  140. package/components/hy-popover/hy-popover.vue +190 -252
  141. package/components/hy-popover/props.ts +48 -10
  142. package/components/hy-popup/hy-popup.vue +162 -248
  143. package/components/hy-popup/props.ts +82 -18
  144. package/components/hy-price/hy-price.vue +45 -104
  145. package/components/hy-price/props.ts +52 -12
  146. package/components/hy-price/typing.d.ts +41 -36
  147. package/components/hy-qrcode/hy-qrcode.vue +115 -185
  148. package/components/hy-qrcode/props.ts +68 -18
  149. package/components/hy-qrcode/typing.d.ts +67 -66
  150. package/components/hy-radio/hy-radio.vue +161 -259
  151. package/components/hy-radio/props.ts +95 -25
  152. package/components/hy-radio/typing.d.ts +85 -84
  153. package/components/hy-rate/hy-rate.vue +185 -270
  154. package/components/hy-rate/props.ts +76 -18
  155. package/components/hy-rate/typing.d.ts +61 -60
  156. package/components/hy-read-more/hy-read-more.vue +93 -136
  157. package/components/hy-read-more/props.ts +43 -13
  158. package/components/hy-scroll-list/hy-scroll-list.vue +81 -102
  159. package/components/hy-scroll-list/props.ts +22 -11
  160. package/components/hy-search/hy-search.vue +155 -284
  161. package/components/hy-search/props.ts +130 -25
  162. package/components/hy-signature/hy-signature.vue +491 -635
  163. package/components/hy-signature/props.ts +115 -26
  164. package/components/hy-signature/typing.d.ts +138 -138
  165. package/components/hy-slider/hy-slider.vue +388 -477
  166. package/components/hy-slider/props.ts +75 -19
  167. package/components/hy-steps/hy-steps.vue +212 -279
  168. package/components/hy-steps/props.ts +47 -13
  169. package/components/hy-submit-bar/hy-submit-bar.vue +137 -222
  170. package/components/hy-submit-bar/props.ts +89 -20
  171. package/components/hy-submit-bar/typing.d.ts +86 -85
  172. package/components/hy-subsection/hy-subsection.vue +132 -185
  173. package/components/hy-subsection/props.ts +50 -17
  174. package/components/hy-subsection/typing.d.ts +52 -52
  175. package/components/hy-swipe-action/hy-swipe-action.vue +228 -283
  176. package/components/hy-swipe-action/props.ts +43 -18
  177. package/components/hy-swipe-action/typing.d.ts +46 -46
  178. package/components/hy-swiper/hy-swiper.vue +159 -286
  179. package/components/hy-swiper/props.ts +126 -28
  180. package/components/hy-swiper/typing.d.ts +115 -115
  181. package/components/hy-switch/hy-switch.vue +112 -176
  182. package/components/hy-switch/props.ts +60 -15
  183. package/components/hy-switch/typing.d.ts +63 -63
  184. package/components/hy-tabBar/hy-tabBar.vue +64 -60
  185. package/components/hy-tabs/hy-tabs.vue +277 -380
  186. package/components/hy-tabs/props.ts +75 -18
  187. package/components/hy-tag/hy-tag.vue +111 -204
  188. package/components/hy-tag/props.ts +81 -19
  189. package/components/hy-text/hy-text.vue +200 -322
  190. package/components/hy-text/props.ts +107 -28
  191. package/components/hy-textarea/hy-textarea.vue +147 -256
  192. package/components/hy-textarea/props.ts +112 -25
  193. package/components/hy-textarea/typing.d.ts +42 -42
  194. package/components/hy-toast/hy-toast.vue +135 -143
  195. package/components/hy-tooltip/hy-tooltip.vue +220 -306
  196. package/components/hy-tooltip/props.ts +79 -15
  197. package/components/hy-transition/hy-transition.vue +111 -138
  198. package/components/hy-transition/props.ts +30 -8
  199. package/components/hy-upload/hy-upload.vue +320 -469
  200. package/components/hy-upload/props.ts +130 -27
  201. package/components/hy-warn/hy-warn.vue +80 -129
  202. package/components/hy-warn/props.ts +47 -12
  203. package/components/hy-waterfall/hy-waterfall.vue +139 -163
  204. package/components/hy-waterfall/props.ts +19 -7
  205. package/components/hy-watermark/hy-watermark.vue +762 -870
  206. package/components/hy-watermark/props.ts +103 -22
  207. package/global.d.ts +2 -0
  208. package/libs/css/theme.scss +3 -3
  209. package/package.json +2 -2
  210. package/web-types.json +1 -1
  211. package/components/hy-folding-panel/index.scss +0 -9
@@ -1,351 +1,224 @@
1
1
  <template>
2
- <view
3
- class="hy-swiper"
4
- :style="{
5
- backgroundColor: bgColor,
6
- height: addUnit(height),
7
- borderRadius: addUnit(radius),
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
- <swiper-item
34
- class="hy-swiper__wrapper--item"
35
- v-for="(item, index) in list"
36
- :key="index"
37
- >
38
- <slot :record="item" :index="index">
39
- <view
40
- class="hy-swiper__wrapper--item__wrapper"
41
- :style="[itemStyle(index)]"
42
- >
43
- <!-- 在nvue中,image图片的宽度默认为屏幕宽度,需要通过flex:1撑开,另外必须设置高度才能显示图片 -->
44
- <image
45
- class="hy-swiper__wrapper--item__wrapper--image"
46
- v-if="getItemType(item) === 'image'"
47
- :src="getSource(item)"
48
- :mode="imgMode"
49
- @tap="clickHandler(index)"
50
- :style="{
51
- height: addUnit(height),
52
- borderRadius: addUnit(radius),
53
- }"
54
- ></image>
55
- <video
56
- class="hy-swiper__wrapper--item__wrapper--video"
57
- v-if="getItemType(item) === 'video'"
58
- :id="`video-${index}`"
59
- :enable-progress-gesture="false"
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
- <text class="hy-line-1">{{ hasTitle(item) }}</text>
74
- </view>
75
- </view>
76
- </slot>
77
- </swiper-item>
78
- </swiper>
79
- <view class="hy-swiper__indicator" :style="[indicatorStyle]">
80
- <slot name="indicator">
81
- <HySwiperIndicator
82
- v-if="!loading && indicator && !showTitle"
83
- :indicatorActiveColor="indicatorActiveColor"
84
- :indicatorInactiveColor="indicatorInactiveColor"
85
- :length="list.length"
86
- :current="currentIndex"
87
- :indicatorMode="indicatorMode"
88
- ></HySwiperIndicator>
89
- </slot>
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
- name: "hy-swiper",
97
- options: {
98
- addGlobalClass: true,
99
- virtualHost: true,
100
- styleIsolation: "shared",
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 "vue";
107
- import type { CSSProperties, PropType } from "vue";
108
- import { addUnit, isVideo, IconConfig } from "../../libs";
109
- import type { ISwiperEmits, SwiperList, SwiperVo } from "./typing";
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 HyIcon from "../hy-icon/hy-icon.vue";
113
- import HySwiperIndicator from "./hy-swiper-indicator.vue";
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
- // const props = withDefaults(defineProps<IProps>(), defaultProps);
123
- const props = defineProps({
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
- () => props.current,
252
- (newVal) => {
253
- currentIndex.value = newVal;
254
- },
255
- );
125
+ () => props.current,
126
+ (newVal) => {
127
+ currentIndex.value = newVal
128
+ }
129
+ )
256
130
 
257
131
  const hasTitle = computed(() => {
258
- return (item: string | Record<string, any>) => {
259
- if (typeof item === "object") {
260
- return item.title || "";
261
- } else {
262
- return "";
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
- return (index: number): CSSProperties => {
272
- const style: CSSProperties = {};
273
- // #ifndef APP-NVUE || MP-TOUTIAO
274
- // 左右流出空间的写法不支持nvue和头条
275
- // 只有配置了此二值,才加上对应的圆角,以及缩放
276
- if (props.nextMargin && props.previousMargin) {
277
- style.borderRadius = addUnit(props.radius);
278
- if (index !== currentIndex.value) style.transform = "scale(0.92)";
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
- // #endif
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
- if (typeof item === "string") return item;
290
- if (typeof item === "object" && props.keyName) return item[props.keyName];
291
- return "";
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
- const { current } = e.detail;
300
- pauseVideo(currentIndex.value);
301
- currentIndex.value = current;
302
- emit("update:current", currentIndex.value);
303
- emit("change", e.detail);
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
- const lastItem = getSource(props.list[Number(index)]);
311
- if (isVideo(lastItem)) {
312
- // 当视频隐藏时,暂停播放
313
- const video = uni.createVideoContext(`video-${index}`, instance);
314
- video.pause();
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
- return typeof item === "object" && item.poster ? item.poster : "";
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
- emit("click", index);
330
- };
203
+ emit('click', index)
204
+ }
331
205
 
332
206
  /**
333
207
  * @description 判断链接是视频还是图片
334
208
  * */
335
209
  const getItemType = computed(() => {
336
- return (item: string | Record<string, unknown>) => {
337
- if (typeof item === "string") return isVideo(item) ? "video" : "image";
338
- if (typeof item === "object" && props.keyName) {
339
- if (!item.type)
340
- return isVideo(item[props.keyName] as string) ? "video" : "image";
341
- if (item.type === "image") return "image";
342
- if (item.type === "video") return "video";
343
- return "image";
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 "./index.scss";
223
+ @import './index.scss';
351
224
  </style>
@@ -1,30 +1,128 @@
1
- import type IProps from "./typing";
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 defaultProps: IProps = {
4
- list: [],
5
- indicator: false,
6
- indicatorActiveColor: "#FFFFFF",
7
- indicatorInactiveColor: "rgba(255, 255, 255, 0.35)",
8
- indicatorStyle: {},
9
- indicatorMode: "line",
10
- autoplay: true,
11
- current: 0,
12
- currentItemId: "",
13
- interval: 3000,
14
- duration: 300,
15
- circular: false,
16
- previousMargin: 0,
17
- nextMargin: 0,
18
- acceleration: false,
19
- displayMultipleItems: 1,
20
- easingFunction: "default",
21
- keyName: "url",
22
- imgMode: "aspectFill",
23
- height: 130,
24
- bgColor: "#f3f4f6",
25
- radius: 4,
26
- loading: false,
27
- showTitle: false,
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 defaultProps;
128
+ export default swiperProps