stellar-ui-v2 1.35.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.
Files changed (141) hide show
  1. package/common/css/common.scss +61 -0
  2. package/components/ste-animate/README.md +117 -0
  3. package/components/ste-animate/animate.scss +247 -0
  4. package/components/ste-animate/ste-animate.vue +200 -0
  5. package/components/ste-badge/README.md +171 -0
  6. package/components/ste-badge/ste-badge.vue +238 -0
  7. package/components/ste-barcode/README.md +36 -0
  8. package/components/ste-barcode/encode2.js +317 -0
  9. package/components/ste-barcode/ste-barcode.vue +213 -0
  10. package/components/ste-button/README.md +129 -0
  11. package/components/ste-button/ste-button.vue +345 -0
  12. package/components/ste-calendar/README.md +304 -0
  13. package/components/ste-calendar/self-date.js +119 -0
  14. package/components/ste-calendar/ste-calendar.vue +578 -0
  15. package/components/ste-checkbox/README.md +297 -0
  16. package/components/ste-checkbox/ste-checkbox.vue +305 -0
  17. package/components/ste-checkbox-group/ste-checkbox-group.vue +133 -0
  18. package/components/ste-code-input/README.md +67 -0
  19. package/components/ste-code-input/ste-code-input.vue +302 -0
  20. package/components/ste-date-picker/README.md +135 -0
  21. package/components/ste-date-picker/ste-date-picker.vue +407 -0
  22. package/components/ste-drag/README.md +103 -0
  23. package/components/ste-drag/ste-drag.vue +203 -0
  24. package/components/ste-dropdown-menu/README.md +358 -0
  25. package/components/ste-dropdown-menu/ste-dropdown-menu.vue +405 -0
  26. package/components/ste-dropdown-menu-item/ste-dropdown-menu-item.vue +176 -0
  27. package/components/ste-icon/README.md +90 -0
  28. package/components/ste-icon/iconfont.css +8 -0
  29. package/components/ste-icon/ste-icon.vue +147 -0
  30. package/components/ste-image/README.md +154 -0
  31. package/components/ste-image/ste-image.vue +218 -0
  32. package/components/ste-index-item/ste-index-item.vue +96 -0
  33. package/components/ste-index-list/README.md +153 -0
  34. package/components/ste-index-list/ste-index-list.vue +128 -0
  35. package/components/ste-input/README.md +146 -0
  36. package/components/ste-input/ste-input.vue +480 -0
  37. package/components/ste-loading/README.md +81 -0
  38. package/components/ste-loading/ste-loading.vue +166 -0
  39. package/components/ste-media-preview/README.md +243 -0
  40. package/components/ste-media-preview/TouchScaleing.js +102 -0
  41. package/components/ste-media-preview/ste-media-preview.vue +267 -0
  42. package/components/ste-message-box/README.md +217 -0
  43. package/components/ste-message-box/ste-message-box.js +72 -0
  44. package/components/ste-message-box/ste-message-box.vue +380 -0
  45. package/components/ste-notice-bar/README.md +129 -0
  46. package/components/ste-notice-bar/ste-notice-bar.vue +331 -0
  47. package/components/ste-number-keyboard/README.md +246 -0
  48. package/components/ste-number-keyboard/keyboard.vue +140 -0
  49. package/components/ste-number-keyboard/ste-number-keyboard.vue +240 -0
  50. package/components/ste-picker/ste-picker.vue +258 -0
  51. package/components/ste-popup/README.md +148 -0
  52. package/components/ste-popup/ste-popup.vue +337 -0
  53. package/components/ste-price/README.md +129 -0
  54. package/components/ste-price/ste-price.vue +258 -0
  55. package/components/ste-progress/README.md +87 -0
  56. package/components/ste-progress/ste-progress.vue +200 -0
  57. package/components/ste-qrcode/README.md +50 -0
  58. package/components/ste-qrcode/ste-qrcode.vue +164 -0
  59. package/components/ste-qrcode/uqrcode.js +34 -0
  60. package/components/ste-radio/README.md +286 -0
  61. package/components/ste-radio/ste-radio.vue +293 -0
  62. package/components/ste-radio-group/ste-radio-group.vue +128 -0
  63. package/components/ste-rate/README.md +115 -0
  64. package/components/ste-rate/ste-rate.vue +202 -0
  65. package/components/ste-read-more/README.md +111 -0
  66. package/components/ste-read-more/ste-read-more.vue +133 -0
  67. package/components/ste-rich-text/README.md +31 -0
  68. package/components/ste-rich-text/ste-rich-text.vue +70 -0
  69. package/components/ste-scroll-to/README.md +68 -0
  70. package/components/ste-scroll-to/mixin.js +173 -0
  71. package/components/ste-scroll-to/ste-scroll-to.vue +45 -0
  72. package/components/ste-scroll-to-item/ste-scroll-to-item.vue +25 -0
  73. package/components/ste-search/README.md +262 -0
  74. package/components/ste-search/ste-search.vue +547 -0
  75. package/components/ste-select/README.md +434 -0
  76. package/components/ste-select/datapager.vue +62 -0
  77. package/components/ste-select/datetime.vue +106 -0
  78. package/components/ste-select/defaultDate.js +142 -0
  79. package/components/ste-select/ste-select.vue +843 -0
  80. package/components/ste-signature/README.md +105 -0
  81. package/components/ste-signature/ste-signature.vue +220 -0
  82. package/components/ste-slider/README.md +165 -0
  83. package/components/ste-slider/ste-slider.vue +544 -0
  84. package/components/ste-step/ste-step.vue +264 -0
  85. package/components/ste-stepper/README.md +170 -0
  86. package/components/ste-stepper/ste-stepper.vue +373 -0
  87. package/components/ste-steps/README.md +132 -0
  88. package/components/ste-steps/ste-steps.vue +65 -0
  89. package/components/ste-sticky/README.md +52 -0
  90. package/components/ste-sticky/ste-sticky.vue +127 -0
  91. package/components/ste-swipe-action/README.md +197 -0
  92. package/components/ste-swipe-action/ste-swipe-action.vue +303 -0
  93. package/components/ste-swipe-action-group/ste-swipe-action-group.vue +104 -0
  94. package/components/ste-swiper/README.md +173 -0
  95. package/components/ste-swiper/ste-swiper.vue +462 -0
  96. package/components/ste-swiper-item/ste-swiper-item.vue +41 -0
  97. package/components/ste-switch/README.md +110 -0
  98. package/components/ste-switch/ste-switch.vue +144 -0
  99. package/components/ste-tab/ste-tab.vue +87 -0
  100. package/components/ste-table/README.md +785 -0
  101. package/components/ste-table/common.js +8 -0
  102. package/components/ste-table/ste-table.vue +666 -0
  103. package/components/ste-table/utils.js +20 -0
  104. package/components/ste-table-column/checkbox-icon.vue +65 -0
  105. package/components/ste-table-column/common.scss +65 -0
  106. package/components/ste-table-column/radio-icon.vue +110 -0
  107. package/components/ste-table-column/ste-table-column.vue +255 -0
  108. package/components/ste-table-column/sub-table.vue +116 -0
  109. package/components/ste-table-column/table-popover.vue +204 -0
  110. package/components/ste-table-column/var.scss +1 -0
  111. package/components/ste-tabs/README.md +475 -0
  112. package/components/ste-tabs/props.js +212 -0
  113. package/components/ste-tabs/ste-tabs.vue +758 -0
  114. package/components/ste-text/README.md +66 -0
  115. package/components/ste-text/ste-text.vue +72 -0
  116. package/components/ste-toast/README.md +243 -0
  117. package/components/ste-toast/ste-toast.js +69 -0
  118. package/components/ste-toast/ste-toast.vue +231 -0
  119. package/components/ste-touch-swipe/README.md +104 -0
  120. package/components/ste-touch-swipe/TouchEvent.js +72 -0
  121. package/components/ste-touch-swipe/ste-touch-swipe.vue +327 -0
  122. package/components/ste-touch-swipe-item/ste-touch-swipe-item.vue +33 -0
  123. package/components/ste-tour/README.md +194 -0
  124. package/components/ste-tour/ste-tour.vue +355 -0
  125. package/components/ste-tree/README.md +240 -0
  126. package/components/ste-tree/ste-tree.vue +350 -0
  127. package/components/ste-upload/README.md +276 -0
  128. package/components/ste-upload/ReadFile.js +229 -0
  129. package/components/ste-upload/ste-upload.vue +526 -0
  130. package/components/ste-video/README.md +60 -0
  131. package/components/ste-video/props.js +149 -0
  132. package/components/ste-video/ste-video.vue +647 -0
  133. package/config/color.js +22 -0
  134. package/index.js +2 -0
  135. package/package.json +19 -0
  136. package/utils/Color.js +66 -0
  137. package/utils/System.js +110 -0
  138. package/utils/dayjs.min.js +1 -0
  139. package/utils/mixin.js +67 -0
  140. package/utils/store.js +7 -0
  141. package/utils/utils.js +604 -0
@@ -0,0 +1,758 @@
1
+ <template>
2
+ <view class="ste-tabs-root" :class="type" :style="[cmpRootStyle]">
3
+ <view class="tab-list-box" :style="[cmpListBackground, { paddingRight: cmpPullDown ? '70rpx' : 0 }]">
4
+ <scroll-view
5
+ class="tab-list view-list"
6
+ :class="{ 'open-down': openPullDown }"
7
+ enhanced
8
+ :scroll-x="cmpScrollX"
9
+ :scroll-with-animation="cmpScrollX"
10
+ :scroll-left="scrollLeft"
11
+ :show-scrollbar="false"
12
+ @scroll="onScroll"
13
+ >
14
+ <block v-for="(tab, index) in cmpTabList" :key="index">
15
+ <view
16
+ class="tab-space"
17
+ :class="{ 'show-tab-line': cmpShowLine }"
18
+ v-if="index > 0"
19
+ :style="{ height: `${cmpActiveTabEl.height}px` }"
20
+ >
21
+ <view class="space-line" />
22
+ </view>
23
+ <view
24
+ class="tab-item"
25
+ :class="{
26
+ active: tab.active,
27
+ disabled: tab.disabled || disabled,
28
+ start: index === 0,
29
+ }"
30
+ @click="onClickTab(tab, index)"
31
+ >
32
+ <view
33
+ class="tab-image"
34
+ v-if="showImage"
35
+ :style="{ backgroundImage: `url(${tab.image})` }"
36
+ ></view>
37
+ <ste-badge
38
+ v-if="showTitle"
39
+ :isBlock="type === 'card'"
40
+ :showDot="tab.showDot"
41
+ :content="tab.badge"
42
+ :showZero="tab.showZeroBadge"
43
+ isInline
44
+ :rootStyle="{ maxWidth: '100%' }"
45
+ >
46
+ <view class="tab-title" :style="[cmpEllipsis, cmpTitleStyle]">
47
+ {{ tab.title }}
48
+ </view>
49
+ </ste-badge>
50
+ <view class="tab-sub-title" v-if="showSubtitle" :style="[cmpEllipsis]">
51
+ {{ tab.subTitle }}
52
+ </view>
53
+ </view>
54
+ </block>
55
+ <view class="tab-line-box" v-if="cmpShowLine">
56
+ <view class="tab-line" :style="[cmpLineStyle]"></view>
57
+ </view>
58
+ </scroll-view>
59
+ <view v-if="cmpPullDown" class="tab-pull-down" @click="onOpenDown">
60
+ <ste-icon code="&#xe676;" size="10px" :color="titleColor" />
61
+ </view>
62
+ <view v-if="cmpPullDown" class="tab-pull-down-box" :class="{ open: openPullDown }">
63
+ <view class="pull-down-content" :style="[cmpPullStyle]">
64
+ <view class="content-tabs" :style="[cmpListBackground]">
65
+ <view class="placeholder">{{ placeholder }}</view>
66
+ <view class="tab-pull-down" @click="onCloseDown">
67
+ <view class="pull-down-icon" :style="[cmpPullIconTransform]">
68
+ <ste-icon code="&#xe676;" size="10px" :color="titleColor" />
69
+ </view>
70
+ </view>
71
+ </view>
72
+ <view class="tab-list" :style="[cmpListBackground, cmpPullListTransform]">
73
+ <view
74
+ class="tab-item"
75
+ v-for="(tab, index) in cmpTabList"
76
+ :key="index"
77
+ :class="{
78
+ active: tab.active,
79
+ disabled: tab.disabled || disabled,
80
+ }"
81
+ @click="onClickTab(tab, index)"
82
+ >
83
+ <view
84
+ class="tab-image"
85
+ v-if="showImage"
86
+ :style="{ backgroundImage: `url(${tab.image})` }"
87
+ ></view>
88
+ <view class="tab-title" v-if="showTitle" :style="[cmpEllipsis]">
89
+ {{ tab.title && tab.title.length > 4 ? `${tab.title.slice(0, 4)}...` : tab.title }}
90
+ </view>
91
+ <view class="tab-sub-title" v-if="showSubtitle" :style="[cmpEllipsis]">
92
+ {{
93
+ tab.subTitle && tab.subTitle.length > 4
94
+ ? `${tab.subTitle.slice(0, 4)}...`
95
+ : tab.subTitle
96
+ }}
97
+ </view>
98
+ </view>
99
+ </view>
100
+ </view>
101
+ </view>
102
+ </view>
103
+ <view class="content">
104
+ <!-- 内容区域 -->
105
+ <ste-touch-swipe
106
+ :index="cmpActiveIndex"
107
+ :childrenLength="cmpTabList.length"
108
+ :duration="duration"
109
+ :disabledIndexs="cmpDisabledIndexs"
110
+ :disabled="!swipeable || lock || disabled"
111
+ @change="onSliding"
112
+ >
113
+ <slot name="default" />
114
+ </ste-touch-swipe>
115
+ </view>
116
+ </view>
117
+ </template>
118
+
119
+ <script>
120
+ import utils from '../../utils/utils.js';
121
+ import props from './props.js';
122
+ import { parentMixin } from '../../utils/mixin.js';
123
+ import useColor from '../../config/color.js';
124
+ let color = useColor();
125
+ /**
126
+ * ste-tabs 标签页
127
+ * @description 标签页组件
128
+ * @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-tabs
129
+ * @property {String | Number} active 当前激活的选项,支持sync双向绑定(类型为number时tab绑定index,类型为string时tab绑定name)
130
+ * @property {String} type 组件类型
131
+ * @value line 线性(默认)
132
+ * @value card 卡片模式
133
+ * @property {Boolean} showImage 是否显示图片
134
+ * @property {Boolean} showTitle 是否显示标题
135
+ * @property {Boolean} showSubtitle 是否显示子标题
136
+ * @property {String} color 主题色(滑块颜色,边框颜色,选中的背景色,激活下拉列表中选项颜色),默认#0090FF
137
+ * @property {String | Number} radius 圆角,默认0,单位rpx
138
+ * @property {String} background 背景
139
+ * @property {Number} duration 切换动画时长,默认0.3,单位秒
140
+ * @property {Boolean} showLine 底部条是否显示,默认true(显示副标题的情况下会自动隐藏)
141
+ * @property {String | Number} lineWidth 底部条宽度,默认52,单位rpx
142
+ * @property {String | Number} lineHeight 底部条高度,默认6,单位rpx
143
+ * @property {Boolean} border 是否显示边框,仅在card模式下生效
144
+ * @property {Boolean} ellipsis 是否开启文本超长省略
145
+ * @property {String | Number} tabWidth 选项宽度,默认auto,单位rpx
146
+ * @property {String | Number} tabPadding 选项内边距,默认24,单位rpx
147
+ * @property {String | Number} tabSpace 选项间距,默认0,单位rpx
148
+ * @property {Number} divideNum 均分最大数量,默认4,设置0则不均分
149
+ * @property {Boolean} sticky 是否开启吸顶
150
+ * @property {Number | String} offsetTop 吸顶距离
151
+ * @property {Boolean} swipeable 是否开启手势滑动切换
152
+ * @property {String} titleColor 主标题字体颜色和下拉列表中主标题颜色,默认值#000000
153
+ * @property {String} activeTitleColor 激活主标题字体颜色,默认值#000000
154
+ * @property {String | Number} titleHeight 主标题高度,默认44,单位rpx
155
+ * @property {String} subColor 子标题字体颜色和下拉列表中子标题颜色,默认值#000000
156
+ * @property {String} activeSubColor 激活子标题字体颜色和下拉列表中子标题颜色,默认值#ffffff
157
+ * @property {String | Number} subTitleHeight 子标题高度,默认42,单位rpx
158
+ * @property {String | Number} subTitleRadius 子标题高度,默认21,单位rpx
159
+ * @property {Number | String} imageWidth 图片宽度,默认80,单位rpx
160
+ * @property {Number | String} imageHeight 图片高度,默认80,单位rpx
161
+ * @property {Number | String} imageRadius 图片圆角,默认50%,单位rpx
162
+ * @property {Number | String} imageBorderWidth 选中图片边框宽度,默认4,单位rpx
163
+ * @property {Boolean} showGapLine 是否显示分割线,默认值false
164
+ * @property {Boolean} lock 是否锁定(无法切换)
165
+ * @property {Boolean} disabled 是否禁用
166
+ * @property {Boolean} pullDown 是否有下拉选项(当选项数量大于均分数量时生效)
167
+ * @property {String} placeholder 下拉占位符,默认值:请选择
168
+ * @property {Number | String} maskTop 下拉蒙层顶部距离,默认0
169
+ * @property {Number | String} maskRight 下拉蒙层右侧距离,默认0
170
+ * @property {Number | String} maskBottom 下拉蒙层底部距离,默认0
171
+ * @property {Number | String} maskLeft 下拉蒙层左侧距离,默认0
172
+ * @property {Number} maskZindex 下拉蒙层层级,默认1001
173
+ * @event {Function} change 选项改变监听,参数{index:number,...item}
174
+ */
175
+ export default {
176
+ group: '导航组件',
177
+ title: 'Tabs 标签页',
178
+ name: 'ste-tabs',
179
+ props,
180
+ mixins: [parentMixin('ste-tabs')],
181
+ data() {
182
+ return {
183
+ dataActive: 0,
184
+ viewScrollLeft: 0,
185
+ scrollLeft: 0,
186
+ showComponent: false,
187
+ tabPropsList: [],
188
+ listBoxEl: null,
189
+ listEl: null,
190
+ tabEls: [],
191
+ openPullDown: false,
192
+ pullTransform: false,
193
+ _updateChildrenTimeout: null,
194
+ _updateTabsTimeout: null,
195
+ };
196
+ },
197
+ computed: {
198
+ cmpTabList() {
199
+ return this.tabPropsList.map((item, index) => {
200
+ const tab = { ...item };
201
+ switch (typeof this.dataActive) {
202
+ case 'string':
203
+ tab.active = this.dataActive === tab.name;
204
+ break;
205
+ case 'number':
206
+ tab.active = this.dataActive === index;
207
+ break;
208
+ }
209
+ if (tab.subTitle?.length > 6) {
210
+ tab.subTitle = tab.subTitle.slice(0, 6);
211
+ }
212
+ return tab;
213
+ });
214
+ },
215
+ cmpDisabledIndexs() {
216
+ const list = [];
217
+ this.cmpTabList.forEach((m, i) => {
218
+ if (m.disabled) list.push(i);
219
+ });
220
+ return list;
221
+ },
222
+ cmpRootStyle() {
223
+ let tabCardBg = utils.Color.formatColor(this.titleColor, 0.05);
224
+ let tabCardBgActive = utils.Color.formatColor(
225
+ this.color ? this.color : color.getColor().steThemeColor,
226
+ 0.1
227
+ );
228
+ let tabCardSubBg = this.color ? this.color : color.getColor().steThemeColor;
229
+ let tabCardSubColor = '#fff';
230
+ let activeTitleColor = this.activeTitleColor;
231
+ let borderWidthStart = '0';
232
+ let borderWidth = '0';
233
+ if (this.type === 'card') {
234
+ activeTitleColor = this.color ? this.color : color.getColor().steThemeColor;
235
+ if (this.border) {
236
+ tabCardBg = 'none';
237
+ tabCardBgActive = this.color ? this.color : color.getColor().steThemeColor;
238
+ tabCardSubBg = '#fff';
239
+ tabCardSubColor = this.color ? this.color : color.getColor().steThemeColor;
240
+ activeTitleColor = '#fff';
241
+ borderWidthStart = '1px';
242
+ borderWidth = '1px 1px 1px 0';
243
+ if (this.tabSpace > 0) {
244
+ borderWidth = '1px';
245
+ }
246
+ }
247
+ }
248
+ const tabSpace = utils.formatPx(this.tabSpace);
249
+ let tabSpaceLine = 0;
250
+ if (this.showGapLine) {
251
+ tabSpaceLine = '1px';
252
+ }
253
+ let tabWidth = utils.formatPx(this.tabWidth);
254
+ if (this.tabPropsList.length > 0 && this.tabPropsList.length <= this.divideNum) {
255
+ const listWidth = this.listEl?.width || 375;
256
+ const tabsWidth = listWidth - tabSpace.slice(0, -2) * (this.tabPropsList.length - 1);
257
+ tabWidth = tabsWidth / this.tabPropsList.length + 'px';
258
+ }
259
+
260
+ const style = {
261
+ '--tabs-color': this.color ? this.color : color.getColor().steThemeColor,
262
+ '--tabs-radius': utils.formatPx(this.radius),
263
+ '--tabs-card-background': tabCardBg,
264
+ '--tabs-card-background-active': tabCardBgActive,
265
+ '--tabs-card-sub-bg': tabCardSubBg,
266
+ '--tabs-card-sub-color': tabCardSubColor,
267
+ '--tabs-line-width': utils.formatPx(this.lineWidth),
268
+ '--tabs-line-height': utils.formatPx(this.lineHeight),
269
+ '--tabs-tab-width': tabWidth,
270
+ '--tabs-tab-padding': utils.formatPx(this.tabPadding),
271
+ '--tabs-tab-padding-bottom': this.cmpShowLine ? utils.formatPx(4) : utils.formatPx(this.tabPadding),
272
+ '--tabs-transition-duration': this.duration ? `${this.duration}s` : 'inherit',
273
+ '--tabs-tab-space': tabSpace,
274
+ '--tabs-tab-space-line': tabSpaceLine,
275
+ '--tabs-tab-border-width': borderWidth,
276
+ '--tabs-tab-border-width-start': borderWidthStart,
277
+ '--tabs-sticky': this.sticky ? 'sticky' : 'relative',
278
+ '--tabs-offset-top': utils.formatPx(this.offsetTop),
279
+ '--tabs-title-color': this.titleColor,
280
+ '--tabs-active-title-color': activeTitleColor,
281
+ '--tabs-title-height': utils.formatPx(this.titleHeight),
282
+ '--tabs-sub-title-height': utils.formatPx(this.subTitleHeight),
283
+ '--tabs-sub-title-radius': utils.formatPx(this.subTitleRadius),
284
+ '--tabs-list-height': this.openPullDown && this.listEl ? `${this.listEl?.height}px` : 'initial',
285
+ '--tabs-image-width': utils.formatPx(this.imageWidth),
286
+ '--tabs-image-height': utils.formatPx(this.imageHeight),
287
+ '--tabs-image-radius': utils.formatPx(this.imageRadius),
288
+ '--tabs-image-border-width': utils.formatPx(this.imageBorderWidth),
289
+ '--tabs-sub-color': this.subColor,
290
+ '--tabs-active-sub-color': this.activeSubColor,
291
+ '--tabs-mask-top': utils.formatPx(this.maskTop),
292
+ '--tabs-mask-right': utils.formatPx(this.maskRight),
293
+ '--tabs-mask-bottom': utils.formatPx(this.maskBottom),
294
+ '--tabs-mask-left': utils.formatPx(this.maskLeft),
295
+ '--tabs-mask-zindex': this.maskZindex,
296
+ opacity: this.showComponent ? '1' : '0',
297
+ zIndex: this.openPullDown ? '1001' : 1,
298
+ };
299
+ return style;
300
+ },
301
+ cmpListBackground() {
302
+ return utils.bg2style(this.background);
303
+ },
304
+ cmpActiveIndex() {
305
+ return this.cmpTabList.findIndex((m) => m.active);
306
+ },
307
+ cmpActiveTabEl() {
308
+ return this.tabEls[this.cmpActiveIndex] || {};
309
+ },
310
+ cmpLineStyle() {
311
+ const width = utils.formatPx(this.lineWidth);
312
+ const display = this.tabEls.length ? 'block' : 'none';
313
+ let marginLeft = 0;
314
+ if (this.cmpActiveIndex !== -1) {
315
+ const activeEl = this.tabEls[this.cmpActiveIndex];
316
+ if (activeEl) {
317
+ marginLeft = activeEl.left - this.listEl?.left + (activeEl.width - width.slice(0, -2)) / 2;
318
+ marginLeft += 'px';
319
+ }
320
+ }
321
+ return { marginLeft, display };
322
+ },
323
+ // 是否可滑动
324
+ cmpScrollX() {
325
+ return this.tabPropsList.length > this.divideNum;
326
+ },
327
+ // 是否有下拉
328
+ cmpPullDown() {
329
+ return this.cmpScrollX && this.pullDown;
330
+ },
331
+ // 下拉区域样式
332
+ cmpPullStyle() {
333
+ if (!this.listBoxEl || !this.openPullDown) return {};
334
+ const style = {};
335
+ style.top = `${this.listBoxEl.top}px`;
336
+ style.left = `${this.listBoxEl.left}px`;
337
+ style.width = `${this.listBoxEl.width}px`;
338
+ return style;
339
+ },
340
+ cmpPullListTransform() {
341
+ return { transform: `translateY(${this.pullTransform ? '0' : '-100%'})` };
342
+ },
343
+ cmpPullIconTransform() {
344
+ return { transform: `rotate(${this.pullTransform ? '180deg' : '0'})` };
345
+ },
346
+ cmpEllipsis() {
347
+ const style = {};
348
+ if (this.ellipsis) {
349
+ style.whiteSpace = 'nowrap';
350
+ style.textOverflow = 'ellipsis';
351
+ }
352
+ return style;
353
+ },
354
+ cmpTitleStyle() {
355
+ const style = {};
356
+ if (this.showSubtitle) {
357
+ style.fontWeight = 'bold';
358
+ style.fontSize = utils.formatPx(32);
359
+ }
360
+ return style;
361
+ },
362
+ cmpShowLine() {
363
+ return this.type === 'line' && this.showLine && !this.showSubtitle;
364
+ },
365
+ },
366
+ watch: {
367
+ active: {
368
+ handler(v) {
369
+ this.dataActive = v;
370
+ },
371
+ immediate: true,
372
+ },
373
+ cmpActiveIndex: {
374
+ handler(v) {
375
+ this.scrollToActive();
376
+ },
377
+ immediate: true,
378
+ },
379
+ cmpRootStyle() {
380
+ clearTimeout(this._updateTabsTimeout);
381
+ this._updateTabsTimeout = setTimeout(async () => {
382
+ this.tabEls = await utils.querySelector('.tab-list-box .tab-list.view-list .tab-item', this, true);
383
+ }, 10);
384
+ },
385
+ children() {
386
+ this.init();
387
+ },
388
+ },
389
+ mounted() {
390
+ this.init();
391
+ },
392
+ methods: {
393
+ init() {
394
+ this.showComponent = false;
395
+ clearTimeout(this._updateChildrenTimeout);
396
+ this._updateChildrenTimeout = setTimeout(() => {
397
+ this.getChildrenProps();
398
+ this.$nextTick(async () => {
399
+ this.listBoxEl = await utils.querySelector('.tab-list-box', this);
400
+ this.listEl = await utils.querySelector('.tab-list-box .tab-list.view-list', this);
401
+ this.tabEls = await utils.querySelector('.tab-list-box .tab-list.view-list .tab-item', this, true);
402
+ this.showComponent = true;
403
+ });
404
+ }, 100);
405
+ },
406
+ getChildrenProps() {
407
+ this.tabPropsList = this.children.map((m) => ({
408
+ title: m.title,
409
+ subTitle: m.subTitle,
410
+ image: m.image,
411
+ name: m.name,
412
+ index: m.index,
413
+ disabled: m.disabled,
414
+ showDot: m.showDot,
415
+ badge: m.badge,
416
+ showZeroBadge: m.showZeroBadge,
417
+ }));
418
+ },
419
+ onClickTab(tab, index) {
420
+ this.$emit('click-tab', { index, ...tab });
421
+ this.onSelect(tab, index);
422
+ },
423
+ async onSelect(tab, index) {
424
+ if (this.lock || tab.disabled || this.disabled) return false;
425
+ if (this.openPullDown) await this.onCloseDown();
426
+ let active = this.dataActive;
427
+ if (typeof this.dataActive === 'string') {
428
+ active = tab.name;
429
+ } else if (typeof this.dataActive === 'number') {
430
+ active = index;
431
+ }
432
+ this.dataActive = active;
433
+ this.$emit('update:active', active);
434
+ this.$emit('change', { ...tab, index });
435
+ return true;
436
+ },
437
+ onScroll(e) {
438
+ this.viewScrollLeft = e?.detail?.scrollLeft || 0;
439
+ },
440
+ scrollToActive() {
441
+ this.$nextTick(async () => {
442
+ const activeEl = await utils.querySelector('.tab-list-box .tab-list.view-list .tab-item.active', this);
443
+ if (!activeEl) return;
444
+ let tabEls = this.tabEls;
445
+ if (!tabEls[this.cmpActiveIndex]) {
446
+ tabEls = await utils.querySelector('.tab-list-box .tab-list.view-list .tab-item', this, true);
447
+ }
448
+ let listEl = this.listEl;
449
+ if (!listEl) {
450
+ listEl = await utils.querySelector('.tab-list-box .tab-list.view-list', this);
451
+ }
452
+ const scrollLeft = utils.scrollViewX({
453
+ viewLeft: activeEl.left,
454
+ viewRight: activeEl.right,
455
+ boxLeft: listEl.left,
456
+ boxRight: listEl.right,
457
+ prevWidth: tabEls[this.cmpActiveIndex - 1]?.width || 0,
458
+ nextWidth: tabEls[this.cmpActiveIndex + 1]?.width || 0,
459
+ scrollLeft: this.viewScrollLeft,
460
+ });
461
+ this.viewScrollLeft = scrollLeft;
462
+ this.scrollLeft = scrollLeft;
463
+ });
464
+ },
465
+ onOpenDown() {
466
+ return new Promise(async (resolve, reject) => {
467
+ this.listBoxEl = await utils.querySelector('.tab-list-box', this);
468
+ this.openPullDown = true;
469
+ setTimeout(() => {
470
+ this.pullTransform = true;
471
+ resolve();
472
+ }, 20);
473
+ });
474
+ },
475
+ onCloseDown() {
476
+ this.pullTransform = false;
477
+ setTimeout(() => {
478
+ this.openPullDown = false;
479
+ }, 200);
480
+ },
481
+ onSliding(index) {
482
+ if (this.disabled) return;
483
+ const tab = this.cmpTabList[index];
484
+ this.onSelect(tab, index);
485
+ },
486
+ },
487
+ };
488
+ </script>
489
+
490
+ <!-- 默认线状样式 -->
491
+ <style lang="scss" scoped>
492
+ .ste-tabs-root {
493
+ display: block;
494
+ width: 100%;
495
+ position: relative;
496
+ & > .tab-list-box {
497
+ position: var(--tabs-sticky);
498
+ top: var(--tabs-offset-top);
499
+ width: 100%;
500
+ background: #fff;
501
+ z-index: 1001;
502
+ border-radius: var(--tabs-radius);
503
+ overflow: hidden;
504
+
505
+ .tab-list {
506
+ width: 100%;
507
+ white-space: nowrap;
508
+ overflow-x: auto;
509
+
510
+ .tab-space {
511
+ display: inline-flex;
512
+ vertical-align: top;
513
+ width: var(--tabs-tab-space);
514
+ min-width: var(--tabs-tab-space-line);
515
+ align-items: center;
516
+ justify-content: center;
517
+ .space-line {
518
+ width: var(--tabs-tab-space-line);
519
+ background-color: rgba(180, 180, 180, 0.3);
520
+ height: 60%;
521
+ }
522
+ &.show-tab-line {
523
+ align-items: flex-end;
524
+ .space-line {
525
+ height: calc(100% - 36rpx);
526
+ transform: translateY(-6rpx);
527
+ }
528
+ }
529
+ }
530
+ .tab-item {
531
+ display: inline-flex;
532
+ flex-direction: column;
533
+ vertical-align: top;
534
+ width: var(--tabs-tab-width);
535
+ padding: var(--tabs-tab-padding);
536
+ padding-bottom: var(--tabs-tab-padding-bottom);
537
+ justify-content: center;
538
+ align-items: center;
539
+ text-align: center;
540
+ white-space: initial;
541
+ overflow: hidden;
542
+
543
+ .tab-image {
544
+ width: var(--tabs-image-width);
545
+ height: var(--tabs-image-height);
546
+ border-radius: var(--tabs-image-radius);
547
+ // border-width: var(--tabs-image-border-width);
548
+ border-width: 0;
549
+ border-style: solid;
550
+ border-color: var(--tabs-color);
551
+ background: rgba(187, 187, 187, 0.4);
552
+ // border-color: transparent;
553
+ overflow: hidden;
554
+ background-size: 100% 100%;
555
+ margin: 0 auto;
556
+ & + .tab-sub-title {
557
+ margin-top: 8rpx;
558
+ }
559
+ }
560
+ .tab-title {
561
+ max-width: 100%;
562
+ height: var(--tabs-title-height);
563
+ line-height: var(--tabs-title-height);
564
+ overflow: hidden;
565
+ font-size: 28rpx;
566
+ color: var(--tabs-title-color);
567
+ word-break: break-all;
568
+ margin: 0 auto;
569
+ & + .tab-sub-title {
570
+ margin-top: 4rpx;
571
+ }
572
+ }
573
+ .tab-sub-title {
574
+ width: 100%;
575
+ height: var(--tabs-sub-title-height);
576
+ line-height: var(--tabs-sub-title-height);
577
+ border-radius: var(--tabs-sub-title-radius);
578
+ max-width: 100%;
579
+ overflow: hidden;
580
+ font-size: 28rpx;
581
+ text-align: center;
582
+ margin: 0 auto;
583
+ color: var(--tabs-sub-color);
584
+ }
585
+
586
+ &.active {
587
+ .tab-image {
588
+ border-width: var(--tabs-image-border-width);
589
+ }
590
+ .tab-title {
591
+ color: var(--tabs-active-title-color);
592
+ font-weight: bold;
593
+ }
594
+ .tab-sub-title {
595
+ background-color: var(--tabs-color);
596
+ color: var(--tabs-active-sub-color);
597
+ }
598
+ }
599
+ &.disabled {
600
+ cursor: no-drop;
601
+ .tab-title,
602
+ .tab-sub-title {
603
+ color: #bbb;
604
+ }
605
+ }
606
+ }
607
+
608
+ .tab-line-box {
609
+ width: 100%;
610
+ padding: 4rpx 0;
611
+ .tab-line {
612
+ background-color: var(--tabs-color);
613
+ transition-duration: var(--tabs-transition-duration);
614
+ width: var(--tabs-line-width);
615
+ height: var(--tabs-line-height);
616
+ border-radius: 4rpx;
617
+ }
618
+ }
619
+
620
+ &.open-down {
621
+ opacity: 0;
622
+ pointer-events: none;
623
+ }
624
+ }
625
+ .tab-pull-down {
626
+ width: 70rpx;
627
+ position: absolute;
628
+ top: 0;
629
+ right: 0;
630
+ bottom: 0;
631
+ background-color: rgba(255, 255, 255, 0.45);
632
+ box-shadow: -5px 0 5px rgba(245, 245, 245, 0.5);
633
+ display: flex;
634
+ align-items: center;
635
+ justify-content: center;
636
+ .pull-down-icon {
637
+ width: 10px;
638
+ height: 10px;
639
+ display: flex;
640
+ align-items: center;
641
+ justify-content: center;
642
+ transition-duration: 0.3s;
643
+ }
644
+ }
645
+ .tab-pull-down-box {
646
+ display: none;
647
+ position: fixed;
648
+ background-color: rgba(0, 0, 0, 0.45);
649
+ z-index: var(--tabs-mask-zindex);
650
+ top: var(--tabs-mask-top);
651
+ right: var(--tabs-mask-right);
652
+ bottom: var(--tabs-mask-bottom);
653
+ left: var(--tabs-mask-left);
654
+ &.open {
655
+ display: block;
656
+ }
657
+ .pull-down-content {
658
+ width: 100%;
659
+ position: fixed;
660
+ height: initial;
661
+ display: block;
662
+ overflow: hidden;
663
+ .content-tabs {
664
+ width: 100%;
665
+ height: var(--tabs-list-height);
666
+ position: relative;
667
+ z-index: 10;
668
+ background-color: #ffffff;
669
+ .placeholder {
670
+ display: flex;
671
+ height: 100%;
672
+ align-items: center;
673
+ padding: 0 24rpx;
674
+ color: var(--tabs-title-color);
675
+ font-size: 28rpx;
676
+ }
677
+ }
678
+ .tab-list {
679
+ display: grid;
680
+ grid-template-columns: 25% 25% 25% 25%;
681
+ grid-row-gap: 30rpx;
682
+ flex-wrap: wrap;
683
+ position: relative;
684
+ z-index: 1;
685
+ background-color: #ffffff;
686
+ border-radius: 0 0 24rpx 24rpx;
687
+ padding: 30rpx 0;
688
+ transition-duration: 0.3s;
689
+ transform: translateY(-100%);
690
+ .tab-item {
691
+ width: 100%;
692
+ margin: 0;
693
+ padding: 0 24rpx;
694
+ &.active {
695
+ .tab-title {
696
+ color: var(--tabs-color);
697
+ }
698
+ }
699
+ }
700
+ }
701
+ }
702
+ }
703
+ }
704
+ }
705
+ </style>
706
+
707
+ <!-- card样式 -->
708
+ <style lang="scss" scoped>
709
+ .ste-tabs-root.card {
710
+ .tab-list-box {
711
+ .tab-list {
712
+ padding: 0;
713
+ .tab-item {
714
+ padding: 12rpx 24rpx;
715
+ background-color: var(--tabs-card-background);
716
+ border-width: var(--tabs-tab-border-width);
717
+ border-style: solid;
718
+ border-color: var(--tabs-color);
719
+ &.start {
720
+ border-width: var(--tabs-tab-border-width-start);
721
+ }
722
+
723
+ &.active {
724
+ background-color: var(--tabs-card-background-active);
725
+ .tab-sub-title {
726
+ background-color: var(--tabs-card-sub-bg);
727
+ color: var(--tabs-card-sub-color);
728
+ }
729
+ }
730
+ &.disabled {
731
+ cursor: no-drop;
732
+ background-color: #f5f5f5;
733
+ .tab-title,
734
+ .tab-sub-title {
735
+ color: #bbb;
736
+ }
737
+ }
738
+ }
739
+
740
+ .tab-line-box {
741
+ display: none;
742
+ }
743
+ }
744
+
745
+ .tab-pull-down-box {
746
+ &.open {
747
+ .pull-down-content {
748
+ .tab-list {
749
+ .tab-item {
750
+ background-color: initial;
751
+ }
752
+ }
753
+ }
754
+ }
755
+ }
756
+ }
757
+ }
758
+ </style>