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,66 @@
1
+ # Text 文本
2
+
3
+ 文本组件
4
+
5
+ ---$
6
+
7
+ ### 代码演示
8
+ #### 可选
9
+ - 当`selectable`为`true`时,可长按选中文字
10
+ ```html
11
+ <ste-text selectable>Stellar UI,全面的组件和便捷的工具会让您信手拈来,如鱼得水</ste-text>
12
+ ```
13
+
14
+ #### 解码
15
+ - `&nbsp;` 解码为一个不间断空格 (Non-Breaking Space)
16
+ - `&lt;` 解码为小于号 <
17
+ - `&gt;` 解码为大于号 >
18
+ - `&amp;` 解码为和号 &
19
+ - `&apos;` 解码为单引号 '
20
+ - `&ensp;` 解码为一个半角空格 ( )
21
+ - `&emsp;` 解码为一个全角空格 ( )
22
+ ```html
23
+ <ste-text decode>Stellar&nbsp;UI</ste-text>
24
+ <ste-text decode>Stellar&lt;UI</ste-text>
25
+ <ste-text decode>Stellar&gt;UI</ste-text>
26
+ <ste-text decode>Stellar&amp;UI</ste-text>
27
+ <ste-text decode>Stellar&apos;UI</ste-text>
28
+ <ste-text decode>Stellar&ensp;UI</ste-text>
29
+ <ste-text decode>Stellar&emsp;UI</ste-text>
30
+ ```
31
+
32
+ #### 换行省略
33
+ ```html
34
+ <ste-text>
35
+ Stellar UI,全面的组件和便捷的工具会让您信手拈来,如鱼得水。Stellar
36
+ UI,全面的组件和便捷的工具会让您信手拈来,如鱼得水。
37
+ </ste-text>
38
+ <ste-text :lines="2">
39
+ Stellar UI,全面的组件和便捷的工具会让您信手拈来,如鱼得水。Stellar
40
+ UI,全面的组件和便捷的工具会让您信手拈来,如鱼得水。
41
+ </ste-text>
42
+ <ste-text :lines="3">
43
+ Stellar UI,全面的组件和便捷的工具会让您信手拈来,如鱼得水。Stellar
44
+ UI,全面的组件和便捷的工具会让您信手拈来,如鱼得水。
45
+ </ste-text>
46
+ ```
47
+
48
+ ---$
49
+ ### API
50
+ #### 组件属性(Props)
51
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
52
+ | --- | --- | --- | --- | --- | --- |
53
+ | `selectable` | 文本是否可选 | `Boolean` | `false` | - | - |
54
+ | `space` | 以何种方式显示连续空格 | `String` | - | `ensp` 中文字符空格一半大小<br/>`emsp` 中文字符空格大小<br/>`nbsp` 根据字体设置的空格大小 | - |
55
+ | `decode` | 是否解码,可解析的 HTML 实体字符有:`&nbsp;&lt;&gt;&amp;&apos;&ensp;&emsp;` | `Boolean` | `false` | - | - |
56
+ | `lines` | 文本显示的行数,如果设置,超出此行数,将会显示省略号 | `Number` | - | - | - |
57
+
58
+ #### 组件插槽(Slots)
59
+
60
+ |插槽名 |说明 |插槽参数 |支持版本 |
61
+ |--- |--- |--- |--- |
62
+ |default|内容 |- |- |
63
+
64
+
65
+ ---$
66
+ {{fuyuwei}}
@@ -0,0 +1,72 @@
1
+ <template>
2
+ <text
3
+ :style="[cmpRootCssVar]"
4
+ class="ste-text-root"
5
+ :class="{ 'ste-text-lines': lines > 0 }"
6
+ :selectable="selectable"
7
+ :user-select="selectable"
8
+ :space="space"
9
+ :decode="decode"
10
+ :number-of-lines="lines"
11
+ >
12
+ <slot></slot>
13
+ </text>
14
+ </template>
15
+
16
+ <script>
17
+ import utils from '../../utils/utils.js';
18
+ /**
19
+ * ste-text 文本
20
+ * @description 文本组件
21
+ * @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-text
22
+ * @property {Boolean} selectable 文本是否可选 默认 false
23
+ * @property {String} space 以何种方式显示连续空格
24
+ * @property {Boolean} decode 是否解码 默认 false
25
+ * @property {Number} lines 文本显示的行数,如果设置,超出此行数,将会显示省略号
26
+ */
27
+
28
+ export default {
29
+ group: '基础组件',
30
+ title: 'Text 文本',
31
+ name: 'ste-text',
32
+ props: {
33
+ selectable: {
34
+ type: [Boolean, null],
35
+ default: false,
36
+ },
37
+ space: {
38
+ type: [String, null],
39
+ default: '',
40
+ },
41
+ decode: {
42
+ type: [Boolean, null],
43
+ default: false,
44
+ },
45
+ lines: {
46
+ type: [Number, null],
47
+ default: undefined,
48
+ },
49
+ },
50
+ data() {
51
+ return {};
52
+ },
53
+ computed: {
54
+ cmpRootCssVar() {
55
+ return { '--overflow-lines': this.lines };
56
+ },
57
+ },
58
+ };
59
+ </script>
60
+
61
+ <style lang="scss" scoped>
62
+ .ste-text-root {
63
+ &.ste-text-lines {
64
+ /* #ifdef MP-WEIXIN || H5 */
65
+ display: -webkit-box;
66
+ -webkit-box-orient: vertical;
67
+ -webkit-line-clamp: var(--overflow-lines);
68
+ overflow: hidden;
69
+ /* #endif */
70
+ }
71
+ }
72
+ </style>
@@ -0,0 +1,243 @@
1
+ # Toast 轻提示
2
+
3
+ 在页面中间弹出黑色半透明提示,用于消息通知、加载提示、操作结果提示等场景。
4
+
5
+ ---$
6
+
7
+
8
+
9
+ ### 使用方法
10
+ 1. 安装 `ste-vue-inset-loader` 插件
11
+ ```
12
+ npm install ste-vue-inset-loader --save-dev
13
+ ```
14
+ 2. 配置 `pages.json` 信息
15
+ ```
16
+ "insetLoader": {
17
+ "config": {
18
+ "toast": "<root-portal><ste-toast id='steToast'></ste-toast></root-portal>"
19
+ },
20
+ // 全局配置
21
+ "label": ["toast"],
22
+ "rootEle": "view"
23
+ },
24
+ ```
25
+ 3. 配置 `vue.config.js` 信息
26
+ ```
27
+ chainWebpack: (config) => {
28
+ config.module
29
+ .rule('vue')
30
+ .test(/\.vue$/)
31
+ .use()
32
+ .loader(path.resolve(__dirname, './node_modules/ste-vue-inset-loader'))
33
+ .end();
34
+ },
35
+ ```
36
+ 4. 在`main.js`里引入混淆文件`app-mixin.js`
37
+ ```
38
+ import mixin from './app-mixin.js';
39
+ Vue.mixin(mixin);
40
+ ```
41
+ 5. 在混淆文件`app-mixin.js`里引入组件的`js`文件,将`showToast`和`hideToast`方法混入全局,每个页面通过 `this.` 来使用对应的方法
42
+ ```
43
+ import useSteToast from '@/node_modules/stellar-ui/components/ste-toast/ste-toast.js';
44
+ let steToast = useSteToast();
45
+ export default {
46
+ methods: {
47
+ showToast(params) {
48
+ // 是否开启提示跨页面功能配置 true为开启 false为关闭
49
+ params.enableCrossPagePrompt = false;
50
+ steToast.showToast(params);
51
+ },
52
+ hideToast: steToast.hideToast,
53
+ },
54
+ };
55
+
56
+ ```
57
+ 6. js文件中使用
58
+ ```
59
+ import useSteToast from '@/node_modules/stellar-ui/components/ste-toast/ste-toast.js';
60
+ let steToast = useSteToast();
61
+ steToast.showToast()
62
+ ```
63
+
64
+ 7. 提示跨页面功能配置
65
+ 在混淆方法中将参数`enableCrossPagePrompt`置为`true`为开启 `false`为关闭
66
+ ```
67
+ showToast(params) {
68
+ // 是否开启提示跨页面功能配置 true为开启 false为关闭
69
+ params.enableCrossPagePrompt = false;
70
+ steToast.showToast(params);
71
+ },
72
+ ```
73
+
74
+ ### 代码演示
75
+
76
+ #### 文字提示
77
+ `title`为提示内容,提示弹窗根据内容自动撑开,最大宽度为260px,超过自动换行,也可手动插入换行符`\n`
78
+ ```
79
+ click1() {
80
+ this.showToast({
81
+ title: '提示内容',
82
+ });
83
+ },
84
+ click2() {
85
+ this.showToast({
86
+ title: '多行内容,多行内容,多行内容,多行内容,多行内容,多行内容,多行内容,多行内容,多行内容,',
87
+ });
88
+ },
89
+ click3() {
90
+ this.showToast({
91
+ title: '换行\n内容',
92
+ });
93
+ },
94
+ ```
95
+
96
+ ### 提示类型
97
+ `icon`为固定的图标类型,默认为`success`,为`loading`时,弹窗不会自动关闭,需手动关闭弹窗,使用`hideToast`方法
98
+ - `success`:显示成功图标
99
+ - `error`:显示失败图标
100
+ - `loading`:显示加载图标
101
+ - `none`:无图标
102
+
103
+ ```
104
+ click4() {
105
+ this.showToast({
106
+ title: '提示内容',
107
+ });
108
+ },
109
+ click5() {
110
+ this.showToast({
111
+ title: '提示内容',
112
+ icon: 'error',
113
+ });
114
+ },
115
+ click6() {
116
+ this.showToast({
117
+ title: '提示内容',
118
+ icon: 'loading',
119
+ });
120
+ },
121
+ click7() {
122
+ this.showToast({
123
+ title: '提示内容',
124
+ icon: 'none',
125
+ });
126
+ },
127
+ ```
128
+ `image`为自定义图标的路径,image 的优先级高于 icon
129
+ ```
130
+ click8() {
131
+ this.showToast({
132
+ title: '提示内容',
133
+ image: 'https://image.whzb.com/chain/StellarUI/组件图标/loading.png',
134
+ });
135
+ },
136
+ ```
137
+
138
+ ### 遮罩层
139
+ `mask`为是否显示透明蒙层,防止触摸穿透,默认为`false`
140
+ ```
141
+ click9() {
142
+ this.showToast({
143
+ title: '提示内容',
144
+ mask: true,
145
+ duration: 5000,
146
+ });
147
+ },
148
+ ```
149
+
150
+ ### 延迟时间
151
+ `duration`为提示的延迟时间,单位ms 值为 0 时,toast 不会自动消失(loading 类型默认为 0)
152
+ ```
153
+ click10() {
154
+ this.showToast({
155
+ title: '提示内容',
156
+ duration: 5000,
157
+ });
158
+ },
159
+ ```
160
+
161
+ ### 提示队列
162
+ `order`为提示队列属性,`同一时间执行`的提示开启函数带有该属性的,将会把这个提示加入队列,队列中的提示按照执行顺序一直执行
163
+ ```
164
+ this.showToast({
165
+ title: '队列1',
166
+ order: true,
167
+ });
168
+ this.showToast({
169
+ title: '队列2',
170
+ duration: 4000,
171
+ order: true,
172
+ });
173
+ this.showToast({
174
+ title: '队列3',
175
+ order: true,
176
+ });
177
+ ```
178
+
179
+
180
+ ### 回调事件
181
+ - `success`:提示打开成功的回调函数
182
+ - `fail`:提示打开失败的回调函数
183
+ - `complete`:提示结束的回调函数(提示打开、失败都会执行)
184
+ - `close`:提示关闭的的回调函数
185
+ ```
186
+ click11() {
187
+ this.showToast({
188
+ title: '提示内容',
189
+ success() {
190
+ setTimeout(() => {
191
+ this.showToast({
192
+ title: '成功',
193
+ icon: 'none',
194
+ });
195
+ }, 2000);
196
+ },
197
+ });
198
+ },
199
+ click12() {
200
+ this.showToast({
201
+ title: '提示内容',
202
+ complete() {
203
+ setTimeout(() => {
204
+ this.showToast({
205
+ title: '结束',
206
+ icon: 'none',
207
+ });
208
+ }, 2000);
209
+ },
210
+ });
211
+ },
212
+ click13() {
213
+ this.showToast({
214
+ title: '提示内容',
215
+ close() {
216
+ this.showToast({
217
+ title: '关闭',
218
+ icon: 'none',
219
+ });
220
+ },
221
+ });
222
+ },
223
+ ```
224
+
225
+ ---$
226
+ ### API
227
+ #### 组件属性(Props)
228
+
229
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
230
+ | --- | --- | --- | --- | --- | --- |
231
+ | `title` | 提示的内容 | `String` | - | - | - |
232
+ | `icon` | 图标 | `String` | `success` | `success`:显示成功图标<br/>`error`:显示失败图标<br/>`loading`:显示加载图标<br/>`none`:无图标<br/> | - |
233
+ | `image` | 自定义图标的路径,image 的优先级高于 icon | `String` | - | - | - |
234
+ | `duration`| 提示的延迟时间,单位`ms` 值为 `0` 时,`toast` 不会自动消失(`loading` 类型默认为 `0`) | `Number` | `1500` | - | - |
235
+ | `mask` | 是否显示透明蒙层,防止触摸穿透 | `Boolean` | `false` | - | - |
236
+ | `order` | 是否是队列提示 | `Boolean` | `false` | - | `v1.29.1` |
237
+ | `success` | 提示打开成功的回调函数 | `Function`| - | - | - |
238
+ | `fail` | 提示打开失败的回调函数 | `Function`| - | - | - |
239
+ | `complete`| 提示结束的回调函数(提示打开、失败都会执行) | `Function`| - | - | - |
240
+ | `close` | 提示关闭的的回调函数 | `Function`| - | - | - |
241
+
242
+ ---$
243
+ {{qinpengfei}}
@@ -0,0 +1,69 @@
1
+ import store from '../../utils/store.js';
2
+ import Vuex from 'vuex';
3
+ let $state = new Vuex.Store({
4
+ state: {
5
+ openBegin: false,
6
+ title: '',
7
+ icon: '',
8
+ image: '',
9
+ duration: 1500,
10
+ mask: false,
11
+ success: null,
12
+ fail: null,
13
+ complete: null,
14
+ close: null,
15
+ enableCrossPagePrompt: false,
16
+ timer: [],
17
+ },
18
+ }).state;
19
+
20
+ function useSteToast() {
21
+ return {
22
+ /*打开弹窗*/
23
+ showToast(params) {
24
+ // 默认持续时间
25
+ let defaultDuration = 1500;
26
+ // 关闭前面的弹窗
27
+ $state.openBegin = false;
28
+ // 关闭系统的弹窗
29
+ uni.hideToast();
30
+ // 提示队列
31
+ let time = 0;
32
+ if (params.order) {
33
+ // 先取上一次存的值 如果为空 则为第一个值
34
+ let toastLastParams = uni.getStorageSync('toastLastParams');
35
+ // 等待的时间 第一个没有等待时间 后面的都是前面的持续时间的合
36
+ if (typeof toastLastParams == 'object') {
37
+ time = toastLastParams.time;
38
+ }
39
+ // 存当前的等待时间 加100ms 以防没有打开中间的提示
40
+ params.time = time + (params.duration ?? defaultDuration) + 100;
41
+ uni.setStorageSync('toastLastParams', params);
42
+ } else {
43
+ // 遇到非队列数据 则清空队列时间
44
+ uni.removeStorageSync('toastLastParams');
45
+ }
46
+ let timer = setTimeout(() => {
47
+ $state.openBegin = true;
48
+ $state.title = params.title ?? '';
49
+ $state.icon = params.icon ?? 'success';
50
+ $state.image = params.image ?? '';
51
+ $state.duration = params.duration ?? defaultDuration;
52
+ $state.mask = params.mask ?? false;
53
+ $state.success = params.success ?? function () {};
54
+ $state.fail = params.fail ?? function () {};
55
+ $state.complete = params.complete ?? function () {};
56
+ $state.close = params.close ?? function () {};
57
+ $state.enableCrossPagePrompt = params.enableCrossPagePrompt ?? false;
58
+ }, time);
59
+ $state.timer.push(timer);
60
+ },
61
+ /*关闭弹窗*/
62
+ hideToast() {
63
+ $state.openBegin = false;
64
+ },
65
+ /**响应式数据*/
66
+ $state,
67
+ };
68
+ }
69
+ export default useSteToast;
@@ -0,0 +1,231 @@
1
+ <template>
2
+ <view class="ste-toast-root" v-if="show">
3
+ <view class="base">
4
+ <view class="box">
5
+ <view v-if="icon != 'none' || image" class="icon-box">
6
+ <block v-if="image">
7
+ <ste-image :src="image" :width="72" :height="72" display="block"></ste-image>
8
+ </block>
9
+ <block v-else>
10
+ <ste-icon
11
+ v-if="icon != 'loading'"
12
+ :code="cmpIcon"
13
+ :size="icon != 'error' ? 72 : 72 * 0.8"
14
+ ></ste-icon>
15
+ <ste-loading v-else :size="72" color="#FFFFFF"></ste-loading>
16
+ </block>
17
+ </view>
18
+ <ste-text clas="title" space="nbsp">{{ title }}</ste-text>
19
+ </view>
20
+ </view>
21
+ <view class="mask" v-if="mask"></view>
22
+ </view>
23
+ </template>
24
+ <script>
25
+ import utils from '../../utils/utils.js';
26
+ import useSteToast from './ste-toast.js';
27
+ let steToast = useSteToast();
28
+ let $state = steToast.$state;
29
+ /**
30
+ * ste-toast 轻提示
31
+ * @description 在页面中间弹出黑色半透明提示,用于消息通知、加载提示、操作结果提示等场景。
32
+ * @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-toast
33
+ * @property {String} title 提示的内容
34
+ * @property {String} icon 图标 默认值:success
35
+ * @value success 显示成功图标 {String}
36
+ * @value error 显示失败图标 {String}
37
+ * @value loading 显示加载图标 {String}
38
+ * @value none 无图标 {String}
39
+ * @property {String} image 自定义图标的路径,image的优先级高于icon
40
+ * @property {Number} duration 提示的延迟时间,单位ms 默认值:1500,值为 0 时,toast 不会自动消失(loading 类型默认为 0)
41
+ * @property {Boolean} mask 是否显示透明蒙层,防止触摸穿透 默认值:false
42
+ * @event {Function} success 提示打开成功的回调函数
43
+ * @event {Function} fail 提示打开失败的回调函数
44
+ * @event {Function} complete 提示结束的回调函数(提示打开、失败都会执行)
45
+ * @event {Function} close 提示关闭的的回调函数
46
+ */
47
+ export default {
48
+ group: '展示组件',
49
+ title: 'Toast 轻提示',
50
+ name: 'ste-toast',
51
+ data() {
52
+ return {
53
+ pageShow: true,
54
+ show: false,
55
+ title: '',
56
+ icon: '',
57
+ image: '',
58
+ duration: '',
59
+ mask: '',
60
+ success: null,
61
+ fail: null,
62
+ complete: null,
63
+ close: null,
64
+ timer: null,
65
+ };
66
+ },
67
+ onPageShow() {
68
+ this.$nextTick(() => {
69
+ this.pageShow = true;
70
+ if (!this.enableCrossPagePrompt) {
71
+ // 每次进入页面 则清空队列时间
72
+ uni.removeStorageSync('toastLastParams');
73
+ // 每次进入新页面 清除所有定时器
74
+ $state.timer.forEach((value) => {
75
+ clearTimeout(value);
76
+ });
77
+ // 清除定时器数据
78
+ $state.timer = [];
79
+ }
80
+ });
81
+ },
82
+ onPageHide() {
83
+ if (!this.enableCrossPagePrompt) {
84
+ this.pageShow = false;
85
+ steToast.hideToast();
86
+ // 每次离开页面 则清空队列时间
87
+ uni.removeStorageSync('toastLastParams');
88
+ // 每次离开页面 清除所有定时器
89
+ $state.timer.forEach((value) => {
90
+ clearTimeout(value);
91
+ });
92
+ // 清除定时器数据
93
+ $state.timer = [];
94
+ }
95
+ },
96
+ // 可能页面存在缓存
97
+ created() {
98
+ this.$nextTick(() => {
99
+ this.pageShow = true;
100
+ if (!this.enableCrossPagePrompt) {
101
+ // 每次进入页面 则清空队列时间
102
+ uni.removeStorageSync('toastLastParams');
103
+ // 每次进入新页面 清除所有定时器
104
+ $state.timer.forEach((value) => {
105
+ clearTimeout(value);
106
+ });
107
+ // 清除定时器数据
108
+ $state.timer = [];
109
+ }
110
+ });
111
+ },
112
+ destroyed() {
113
+ if (!this.enableCrossPagePrompt) {
114
+ this.pageShow = false;
115
+ steToast.hideToast();
116
+ // 每次离开页面 则清空队列时间
117
+ uni.removeStorageSync('toastLastParams');
118
+ // 每次离开页面 清除所有定时器
119
+ $state.timer.forEach((value) => {
120
+ clearTimeout(value);
121
+ });
122
+ // 清除定时器数据
123
+ $state.timer = [];
124
+ }
125
+ },
126
+ computed: {
127
+ cmpIcon() {
128
+ let iconObj = {
129
+ success: '&#xe67a;',
130
+ error: '&#xe67b;',
131
+ };
132
+ return iconObj[this.icon] ?? '';
133
+ },
134
+ openBegin() {
135
+ return $state.openBegin;
136
+ },
137
+ enableCrossPagePrompt() {
138
+ return $state.enableCrossPagePrompt;
139
+ },
140
+ },
141
+ watch: {
142
+ openBegin: {
143
+ handler(newVal) {
144
+ if (newVal && this.pageShow) {
145
+ try {
146
+ clearTimeout(this.timer);
147
+ this.show = newVal;
148
+ this.title = $state.title ?? '';
149
+ this.icon = $state.icon ?? 'success';
150
+ this.image = $state.image ?? '';
151
+ this.duration = $state.duration ?? 1500;
152
+ if (this.icon == 'loading') {
153
+ this.duration = 0;
154
+ }
155
+ this.mask = $state.mask ?? false;
156
+ this.success = $state.success ?? function () {};
157
+ this.fail = $state.fail ?? function () {};
158
+ this.complete = $state.complete ?? function () {};
159
+ this.close = $state.close ?? function () {};
160
+ if (this.duration) {
161
+ this.timer = setTimeout(() => {
162
+ steToast.hideToast();
163
+ }, this.duration);
164
+ }
165
+ this.success();
166
+ } catch (error) {
167
+ this.fail();
168
+ }
169
+ this.complete();
170
+ } else {
171
+ this.show = false;
172
+ }
173
+ },
174
+ immediate: true,
175
+ },
176
+ show: {
177
+ handler(newVal) {
178
+ if (!newVal) {
179
+ this.close();
180
+ // 关闭弹窗 则清空队列时间
181
+ uni.removeStorageSync('toastLastParams');
182
+ }
183
+ },
184
+ },
185
+ },
186
+ };
187
+ </script>
188
+
189
+ <style lang="scss" scoped>
190
+ .ste-toast-root {
191
+ .base {
192
+ position: fixed;
193
+ text-align: center;
194
+ z-index: 9999;
195
+ top: 40%;
196
+ left: 0;
197
+ transform: translateY(-40%);
198
+ width: 100vw;
199
+ }
200
+ .box {
201
+ max-width: 520rpx;
202
+ background-color: rgba(0, 0, 0, 0.7);
203
+ border-radius: 16rpx;
204
+ font-size: 32rpx;
205
+ font-weight: bold;
206
+ color: #ffffff;
207
+ line-height: 44rpx;
208
+ padding: 40rpx 48rpx;
209
+ word-break: break-all;
210
+ text-align: center;
211
+ margin: 0 auto;
212
+ display: inline-block;
213
+ }
214
+ .icon-box {
215
+ margin-bottom: 24rpx;
216
+ text-align: center;
217
+ display: flex;
218
+ justify-content: center;
219
+ }
220
+
221
+ .mask {
222
+ position: fixed;
223
+ width: 100vw;
224
+ height: 100vh;
225
+ background-color: transparent;
226
+ z-index: 10000;
227
+ top: 0;
228
+ left: 0;
229
+ }
230
+ }
231
+ </style>