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,217 @@
|
|
|
1
|
+
# MessageBox 弹框
|
|
2
|
+
|
|
3
|
+
模拟系统的消息提示框而实现的一套模态对话框组件,用于消息提示、确认消息和提交内容。
|
|
4
|
+
|
|
5
|
+
---$
|
|
6
|
+
### 使用方法
|
|
7
|
+
1. 安装 `ste-vue-inset-loader` 插件
|
|
8
|
+
```
|
|
9
|
+
npm install ste-vue-inset-loader --save-dev
|
|
10
|
+
```
|
|
11
|
+
2. 配置 `pages.json` 信息
|
|
12
|
+
```
|
|
13
|
+
"insetLoader": {
|
|
14
|
+
"config": {
|
|
15
|
+
"msgBox": "<root-portal><ste-message-box id='steMessageBox'></ste-message-box></root-portal>"
|
|
16
|
+
},
|
|
17
|
+
// 全局配置
|
|
18
|
+
"label": ["msgBox"],
|
|
19
|
+
"rootEle": "view"
|
|
20
|
+
},
|
|
21
|
+
```
|
|
22
|
+
3. 配置 `vue.config.js` 信息
|
|
23
|
+
```
|
|
24
|
+
chainWebpack: (config) => {
|
|
25
|
+
config.module
|
|
26
|
+
.rule('vue')
|
|
27
|
+
.test(/\.vue$/)
|
|
28
|
+
.use()
|
|
29
|
+
.loader(path.resolve(__dirname, './node_modules/ste-vue-inset-loader'))
|
|
30
|
+
.end();
|
|
31
|
+
},
|
|
32
|
+
```
|
|
33
|
+
4. 在`main.js`里引入混淆文件`app-mixin.js`
|
|
34
|
+
```
|
|
35
|
+
import mixin from './app-mixin.js';
|
|
36
|
+
Vue.mixin(mixin);
|
|
37
|
+
```
|
|
38
|
+
5. 在混淆文件`app-mixin.js`里引入组件的`js`文件,将`showToast`和`hideToast`方法混入全局,每个页面通过 `this.` 来使用对应的方法
|
|
39
|
+
```
|
|
40
|
+
import useSteMsgBox from '@/node_modules/stellar-ui/components/ste-message-box/ste-message-box.js';
|
|
41
|
+
let steMsgBox = useSteMsgBox();
|
|
42
|
+
export default {
|
|
43
|
+
methods: {
|
|
44
|
+
showMsgBox: steMsgBox.showMsgBox,
|
|
45
|
+
hideMsgBox: steMsgBox.hideMsgBox
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
6. js文件中使用
|
|
51
|
+
```
|
|
52
|
+
import useSteMsgBox from '@/node_modules/stellar-ui/components/ste-message-box/ste-message-box.js';
|
|
53
|
+
let steMsgBox = useSteMsgBox();
|
|
54
|
+
steMsgBox.showMsgBox();
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 代码演示
|
|
58
|
+
#### 基础使用
|
|
59
|
+
可在标题(`title`)和内容(`content`)中使用`\n`来实现换行
|
|
60
|
+
```
|
|
61
|
+
this.showMsgBox({
|
|
62
|
+
title: '确认删除订单吗?',
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### 带图标
|
|
67
|
+
- 内置三种图标类型:`info`、`success`、`error`
|
|
68
|
+
- 当显示图标时,内容(`content`)会失效,只显示标题(`title`)
|
|
69
|
+
```
|
|
70
|
+
msgBoxIcon1() {
|
|
71
|
+
this.showMsgBox({
|
|
72
|
+
title: '提示',
|
|
73
|
+
icon: 'info',
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
msgBoxIcon2() {
|
|
77
|
+
this.showMsgBox({
|
|
78
|
+
title: '提示',
|
|
79
|
+
icon: 'success',
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
msgBoxIcon3() {
|
|
83
|
+
this.showMsgBox({
|
|
84
|
+
title: '提示',
|
|
85
|
+
icon: 'error',
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### 自定义按钮
|
|
91
|
+
```
|
|
92
|
+
msgBoxBtn1() {
|
|
93
|
+
this.showMsgBox({
|
|
94
|
+
title: '提示',
|
|
95
|
+
content: '确认删除订单吗?',
|
|
96
|
+
cancelText: '算了',
|
|
97
|
+
confirmText: '删吧',
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
msgBoxBtn2() {
|
|
101
|
+
this.showMsgBox({
|
|
102
|
+
title: '提示',
|
|
103
|
+
content: '确认删除订单吗?',
|
|
104
|
+
cancelColor: '#e1e',
|
|
105
|
+
confirmColor: '#a8ae1e',
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
msgBoxBtn3() {
|
|
109
|
+
this.showMsgBox({
|
|
110
|
+
title: '提示',
|
|
111
|
+
content: '确认删除订单吗?',
|
|
112
|
+
showCancel: false,
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
#### 显示输入框
|
|
118
|
+
当显示输入框时,内容(`content`)将不显示
|
|
119
|
+
```
|
|
120
|
+
msgBoxInput() {
|
|
121
|
+
this.showMsgBox({
|
|
122
|
+
title: '提示',
|
|
123
|
+
content: '确认删除订单吗?',
|
|
124
|
+
editable: true,
|
|
125
|
+
placeholderText: '请输入',
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### 插槽
|
|
131
|
+
如果提供的弹框内容不满足需求,可以使用插槽自定义弹框内容。
|
|
132
|
+
可以通过指定唯一标识`selector`的方式,在一个页面中使用多个`ste-message-box`,`useSteMsgBox(selector)`会返回一个指定了selector的组件实例。
|
|
133
|
+
```
|
|
134
|
+
<ste-button @click="customClick">插槽</ste-button>
|
|
135
|
+
<ste-message-box selector="myMsgBox">
|
|
136
|
+
<view style="display: flex; justify-content: center; padding-bottom: 20rpx;width: 504rpx">
|
|
137
|
+
<ste-rate v-model="rate"></ste-rate>
|
|
138
|
+
</view>
|
|
139
|
+
</ste-message-box>
|
|
140
|
+
<script>
|
|
141
|
+
import useSteMsgBox from '@/node_modules/stellar-ui/components/ste-message-box/ste-message-box.js';
|
|
142
|
+
const msgBox = useSteMsgBox('myMsgBox');
|
|
143
|
+
export default {
|
|
144
|
+
data() {
|
|
145
|
+
return {
|
|
146
|
+
rate: 0,
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
methods: {
|
|
150
|
+
customClick() {
|
|
151
|
+
msgBox.showMsgBox({
|
|
152
|
+
title: '评分',
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
</script>
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
#### 回调事件
|
|
162
|
+
```
|
|
163
|
+
msgBoxCallback1() {
|
|
164
|
+
this.showMsgBox({
|
|
165
|
+
title: '提示',
|
|
166
|
+
cancel: () => {
|
|
167
|
+
this.showToast({
|
|
168
|
+
title: '点击了取消',
|
|
169
|
+
});
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
},
|
|
173
|
+
msgBoxCallback2() {
|
|
174
|
+
this.showMsgBox({
|
|
175
|
+
title: '提示',
|
|
176
|
+
confirm: () => {
|
|
177
|
+
this.showToast({
|
|
178
|
+
title: '点击了确认',
|
|
179
|
+
});
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
},
|
|
183
|
+
msgBoxCallback3() {
|
|
184
|
+
this.showMsgBox({
|
|
185
|
+
title: '提示',
|
|
186
|
+
complete: () => {
|
|
187
|
+
this.showToast({
|
|
188
|
+
title: '弹框完成',
|
|
189
|
+
});
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
},
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---$
|
|
196
|
+
### API
|
|
197
|
+
#### 组件属性(Props)
|
|
198
|
+
|
|
199
|
+
| 参数 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
|
|
200
|
+
| --- | --- | --- | --- | --- | --- |
|
|
201
|
+
| `title` | 提示的标题 | `String` | - | - | - |
|
|
202
|
+
| `content` | 提示的内容 | `String` | - | - | - |
|
|
203
|
+
| `icon` | 提示区域显示图标,此时content会失效 | `String` | - | - | - |
|
|
204
|
+
| `showCancel` | 是否显示取消按钮 | `Boolean` | `true` | - | - |
|
|
205
|
+
| `cancelText` | 提示的内容 | `String` | `取消` | - | - |
|
|
206
|
+
| `cancelColor` | 取消按钮的文字颜色 | `String` | `#333333` | - | - |
|
|
207
|
+
| `confirmText` | 确认按钮的文字,最多 4 个字符 | `String` | `确认` | - | - |
|
|
208
|
+
| `confirmColor` | 确认按钮的文字颜色 | `String` | `#0090FF` | - | - |
|
|
209
|
+
| `editable` | 是否显示输入框 | `Boolean` | `false` | - | - |
|
|
210
|
+
| `placeholderText` | 显示输入框时的提示文本 | `String` | - | - | - |
|
|
211
|
+
| `confirm` | 点击确认的回调函数 | `Function`| `null` | - | - |
|
|
212
|
+
| `cancel` | 点击取消的回调函数 | `Function`| `null` | - | - |
|
|
213
|
+
| `complete` | 弹框关闭的回调函数(无论是确认关闭还是取消关闭) | `Function`| `null` | - | - |
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
---$
|
|
217
|
+
{{fuyuwei}}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import Vue from 'vue';
|
|
2
|
+
import Vuex from 'vuex';
|
|
3
|
+
|
|
4
|
+
Vue.use(Vuex);
|
|
5
|
+
const DEFAULT_KEY = '$steMsgBoxKey';
|
|
6
|
+
const DEFAULT_CONFIG = {
|
|
7
|
+
title: '',
|
|
8
|
+
content: '',
|
|
9
|
+
showCancel: true,
|
|
10
|
+
icon: '',
|
|
11
|
+
cancelText: '取消',
|
|
12
|
+
cancelColor: '#333333',
|
|
13
|
+
confirmText: '确认',
|
|
14
|
+
confirmColor: '',
|
|
15
|
+
editable: false,
|
|
16
|
+
placeholderText: '',
|
|
17
|
+
success: null,
|
|
18
|
+
fail: null,
|
|
19
|
+
complete: null,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const store = new Vuex.Store({
|
|
23
|
+
state: {},
|
|
24
|
+
mutations: {
|
|
25
|
+
initializeState(state, key) {
|
|
26
|
+
if (!state[key]) {
|
|
27
|
+
Vue.set(state, key, {
|
|
28
|
+
selector: key,
|
|
29
|
+
openBegin: false,
|
|
30
|
+
...DEFAULT_CONFIG,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
setState(state, { key, params }) {
|
|
35
|
+
Object.assign(state[key], params);
|
|
36
|
+
},
|
|
37
|
+
resetState(state, key) {
|
|
38
|
+
Object.assign(state[key], {
|
|
39
|
+
openBegin: false,
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
function useSteMsgBox(key) {
|
|
46
|
+
key = key ?? DEFAULT_KEY;
|
|
47
|
+
store.commit('initializeState', key);
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
showMsgBox(params) {
|
|
51
|
+
store.commit('setState', {
|
|
52
|
+
key,
|
|
53
|
+
params: {
|
|
54
|
+
...DEFAULT_CONFIG,
|
|
55
|
+
...params,
|
|
56
|
+
confirm: params.confirm ?? function () {},
|
|
57
|
+
cancel: params.cancel ?? function () {},
|
|
58
|
+
complete: params.complete ?? function () {},
|
|
59
|
+
openBegin: true,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
hideMsgBox() {
|
|
64
|
+
store.commit('resetState', key);
|
|
65
|
+
},
|
|
66
|
+
$state: store.state[key],
|
|
67
|
+
$store: store,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default useSteMsgBox;
|
|
72
|
+
export { DEFAULT_KEY };
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="ste-message-box-root"
|
|
4
|
+
:style="[cmpRootStyle]"
|
|
5
|
+
:class="[cmpRootClass]"
|
|
6
|
+
:animation="maskAnimationData"
|
|
7
|
+
v-if="show"
|
|
8
|
+
>
|
|
9
|
+
<view class="ste-message-box-content" :animation="animationData">
|
|
10
|
+
<view class="content-box">
|
|
11
|
+
<view class="icon-box" v-if="icon">
|
|
12
|
+
<ste-icon :code="cmpIconCode" color="#999999" size="45"></ste-icon>
|
|
13
|
+
</view>
|
|
14
|
+
<view class="ste-message-title">{{ title }}</view>
|
|
15
|
+
<view class="msg" v-if="!icon">
|
|
16
|
+
<slot>
|
|
17
|
+
<view class="text" v-if="!editable">{{ content }}</view>
|
|
18
|
+
<view v-else class="input-box">
|
|
19
|
+
<text class="placeholder-text" v-show="showInputPlaceholder">
|
|
20
|
+
{{ placeholderText }}
|
|
21
|
+
</text>
|
|
22
|
+
<input
|
|
23
|
+
:value="inputValue"
|
|
24
|
+
class="ste-message-box-input"
|
|
25
|
+
@input="handleInput"
|
|
26
|
+
@focus="handleInputFocus"
|
|
27
|
+
@blur="handleInputBlur"
|
|
28
|
+
/>
|
|
29
|
+
</view>
|
|
30
|
+
</slot>
|
|
31
|
+
</view>
|
|
32
|
+
</view>
|
|
33
|
+
<view class="footer">
|
|
34
|
+
<view class="cancel text" v-if="showCancel" @click="handleCancel">
|
|
35
|
+
{{ cancelText }}
|
|
36
|
+
</view>
|
|
37
|
+
<view class="confirm text" @click="handleConfirm">
|
|
38
|
+
{{ confirmText }}
|
|
39
|
+
</view>
|
|
40
|
+
</view>
|
|
41
|
+
</view>
|
|
42
|
+
</view>
|
|
43
|
+
</template>
|
|
44
|
+
|
|
45
|
+
<script>
|
|
46
|
+
import { mapState } from 'vuex';
|
|
47
|
+
import useColor from '../../config/color.js';
|
|
48
|
+
let color = useColor();
|
|
49
|
+
import utils from '../../utils/utils.js';
|
|
50
|
+
import useSteMsgBox, { DEFAULT_KEY } from './ste-message-box.js';
|
|
51
|
+
const DURATION = 200;
|
|
52
|
+
const ANIMATION_PROP = { duration: DURATION, timingFunction: 'ease-out' };
|
|
53
|
+
const ICON_OBJ = {
|
|
54
|
+
info: '',
|
|
55
|
+
success: '',
|
|
56
|
+
error: '',
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* ste-message-box 弹框
|
|
60
|
+
* @description 模拟系统的消息提示框而实现的一套模态对话框组件,用于消息提示、确认消息和提交内容。
|
|
61
|
+
* @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-message-box
|
|
62
|
+
* @property {String} title 提示的标题
|
|
63
|
+
* @property {String} content 提示的内容
|
|
64
|
+
* @property {String} icon 提示区域显示图标,此时content会失效
|
|
65
|
+
* @property {String} cancelText 取消按钮的文字,最多 4 个字符
|
|
66
|
+
* @property {String} cancelColor 取消按钮的文字颜色,必须是 16 进制格式的颜色字符串
|
|
67
|
+
* @property {String} confirmText 确认按钮的文字,最多 4 个字符
|
|
68
|
+
* @property {String} confirmColor 确认按钮的文字颜色,必须是 16 进制格式的颜色字符串
|
|
69
|
+
* @property {Boolean} editable 是否显示输入框
|
|
70
|
+
* @property {String} placeholderText 显示输入框时的提示文本
|
|
71
|
+
* @event {Function} success 提示打开成功的回调函数
|
|
72
|
+
* @event {Function} fail 提示打开失败的回调函数
|
|
73
|
+
* @event {Function} complete 提示结束的回调函数(提示打开、失败都会执行)
|
|
74
|
+
*/
|
|
75
|
+
export default {
|
|
76
|
+
group: '展示组件',
|
|
77
|
+
title: 'MessageBox 弹框',
|
|
78
|
+
name: 'ste-message-box',
|
|
79
|
+
props: {
|
|
80
|
+
selector: {
|
|
81
|
+
type: [String, null],
|
|
82
|
+
default: DEFAULT_KEY,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
data() {
|
|
86
|
+
return {
|
|
87
|
+
title: '确认删除订单?',
|
|
88
|
+
content: '',
|
|
89
|
+
icon: '',
|
|
90
|
+
cancelText: '取消',
|
|
91
|
+
cancelColor: '#333333',
|
|
92
|
+
confirmText: '确认',
|
|
93
|
+
confirmColor: '',
|
|
94
|
+
showCancel: true,
|
|
95
|
+
editable: false,
|
|
96
|
+
placeholderText: '',
|
|
97
|
+
inputType: '',
|
|
98
|
+
confirm: null,
|
|
99
|
+
cancel: null,
|
|
100
|
+
complete: null,
|
|
101
|
+
// 内部值
|
|
102
|
+
pageShow: true,
|
|
103
|
+
show: false,
|
|
104
|
+
inputValue: '',
|
|
105
|
+
animationData: null,
|
|
106
|
+
maskAnimationData: null,
|
|
107
|
+
iconObj: {
|
|
108
|
+
info: '',
|
|
109
|
+
success: '',
|
|
110
|
+
error: '',
|
|
111
|
+
},
|
|
112
|
+
open: false,
|
|
113
|
+
tmpMsg: null,
|
|
114
|
+
showInputPlaceholder: true,
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
beforeCreate() {},
|
|
118
|
+
created() {
|
|
119
|
+
this.pageShow = true;
|
|
120
|
+
},
|
|
121
|
+
destroyed() {
|
|
122
|
+
this.pageShow = false;
|
|
123
|
+
this.cmpSteMsgBox.hideMsgBox();
|
|
124
|
+
},
|
|
125
|
+
computed: {
|
|
126
|
+
cmpRootStyle() {
|
|
127
|
+
let style = {
|
|
128
|
+
opacity: 0,
|
|
129
|
+
'--cancel-color': this.cancelColor,
|
|
130
|
+
'--confirm-color': this.confirmColor ? this.confirmColor : color.getColor().steThemeColor,
|
|
131
|
+
};
|
|
132
|
+
return style;
|
|
133
|
+
},
|
|
134
|
+
cmpRootClass() {
|
|
135
|
+
let classArr = [];
|
|
136
|
+
if (this.icon) {
|
|
137
|
+
classArr.push('icon-type');
|
|
138
|
+
}
|
|
139
|
+
if (!this.content && !this.$slots.default) {
|
|
140
|
+
classArr.push('no-content');
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (this.$slots && this.$slots.default) {
|
|
144
|
+
classArr.push('slot-type');
|
|
145
|
+
}
|
|
146
|
+
return classArr.join(' ');
|
|
147
|
+
},
|
|
148
|
+
cmpIconCode() {
|
|
149
|
+
return ICON_OBJ[this.icon] ? ICON_OBJ[this.icon] : ICON_OBJ.info;
|
|
150
|
+
},
|
|
151
|
+
cmpSteMsgBox() {
|
|
152
|
+
if (!this.tmpMsg) {
|
|
153
|
+
this.tmpMsg = useSteMsgBox(this.selector);
|
|
154
|
+
}
|
|
155
|
+
return this.tmpMsg;
|
|
156
|
+
},
|
|
157
|
+
openBegin() {
|
|
158
|
+
return this.cmpSteMsgBox.$state.openBegin;
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
watch: {
|
|
162
|
+
openBegin: {
|
|
163
|
+
handler(newVal) {
|
|
164
|
+
let $state = this.tmpMsg.$state;
|
|
165
|
+
if (newVal) {
|
|
166
|
+
this.inputValue = '';
|
|
167
|
+
this.title = $state.title;
|
|
168
|
+
this.content = $state.content;
|
|
169
|
+
this.icon = $state.icon;
|
|
170
|
+
this.cancelText = $state.cancelText || this.cancelText;
|
|
171
|
+
this.confirmText = $state.confirmText || this.confirmText;
|
|
172
|
+
this.confirmColor = $state.confirmColor
|
|
173
|
+
? $state.confirmColor
|
|
174
|
+
: this.confirmColor
|
|
175
|
+
? this.confirmColor
|
|
176
|
+
: color.getColor().steThemeColor;
|
|
177
|
+
this.showCancel = $state.showCancel === false ? false : true;
|
|
178
|
+
this.cancelColor = $state.cancelColor || this.cancelColor;
|
|
179
|
+
this.editable = $state.editable === false ? false : true;
|
|
180
|
+
this.placeholderText = $state.placeholderText || this.placeholderText;
|
|
181
|
+
|
|
182
|
+
this.confirm = $state.confirm;
|
|
183
|
+
this.cancel = $state.cancel;
|
|
184
|
+
this.complete = $state.complete;
|
|
185
|
+
this.showBox();
|
|
186
|
+
} else {
|
|
187
|
+
this.closeBox();
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
// immediate: true,
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
methods: {
|
|
194
|
+
async showBox() {
|
|
195
|
+
this.show = true;
|
|
196
|
+
await utils.sleep(50);
|
|
197
|
+
let animation = uni.createAnimation(ANIMATION_PROP);
|
|
198
|
+
let maskAnimation = uni.createAnimation(ANIMATION_PROP);
|
|
199
|
+
maskAnimation.opacity(1).step();
|
|
200
|
+
animation.scale(1).step();
|
|
201
|
+
this.animationData = animation.export();
|
|
202
|
+
this.maskAnimationData = maskAnimation.export();
|
|
203
|
+
},
|
|
204
|
+
closeBox() {
|
|
205
|
+
let animation = uni.createAnimation(ANIMATION_PROP);
|
|
206
|
+
let maskAnimation = uni.createAnimation(ANIMATION_PROP);
|
|
207
|
+
maskAnimation.opacity(0).step({ duration: DURATION });
|
|
208
|
+
animation.scale(0).step();
|
|
209
|
+
this.animationData = animation.export();
|
|
210
|
+
this.maskAnimationData = maskAnimation.export();
|
|
211
|
+
setTimeout(() => {
|
|
212
|
+
this.show = false;
|
|
213
|
+
this.showInputPlaceholder = true;
|
|
214
|
+
}, DURATION);
|
|
215
|
+
},
|
|
216
|
+
handleInput(e) {
|
|
217
|
+
this.inputValue = e.detail.value;
|
|
218
|
+
},
|
|
219
|
+
handleConfirm() {
|
|
220
|
+
this.confirm(this.inputValue);
|
|
221
|
+
this.handleComplete();
|
|
222
|
+
},
|
|
223
|
+
handleCancel() {
|
|
224
|
+
this.cancel(this.inputValue);
|
|
225
|
+
this.handleComplete();
|
|
226
|
+
},
|
|
227
|
+
handleComplete() {
|
|
228
|
+
this.complete(this.inputValue);
|
|
229
|
+
this.tmpMsg.hideMsgBox();
|
|
230
|
+
},
|
|
231
|
+
// 用input自带占位符时,由于动画原因导致最终显示会有一个下降的效果
|
|
232
|
+
handleInputFocus() {
|
|
233
|
+
this.showInputPlaceholder = false;
|
|
234
|
+
},
|
|
235
|
+
handleInputBlur() {
|
|
236
|
+
if (!this.inputValue) {
|
|
237
|
+
this.showInputPlaceholder = true;
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
</script>
|
|
243
|
+
|
|
244
|
+
<style lang="scss" scoped>
|
|
245
|
+
.ste-message-box-root {
|
|
246
|
+
height: 100vh;
|
|
247
|
+
width: 100vw;
|
|
248
|
+
overflow: hidden;
|
|
249
|
+
position: fixed;
|
|
250
|
+
left: 0;
|
|
251
|
+
top: 0;
|
|
252
|
+
overflow: hidden;
|
|
253
|
+
display: flex;
|
|
254
|
+
justify-content: center;
|
|
255
|
+
align-items: center;
|
|
256
|
+
touch-action: none;
|
|
257
|
+
background-color: rgba(0, 0, 0, 0.6);
|
|
258
|
+
z-index: 99999;
|
|
259
|
+
|
|
260
|
+
&.slot-type {
|
|
261
|
+
.ste-message-title {
|
|
262
|
+
padding-bottom: 24rpx !important;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.msg {
|
|
266
|
+
padding: 0 !important;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
&.icon-type {
|
|
271
|
+
.ste-message-title {
|
|
272
|
+
padding: 24rpx 0 34rpx 0 !important;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
&.no-content {
|
|
277
|
+
.ste-message-title {
|
|
278
|
+
padding-bottom: 48rpx !important;
|
|
279
|
+
}
|
|
280
|
+
.msg {
|
|
281
|
+
padding: 0 !important;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.ste-message-box-content {
|
|
286
|
+
background: #ffffff;
|
|
287
|
+
border-radius: 16rpx;
|
|
288
|
+
// border: 2rpx solid #eeeeee;
|
|
289
|
+
min-width: 570rpx;
|
|
290
|
+
max-width: 610rpx;
|
|
291
|
+
display: inline-flex;
|
|
292
|
+
flex-direction: column;
|
|
293
|
+
transform: scale(0);
|
|
294
|
+
.content-box {
|
|
295
|
+
.icon-box {
|
|
296
|
+
padding-top: 4rpx;
|
|
297
|
+
height: 80rpx;
|
|
298
|
+
width: 80rpx;
|
|
299
|
+
border-radius: 50%;
|
|
300
|
+
background: #f1f1f1;
|
|
301
|
+
margin: 32rpx auto 0 auto;
|
|
302
|
+
|
|
303
|
+
display: flex;
|
|
304
|
+
align-items: center;
|
|
305
|
+
justify-content: center;
|
|
306
|
+
}
|
|
307
|
+
.ste-message-title {
|
|
308
|
+
width: 100%;
|
|
309
|
+
padding-top: 48rpx;
|
|
310
|
+
padding-bottom: 24rpx;
|
|
311
|
+
font-weight: bold;
|
|
312
|
+
font-size: 32rpx;
|
|
313
|
+
text-align: center;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.msg {
|
|
317
|
+
padding: 0 32rpx 48rpx 32rpx;
|
|
318
|
+
text-align: center;
|
|
319
|
+
.text {
|
|
320
|
+
width: 100%;
|
|
321
|
+
font-size: 28rpx;
|
|
322
|
+
text-align: center;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.input-box {
|
|
326
|
+
position: relative;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.placeholder-text {
|
|
330
|
+
position: absolute;
|
|
331
|
+
left: 50%;
|
|
332
|
+
top: 50%;
|
|
333
|
+
transform: translate(-50%, -50%);
|
|
334
|
+
color: #999999;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.ste-message-box-input {
|
|
338
|
+
height: 80rpx;
|
|
339
|
+
width: 548rpx;
|
|
340
|
+
background: #f5f5f5;
|
|
341
|
+
border-radius: 8px 8px 8px 8px;
|
|
342
|
+
text-align: center;
|
|
343
|
+
padding: 0 24rpx;
|
|
344
|
+
font-size: 28rpx;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
.footer {
|
|
349
|
+
display: flex;
|
|
350
|
+
height: 96rpx;
|
|
351
|
+
> .text {
|
|
352
|
+
height: 100%;
|
|
353
|
+
border-top: 2rpx solid #eeeeee;
|
|
354
|
+
flex: 1;
|
|
355
|
+
display: flex;
|
|
356
|
+
align-items: center;
|
|
357
|
+
justify-content: center;
|
|
358
|
+
font-weight: bold;
|
|
359
|
+
font-size: 32rpx;
|
|
360
|
+
|
|
361
|
+
/* #ifdef H5 || WEB */
|
|
362
|
+
cursor: pointer;
|
|
363
|
+
/* #endif */
|
|
364
|
+
|
|
365
|
+
&.cancel {
|
|
366
|
+
color: var(--cancel-color);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
&.confirm {
|
|
370
|
+
color: var(--confirm-color);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
& + .text {
|
|
374
|
+
border-left: 2rpx solid #eeeeee;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
</style>
|