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.
- package/common/css/common.scss +61 -0
- package/components/ste-animate/README.md +117 -0
- package/components/ste-animate/animate.scss +247 -0
- package/components/ste-animate/ste-animate.vue +200 -0
- package/components/ste-badge/README.md +171 -0
- package/components/ste-badge/ste-badge.vue +238 -0
- package/components/ste-barcode/README.md +36 -0
- package/components/ste-barcode/encode2.js +317 -0
- package/components/ste-barcode/ste-barcode.vue +213 -0
- package/components/ste-button/README.md +129 -0
- package/components/ste-button/ste-button.vue +345 -0
- package/components/ste-calendar/README.md +304 -0
- package/components/ste-calendar/self-date.js +119 -0
- package/components/ste-calendar/ste-calendar.vue +578 -0
- package/components/ste-checkbox/README.md +297 -0
- package/components/ste-checkbox/ste-checkbox.vue +305 -0
- package/components/ste-checkbox-group/ste-checkbox-group.vue +133 -0
- package/components/ste-code-input/README.md +67 -0
- package/components/ste-code-input/ste-code-input.vue +302 -0
- package/components/ste-date-picker/README.md +135 -0
- package/components/ste-date-picker/ste-date-picker.vue +407 -0
- package/components/ste-drag/README.md +103 -0
- package/components/ste-drag/ste-drag.vue +203 -0
- package/components/ste-dropdown-menu/README.md +358 -0
- package/components/ste-dropdown-menu/ste-dropdown-menu.vue +405 -0
- package/components/ste-dropdown-menu-item/ste-dropdown-menu-item.vue +176 -0
- package/components/ste-icon/README.md +90 -0
- package/components/ste-icon/iconfont.css +8 -0
- package/components/ste-icon/ste-icon.vue +147 -0
- package/components/ste-image/README.md +154 -0
- package/components/ste-image/ste-image.vue +218 -0
- package/components/ste-index-item/ste-index-item.vue +96 -0
- package/components/ste-index-list/README.md +153 -0
- package/components/ste-index-list/ste-index-list.vue +128 -0
- package/components/ste-input/README.md +146 -0
- package/components/ste-input/ste-input.vue +480 -0
- package/components/ste-loading/README.md +81 -0
- package/components/ste-loading/ste-loading.vue +166 -0
- package/components/ste-media-preview/README.md +243 -0
- package/components/ste-media-preview/TouchScaleing.js +102 -0
- package/components/ste-media-preview/ste-media-preview.vue +267 -0
- package/components/ste-message-box/README.md +217 -0
- package/components/ste-message-box/ste-message-box.js +72 -0
- package/components/ste-message-box/ste-message-box.vue +380 -0
- package/components/ste-notice-bar/README.md +129 -0
- package/components/ste-notice-bar/ste-notice-bar.vue +331 -0
- package/components/ste-number-keyboard/README.md +246 -0
- package/components/ste-number-keyboard/keyboard.vue +140 -0
- package/components/ste-number-keyboard/ste-number-keyboard.vue +240 -0
- package/components/ste-picker/ste-picker.vue +258 -0
- package/components/ste-popup/README.md +148 -0
- package/components/ste-popup/ste-popup.vue +337 -0
- package/components/ste-price/README.md +129 -0
- package/components/ste-price/ste-price.vue +258 -0
- package/components/ste-progress/README.md +87 -0
- package/components/ste-progress/ste-progress.vue +200 -0
- package/components/ste-qrcode/README.md +50 -0
- package/components/ste-qrcode/ste-qrcode.vue +164 -0
- package/components/ste-qrcode/uqrcode.js +34 -0
- package/components/ste-radio/README.md +286 -0
- package/components/ste-radio/ste-radio.vue +293 -0
- package/components/ste-radio-group/ste-radio-group.vue +128 -0
- package/components/ste-rate/README.md +115 -0
- package/components/ste-rate/ste-rate.vue +202 -0
- package/components/ste-read-more/README.md +111 -0
- package/components/ste-read-more/ste-read-more.vue +133 -0
- package/components/ste-rich-text/README.md +31 -0
- package/components/ste-rich-text/ste-rich-text.vue +70 -0
- package/components/ste-scroll-to/README.md +68 -0
- package/components/ste-scroll-to/mixin.js +173 -0
- package/components/ste-scroll-to/ste-scroll-to.vue +45 -0
- package/components/ste-scroll-to-item/ste-scroll-to-item.vue +25 -0
- package/components/ste-search/README.md +262 -0
- package/components/ste-search/ste-search.vue +547 -0
- package/components/ste-select/README.md +434 -0
- package/components/ste-select/datapager.vue +62 -0
- package/components/ste-select/datetime.vue +106 -0
- package/components/ste-select/defaultDate.js +142 -0
- package/components/ste-select/ste-select.vue +843 -0
- package/components/ste-signature/README.md +105 -0
- package/components/ste-signature/ste-signature.vue +220 -0
- package/components/ste-slider/README.md +165 -0
- package/components/ste-slider/ste-slider.vue +544 -0
- package/components/ste-step/ste-step.vue +264 -0
- package/components/ste-stepper/README.md +170 -0
- package/components/ste-stepper/ste-stepper.vue +373 -0
- package/components/ste-steps/README.md +132 -0
- package/components/ste-steps/ste-steps.vue +65 -0
- package/components/ste-sticky/README.md +52 -0
- package/components/ste-sticky/ste-sticky.vue +127 -0
- package/components/ste-swipe-action/README.md +197 -0
- package/components/ste-swipe-action/ste-swipe-action.vue +303 -0
- package/components/ste-swipe-action-group/ste-swipe-action-group.vue +104 -0
- package/components/ste-swiper/README.md +173 -0
- package/components/ste-swiper/ste-swiper.vue +462 -0
- package/components/ste-swiper-item/ste-swiper-item.vue +41 -0
- package/components/ste-switch/README.md +110 -0
- package/components/ste-switch/ste-switch.vue +144 -0
- package/components/ste-tab/ste-tab.vue +87 -0
- package/components/ste-table/README.md +785 -0
- package/components/ste-table/common.js +8 -0
- package/components/ste-table/ste-table.vue +666 -0
- package/components/ste-table/utils.js +20 -0
- package/components/ste-table-column/checkbox-icon.vue +65 -0
- package/components/ste-table-column/common.scss +65 -0
- package/components/ste-table-column/radio-icon.vue +110 -0
- package/components/ste-table-column/ste-table-column.vue +255 -0
- package/components/ste-table-column/sub-table.vue +116 -0
- package/components/ste-table-column/table-popover.vue +204 -0
- package/components/ste-table-column/var.scss +1 -0
- package/components/ste-tabs/README.md +475 -0
- package/components/ste-tabs/props.js +212 -0
- package/components/ste-tabs/ste-tabs.vue +758 -0
- package/components/ste-text/README.md +66 -0
- package/components/ste-text/ste-text.vue +72 -0
- package/components/ste-toast/README.md +243 -0
- package/components/ste-toast/ste-toast.js +69 -0
- package/components/ste-toast/ste-toast.vue +231 -0
- package/components/ste-touch-swipe/README.md +104 -0
- package/components/ste-touch-swipe/TouchEvent.js +72 -0
- package/components/ste-touch-swipe/ste-touch-swipe.vue +327 -0
- package/components/ste-touch-swipe-item/ste-touch-swipe-item.vue +33 -0
- package/components/ste-tour/README.md +194 -0
- package/components/ste-tour/ste-tour.vue +355 -0
- package/components/ste-tree/README.md +240 -0
- package/components/ste-tree/ste-tree.vue +350 -0
- package/components/ste-upload/README.md +276 -0
- package/components/ste-upload/ReadFile.js +229 -0
- package/components/ste-upload/ste-upload.vue +526 -0
- package/components/ste-video/README.md +60 -0
- package/components/ste-video/props.js +149 -0
- package/components/ste-video/ste-video.vue +647 -0
- package/config/color.js +22 -0
- package/index.js +2 -0
- package/package.json +19 -0
- package/utils/Color.js +66 -0
- package/utils/System.js +110 -0
- package/utils/dayjs.min.js +1 -0
- package/utils/mixin.js +67 -0
- package/utils/store.js +7 -0
- package/utils/utils.js +604 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="ste-rate-root">
|
|
3
|
+
<view class="list" :style="[cmpListStyle]">
|
|
4
|
+
<view v-for="index in cmpCount" class="item" :key="index">
|
|
5
|
+
<view class="icon-box inactive" @click="onSelect(index)">
|
|
6
|
+
<ste-icon :code="cmpInactiveCode" :color="inactiveColor" :size="size"></ste-icon>
|
|
7
|
+
</view>
|
|
8
|
+
<view class="icon-box active" @click="onSelect(index)" :style="{ width: getWidth(index) }">
|
|
9
|
+
<ste-icon
|
|
10
|
+
:code="cmpActiveCode"
|
|
11
|
+
:color="disabled ? '#C8C9CC' : cmpActiveColor"
|
|
12
|
+
:size="size"
|
|
13
|
+
></ste-icon>
|
|
14
|
+
</view>
|
|
15
|
+
</view>
|
|
16
|
+
</view>
|
|
17
|
+
</view>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
import utils from '../../utils/utils.js';
|
|
22
|
+
import useColor from '../../config/color.js';
|
|
23
|
+
let color = useColor();
|
|
24
|
+
/**
|
|
25
|
+
* ste-rate 评分
|
|
26
|
+
* @description 评分组件,用于对事物进行评级操作。
|
|
27
|
+
* @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-rate
|
|
28
|
+
* @property {Number} value 当前评分数(支持v-model双向绑定)默认 0
|
|
29
|
+
* @property {Number} count 图标总数 默认 5
|
|
30
|
+
* @property {Number} score 每颗星星代表的分数 默认 1
|
|
31
|
+
* @property {Boolean} disabled 禁用 默认 false
|
|
32
|
+
* @property {Boolean} readonly 只读(不置灰) 默认 false
|
|
33
|
+
* @property {Number|String} size 评分图标的大小,单位rpx 默认 44
|
|
34
|
+
* @property {String} inactiveColor 未选中的颜色 默认 #dddddd
|
|
35
|
+
* @property {String} activeColor 选中的颜色 默认 #0090FF
|
|
36
|
+
* @property {String} inactiveCode 未选中的图标code 默认 
|
|
37
|
+
* @property {String} activeCode 选中的图标code 默认 
|
|
38
|
+
* @property {Number|String} gutter 每个图标之间的距离,单位rpx 默认 10
|
|
39
|
+
* @property {Array} iconData 每个分值对应的图标code
|
|
40
|
+
* @event {Function} change 当前分值变化时触发的事件
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
export default {
|
|
44
|
+
group: '表单组件',
|
|
45
|
+
title: 'Rate 评分',
|
|
46
|
+
name: 'ste-rate',
|
|
47
|
+
props: {
|
|
48
|
+
value: {
|
|
49
|
+
type: [Number, null],
|
|
50
|
+
default: 0,
|
|
51
|
+
},
|
|
52
|
+
count: {
|
|
53
|
+
type: [Number, null],
|
|
54
|
+
default: 5,
|
|
55
|
+
},
|
|
56
|
+
score: {
|
|
57
|
+
type: [Number, null],
|
|
58
|
+
default: 1,
|
|
59
|
+
},
|
|
60
|
+
disabled: {
|
|
61
|
+
type: [Boolean, null],
|
|
62
|
+
default: false,
|
|
63
|
+
},
|
|
64
|
+
readonly: {
|
|
65
|
+
type: [Boolean, null],
|
|
66
|
+
default: false,
|
|
67
|
+
},
|
|
68
|
+
size: {
|
|
69
|
+
type: [String, Number, null],
|
|
70
|
+
default: 44,
|
|
71
|
+
},
|
|
72
|
+
inactiveColor: {
|
|
73
|
+
type: [String, null],
|
|
74
|
+
default: '#dddddd',
|
|
75
|
+
},
|
|
76
|
+
activeColor: {
|
|
77
|
+
type: [String, null],
|
|
78
|
+
default: '',
|
|
79
|
+
},
|
|
80
|
+
inactiveCode: {
|
|
81
|
+
type: [String, null],
|
|
82
|
+
default: '',
|
|
83
|
+
},
|
|
84
|
+
activeCode: {
|
|
85
|
+
type: [String, null],
|
|
86
|
+
default: '',
|
|
87
|
+
},
|
|
88
|
+
gutter: {
|
|
89
|
+
type: [String, Number, null],
|
|
90
|
+
default: 10,
|
|
91
|
+
},
|
|
92
|
+
iconData: {
|
|
93
|
+
type: [Array, null],
|
|
94
|
+
default: () => [],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
model: {
|
|
98
|
+
prop: 'value',
|
|
99
|
+
// 派发事件名,更新父组件数据
|
|
100
|
+
event: 'input',
|
|
101
|
+
},
|
|
102
|
+
data() {
|
|
103
|
+
return {};
|
|
104
|
+
},
|
|
105
|
+
computed: {
|
|
106
|
+
cmpListStyle() {
|
|
107
|
+
let style = {};
|
|
108
|
+
style['columnGap'] = utils.formatPx(this.gutter);
|
|
109
|
+
// #ifdef H5
|
|
110
|
+
if (this.disabled || this.readonly) {
|
|
111
|
+
style['cursor'] = 'not-allowed';
|
|
112
|
+
} else {
|
|
113
|
+
style['cursor'] = 'pointer';
|
|
114
|
+
}
|
|
115
|
+
// #endif
|
|
116
|
+
return style;
|
|
117
|
+
},
|
|
118
|
+
cmpCount() {
|
|
119
|
+
// 兼容浏览器和微信 对数字循环的处理不同
|
|
120
|
+
return Array.from({ length: this.count }, (_, index) => index);
|
|
121
|
+
},
|
|
122
|
+
cmpActiveCode() {
|
|
123
|
+
let code = this.getIconCode();
|
|
124
|
+
if (code) return code;
|
|
125
|
+
return this.activeCode;
|
|
126
|
+
},
|
|
127
|
+
cmpInactiveCode() {
|
|
128
|
+
let code = this.getIconCode();
|
|
129
|
+
if (code) return code;
|
|
130
|
+
return this.inactiveCode;
|
|
131
|
+
},
|
|
132
|
+
cmpActiveColor() {
|
|
133
|
+
return this.activeColor ? this.activeColor : color.getColor().steThemeColor;
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
methods: {
|
|
137
|
+
onSelect(index) {
|
|
138
|
+
if (!this.disabled && !this.readonly) {
|
|
139
|
+
let value = (index + 1) * this.score;
|
|
140
|
+
if (this.value != value) {
|
|
141
|
+
// 更新 model
|
|
142
|
+
this.$emit('input', value);
|
|
143
|
+
// change回调
|
|
144
|
+
this.$emit('change', value);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
// 计算已评分占未评分的宽度
|
|
149
|
+
getWidth(index) {
|
|
150
|
+
let value = (index + 1) * this.score;
|
|
151
|
+
let diff = this.value - value;
|
|
152
|
+
// 全部占据
|
|
153
|
+
if (diff >= 0) {
|
|
154
|
+
return '100%';
|
|
155
|
+
}
|
|
156
|
+
// 部分占据
|
|
157
|
+
else if (Math.abs(diff) > 0 && Math.abs(diff) < this.score) {
|
|
158
|
+
return (1 - Math.abs(diff) / this.score).toFixed(2) * 100 + '%';
|
|
159
|
+
}
|
|
160
|
+
// 未占据
|
|
161
|
+
else {
|
|
162
|
+
return 0;
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
// 根据iconData来算出每个分值对应的iconCode
|
|
166
|
+
getIconCode() {
|
|
167
|
+
if (!this.iconData || this.iconData.length === 0) return;
|
|
168
|
+
|
|
169
|
+
let curScroeIndex = Math.ceil(this.value / this.score) - 1;
|
|
170
|
+
// 如果索引在数组范围内且对应的值不为空,直接返回该值
|
|
171
|
+
if (curScroeIndex < this.iconData.length && this.iconData[curScroeIndex] !== '') {
|
|
172
|
+
return this.iconData[curScroeIndex];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// 否则,从索引位置向左搜索最近的非空值
|
|
176
|
+
for (let i = curScroeIndex; i >= 0; i--) {
|
|
177
|
+
if (this.iconData[i] !== '') {
|
|
178
|
+
return this.iconData[i];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
</script>
|
|
185
|
+
|
|
186
|
+
<style lang="scss" scoped>
|
|
187
|
+
.ste-rate-root {
|
|
188
|
+
.list {
|
|
189
|
+
display: flex;
|
|
190
|
+
|
|
191
|
+
.item {
|
|
192
|
+
position: relative;
|
|
193
|
+
|
|
194
|
+
.active {
|
|
195
|
+
position: absolute;
|
|
196
|
+
overflow: hidden;
|
|
197
|
+
top: 0;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
</style>
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# ReadMore 展开更多
|
|
2
|
+
|
|
3
|
+
用于多行文本展示需要折叠的场景
|
|
4
|
+
|
|
5
|
+
---$
|
|
6
|
+
|
|
7
|
+
### 代码演示
|
|
8
|
+
#### 基础使用
|
|
9
|
+
```html
|
|
10
|
+
<view>
|
|
11
|
+
<ste-read-more>{{ moreStr }}</ste-read-more>
|
|
12
|
+
</view>
|
|
13
|
+
<script>
|
|
14
|
+
export default {
|
|
15
|
+
data() {
|
|
16
|
+
return {
|
|
17
|
+
moreStr: '浔阳江头夜送客,枫叶荻花秋瑟瑟。主人下马客在船,举酒欲饮无管弦。醉不成欢惨将别,别时茫茫江浸月。 忽闻水上琵琶声,主人忘归客不发。寻声暗问弹者谁,琵琶声停欲语迟。移船相近邀相见,添酒回灯重开宴。千呼万唤始出来,犹抱琵琶半遮面。凝绝不通声暂歇。悄无言,唯见江心秋月白。 沉吟放拨插弦中,整顿衣裳起敛容。自言本是京城女,家在虾蟆陵下住。十三学得琵琶成,名属教坊第一部。曲罢曾教善才服,妆成每被秋娘妒。五陵年少争缠头,一曲红绡不知数。钿头银篦击节碎,血色罗裙翻酒污。今年欢笑复明年,秋月春风等闲度。弟走从军阿姨死,暮去朝来颜色故'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### 收起后展示按钮
|
|
25
|
+
```html
|
|
26
|
+
<view>
|
|
27
|
+
<ste-read-more toggle>{{ moreStr }}</ste-read-more>
|
|
28
|
+
</view>
|
|
29
|
+
<script>
|
|
30
|
+
export default {
|
|
31
|
+
data() {
|
|
32
|
+
return {
|
|
33
|
+
moreStr: '浔阳江头夜送客,枫叶荻花秋瑟瑟。主人下马客在船,举酒欲饮无管弦。醉不成欢惨将别,别时茫茫江浸月。 忽闻水上琵琶声,主人忘归客不发。寻声暗问弹者谁,琵琶声停欲语迟。移船相近邀相见,添酒回灯重开宴。千呼万唤始出来,犹抱琵琶半遮面。凝绝不通声暂歇。悄无言,唯见江心秋月白。 沉吟放拨插弦中,整顿衣裳起敛容。自言本是京城女,家在虾蟆陵下住。十三学得琵琶成,名属教坊第一部。曲罢曾教善才服,妆成每被秋娘妒。五陵年少争缠头,一曲红绡不知数。钿头银篦击节碎,血色罗裙翻酒污。今年欢笑复明年,秋月春风等闲度。弟走从军阿姨死,暮去朝来颜色故'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
#### 提示文字
|
|
41
|
+
```html
|
|
42
|
+
<view>
|
|
43
|
+
<ste-read-more toggle openText="收起吧" closeText="展开吧" color="#f1f" fontSize="32">{{ moreStr }}</ste-read-more>
|
|
44
|
+
</view>
|
|
45
|
+
<script>
|
|
46
|
+
export default {
|
|
47
|
+
data() {
|
|
48
|
+
return {
|
|
49
|
+
moreStr: '浔阳江头夜送客,枫叶荻花秋瑟瑟。主人下马客在船,举酒欲饮无管弦。醉不成欢惨将别,别时茫茫江浸月。 忽闻水上琵琶声,主人忘归客不发。寻声暗问弹者谁,琵琶声停欲语迟。移船相近邀相见,添酒回灯重开宴。千呼万唤始出来,犹抱琵琶半遮面。凝绝不通声暂歇。悄无言,唯见江心秋月白。 沉吟放拨插弦中,整顿衣裳起敛容。自言本是京城女,家在虾蟆陵下住。十三学得琵琶成,名属教坊第一部。曲罢曾教善才服,妆成每被秋娘妒。五陵年少争缠头,一曲红绡不知数。钿头银篦击节碎,血色罗裙翻酒污。今年欢笑复明年,秋月春风等闲度。弟走从军阿姨死,暮去朝来颜色故'
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### 异步初始化
|
|
57
|
+
有时候需要展示的内容是从后端获取的,组件内部的`mounted`生命周期初始化时,请求尚未回来,会导致 内容的高度在初始化有误差。可以在请求完毕渲染后(指的是this.$nextTick),通过`ref`调用组件的`init`方法,重新初始化
|
|
58
|
+
```html
|
|
59
|
+
<view>
|
|
60
|
+
<ste-read-more ref="steReadMore">{{ moreStr }}</ste-read-more>
|
|
61
|
+
</view>
|
|
62
|
+
<script>
|
|
63
|
+
export default {
|
|
64
|
+
data() {
|
|
65
|
+
return {
|
|
66
|
+
moreStr: ''
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
created() {
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
this.moreStr = '浔阳江头夜送客,枫叶荻花秋瑟瑟。主人下马客在船,举酒欲饮无管弦。醉不成欢惨将别,别时茫茫江浸月。 忽闻水上琵琶声,主人忘归客不发。寻声暗问弹者谁,琵琶声停欲语迟。移船相近邀相见,添酒回灯重开宴。千呼万唤始出来,犹抱琵琶半遮面。凝绝不通声暂歇。悄无言,唯见江心秋月白。 沉吟放拨插弦中,整顿衣裳起敛容。自言本是京城女,家在虾蟆陵下住。十三学得琵琶成,名属教坊第一部。曲罢曾教善才服,妆成每被秋娘妒。五陵年少争缠头,一曲红绡不知数。钿头银篦击节碎,血色罗裙翻酒污。今年欢笑复明年,秋月春风等闲度。弟走从军阿姨死,暮去朝来颜色故';
|
|
72
|
+
this.$nextTick(() => {
|
|
73
|
+
this.$refs.steReadMore.init();
|
|
74
|
+
});
|
|
75
|
+
}, 1500);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
</script>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---$
|
|
82
|
+
### API
|
|
83
|
+
#### 组件属性(Props)
|
|
84
|
+
|
|
85
|
+
| 参数 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
|
|
86
|
+
| --- | --- | --- | --- | --- | --- |
|
|
87
|
+
| `showHeight` | 内容超出此高度才会显示展开全文按钮,单位rpx | `String/Number` | `400` | - | - |
|
|
88
|
+
| `toggle` | 展开后是否显示收起按钮 | `Boolean` | `false` | - | - |
|
|
89
|
+
| `closeText` | 关闭时的提示文字 | `String` | `展开阅读全文` | - | - |
|
|
90
|
+
| `openText` | 展开时的提示文字 | `String` | `收起` | - | - |
|
|
91
|
+
| `fontSize` | 提示文字的大小,单位rpx | `String/Number` | `28` | - | - |
|
|
92
|
+
| `color` | 提示文字的颜色 | `String` | `#2979ff` | - | - |
|
|
93
|
+
|
|
94
|
+
#### Events
|
|
95
|
+
| 方法名 | 说明 | 方法参数 | 支持版本 |
|
|
96
|
+
| --- | --- | --- | --- |
|
|
97
|
+
| `open` | 内容被展开时触发 | - | - |
|
|
98
|
+
| `close` | 内容被收起时触发 | - | - |
|
|
99
|
+
|
|
100
|
+
#### Slots
|
|
101
|
+
|插槽名 |说明 |插槽参数 |支持版本 |
|
|
102
|
+
| --- | --- | --- | --- |
|
|
103
|
+
| `default` | 单选框文本内容 | - | - |
|
|
104
|
+
|
|
105
|
+
#### Methods
|
|
106
|
+
| 方法名| 说明 | 方法参数 | 支持版本 |
|
|
107
|
+
| --- | --- | --- | --- |
|
|
108
|
+
| `init`| 重新初始化组件内部高度计算过程,如果是异步获取内容需要用到 | - | - |
|
|
109
|
+
|
|
110
|
+
---$
|
|
111
|
+
{{fuyuwei}}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="ste-read-more-root">
|
|
3
|
+
<view class="content-box" :style="[cmpContentStyle]">
|
|
4
|
+
<view class="content">
|
|
5
|
+
<slot></slot>
|
|
6
|
+
</view>
|
|
7
|
+
</view>
|
|
8
|
+
<view class="action-box" :style="[cmpActionStyle]" v-if="cmpShowAction">
|
|
9
|
+
<view @click="handleToggleStatus">{{ open ? openText : closeText }}</view>
|
|
10
|
+
<ste-icon :code="open ? '' : ''" size="28" marginBottom="3"></ste-icon>
|
|
11
|
+
</view>
|
|
12
|
+
</view>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
import utils from '../../utils/utils.js';
|
|
17
|
+
export default {
|
|
18
|
+
group: '展示组件',
|
|
19
|
+
title: 'ReadMore 阅读更多',
|
|
20
|
+
name: 'ste-read-more',
|
|
21
|
+
props: {
|
|
22
|
+
showHeight: {
|
|
23
|
+
type: [String, Number, null],
|
|
24
|
+
default: 400,
|
|
25
|
+
},
|
|
26
|
+
// 展开后是否显示收起按钮
|
|
27
|
+
toggle: {
|
|
28
|
+
type: [Boolean, null],
|
|
29
|
+
default: false,
|
|
30
|
+
},
|
|
31
|
+
closeText: {
|
|
32
|
+
type: [String, null],
|
|
33
|
+
default: '展开阅读全文',
|
|
34
|
+
},
|
|
35
|
+
openText: {
|
|
36
|
+
type: [String, null],
|
|
37
|
+
default: '收起',
|
|
38
|
+
},
|
|
39
|
+
fontSize: {
|
|
40
|
+
type: [String, Number, null],
|
|
41
|
+
default: 28,
|
|
42
|
+
},
|
|
43
|
+
color: {
|
|
44
|
+
type: [String, null],
|
|
45
|
+
default: '#666666',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
data() {
|
|
49
|
+
return {
|
|
50
|
+
open: false,
|
|
51
|
+
showToggle: false,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
watch: {},
|
|
55
|
+
computed: {
|
|
56
|
+
cmpContentStyle() {
|
|
57
|
+
let style = {};
|
|
58
|
+
if (this.showToggle) {
|
|
59
|
+
style.height = this.open ? 'auto' : utils.addUnit(this.showHeight);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return style;
|
|
63
|
+
},
|
|
64
|
+
cmpActionStyle() {
|
|
65
|
+
let style = {
|
|
66
|
+
color: this.color,
|
|
67
|
+
fontSize: utils.addUnit(this.fontSize),
|
|
68
|
+
background: this.open
|
|
69
|
+
? ''
|
|
70
|
+
: 'linear-gradient(-180deg, rgba(255, 255, 255, 0) 0%, rgb(255, 255, 255) 80%)',
|
|
71
|
+
};
|
|
72
|
+
return style;
|
|
73
|
+
},
|
|
74
|
+
cmpShowAction() {
|
|
75
|
+
let show = true;
|
|
76
|
+
if (!this.showToggle) {
|
|
77
|
+
show = false;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (this.open && !this.toggle) {
|
|
81
|
+
show = false;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return show;
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
mounted() {
|
|
88
|
+
this.init();
|
|
89
|
+
},
|
|
90
|
+
methods: {
|
|
91
|
+
init() {
|
|
92
|
+
utils.sleep(200).then(() => {
|
|
93
|
+
utils.querySelector('.content', this).then((rect) => {
|
|
94
|
+
this.showToggle = parseInt(rect.height) > parseInt(utils.formatPx(this.showHeight));
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
handleToggleStatus() {
|
|
99
|
+
if (!this.open) {
|
|
100
|
+
this.$emit('open');
|
|
101
|
+
} else {
|
|
102
|
+
this.$emit('close');
|
|
103
|
+
}
|
|
104
|
+
this.open = !this.open;
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
</script>
|
|
109
|
+
|
|
110
|
+
<style lang="scss" scoped>
|
|
111
|
+
.ste-read-more-root {
|
|
112
|
+
.content-box {
|
|
113
|
+
overflow: hidden;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.action-box {
|
|
117
|
+
display: flex;
|
|
118
|
+
justify-content: center;
|
|
119
|
+
align-items: center;
|
|
120
|
+
|
|
121
|
+
position: relative;
|
|
122
|
+
padding-top: 200rpx;
|
|
123
|
+
margin-top: -200rpx;
|
|
124
|
+
// margin-bottom: 20rpx;
|
|
125
|
+
|
|
126
|
+
text {
|
|
127
|
+
cursor: pointer;
|
|
128
|
+
font-size: 28rpx;
|
|
129
|
+
margin-right: 16rpx;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
</style>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# RichText 富文本
|
|
2
|
+
|
|
3
|
+
富文本,增加文本换行功能,解决两张图片中间有空隙的问题。
|
|
4
|
+
|
|
5
|
+
---$
|
|
6
|
+
|
|
7
|
+
#### 一张图片
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<ste-rich-text :text="node1"></ste-rich-text>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
#### 两张图片
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<ste-rich-text :text="node2"></ste-rich-text>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---$
|
|
20
|
+
### API
|
|
21
|
+
|
|
22
|
+
#### Props
|
|
23
|
+
|
|
24
|
+
|属性名 |说明 |类型 |默认值 |可选值 | 支持版本 |
|
|
25
|
+
| --- |--- | --- | --- | --- | --- |
|
|
26
|
+
| `text` | 富文本值 | `String` | - | - | - |
|
|
27
|
+
| `space` | 显示连续空格 | `String` | `"nbsp"` | `"ensp"`:中文字符空格一半大小 <br/> `"emsp"`:中文字符空格大小<br/>`"nbsp"`:根据字体设置的空格大小 | - |
|
|
28
|
+
| `userSelect` | 文本是否可选 | `Boolean` | `false` | - | - |
|
|
29
|
+
|
|
30
|
+
---$
|
|
31
|
+
{{zyy}}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 富文本组件 -->
|
|
3
|
+
<view style="overflow: hidden">
|
|
4
|
+
<rich-text
|
|
5
|
+
:nodes="replaceVerticalAlign(text)"
|
|
6
|
+
:user-select="userSelect"
|
|
7
|
+
class="rich-text"
|
|
8
|
+
:space="space"
|
|
9
|
+
></rich-text>
|
|
10
|
+
</view>
|
|
11
|
+
</template>
|
|
12
|
+
<script>
|
|
13
|
+
import utils from '../../utils/utils.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* ste-rich-text 按钮
|
|
17
|
+
* @description 富文本组件
|
|
18
|
+
* @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-rich-text
|
|
19
|
+
* @property {String} text 富文本值
|
|
20
|
+
* @property {String} space 显示连续空格 默认值 nbsp
|
|
21
|
+
* @value ensp 中文字符空格一半大小 {String}
|
|
22
|
+
* @value emsp 中文字符空格大小 {String}
|
|
23
|
+
* @value nbsp 根据字体设置的空格大小 {String}
|
|
24
|
+
* @property {Boolean} userSelect 文本是否可选 默认 false
|
|
25
|
+
*/
|
|
26
|
+
export default {
|
|
27
|
+
group: '表单组件',
|
|
28
|
+
title: 'RichText 富文本',
|
|
29
|
+
name: 'ste-rich-text',
|
|
30
|
+
props: {
|
|
31
|
+
text: {
|
|
32
|
+
type: [String, null],
|
|
33
|
+
default: '',
|
|
34
|
+
},
|
|
35
|
+
space: {
|
|
36
|
+
type: [String, null],
|
|
37
|
+
default: 'nbsp',
|
|
38
|
+
},
|
|
39
|
+
userSelect: {
|
|
40
|
+
type: [Boolean, null],
|
|
41
|
+
default: false,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
data() {
|
|
45
|
+
return {};
|
|
46
|
+
},
|
|
47
|
+
methods: {
|
|
48
|
+
replaceVerticalAlign(text) {
|
|
49
|
+
if (!text) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
let html = text;
|
|
53
|
+
html = utils.richTextTagAddStyle(html, 'p', ['margin', 'margin-top'], ';margin-top:0');
|
|
54
|
+
html = utils.richTextTagAddStyle(html, 'p', ['margin', 'margin-bottom'], ';margin-bottom:0');
|
|
55
|
+
html = utils.richTextTagAddStyle(html, 'img', 'vertical-align', ';vertical-align:top');
|
|
56
|
+
// 解决微信小程序会忽略空白换行的问题
|
|
57
|
+
html = html.replace(/↵/g, '\n');
|
|
58
|
+
html = html.replace(/ /g, '\n');
|
|
59
|
+
return html;
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
mounted() {},
|
|
64
|
+
};
|
|
65
|
+
</script>
|
|
66
|
+
<style lang="scss" scoped>
|
|
67
|
+
.rich-text {
|
|
68
|
+
word-break: break-all;
|
|
69
|
+
}
|
|
70
|
+
</style>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# ScrollTo 滚动锚点
|
|
2
|
+
|
|
3
|
+
滚动锚点,可以滚动到指定锚点。
|
|
4
|
+
|
|
5
|
+
---$
|
|
6
|
+
|
|
7
|
+
#### 基础用法
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<ste-tabs :active.sync="active" sticky>
|
|
11
|
+
<ste-tab v-for="(m, i) in imgs" :key="i" :title="`标签${i + 1}`" />
|
|
12
|
+
</ste-tabs>
|
|
13
|
+
<ste-scroll-to ref="scrollTo" height="1200" :active.sync="active">
|
|
14
|
+
<ste-scroll-to-item v-for="(m, i) in imgs" :key="i">
|
|
15
|
+
<view>内容{{ i + 1 }}</view>
|
|
16
|
+
<image :src="m" mode="widthFix"></image>
|
|
17
|
+
</ste-scroll-to-item>
|
|
18
|
+
</ste-scroll-to>
|
|
19
|
+
<script>
|
|
20
|
+
export default {
|
|
21
|
+
data() {
|
|
22
|
+
return {
|
|
23
|
+
active: 0,
|
|
24
|
+
imgs: [
|
|
25
|
+
'https://image.whzb.com/chain/StellarUI/image/img1.jpg',
|
|
26
|
+
'https://image.whzb.com/chain/StellarUI/image/img2.jfif',
|
|
27
|
+
'https://image.whzb.com/chain/StellarUI/image/img3.jpg',
|
|
28
|
+
'https://image.whzb.com/chain/StellarUI/image/img4.jpg',
|
|
29
|
+
'https://image.whzb.com/chain/StellarUI/image/img1.jpg',
|
|
30
|
+
'https://image.whzb.com/chain/StellarUI/image/img2.jfif',
|
|
31
|
+
'https://image.whzb.com/chain/StellarUI/image/img3.jpg',
|
|
32
|
+
'https://image.whzb.com/chain/StellarUI/image/img4.jpg',
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
mounted() {
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
this.$refs.scrollTo.init();
|
|
39
|
+
}, 500);
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
---$
|
|
48
|
+
### API
|
|
49
|
+
|
|
50
|
+
#### ScrollTo Props
|
|
51
|
+
|
|
52
|
+
| 属性名 | 说明 |类型 |默认值 |可选值 | 支持版本 |
|
|
53
|
+
| --- |--- | --- | --- | --- | --- |
|
|
54
|
+
| `active`| 当前激活的锚点index,支持sync双向绑定,默认值0 | `Number` | `0` | - | - |
|
|
55
|
+
| `height`| 高度,默认值100% | `String`/`Number` | `"100%"`| - | - |
|
|
56
|
+
|
|
57
|
+
#### ScrollTo Events
|
|
58
|
+
| 事件名 |说明 |事件参数 |支持版本 |
|
|
59
|
+
|--- |--- |--- |--- |
|
|
60
|
+
| `change`| 滚动锚点时触发 | `active`: 当前激活的锚点下标 | - |
|
|
61
|
+
|
|
62
|
+
#### ScrollTo Method
|
|
63
|
+
| 方法名| 说明 |支持版本 |
|
|
64
|
+
| --- | --- |--- |
|
|
65
|
+
| `init`| 初始化锚点信息,在渲染完成后调用 | - |
|
|
66
|
+
|
|
67
|
+
---$
|
|
68
|
+
{{xuyajun}}
|