stellar-ui-v2 1.40.21 → 1.40.22

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.
@@ -1,364 +1,364 @@
1
- <template>
2
- <view class="ste-message-box-root" :style="[cmpRootStyle]" :class="[cmpRootClass]" :animation="maskAnimationData" v-if="show">
3
- <view class="ste-message-box-content" :animation="animationData">
4
- <view class="content-box">
5
- <view class="icon-box" v-if="icon">
6
- <ste-icon :code="cmpIconCode" color="#999999" size="45"></ste-icon>
7
- </view>
8
- <view class="ste-message-title">{{ title }}</view>
9
- <view class="msg" v-if="!icon">
10
- <slot>
11
- <view class="text" v-if="!editable">{{ content }}</view>
12
- <view v-else class="input-box">
13
- <text class="placeholder-text" v-show="showInputPlaceholder">
14
- {{ placeholderText }}
15
- </text>
16
- <input :value="inputValue" class="ste-message-box-input" @input="handleInput" @focus="handleInputFocus" @blur="handleInputBlur" />
17
- </view>
18
- </slot>
19
- </view>
20
- </view>
21
- <view class="footer">
22
- <view class="cancel text" v-if="showCancel" @click="handleCancel">
23
- {{ cancelText }}
24
- </view>
25
- <view class="confirm text" @click="handleConfirm">
26
- {{ confirmText }}
27
- </view>
28
- </view>
29
- </view>
30
- </view>
31
- </template>
32
-
33
- <script>
34
- import { mapState } from 'vuex';
35
- import useColor from '../../config/color.js';
36
- let color = useColor();
37
- import utils from '../../utils/utils.js';
38
- import useSteMsgBox, { DEFAULT_KEY } from './ste-message-box.js';
39
- const DURATION = 200;
40
- const ANIMATION_PROP = { duration: DURATION, timingFunction: 'ease-out' };
41
- const ICON_OBJ = {
42
- info: '&#xe67d;',
43
- success: '&#xe67a;',
44
- error: '&#xe67b;',
45
- };
46
- /**
47
- * ste-message-box 弹框
48
- * @description 模拟系统的消息提示框而实现的一套模态对话框组件,用于消息提示、确认消息和提交内容。
49
- * @tutorial https://stellar-ui.intecloud.com.cn/?projectName=stellar-ui&menu=%E7%BB%84%E4%BB%B6&active=ste-message-box
50
- * @property {String} title 提示的标题
51
- * @property {String} content 提示的内容
52
- * @property {String} icon 提示区域显示图标,此时content会失效
53
- * @property {String} cancelText 取消按钮的文字,最多 4 个字符
54
- * @property {String} cancelColor 取消按钮的文字颜色,必须是 16 进制格式的颜色字符串
55
- * @property {String} confirmText 确认按钮的文字,最多 4 个字符
56
- * @property {String} confirmColor 确认按钮的文字颜色,必须是 16 进制格式的颜色字符串
57
- * @property {Boolean} editable 是否显示输入框
58
- * @property {String} placeholderText 显示输入框时的提示文本
59
- * @event {Function} success 提示打开成功的回调函数
60
- * @event {Function} fail 提示打开失败的回调函数
61
- * @event {Function} complete 提示结束的回调函数(提示打开、失败都会执行)
62
- */
63
- export default {
64
- group: '展示组件',
65
- title: 'MessageBox 弹框',
66
- name: 'ste-message-box',
67
- props: {
68
- selector: {
69
- type: [String, null],
70
- default: DEFAULT_KEY,
71
- },
72
- },
73
- data() {
74
- return {
75
- title: '确认删除订单?',
76
- content: '',
77
- icon: '',
78
- cancelText: '取消',
79
- cancelColor: '#333333',
80
- confirmText: '确认',
81
- confirmColor: '',
82
- showCancel: true,
83
- editable: false,
84
- placeholderText: '',
85
- inputType: '',
86
- confirm: null,
87
- cancel: null,
88
- complete: null,
89
- // 内部值
90
- pageShow: true,
91
- show: false,
92
- inputValue: '',
93
- animationData: null,
94
- maskAnimationData: null,
95
- iconObj: {
96
- info: '&#xe67d;',
97
- success: '&#xe67a;',
98
- error: '&#xe67b;',
99
- },
100
- open: false,
101
- tmpMsg: null,
102
- showInputPlaceholder: true,
103
- };
104
- },
105
- beforeCreate() {},
106
- created() {
107
- this.pageShow = true;
108
- },
109
- destroyed() {
110
- this.pageShow = false;
111
- this.cmpSteMsgBox.hideMsgBox();
112
- },
113
- computed: {
114
- cmpRootStyle() {
115
- let style = {
116
- opacity: 0,
117
- '--cancel-color': this.cancelColor,
118
- '--confirm-color': this.confirmColor ? this.confirmColor : color.getColor().steThemeColor,
119
- };
120
- return style;
121
- },
122
- cmpRootClass() {
123
- let classArr = [];
124
- if (this.icon) {
125
- classArr.push('icon-type');
126
- }
127
- if (!this.content && !this.$slots.default && !this.editable) {
128
- classArr.push('no-content');
129
- }
130
-
131
- if (this.$slots && this.$slots.default) {
132
- classArr.push('slot-type');
133
- }
134
- return classArr.join(' ');
135
- },
136
- cmpIconCode() {
137
- return ICON_OBJ[this.icon] ? ICON_OBJ[this.icon] : ICON_OBJ.info;
138
- },
139
- cmpSteMsgBox() {
140
- if (!this.tmpMsg) {
141
- this.tmpMsg = useSteMsgBox(this.selector);
142
- }
143
- return this.tmpMsg;
144
- },
145
- openBegin() {
146
- return this.cmpSteMsgBox.$state.openBegin;
147
- },
148
- },
149
- watch: {
150
- openBegin: {
151
- handler(newVal) {
152
- let $state = this.tmpMsg.$state;
153
- if (newVal) {
154
- this.inputValue = '';
155
- this.title = $state.title;
156
- this.content = $state.content;
157
- this.icon = $state.icon;
158
- this.cancelText = $state.cancelText || this.cancelText;
159
- this.confirmText = $state.confirmText || this.confirmText;
160
- this.confirmColor = $state.confirmColor ? $state.confirmColor : this.confirmColor ? this.confirmColor : color.getColor().steThemeColor;
161
- this.showCancel = $state.showCancel === false ? false : true;
162
- this.cancelColor = $state.cancelColor || this.cancelColor;
163
- this.editable = $state.editable === false ? false : true;
164
- this.placeholderText = $state.placeholderText || this.placeholderText;
165
-
166
- this.confirm = $state.confirm;
167
- this.cancel = $state.cancel;
168
- this.complete = $state.complete;
169
- this.showBox();
170
- } else {
171
- this.closeBox();
172
- }
173
- },
174
- // immediate: true,
175
- },
176
- },
177
- methods: {
178
- async showBox() {
179
- this.show = true;
180
- await utils.sleep(50);
181
- let animation = uni.createAnimation(ANIMATION_PROP);
182
- let maskAnimation = uni.createAnimation(ANIMATION_PROP);
183
- maskAnimation.opacity(1).step();
184
- animation.scale(1).step();
185
- this.animationData = animation.export();
186
- this.maskAnimationData = maskAnimation.export();
187
- },
188
- closeBox() {
189
- let animation = uni.createAnimation(ANIMATION_PROP);
190
- let maskAnimation = uni.createAnimation(ANIMATION_PROP);
191
- maskAnimation.opacity(0).step({ duration: DURATION });
192
- animation.scale(0).step();
193
- this.animationData = animation.export();
194
- this.maskAnimationData = maskAnimation.export();
195
- setTimeout(() => {
196
- this.show = false;
197
- this.showInputPlaceholder = true;
198
- }, DURATION);
199
- },
200
- handleInput(e) {
201
- this.inputValue = e.detail.value;
202
- },
203
- handleConfirm() {
204
- this.confirm(this.inputValue);
205
- this.handleComplete();
206
- },
207
- handleCancel() {
208
- this.cancel(this.inputValue);
209
- this.handleComplete();
210
- },
211
- handleComplete() {
212
- this.complete(this.inputValue);
213
- this.tmpMsg.hideMsgBox();
214
- },
215
- // 用input自带占位符时,由于动画原因导致最终显示会有一个下降的效果
216
- handleInputFocus() {
217
- this.showInputPlaceholder = false;
218
- },
219
- handleInputBlur() {
220
- if (!this.inputValue) {
221
- this.showInputPlaceholder = true;
222
- }
223
- },
224
- },
225
- };
226
- </script>
227
-
228
- <style lang="scss" scoped>
229
- .ste-message-box-root {
230
- height: 100vh;
231
- width: 100vw;
232
- overflow: hidden;
233
- position: fixed;
234
- left: 0;
235
- top: 0;
236
- overflow: hidden;
237
- display: flex;
238
- justify-content: center;
239
- align-items: center;
240
- touch-action: none;
241
- background-color: rgba(0, 0, 0, 0.6);
242
- z-index: 99999;
243
-
244
- &.slot-type {
245
- .ste-message-title {
246
- padding-bottom: 24rpx !important;
247
- }
248
-
249
- .msg {
250
- padding: 0 !important;
251
- }
252
- }
253
-
254
- &.icon-type {
255
- .ste-message-title {
256
- padding: 24rpx 0 34rpx 0 !important;
257
- }
258
- }
259
-
260
- &.no-content {
261
- .ste-message-title {
262
- padding-bottom: 48rpx !important;
263
- }
264
- .msg {
265
- padding: 0 !important;
266
- }
267
- }
268
-
269
- .ste-message-box-content {
270
- background: #ffffff;
271
- border-radius: 16rpx;
272
- // border: 2rpx solid #eeeeee;
273
- min-width: 570rpx;
274
- max-width: 610rpx;
275
- display: inline-flex;
276
- flex-direction: column;
277
- transform: scale(0);
278
- .content-box {
279
- .icon-box {
280
- padding-top: 4rpx;
281
- height: 80rpx;
282
- width: 80rpx;
283
- border-radius: 50%;
284
- background: #f1f1f1;
285
- margin: 32rpx auto 0 auto;
286
-
287
- display: flex;
288
- align-items: center;
289
- justify-content: center;
290
- }
291
- .ste-message-title {
292
- width: 100%;
293
- padding-top: 48rpx;
294
- padding-bottom: 24rpx;
295
- font-weight: bold;
296
- font-size: 32rpx;
297
- text-align: center;
298
- }
299
-
300
- .msg {
301
- padding: 0 32rpx 48rpx 32rpx;
302
- text-align: center;
303
- .text {
304
- width: 100%;
305
- font-size: 28rpx;
306
- text-align: center;
307
- }
308
-
309
- .input-box {
310
- position: relative;
311
- }
312
-
313
- .placeholder-text {
314
- position: absolute;
315
- left: 50%;
316
- top: 50%;
317
- transform: translate(-50%, -50%);
318
- color: #999999;
319
- }
320
-
321
- .ste-message-box-input {
322
- height: 80rpx;
323
- width: 548rpx;
324
- background: #f5f5f5;
325
- border-radius: 8px 8px 8px 8px;
326
- text-align: center;
327
- padding: 0 24rpx;
328
- font-size: 28rpx;
329
- }
330
- }
331
- }
332
- .footer {
333
- display: flex;
334
- height: 96rpx;
335
- > .text {
336
- height: 100%;
337
- border-top: 2rpx solid #eeeeee;
338
- flex: 1;
339
- display: flex;
340
- align-items: center;
341
- justify-content: center;
342
- font-weight: bold;
343
- font-size: 32rpx;
344
-
345
- /* #ifdef H5 || WEB */
346
- cursor: pointer;
347
- /* #endif */
348
-
349
- &.cancel {
350
- color: var(--cancel-color);
351
- }
352
-
353
- &.confirm {
354
- color: var(--confirm-color);
355
- }
356
-
357
- & + .text {
358
- border-left: 2rpx solid #eeeeee;
359
- }
360
- }
361
- }
362
- }
363
- }
364
- </style>
1
+ <template>
2
+ <view class="ste-message-box-root" :style="[cmpRootStyle]" :class="[cmpRootClass]" :animation="maskAnimationData" v-if="show">
3
+ <view class="ste-message-box-content" :animation="animationData">
4
+ <view class="content-box">
5
+ <view class="icon-box" v-if="icon">
6
+ <ste-icon :code="cmpIconCode" color="#999999" size="45"></ste-icon>
7
+ </view>
8
+ <view class="ste-message-title">{{ title }}</view>
9
+ <view class="msg" v-if="!icon">
10
+ <slot>
11
+ <view class="text" v-if="!editable">{{ content }}</view>
12
+ <view v-else class="input-box">
13
+ <text class="placeholder-text" v-show="showInputPlaceholder">
14
+ {{ placeholderText }}
15
+ </text>
16
+ <input :value="inputValue" class="ste-message-box-input" @input="handleInput" @focus="handleInputFocus" @blur="handleInputBlur" />
17
+ </view>
18
+ </slot>
19
+ </view>
20
+ </view>
21
+ <view class="footer">
22
+ <view class="cancel text" v-if="showCancel" @click="handleCancel">
23
+ {{ cancelText }}
24
+ </view>
25
+ <view class="confirm text" @click="handleConfirm">
26
+ {{ confirmText }}
27
+ </view>
28
+ </view>
29
+ </view>
30
+ </view>
31
+ </template>
32
+
33
+ <script>
34
+ import { mapState } from 'vuex';
35
+ import useColor from '../../config/color.js';
36
+ let color = useColor();
37
+ import utils from '../../utils/utils.js';
38
+ import useSteMsgBox, { DEFAULT_KEY } from './ste-message-box.js';
39
+ const DURATION = 200;
40
+ const ANIMATION_PROP = { duration: DURATION, timingFunction: 'ease-out' };
41
+ const ICON_OBJ = {
42
+ info: '&#xe67d;',
43
+ success: '&#xe67a;',
44
+ error: '&#xe67b;',
45
+ };
46
+ /**
47
+ * ste-message-box 弹框
48
+ * @description 模拟系统的消息提示框而实现的一套模态对话框组件,用于消息提示、确认消息和提交内容。
49
+ * @tutorial https://stellar-ui.intecloud.com.cn/?projectName=stellar-ui&menu=%E7%BB%84%E4%BB%B6&active=ste-message-box
50
+ * @property {String} title 提示的标题
51
+ * @property {String} content 提示的内容
52
+ * @property {String} icon 提示区域显示图标,此时content会失效
53
+ * @property {String} cancelText 取消按钮的文字,最多 4 个字符
54
+ * @property {String} cancelColor 取消按钮的文字颜色,必须是 16 进制格式的颜色字符串
55
+ * @property {String} confirmText 确认按钮的文字,最多 4 个字符
56
+ * @property {String} confirmColor 确认按钮的文字颜色,必须是 16 进制格式的颜色字符串
57
+ * @property {Boolean} editable 是否显示输入框
58
+ * @property {String} placeholderText 显示输入框时的提示文本
59
+ * @event {Function} success 提示打开成功的回调函数
60
+ * @event {Function} fail 提示打开失败的回调函数
61
+ * @event {Function} complete 提示结束的回调函数(提示打开、失败都会执行)
62
+ */
63
+ export default {
64
+ group: '展示组件',
65
+ title: 'MessageBox 弹框',
66
+ name: 'ste-message-box',
67
+ props: {
68
+ selector: {
69
+ type: [String, null],
70
+ default: DEFAULT_KEY,
71
+ },
72
+ },
73
+ data() {
74
+ return {
75
+ title: '确认删除订单?',
76
+ content: '',
77
+ icon: '',
78
+ cancelText: '取消',
79
+ cancelColor: '#333333',
80
+ confirmText: '确认',
81
+ confirmColor: '',
82
+ showCancel: true,
83
+ editable: false,
84
+ placeholderText: '',
85
+ inputType: '',
86
+ confirm: null,
87
+ cancel: null,
88
+ complete: null,
89
+ // 内部值
90
+ pageShow: true,
91
+ show: false,
92
+ inputValue: '',
93
+ animationData: null,
94
+ maskAnimationData: null,
95
+ iconObj: {
96
+ info: '&#xe67d;',
97
+ success: '&#xe67a;',
98
+ error: '&#xe67b;',
99
+ },
100
+ open: false,
101
+ tmpMsg: null,
102
+ showInputPlaceholder: true,
103
+ };
104
+ },
105
+ beforeCreate() {},
106
+ created() {
107
+ this.pageShow = true;
108
+ },
109
+ destroyed() {
110
+ this.pageShow = false;
111
+ this.cmpSteMsgBox.hideMsgBox();
112
+ },
113
+ computed: {
114
+ cmpRootStyle() {
115
+ let style = {
116
+ opacity: 0,
117
+ '--cancel-color': this.cancelColor,
118
+ '--confirm-color': this.confirmColor ? this.confirmColor : color.getColor().steThemeColor,
119
+ };
120
+ return style;
121
+ },
122
+ cmpRootClass() {
123
+ let classArr = [];
124
+ if (this.icon) {
125
+ classArr.push('icon-type');
126
+ }
127
+ if (!this.content && !this.$slots.default && !this.editable) {
128
+ classArr.push('no-content');
129
+ }
130
+
131
+ if (this.$slots && this.$slots.default) {
132
+ classArr.push('slot-type');
133
+ }
134
+ return classArr.join(' ');
135
+ },
136
+ cmpIconCode() {
137
+ return ICON_OBJ[this.icon] ? ICON_OBJ[this.icon] : ICON_OBJ.info;
138
+ },
139
+ cmpSteMsgBox() {
140
+ if (!this.tmpMsg) {
141
+ this.tmpMsg = useSteMsgBox(this.selector);
142
+ }
143
+ return this.tmpMsg;
144
+ },
145
+ openBegin() {
146
+ return this.cmpSteMsgBox.$state.openBegin;
147
+ },
148
+ },
149
+ watch: {
150
+ openBegin: {
151
+ handler(newVal) {
152
+ let $state = this.tmpMsg.$state;
153
+ if (newVal) {
154
+ this.inputValue = '';
155
+ this.title = $state.title;
156
+ this.content = $state.content;
157
+ this.icon = $state.icon;
158
+ this.cancelText = $state.cancelText || this.cancelText;
159
+ this.confirmText = $state.confirmText || this.confirmText;
160
+ this.confirmColor = $state.confirmColor ? $state.confirmColor : this.confirmColor ? this.confirmColor : color.getColor().steThemeColor;
161
+ this.showCancel = $state.showCancel === false ? false : true;
162
+ this.cancelColor = $state.cancelColor || this.cancelColor;
163
+ this.editable = $state.editable === false ? false : true;
164
+ this.placeholderText = $state.placeholderText || this.placeholderText;
165
+
166
+ this.confirm = $state.confirm;
167
+ this.cancel = $state.cancel;
168
+ this.complete = $state.complete;
169
+ this.showBox();
170
+ } else {
171
+ this.closeBox();
172
+ }
173
+ },
174
+ // immediate: true,
175
+ },
176
+ },
177
+ methods: {
178
+ async showBox() {
179
+ this.show = true;
180
+ await utils.sleep(50);
181
+ let animation = uni.createAnimation(ANIMATION_PROP);
182
+ let maskAnimation = uni.createAnimation(ANIMATION_PROP);
183
+ maskAnimation.opacity(1).step();
184
+ animation.scale(1).step();
185
+ this.animationData = animation.export();
186
+ this.maskAnimationData = maskAnimation.export();
187
+ },
188
+ closeBox() {
189
+ let animation = uni.createAnimation(ANIMATION_PROP);
190
+ let maskAnimation = uni.createAnimation(ANIMATION_PROP);
191
+ maskAnimation.opacity(0).step({ duration: DURATION });
192
+ animation.scale(0).step();
193
+ this.animationData = animation.export();
194
+ this.maskAnimationData = maskAnimation.export();
195
+ setTimeout(() => {
196
+ this.show = false;
197
+ this.showInputPlaceholder = true;
198
+ }, DURATION);
199
+ },
200
+ handleInput(e) {
201
+ this.inputValue = e.detail.value;
202
+ },
203
+ handleConfirm() {
204
+ this.confirm(this.inputValue);
205
+ this.handleComplete();
206
+ },
207
+ handleCancel() {
208
+ this.cancel(this.inputValue);
209
+ this.handleComplete();
210
+ },
211
+ handleComplete() {
212
+ this.complete(this.inputValue);
213
+ this.tmpMsg.hideMsgBox();
214
+ },
215
+ // 用input自带占位符时,由于动画原因导致最终显示会有一个下降的效果
216
+ handleInputFocus() {
217
+ this.showInputPlaceholder = false;
218
+ },
219
+ handleInputBlur() {
220
+ if (!this.inputValue) {
221
+ this.showInputPlaceholder = true;
222
+ }
223
+ },
224
+ },
225
+ };
226
+ </script>
227
+
228
+ <style lang="scss" scoped>
229
+ .ste-message-box-root {
230
+ height: 100vh;
231
+ width: 100vw;
232
+ overflow: hidden;
233
+ position: fixed;
234
+ left: 0;
235
+ top: 0;
236
+ overflow: hidden;
237
+ display: flex;
238
+ justify-content: center;
239
+ align-items: center;
240
+ touch-action: none;
241
+ background-color: rgba(0, 0, 0, 0.6);
242
+ z-index: 99999;
243
+
244
+ &.slot-type {
245
+ .ste-message-title {
246
+ padding-bottom: 24rpx !important;
247
+ }
248
+
249
+ .msg {
250
+ padding: 0 !important;
251
+ }
252
+ }
253
+
254
+ &.icon-type {
255
+ .ste-message-title {
256
+ padding: 24rpx 0 34rpx 0 !important;
257
+ }
258
+ }
259
+
260
+ &.no-content {
261
+ .ste-message-title {
262
+ padding-bottom: 48rpx !important;
263
+ }
264
+ .msg {
265
+ padding: 0 !important;
266
+ }
267
+ }
268
+
269
+ .ste-message-box-content {
270
+ background: #ffffff;
271
+ border-radius: 16rpx;
272
+ // border: 2rpx solid #eeeeee;
273
+ min-width: 570rpx;
274
+ max-width: 610rpx;
275
+ display: inline-flex;
276
+ flex-direction: column;
277
+ transform: scale(0);
278
+ .content-box {
279
+ .icon-box {
280
+ padding-top: 4rpx;
281
+ height: 80rpx;
282
+ width: 80rpx;
283
+ border-radius: 50%;
284
+ background: #f1f1f1;
285
+ margin: 32rpx auto 0 auto;
286
+
287
+ display: flex;
288
+ align-items: center;
289
+ justify-content: center;
290
+ }
291
+ .ste-message-title {
292
+ width: 100%;
293
+ padding-top: 48rpx;
294
+ padding-bottom: 24rpx;
295
+ font-weight: bold;
296
+ font-size: 32rpx;
297
+ text-align: center;
298
+ }
299
+
300
+ .msg {
301
+ padding: 0 32rpx 48rpx 32rpx;
302
+ text-align: center;
303
+ .text {
304
+ width: 100%;
305
+ font-size: 28rpx;
306
+ text-align: center;
307
+ }
308
+
309
+ .input-box {
310
+ position: relative;
311
+ }
312
+
313
+ .placeholder-text {
314
+ position: absolute;
315
+ left: 50%;
316
+ top: 50%;
317
+ transform: translate(-50%, -50%);
318
+ color: #999999;
319
+ }
320
+
321
+ .ste-message-box-input {
322
+ height: 80rpx;
323
+ width: 548rpx;
324
+ background: #f5f5f5;
325
+ border-radius: 8px 8px 8px 8px;
326
+ text-align: center;
327
+ padding: 0 24rpx;
328
+ font-size: 28rpx;
329
+ }
330
+ }
331
+ }
332
+ .footer {
333
+ display: flex;
334
+ height: 96rpx;
335
+ > .text {
336
+ height: 100%;
337
+ border-top: 2rpx solid #eeeeee;
338
+ flex: 1;
339
+ display: flex;
340
+ align-items: center;
341
+ justify-content: center;
342
+ font-weight: bold;
343
+ font-size: 32rpx;
344
+
345
+ /* #ifdef H5 || WEB */
346
+ cursor: pointer;
347
+ /* #endif */
348
+
349
+ &.cancel {
350
+ color: var(--cancel-color);
351
+ }
352
+
353
+ &.confirm {
354
+ color: var(--confirm-color);
355
+ }
356
+
357
+ & + .text {
358
+ border-left: 2rpx solid #eeeeee;
359
+ }
360
+ }
361
+ }
362
+ }
363
+ }
364
+ </style>