stellar-ui-v2 1.36.1 → 1.37.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/README.md +60 -60
- package/components/ste-badge/ste-badge.vue +238 -238
- package/components/ste-button/ste-button.vue +16 -1
- package/components/ste-calendar/ste-calendar.vue +578 -578
- package/components/ste-checkbox/ste-checkbox.vue +303 -305
- package/components/ste-checkbox-group/ste-checkbox-group.vue +1 -1
- package/components/ste-icon/ste-icon.vue +143 -147
- package/components/ste-index-item/ste-index-item.vue +99 -96
- package/components/ste-index-list/ste-index-list.vue +128 -128
- package/components/ste-loading/ste-loading.vue +166 -166
- package/components/ste-media-preview/ste-media-preview.vue +267 -267
- package/components/ste-notice-bar/ste-notice-bar.vue +341 -331
- package/components/ste-number-keyboard/keyboard.vue +144 -140
- package/components/ste-number-keyboard/ste-number-keyboard.vue +226 -240
- package/components/ste-qrcode/ste-qrcode.vue +94 -40
- package/components/ste-radio/ste-radio.vue +291 -293
- package/components/ste-rate/ste-rate.vue +206 -202
- package/components/ste-rich-text/ste-rich-text.vue +70 -70
- package/components/ste-scroll-to/ste-scroll-to.vue +3 -9
- package/components/ste-scroll-to-item/ste-scroll-to-item.vue +1 -1
- package/components/ste-search/ste-search.vue +27 -47
- package/components/ste-select/ste-select.vue +2 -2
- package/components/ste-slider/ste-slider.vue +554 -544
- package/components/ste-step/ste-step.vue +264 -264
- package/components/ste-stepper/ste-stepper.vue +1 -0
- package/components/ste-steps/ste-steps.vue +65 -65
- package/components/ste-sticky/ste-sticky.vue +127 -127
- package/components/ste-swipe-action/ste-swipe-action.vue +311 -303
- package/components/ste-swiper-item/ste-swiper-item.vue +1 -1
- package/components/ste-switch/ste-switch.vue +148 -144
- package/components/ste-tab/ste-tab.vue +87 -87
- package/components/ste-tabs/README.md +2 -2
- package/components/ste-tabs/ste-tabs.vue +60 -72
- package/components/ste-tour/ste-tour.vue +18 -23
- package/components/ste-tree/ste-tree.vue +351 -350
- package/components/ste-upload/ste-upload.vue +519 -526
- package/package.json +3 -3
- package/utils/System.js +143 -110
- package/utils/utils.js +625 -595
package/README.md
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img alt="logo" src="https://image.whzb.com/chain/StellarUI/logo.png" width="200">
|
|
3
|
-
</p>
|
|
4
|
-
<h1 align="center">StellarUI</h1>
|
|
5
|
-
|
|
6
|
-
<p align="center">📱 一个基于vue2构建,打造的uni-app组件库</p>
|
|
7
|
-
|
|
8
|
-
<p align="center">
|
|
9
|
-
🚀 <a href="https://stellar-ui.intecloud.com.cn/pc/index/index">文档网站</a>
|
|
10
|
-
|
|
11
|
-
## ✨ 特性
|
|
12
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img alt="logo" src="https://image.whzb.com/chain/StellarUI/logo.png" width="200">
|
|
3
|
+
</p>
|
|
4
|
+
<h1 align="center">StellarUI</h1>
|
|
5
|
+
|
|
6
|
+
<p align="center">📱 一个基于vue2构建,打造的uni-app组件库</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
🚀 <a href="https://stellar-ui.intecloud.com.cn/pc/index/index">文档网站</a>
|
|
10
|
+
|
|
11
|
+
## ✨ 特性
|
|
12
|
+
|
|
13
13
|
- 🎯 多平台覆盖,支持 微信小程序、支付宝小程序、H5.
|
|
14
14
|
- 🚀 40+ 个高质量组件,覆盖移动端主流场景.
|
|
15
15
|
- 📖 提供丰富的文档和组件示例.
|
|
16
|
-
- 🎨 支持修改 CSS 变量实现主题定制.
|
|
17
|
-
|
|
18
|
-
## 📱 预览
|
|
19
|
-
|
|
20
|
-
扫描二维码访问演示,注意:因微信审核机制限制,当前的微信小程序示例可能不是最新版本,可以 clone 代码到本地预览。
|
|
21
|
-
|
|
22
|
-
<p style="display:flex;gap:24px">
|
|
23
|
-
<img src="https://image.whzb.com/chain/StellarUI/%E5%BE%AE%E4%BF%A1.jpg" width="200" height="200"/>
|
|
24
|
-
<img src="https://image.whzb.com/chain/StellarUI/%E6%94%AF%E4%BB%98%E5%AE%9D.png" width="200" height="200" />
|
|
25
|
-
</p>
|
|
16
|
+
- 🎨 支持修改 CSS 变量实现主题定制.
|
|
17
|
+
|
|
18
|
+
## 📱 预览
|
|
19
|
+
|
|
20
|
+
扫描二维码访问演示,注意:因微信审核机制限制,当前的微信小程序示例可能不是最新版本,可以 clone 代码到本地预览。
|
|
21
|
+
|
|
22
|
+
<p style="display:flex;gap:24px">
|
|
23
|
+
<img src="https://image.whzb.com/chain/StellarUI/%E5%BE%AE%E4%BF%A1.jpg" width="200" height="200"/>
|
|
24
|
+
<img src="https://image.whzb.com/chain/StellarUI/%E6%94%AF%E4%BB%98%E5%AE%9D.png" width="200" height="200" />
|
|
25
|
+
</p>
|
|
26
26
|
|
|
27
27
|
## 平台支持
|
|
28
28
|
|
|
@@ -30,22 +30,22 @@
|
|
|
30
30
|
|:-:|:-: |:-: |:-: |:-: |:-: |:-: |
|
|
31
31
|
|x |√ |√ |√ |× |× |× |
|
|
32
32
|
|
|
33
|
-
## 安装
|
|
34
|
-
|
|
35
|
-
```bash [npm]
|
|
36
|
-
npm i stellar-ui-v2 -S
|
|
33
|
+
## 安装
|
|
34
|
+
|
|
35
|
+
```bash [npm]
|
|
36
|
+
npm i stellar-ui-v2 -S
|
|
37
37
|
```
|
|
38
|
-
|
|
39
|
-
## 快速上手
|
|
40
|
-
|
|
41
|
-
详细说明见 [快速上手](https://stellar-ui.intecloud.com.cn/pc/index/index?name=handbook-%E5%BF%AB%E9%80%9F%E4%B8%8A%E6%89%8B)。
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
## 优秀案例
|
|
45
|
-
|
|
46
|
-
我们非常欢迎大家一起贡献优秀的 Demo 与案例,欢迎在此 [issue](https://github.com/wuhanshuzhiyun/
|
|
47
|
-
|
|
48
|
-
<table
|
|
38
|
+
|
|
39
|
+
## 快速上手
|
|
40
|
+
|
|
41
|
+
详细说明见 [快速上手](https://stellar-ui.intecloud.com.cn/pc/index/index?name=handbook-%E5%BF%AB%E9%80%9F%E4%B8%8A%E6%89%8B)。
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## 优秀案例
|
|
45
|
+
|
|
46
|
+
我们非常欢迎大家一起贡献优秀的 Demo 与案例,欢迎在此 [issue](https://github.com/wuhanshuzhiyun/StellarUI/issues/1) 提交案例。
|
|
47
|
+
|
|
48
|
+
<table border="0">
|
|
49
49
|
<tr>
|
|
50
50
|
<td>
|
|
51
51
|
<img width="250" src="https://image.whzb.com/chain/StellarUI/头像/邻里购.png" />
|
|
@@ -72,19 +72,19 @@ npm i stellar-ui-v2 -S
|
|
|
72
72
|
</td>
|
|
73
73
|
</tr>
|
|
74
74
|
</table>
|
|
75
|
-
|
|
76
|
-
## 周边生态
|
|
77
|
-
|
|
78
|
-
| 项目
|
|
79
|
-
| ---
|
|
80
|
-
|[
|
|
81
|
-
|[ste-vue-inset-loader](https://github.com/wuhanshuzhiyun/ste-vue-inset-loader)
|
|
82
|
-
|[ste-helper](https://
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
|
|
76
|
+
## 周边生态
|
|
77
|
+
|
|
78
|
+
| 项目 | 描述 |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
|[StellarUI-Plus](https://github.com/wuhanshuzhiyun/stellar-ui-plus) | 一个基于vue3构建,打造的uni-app组件库 |
|
|
81
|
+
|[ste-vue-inset-loader](https://github.com/wuhanshuzhiyun/ste-vue-inset-loader) |常用于小程序需要全局引入组件的场景的包 |
|
|
82
|
+
|[ste-helper](https://github.com/wuhanshuzhiyun/stellar-ui-plus/tree/main/plugins/ste-helper) |旨在帮助开发者更加有效率的使用 StellarUI-Plus来开发项目的vscode插件 |
|
|
83
|
+
|[ste-cli](https://github.com/wuhanshuzhiyun/ste-cli) |stellar配套的脚手架 |
|
|
84
|
+
|
|
85
85
|
## 核心团队
|
|
86
86
|
以下是`StellarUI`的核心贡献者们:
|
|
87
|
-
|
|
87
|
+
|
|
88
88
|
<table border="0">
|
|
89
89
|
<tr>
|
|
90
90
|
<td>
|
|
@@ -158,20 +158,20 @@ npm i stellar-ui-v2 -S
|
|
|
158
158
|
</p>
|
|
159
159
|
</td>
|
|
160
160
|
</tr>
|
|
161
|
-
</table>
|
|
161
|
+
</table>
|
|
162
162
|
|
|
163
163
|
### 贡献者们
|
|
164
164
|
|
|
165
|
-
感谢以下小伙伴们为 `StellarUI` 发展做出的贡献:
|
|
166
|
-
|
|
167
|
-
<a href="https://github.com/wuhanshuzhiyun/stellar-ui/graphs/contributors">
|
|
168
|
-
<img src="https://contrib.rocks/image?repo=wuhanshuzhiyun/stellar-ui" alt="contributors">
|
|
165
|
+
感谢以下小伙伴们为 `StellarUI` 发展做出的贡献:
|
|
166
|
+
|
|
167
|
+
<a href="https://github.com/wuhanshuzhiyun/stellar-ui/graphs/contributors">
|
|
168
|
+
<img src="https://contrib.rocks/image?repo=wuhanshuzhiyun/stellar-ui" alt="contributors">
|
|
169
169
|
</a>
|
|
170
|
-
|
|
171
|
-
## 鸣谢
|
|
172
|
-
- [uni-helper](https://github.com/uni-helper) - 感谢 uni-helper 团队提供的 uni-app 工具库,让 StellarUI 能够更方便地使用。
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
## 开源协议
|
|
176
|
-
|
|
170
|
+
|
|
171
|
+
## 鸣谢
|
|
172
|
+
- [uni-helper](https://github.com/uni-helper) - 感谢 uni-helper 团队提供的 uni-app 工具库,让 StellarUI 能够更方便地使用。
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
## 开源协议
|
|
176
|
+
|
|
177
177
|
本项目基于 [MIT](https://zh.wikipedia.org/wiki/MIT%E8%A8%B1%E5%8F%AF%E8%AD%89) 协议,请自由地享受和参与开源。
|
|
@@ -1,238 +1,238 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="ste-badge-root" :style="[rootStyle, { display: isInline ? 'inline-block' : 'block' }]">
|
|
3
|
-
<view
|
|
4
|
-
class="ste-badge-content"
|
|
5
|
-
:style="[cmpContentStyle]"
|
|
6
|
-
:class="'ste-badge-' + position"
|
|
7
|
-
v-if="showDot || cmpShowContent || $slots.content"
|
|
8
|
-
>
|
|
9
|
-
<view v-if="showDot" class="dot-box" />
|
|
10
|
-
<view
|
|
11
|
-
v-else
|
|
12
|
-
class="content-box"
|
|
13
|
-
:class="{ 'no-padding': $slots.content || (content && (content.length == 1 || content < 10)) }"
|
|
14
|
-
>
|
|
15
|
-
<slot name="content">
|
|
16
|
-
<view class="ste-badge-content-text">{{ cmpContent }}</view>
|
|
17
|
-
</slot>
|
|
18
|
-
</view>
|
|
19
|
-
</view>
|
|
20
|
-
<slot></slot>
|
|
21
|
-
</view>
|
|
22
|
-
</template>
|
|
23
|
-
|
|
24
|
-
<script>
|
|
25
|
-
import utils from '../../utils/utils.js';
|
|
26
|
-
/**
|
|
27
|
-
* ste-badge 徽标
|
|
28
|
-
* @description 徽标组件
|
|
29
|
-
* @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-badge
|
|
30
|
-
* @property {Number|String} content 徽标内容
|
|
31
|
-
* @property {String} background 背景 默认 #ee0a24
|
|
32
|
-
* @property {Boolean} showDot 是否展示为小红点 默认 false
|
|
33
|
-
* @property {Number|String} offsetX 根据徽标位置,设置x轴偏移量 默认 auto
|
|
34
|
-
* @property {Number|String} offsetY 根据徽标位置,设置y轴偏移量 默认 auto
|
|
35
|
-
* @property {Boolean} showZero 当 content 为数字 0,是否展示徽标,默认 false
|
|
36
|
-
* @property {String} position 徽标位置 默认 topRight
|
|
37
|
-
* @value topRight 上右 {String}
|
|
38
|
-
* @value topLeft 上左 {String}
|
|
39
|
-
* @value bottomLeft 下左 {String}
|
|
40
|
-
* @value bottomRight 下右 {String}
|
|
41
|
-
* @property {Number} max 徽标最大显示值 默认 99
|
|
42
|
-
* @property {Boolean} showBorder 是否显示边框 默认 false
|
|
43
|
-
* @property {String} borderColor 边框颜色
|
|
44
|
-
* @property {Number} zIndex 层级 默认 2
|
|
45
|
-
* @property {Boolean} isInline display属性是否为inline-block 默认 false
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
export default {
|
|
49
|
-
group: '基础组件',
|
|
50
|
-
title: 'Badge 徽标',
|
|
51
|
-
name: 'ste-badge',
|
|
52
|
-
options: {
|
|
53
|
-
virtualHost: true,
|
|
54
|
-
},
|
|
55
|
-
props: {
|
|
56
|
-
content: {
|
|
57
|
-
type: [String, Number, Boolean, null],
|
|
58
|
-
default: '',
|
|
59
|
-
},
|
|
60
|
-
background: {
|
|
61
|
-
type: [String, null],
|
|
62
|
-
default: '#ee0a24',
|
|
63
|
-
},
|
|
64
|
-
showDot: {
|
|
65
|
-
type: [Boolean, null],
|
|
66
|
-
default: false,
|
|
67
|
-
},
|
|
68
|
-
offsetX: {
|
|
69
|
-
type: [String, Number, null],
|
|
70
|
-
default: 'auto',
|
|
71
|
-
},
|
|
72
|
-
offsetY: {
|
|
73
|
-
type: [String, Number, null],
|
|
74
|
-
default: 'auto',
|
|
75
|
-
},
|
|
76
|
-
showZero: {
|
|
77
|
-
type: [Boolean, null],
|
|
78
|
-
default: false,
|
|
79
|
-
},
|
|
80
|
-
position: {
|
|
81
|
-
type: [String, null],
|
|
82
|
-
default: 'topRight',
|
|
83
|
-
},
|
|
84
|
-
max: {
|
|
85
|
-
type: [Number, null],
|
|
86
|
-
default: 99,
|
|
87
|
-
},
|
|
88
|
-
showBorder: {
|
|
89
|
-
type: [Boolean, null],
|
|
90
|
-
default: false,
|
|
91
|
-
},
|
|
92
|
-
borderColor: {
|
|
93
|
-
type: [String, null],
|
|
94
|
-
default: '#fff',
|
|
95
|
-
},
|
|
96
|
-
zIndex: {
|
|
97
|
-
type: [Number, null],
|
|
98
|
-
default: 2,
|
|
99
|
-
},
|
|
100
|
-
isInline: {
|
|
101
|
-
type: [Boolean, null],
|
|
102
|
-
default: false,
|
|
103
|
-
},
|
|
104
|
-
rootStyle: {
|
|
105
|
-
type: [Object, null],
|
|
106
|
-
default: () => ({}),
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
computed: {
|
|
110
|
-
cmpContentStyle() {
|
|
111
|
-
let style = {};
|
|
112
|
-
if (this.background) {
|
|
113
|
-
style = { backgroundColor: 'transparent', ...utils.bg2style(this.background) };
|
|
114
|
-
}
|
|
115
|
-
if (this.offsetX != 'auto' || this.offsetY != 'auto' || this.offsetX == 0 || this.offsetY == 0) {
|
|
116
|
-
style.transform = 'translate(0,0)';
|
|
117
|
-
|
|
118
|
-
switch (this.position) {
|
|
119
|
-
case 'topLeft':
|
|
120
|
-
style.left = utils.addUnit(this.offsetX);
|
|
121
|
-
style.top = utils.addUnit(this.offsetY);
|
|
122
|
-
break;
|
|
123
|
-
case 'bottomLeft':
|
|
124
|
-
style.left = utils.addUnit(this.offsetX);
|
|
125
|
-
style.bottom = utils.addUnit(this.offsetY);
|
|
126
|
-
break;
|
|
127
|
-
case 'bottomRight':
|
|
128
|
-
style.right = utils.addUnit(this.offsetX);
|
|
129
|
-
style.bottom = utils.addUnit(this.offsetY);
|
|
130
|
-
break;
|
|
131
|
-
default:
|
|
132
|
-
style.right = utils.addUnit(this.offsetX);
|
|
133
|
-
style.top = utils.addUnit(this.offsetY);
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
if (this.showBorder) {
|
|
138
|
-
style.border = 'solid 1px ' + this.borderColor;
|
|
139
|
-
}
|
|
140
|
-
style['z-index'] = this.zIndex;
|
|
141
|
-
|
|
142
|
-
return style;
|
|
143
|
-
},
|
|
144
|
-
cmpShowContent() {
|
|
145
|
-
return this.showZero ? true : this.content && this.content != '0';
|
|
146
|
-
},
|
|
147
|
-
cmpContent() {
|
|
148
|
-
if (utils.isNumber(this.content) && this.content > this.max) {
|
|
149
|
-
return `${this.max}+`;
|
|
150
|
-
} else {
|
|
151
|
-
return String(this.content);
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
</script>
|
|
157
|
-
|
|
158
|
-
<style lang="scss" scoped>
|
|
159
|
-
$default-size: 28rpx;
|
|
160
|
-
.ste-badge-root {
|
|
161
|
-
position: relative;
|
|
162
|
-
|
|
163
|
-
.ste-badge-content {
|
|
164
|
-
display: inline-block;
|
|
165
|
-
position: absolute;
|
|
166
|
-
font-size: 24rpx;
|
|
167
|
-
color: #ffffff;
|
|
168
|
-
background-color: #ee0a24;
|
|
169
|
-
border-radius: 99999rpx;
|
|
170
|
-
width: fit-content;
|
|
171
|
-
background-size: cover;
|
|
172
|
-
|
|
173
|
-
.content-box {
|
|
174
|
-
display: flex;
|
|
175
|
-
align-items: center;
|
|
176
|
-
justify-content: center;
|
|
177
|
-
height: $default-size;
|
|
178
|
-
max-height: $default-size;
|
|
179
|
-
min-height: $default-size;
|
|
180
|
-
width: auto;
|
|
181
|
-
min-width: $default-size;
|
|
182
|
-
overflow: hidden;
|
|
183
|
-
|
|
184
|
-
padding: 0 8rpx;
|
|
185
|
-
line-height: 0;
|
|
186
|
-
|
|
187
|
-
&.no-padding {
|
|
188
|
-
padding: 0;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
.dot-box {
|
|
193
|
-
height: 12rpx;
|
|
194
|
-
width: 12rpx;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
&-text {
|
|
198
|
-
font-size: 22rpx;
|
|
199
|
-
color: #ffffff;
|
|
200
|
-
line-height: $default-size;
|
|
201
|
-
vertical-align: middle;
|
|
202
|
-
position: relative;
|
|
203
|
-
// #ifdef H5
|
|
204
|
-
top: -0.5rpx;
|
|
205
|
-
// #endif
|
|
206
|
-
// #ifdef MP-WEIXIN
|
|
207
|
-
// top: -0.5rpx;
|
|
208
|
-
// #endif
|
|
209
|
-
// #ifdef MP-ALIPAY
|
|
210
|
-
// top: 0.5rpx;
|
|
211
|
-
// #endif
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
.ste-badge- {
|
|
216
|
-
&topRight {
|
|
217
|
-
top: 0;
|
|
218
|
-
right: 0;
|
|
219
|
-
transform: translate(50%, -50%);
|
|
220
|
-
}
|
|
221
|
-
&topLeft {
|
|
222
|
-
top: 0;
|
|
223
|
-
left: 0;
|
|
224
|
-
transform: translate(-50%, -50%);
|
|
225
|
-
}
|
|
226
|
-
&bottomLeft {
|
|
227
|
-
bottom: 0;
|
|
228
|
-
left: 0;
|
|
229
|
-
transform: translate(-50%, 50%);
|
|
230
|
-
}
|
|
231
|
-
&bottomRight {
|
|
232
|
-
bottom: 0;
|
|
233
|
-
right: 0;
|
|
234
|
-
transform: translate(50%, 50%);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<view class="ste-badge-root" :style="[rootStyle, { display: isInline ? 'inline-block' : 'block' }]">
|
|
3
|
+
<view
|
|
4
|
+
class="ste-badge-content"
|
|
5
|
+
:style="[cmpContentStyle]"
|
|
6
|
+
:class="'ste-badge-' + position"
|
|
7
|
+
v-if="showDot || cmpShowContent || $slots.content"
|
|
8
|
+
>
|
|
9
|
+
<view v-if="showDot" class="dot-box" />
|
|
10
|
+
<view
|
|
11
|
+
v-else
|
|
12
|
+
class="content-box"
|
|
13
|
+
:class="{ 'no-padding': $slots.content || (content && (content.length == 1 || content < 10)) }"
|
|
14
|
+
>
|
|
15
|
+
<slot name="content">
|
|
16
|
+
<view class="ste-badge-content-text">{{ cmpContent }}</view>
|
|
17
|
+
</slot>
|
|
18
|
+
</view>
|
|
19
|
+
</view>
|
|
20
|
+
<slot></slot>
|
|
21
|
+
</view>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
import utils from '../../utils/utils.js';
|
|
26
|
+
/**
|
|
27
|
+
* ste-badge 徽标
|
|
28
|
+
* @description 徽标组件
|
|
29
|
+
* @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-badge
|
|
30
|
+
* @property {Number|String} content 徽标内容
|
|
31
|
+
* @property {String} background 背景 默认 #ee0a24
|
|
32
|
+
* @property {Boolean} showDot 是否展示为小红点 默认 false
|
|
33
|
+
* @property {Number|String} offsetX 根据徽标位置,设置x轴偏移量 默认 auto
|
|
34
|
+
* @property {Number|String} offsetY 根据徽标位置,设置y轴偏移量 默认 auto
|
|
35
|
+
* @property {Boolean} showZero 当 content 为数字 0,是否展示徽标,默认 false
|
|
36
|
+
* @property {String} position 徽标位置 默认 topRight
|
|
37
|
+
* @value topRight 上右 {String}
|
|
38
|
+
* @value topLeft 上左 {String}
|
|
39
|
+
* @value bottomLeft 下左 {String}
|
|
40
|
+
* @value bottomRight 下右 {String}
|
|
41
|
+
* @property {Number} max 徽标最大显示值 默认 99
|
|
42
|
+
* @property {Boolean} showBorder 是否显示边框 默认 false
|
|
43
|
+
* @property {String} borderColor 边框颜色
|
|
44
|
+
* @property {Number} zIndex 层级 默认 2
|
|
45
|
+
* @property {Boolean} isInline display属性是否为inline-block 默认 false
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
export default {
|
|
49
|
+
group: '基础组件',
|
|
50
|
+
title: 'Badge 徽标',
|
|
51
|
+
name: 'ste-badge',
|
|
52
|
+
options: {
|
|
53
|
+
virtualHost: true,
|
|
54
|
+
},
|
|
55
|
+
props: {
|
|
56
|
+
content: {
|
|
57
|
+
type: [String, Number, Boolean, null],
|
|
58
|
+
default: '',
|
|
59
|
+
},
|
|
60
|
+
background: {
|
|
61
|
+
type: [String, null],
|
|
62
|
+
default: '#ee0a24',
|
|
63
|
+
},
|
|
64
|
+
showDot: {
|
|
65
|
+
type: [Boolean, null],
|
|
66
|
+
default: false,
|
|
67
|
+
},
|
|
68
|
+
offsetX: {
|
|
69
|
+
type: [String, Number, null],
|
|
70
|
+
default: 'auto',
|
|
71
|
+
},
|
|
72
|
+
offsetY: {
|
|
73
|
+
type: [String, Number, null],
|
|
74
|
+
default: 'auto',
|
|
75
|
+
},
|
|
76
|
+
showZero: {
|
|
77
|
+
type: [Boolean, null],
|
|
78
|
+
default: false,
|
|
79
|
+
},
|
|
80
|
+
position: {
|
|
81
|
+
type: [String, null],
|
|
82
|
+
default: 'topRight',
|
|
83
|
+
},
|
|
84
|
+
max: {
|
|
85
|
+
type: [Number, null],
|
|
86
|
+
default: 99,
|
|
87
|
+
},
|
|
88
|
+
showBorder: {
|
|
89
|
+
type: [Boolean, null],
|
|
90
|
+
default: false,
|
|
91
|
+
},
|
|
92
|
+
borderColor: {
|
|
93
|
+
type: [String, null],
|
|
94
|
+
default: '#fff',
|
|
95
|
+
},
|
|
96
|
+
zIndex: {
|
|
97
|
+
type: [Number, null],
|
|
98
|
+
default: 2,
|
|
99
|
+
},
|
|
100
|
+
isInline: {
|
|
101
|
+
type: [Boolean, null],
|
|
102
|
+
default: false,
|
|
103
|
+
},
|
|
104
|
+
rootStyle: {
|
|
105
|
+
type: [Object, null],
|
|
106
|
+
default: () => ({}),
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
computed: {
|
|
110
|
+
cmpContentStyle() {
|
|
111
|
+
let style = {};
|
|
112
|
+
if (this.background) {
|
|
113
|
+
style = { backgroundColor: 'transparent', ...utils.bg2style(this.background) };
|
|
114
|
+
}
|
|
115
|
+
if (this.offsetX != 'auto' || this.offsetY != 'auto' || this.offsetX == 0 || this.offsetY == 0) {
|
|
116
|
+
style.transform = 'translate(0,0)';
|
|
117
|
+
|
|
118
|
+
switch (this.position) {
|
|
119
|
+
case 'topLeft':
|
|
120
|
+
style.left = utils.addUnit(this.offsetX);
|
|
121
|
+
style.top = utils.addUnit(this.offsetY);
|
|
122
|
+
break;
|
|
123
|
+
case 'bottomLeft':
|
|
124
|
+
style.left = utils.addUnit(this.offsetX);
|
|
125
|
+
style.bottom = utils.addUnit(this.offsetY);
|
|
126
|
+
break;
|
|
127
|
+
case 'bottomRight':
|
|
128
|
+
style.right = utils.addUnit(this.offsetX);
|
|
129
|
+
style.bottom = utils.addUnit(this.offsetY);
|
|
130
|
+
break;
|
|
131
|
+
default:
|
|
132
|
+
style.right = utils.addUnit(this.offsetX);
|
|
133
|
+
style.top = utils.addUnit(this.offsetY);
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (this.showBorder) {
|
|
138
|
+
style.border = 'solid 1px ' + this.borderColor;
|
|
139
|
+
}
|
|
140
|
+
style['z-index'] = this.zIndex;
|
|
141
|
+
|
|
142
|
+
return style;
|
|
143
|
+
},
|
|
144
|
+
cmpShowContent() {
|
|
145
|
+
return this.showZero ? true : this.content && this.content != '0';
|
|
146
|
+
},
|
|
147
|
+
cmpContent() {
|
|
148
|
+
if (utils.isNumber(this.content) && this.content > this.max) {
|
|
149
|
+
return `${this.max}+`;
|
|
150
|
+
} else {
|
|
151
|
+
return String(this.content);
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
</script>
|
|
157
|
+
|
|
158
|
+
<style lang="scss" scoped>
|
|
159
|
+
$default-size: 28rpx;
|
|
160
|
+
.ste-badge-root {
|
|
161
|
+
position: relative;
|
|
162
|
+
|
|
163
|
+
.ste-badge-content {
|
|
164
|
+
display: inline-block;
|
|
165
|
+
position: absolute;
|
|
166
|
+
font-size: 24rpx;
|
|
167
|
+
color: #ffffff;
|
|
168
|
+
background-color: #ee0a24;
|
|
169
|
+
border-radius: 99999rpx;
|
|
170
|
+
width: fit-content;
|
|
171
|
+
background-size: cover;
|
|
172
|
+
|
|
173
|
+
.content-box {
|
|
174
|
+
display: flex;
|
|
175
|
+
align-items: center;
|
|
176
|
+
justify-content: center;
|
|
177
|
+
height: $default-size;
|
|
178
|
+
max-height: $default-size;
|
|
179
|
+
min-height: $default-size;
|
|
180
|
+
width: auto;
|
|
181
|
+
min-width: $default-size;
|
|
182
|
+
overflow: hidden;
|
|
183
|
+
|
|
184
|
+
padding: 0 8rpx;
|
|
185
|
+
line-height: 0;
|
|
186
|
+
|
|
187
|
+
&.no-padding {
|
|
188
|
+
padding: 0;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.dot-box {
|
|
193
|
+
height: 12rpx;
|
|
194
|
+
width: 12rpx;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
&-text {
|
|
198
|
+
font-size: 22rpx;
|
|
199
|
+
color: #ffffff;
|
|
200
|
+
line-height: $default-size;
|
|
201
|
+
vertical-align: middle;
|
|
202
|
+
position: relative;
|
|
203
|
+
// #ifdef H5
|
|
204
|
+
top: -0.5rpx;
|
|
205
|
+
// #endif
|
|
206
|
+
// #ifdef MP-WEIXIN
|
|
207
|
+
// top: -0.5rpx;
|
|
208
|
+
// #endif
|
|
209
|
+
// #ifdef MP-ALIPAY
|
|
210
|
+
// top: 0.5rpx;
|
|
211
|
+
// #endif
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.ste-badge- {
|
|
216
|
+
&topRight {
|
|
217
|
+
top: 0;
|
|
218
|
+
right: 0;
|
|
219
|
+
transform: translate(50%, -50%);
|
|
220
|
+
}
|
|
221
|
+
&topLeft {
|
|
222
|
+
top: 0;
|
|
223
|
+
left: 0;
|
|
224
|
+
transform: translate(-50%, -50%);
|
|
225
|
+
}
|
|
226
|
+
&bottomLeft {
|
|
227
|
+
bottom: 0;
|
|
228
|
+
left: 0;
|
|
229
|
+
transform: translate(-50%, 50%);
|
|
230
|
+
}
|
|
231
|
+
&bottomRight {
|
|
232
|
+
bottom: 0;
|
|
233
|
+
right: 0;
|
|
234
|
+
transform: translate(50%, 50%);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
</style>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<button
|
|
3
3
|
v-if="stopPropagation"
|
|
4
|
-
class="
|
|
4
|
+
:class="[cmpBtnRootClass]"
|
|
5
5
|
:disabled="disabled"
|
|
6
6
|
:hover-class="!loading ? 'ste-button--root-active' : ''"
|
|
7
7
|
@click.stop="handleClick"
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
@chooseavatar="chooseavatar"
|
|
22
22
|
@getAuthorize="getAuthorize"
|
|
23
23
|
@followLifestyle="followLifestyle"
|
|
24
|
+
data-test="button"
|
|
24
25
|
>
|
|
25
26
|
<view class="btn-box">
|
|
26
27
|
<text v-if="loading">加载中.......</text>
|
|
@@ -156,6 +157,20 @@ export default {
|
|
|
156
157
|
},
|
|
157
158
|
created() {},
|
|
158
159
|
computed: {
|
|
160
|
+
cmpBtnRootClass() {
|
|
161
|
+
let classes = ['ste-button--root'];
|
|
162
|
+
classes.push(`ste-button--mode-${this.mode}`);
|
|
163
|
+
|
|
164
|
+
if (this.round) {
|
|
165
|
+
classes.push('ste-button--round');
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (this.disabled) {
|
|
169
|
+
classes.push('ste-button--disabled');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return classes.join(' ');
|
|
173
|
+
},
|
|
159
174
|
cmpBtnStyle() {
|
|
160
175
|
let style = {};
|
|
161
176
|
// 为解决支付宝动态类名时不兼容,尽量使用内联样式
|