uni-oaview 1.1.16 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +410 -1
- package/components/oa-confirm/oa-confirm.vue +1 -1
- package/components/oa-confirm-new/oa-confirm-new.vue +141 -0
- package/components/oa-modal-wrapper/oa-modal-wrapper.vue +445 -0
- package/components/oa-page/global-components.vue +14 -0
- package/components/oa-page/oa-page.vue +14 -1
- package/constants/event-names.ts +20 -0
- package/dist/index.d.ts +200 -2
- package/dist/index.esm.js +680 -1
- package/index.scss +4 -0
- package/package.json +5 -4
- package/src/utils/create-modal.ts +132 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/message-box.ts +51 -0
- package/src/utils/version-check/README.md +401 -0
- package/src/utils/version-check/index.ts +8 -0
- package/src/utils/version-check/runtime.ts +185 -0
- package/src/utils/version-check/types.ts +51 -0
package/README.md
CHANGED
|
@@ -1 +1,410 @@
|
|
|
1
|
-
|
|
1
|
+
# OA View SDK - uni-app 组件库
|
|
2
|
+
|
|
3
|
+
本组件项目不能直接运行,查看效果下载 https://gitlab.mockuai.com/FrontToClient/mk-uview
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 目录
|
|
8
|
+
|
|
9
|
+
- [组件列表](#组件列表)
|
|
10
|
+
- [工具函数](#工具函数)
|
|
11
|
+
- [createModal - 函数式弹框](#createmodal---函数式弹框)
|
|
12
|
+
- [Message - 消息提示](#message---消息提示)
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 组件列表
|
|
17
|
+
|
|
18
|
+
| 组件名 | 说明 | 位置 |
|
|
19
|
+
| -------------------------- | --------------------------------------- | -------------------------------------- |
|
|
20
|
+
| `oa-area-select` | 省市区选择组件 | `components/oa-area-select/` |
|
|
21
|
+
| `oa-area-select-popup` | 省市区选择弹框 | `components/oa-area-select-popup/` |
|
|
22
|
+
| `oa-confirm` | 确认弹框组件(配合 Message 使用) | `components/oa-confirm/` |
|
|
23
|
+
| `oa-login` | 登录组件 | `components/oa-login/` |
|
|
24
|
+
| `oa-modal-wrapper` | 函数式弹框容器(配合 createModal 使用) | `components/oa-modal-wrapper/` |
|
|
25
|
+
| `oa-multiple-select` | 多选组件 | `components/oa-multiple-select/` |
|
|
26
|
+
| `oa-multiple-select-popup` | 多选弹框 | `components/oa-multiple-select-popup/` |
|
|
27
|
+
| `oa-page` | 页面容器组件(必需) | `components/oa-page/` |
|
|
28
|
+
| `oa-popup` | 弹框组件(uni-popup 封装) | `components/oa-popup/` |
|
|
29
|
+
| `oa-rate` | 评分组件 | `components/oa-rate/` |
|
|
30
|
+
| `oa-select` | 选择组件 | `components/oa-select/` |
|
|
31
|
+
| `oa-select-popup` | 选择弹框 | `components/oa-select-popup/` |
|
|
32
|
+
| `oa-skeleton` | 骨架屏组件 | `components/oa-skeleton/` |
|
|
33
|
+
| `oa-toast` | Toast 组件(配合 Message 使用) | `components/oa-toast/` |
|
|
34
|
+
| `oa-user-avatar` | 用户头像组件 | `components/oa-user-avatar/` |
|
|
35
|
+
| `oa-vconsole` | 调试工具组件 | `components/oa-vconsole/` |
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 工具函数
|
|
40
|
+
|
|
41
|
+
### createModal - 函数式弹框
|
|
42
|
+
|
|
43
|
+
基于事件总线的函数式弹框调用方案,支持多弹框叠加、自定义头部、Promise 和 subscribe 两种回调模式。
|
|
44
|
+
|
|
45
|
+
**使用前请确保页面已使用 `oa-page` 组件包裹。**
|
|
46
|
+
|
|
47
|
+
#### 基础用法
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { createModal } from '@/uni-oaview/src/utils/create-modal';
|
|
51
|
+
import UserSelect from './components/user-select.vue';
|
|
52
|
+
|
|
53
|
+
// 方式 1:使用 subscribe(类似 RxJS)
|
|
54
|
+
createModal(UserSelect, {
|
|
55
|
+
title: '选择用户',
|
|
56
|
+
props: { list: userList.value },
|
|
57
|
+
}).subscribe((result) => {
|
|
58
|
+
console.log('选中用户:', result);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// 方式 2:使用 Promise(async/await)
|
|
62
|
+
const result = await createModal(UserSelect, {
|
|
63
|
+
title: '选择用户',
|
|
64
|
+
props: { list: userList.value },
|
|
65
|
+
});
|
|
66
|
+
console.log('选中用户:', result);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### API
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
function createModal(component: Component, options?: ModalOptions & { props?: Record<string, any> }): CreateModalReturn;
|
|
73
|
+
|
|
74
|
+
interface ModalOptions {
|
|
75
|
+
// uni-popup 原生属性
|
|
76
|
+
type?: 'center' | 'top' | 'bottom' | 'left' | 'right'; // 弹框类型
|
|
77
|
+
maskClick?: boolean; // 点击蒙层是否关闭(已废弃,使用 isMaskClick)
|
|
78
|
+
isMaskClick?: boolean; // 点击蒙层是否关闭弹框
|
|
79
|
+
animation?: boolean; // 是否开启动画
|
|
80
|
+
safeArea?: boolean; // 是否适配底部安全区
|
|
81
|
+
backgroundColor?: string; // 弹框背景色
|
|
82
|
+
maskBackgroundColor?: string; // 蒙层背景色,默认 'rgba(0, 0, 0, 0.4)'
|
|
83
|
+
borderRadius?: string; // 弹框圆角,默认 '16px 16px 0 0'
|
|
84
|
+
|
|
85
|
+
// 头部配置
|
|
86
|
+
header?: ModalHeaderOptions;
|
|
87
|
+
title?: string; // 弹框标题(当 header.title 不存在时使用)
|
|
88
|
+
|
|
89
|
+
// 内容区配置
|
|
90
|
+
contentPadding?: boolean; // 默认 true,添加 16px 内边距
|
|
91
|
+
maxHeight?: string; // 默认 '80vh'
|
|
92
|
+
|
|
93
|
+
// 蒙层控制
|
|
94
|
+
showMask?: boolean; // 是否显示蒙层,默认 true
|
|
95
|
+
|
|
96
|
+
// 回调
|
|
97
|
+
onHeaderAction?: (action: string, modalId: string) => void;
|
|
98
|
+
onConfirm?: () => boolean | Promise<boolean>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface ModalHeaderOptions {
|
|
102
|
+
show?: boolean; // 是否显示头部
|
|
103
|
+
showClose?: boolean; // 是否显示关闭按钮
|
|
104
|
+
title?: string; // 头部标题文本
|
|
105
|
+
left?: Component | string; // 左侧内容(文本或组件)
|
|
106
|
+
leftProps?: Record<string, any>; // 左侧内容的属性
|
|
107
|
+
center?: Component | string; // 中间内容(文本或组件)
|
|
108
|
+
centerProps?: Record<string, any>; // 中间内容的属性
|
|
109
|
+
right?: Component | string; // 右侧内容(文本或组件)
|
|
110
|
+
rightProps?: Record<string, any>; // 右侧内容的属性
|
|
111
|
+
submitText?: string; // 提交按钮文本,不填则不显示提交按钮
|
|
112
|
+
submitProps?: Record<string, any>; // 提交按钮的属性
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
interface CreateModalReturn {
|
|
116
|
+
subscribe: (callback: (result: any) => void) => CreateModalReturn; // 订阅弹框关闭事件
|
|
117
|
+
close: (result?: any) => void; // 关闭弹框
|
|
118
|
+
updateProps: (props: Record<string, any>) => void; // 更新弹框内容组件的 props
|
|
119
|
+
then: Promise<any>['then']; // Promise then 方法
|
|
120
|
+
catch: Promise<any>['catch']; // Promise catch 方法
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### 自定义头部示例
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
// 方式 1:使用字符串
|
|
128
|
+
createModal(UserSelect, {
|
|
129
|
+
header: {
|
|
130
|
+
left: '返回',
|
|
131
|
+
center: '选择用户',
|
|
132
|
+
right: '确定',
|
|
133
|
+
showClose: false,
|
|
134
|
+
},
|
|
135
|
+
onHeaderAction: (action) => {
|
|
136
|
+
if (action === 'right-click') {
|
|
137
|
+
console.log('点击了确定');
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// 方式 2:使用自定义组件
|
|
143
|
+
import CustomCloseBtn from './components/custom-close-btn.vue';
|
|
144
|
+
import CustomTitle from './components/custom-title.vue';
|
|
145
|
+
|
|
146
|
+
createModal(UserSelect, {
|
|
147
|
+
header: {
|
|
148
|
+
left: CustomCloseBtn,
|
|
149
|
+
leftProps: { color: '#333' },
|
|
150
|
+
center: CustomTitle,
|
|
151
|
+
centerProps: { title: '自定义标题' },
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// 方式 3:无头部(完全自定义)
|
|
156
|
+
createModal(CustomPopup, {
|
|
157
|
+
header: { show: false },
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// 方式 4:使用提交按钮(新增)
|
|
161
|
+
createModal(UserSelect, {
|
|
162
|
+
header: {
|
|
163
|
+
title: '选择用户',
|
|
164
|
+
submitText: '确定', // 显示提交按钮
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// 方式 5:提交按钮和自定义按钮(提交按钮优先级高)
|
|
169
|
+
createModal(UserSelect, {
|
|
170
|
+
header: {
|
|
171
|
+
title: '选择用户',
|
|
172
|
+
submitText: '确定', // 显示提交按钮,忽略 right
|
|
173
|
+
right: '关闭', // 不会显示
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
#### 子组件规范
|
|
179
|
+
|
|
180
|
+
```vue
|
|
181
|
+
<!-- components/user-select.vue -->
|
|
182
|
+
<template>
|
|
183
|
+
<view class="user-select">
|
|
184
|
+
<!-- 内容区,无需处理头部和底部安全区 -->
|
|
185
|
+
<scroll-view scroll-y class="list">
|
|
186
|
+
<view v-for="user in props.list" :key="user.id" @click="selectUser(user)">
|
|
187
|
+
{{ user.name }}
|
|
188
|
+
</view>
|
|
189
|
+
</scroll-view>
|
|
190
|
+
</view>
|
|
191
|
+
</template>
|
|
192
|
+
|
|
193
|
+
<script setup lang="ts">
|
|
194
|
+
const props = defineProps<{
|
|
195
|
+
list: Array<{ id: string; name: string }>;
|
|
196
|
+
}>();
|
|
197
|
+
|
|
198
|
+
const emit = defineEmits(['close', 'update', 'submit']);
|
|
199
|
+
|
|
200
|
+
const selectUser = (user: any) => {
|
|
201
|
+
// 关闭弹框并传回结果
|
|
202
|
+
emit('close', user);
|
|
203
|
+
|
|
204
|
+
// 或使用 submit(支持 onConfirm 回调)
|
|
205
|
+
emit('submit', user);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// 更新父级传入的 props(可选)
|
|
209
|
+
const updateList = (newList: any[]) => {
|
|
210
|
+
emit('update', { list: newList });
|
|
211
|
+
};
|
|
212
|
+
</script>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
#### 外部控制弹框
|
|
216
|
+
|
|
217
|
+
```ts
|
|
218
|
+
const modal = createModal(UserSelect, {
|
|
219
|
+
title: '选择用户',
|
|
220
|
+
props: { list: [] },
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// 更新 props
|
|
224
|
+
modal.updateProps({ list: newList });
|
|
225
|
+
|
|
226
|
+
// 手动关闭
|
|
227
|
+
modal.close({ selected: true });
|
|
228
|
+
|
|
229
|
+
// 关闭所有弹框
|
|
230
|
+
import { closeAllModals } from '@/uni-oaview/src/utils/create-modal';
|
|
231
|
+
closeAllModals();
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
#### 注意事项
|
|
235
|
+
|
|
236
|
+
1. **必须包裹 oa-page**:每个使用 `createModal` 的页面都需要使用 `oa-page` 组件包裹
|
|
237
|
+
2. **最大弹框数**:同时最多打开 5 个弹框,超出会自动关闭最早的弹框
|
|
238
|
+
3. **返回键处理**:在 App 端,点击返回键会优先关闭最上层弹框
|
|
239
|
+
4. **页面卸载**:页面卸载时会自动关闭所有弹框并清理事件监听
|
|
240
|
+
5. **类型安全**:所有接口已导出,可配合 TypeScript 使用
|
|
241
|
+
|
|
242
|
+
#### 新增功能说明
|
|
243
|
+
|
|
244
|
+
**蒙层控制(showMask)**
|
|
245
|
+
```ts
|
|
246
|
+
// 隐藏蒙层
|
|
247
|
+
createModal(MyComponent, {
|
|
248
|
+
showMask: false,
|
|
249
|
+
props: { /* ... */ }
|
|
250
|
+
});
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**蒙层样式定制(maskBackgroundColor)**
|
|
254
|
+
```ts
|
|
255
|
+
// 自定义蒙层颜色
|
|
256
|
+
createModal(MyComponent, {
|
|
257
|
+
maskBackgroundColor: 'rgba(0, 0, 0, 0.6)', // 更深的蒙层
|
|
258
|
+
props: { /* ... */ }
|
|
259
|
+
});
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**弹框圆角定制(borderRadius)**
|
|
263
|
+
```ts
|
|
264
|
+
// 自定义圆角,默认 '16px 16px 0 0'
|
|
265
|
+
createModal(MyComponent, {
|
|
266
|
+
borderRadius: '10px 10px 10px 10px', // 四个角都有圆角
|
|
267
|
+
props: { /* ... */ }
|
|
268
|
+
});
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
**提交按钮(submitText)**
|
|
272
|
+
```ts
|
|
273
|
+
// 显示提交按钮,点击触发内部组件的 @submit 事件
|
|
274
|
+
createModal(MyComponent, {
|
|
275
|
+
header: {
|
|
276
|
+
title: '选择用户',
|
|
277
|
+
submitText: '确定', // 提交按钮文本
|
|
278
|
+
},
|
|
279
|
+
props: { /* ... */ }
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// 内部组件中触发提交
|
|
283
|
+
emit('submit', result);
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
**蒙层点击行为(isMaskClick)**
|
|
287
|
+
```ts
|
|
288
|
+
// 点击蒙层关闭弹框(推荐使用 isMaskClick,maskClick 已废弃)
|
|
289
|
+
createModal(MyComponent, {
|
|
290
|
+
isMaskClick: true,
|
|
291
|
+
props: { /* ... */ }
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
### Message - 消息提示
|
|
298
|
+
|
|
299
|
+
基于事件总线的消息提示工具,支持 Toast 和 Confirm 两种模式。
|
|
300
|
+
|
|
301
|
+
**使用前请确保页面已使用 `oa-page` 组件包裹。**
|
|
302
|
+
|
|
303
|
+
#### Toast 提示
|
|
304
|
+
|
|
305
|
+
```ts
|
|
306
|
+
import { Message } from '@/uni-oaview/src/utils/message';
|
|
307
|
+
|
|
308
|
+
// 成功提示
|
|
309
|
+
await Message.success('操作成功', '数据已保存');
|
|
310
|
+
|
|
311
|
+
// 警告提示
|
|
312
|
+
await Message.warning('注意', '请检查输入内容');
|
|
313
|
+
|
|
314
|
+
// 自定义按钮文本
|
|
315
|
+
await Message.success('提交成功', '等待审核', '我知道了');
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
#### Confirm 确认框
|
|
319
|
+
|
|
320
|
+
```ts
|
|
321
|
+
import { Message } from '@/uni-oaview/src/utils/message';
|
|
322
|
+
|
|
323
|
+
try {
|
|
324
|
+
await Message.confirm('确定要删除吗?', '提示', '删除', '取消');
|
|
325
|
+
// 用户点击了确定
|
|
326
|
+
console.log('执行删除');
|
|
327
|
+
} catch {
|
|
328
|
+
// 用户点击了取消
|
|
329
|
+
console.log('取消删除');
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
#### API
|
|
334
|
+
|
|
335
|
+
```ts
|
|
336
|
+
interface Message {
|
|
337
|
+
/**
|
|
338
|
+
* 成功提示
|
|
339
|
+
* @param title 标题
|
|
340
|
+
* @param content 内容
|
|
341
|
+
* @param confirmText 确认按钮文本(默认"我知道了")
|
|
342
|
+
*/
|
|
343
|
+
success(title: string, content: string, confirmText?: string): Promise<void>;
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* 警告提示
|
|
347
|
+
* @param title 标题
|
|
348
|
+
* @param content 内容
|
|
349
|
+
* @param confirmText 确认按钮文本(默认"我知道了")
|
|
350
|
+
*/
|
|
351
|
+
warning(title: string, content: string, confirmText?: string): Promise<void>;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* 确认弹窗
|
|
355
|
+
* @param content 确认内容
|
|
356
|
+
* @param title 标题(默认"温馨提示")
|
|
357
|
+
* @param confirmText 确定按钮文本(默认"确认")
|
|
358
|
+
* @param cancelText 取消按钮文本(默认"取消")
|
|
359
|
+
* @returns Promise,确认 resolve,取消 reject
|
|
360
|
+
*/
|
|
361
|
+
confirm(content: string, title?: string, confirmText?: string, cancelText?: string): Promise<void>;
|
|
362
|
+
}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
## 页面规范
|
|
368
|
+
|
|
369
|
+
### 必须使用 oa-page
|
|
370
|
+
|
|
371
|
+
所有页面都需要使用 `oa-page` 组件作为根容器,否则 `createModal` 和 `Message` 将无法正常工作。
|
|
372
|
+
|
|
373
|
+
```vue
|
|
374
|
+
<template>
|
|
375
|
+
<oa-page>
|
|
376
|
+
<!-- 页面内容 -->
|
|
377
|
+
<view class="page-content">
|
|
378
|
+
<!-- ... -->
|
|
379
|
+
</view>
|
|
380
|
+
</oa-page>
|
|
381
|
+
</template>
|
|
382
|
+
|
|
383
|
+
<script setup lang="ts">
|
|
384
|
+
// 页面逻辑
|
|
385
|
+
</script>
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### 文件命名规范
|
|
389
|
+
|
|
390
|
+
- **组件文件**:kebab-case(短横线连接)
|
|
391
|
+
- ✅ `user-select.vue`
|
|
392
|
+
- ❌ `UserSelect.vue`
|
|
393
|
+
- **工具函数**:kebab-case
|
|
394
|
+
- ✅ `create-modal.ts`
|
|
395
|
+
- ❌ `createModal.ts`
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
## 注意事项
|
|
400
|
+
|
|
401
|
+
1. **事件前缀**:所有内部事件都使用 `oa-ehK3Krfu#$opk^Ug!6Ce!-` 前缀,避免与其他库冲突
|
|
402
|
+
2. **类型安全**:建议所有组件使用 TypeScript 编写,并导出 Props 类型
|
|
403
|
+
3. **内存管理**:页面卸载时会自动清理弹框和事件监听,无需手动处理
|
|
404
|
+
4. **样式隔离**:弹框组件使用 scoped 样式,避免样式污染
|
|
405
|
+
|
|
406
|
+
---
|
|
407
|
+
|
|
408
|
+
## License
|
|
409
|
+
|
|
410
|
+
MIT
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<uni-popup ref="popupRef" background-color="
|
|
2
|
+
<uni-popup ref="popupRef" background-color="none" v-if="isShow" :is-mask-click="false">
|
|
3
3
|
<view class="popup-content">
|
|
4
4
|
<image src="../../imgs/toast/warning.svg" style="width: 32px; height: 32px" />
|
|
5
5
|
<span class="title">{{ state.title }}</span>
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<uni-popup ref="popupRef" background-color="none" v-if="isShow" :is-mask-click="false">
|
|
3
|
+
<view class="popup-content">
|
|
4
|
+
<p class="title">{{ state.title }}</p>
|
|
5
|
+
<p class="subtitle">{{ state.subtitle }}</p>
|
|
6
|
+
<view class="divider" />
|
|
7
|
+
<view class="submit-buttons">
|
|
8
|
+
<view class="cancel-button" @click="submitClick('cancel')">{{ state.cancelText }}</view>
|
|
9
|
+
<view class="divider-vertical" />
|
|
10
|
+
<view class="confirm-button" @click="submitClick('confirm')">{{ state.confirmText }}</view>
|
|
11
|
+
</view>
|
|
12
|
+
</view>
|
|
13
|
+
</uni-popup>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script lang="ts" setup>
|
|
17
|
+
import { reactive, ref } from 'vue';
|
|
18
|
+
import { OPEN_CONFIRM_BOX_NEW } from '../../constants';
|
|
19
|
+
import { onHide, onShow } from '@dcloudio/uni-app';
|
|
20
|
+
|
|
21
|
+
const popupRef = ref();
|
|
22
|
+
const isPageAlive = ref(false);
|
|
23
|
+
const isShow = ref(false);
|
|
24
|
+
|
|
25
|
+
const state = reactive({
|
|
26
|
+
title: '',
|
|
27
|
+
subtitle: '',
|
|
28
|
+
confirmText: '确定',
|
|
29
|
+
cancelText: '取消',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
let innerCallback: any = null;
|
|
33
|
+
|
|
34
|
+
const submitClick = (type: 'cancel' | 'confirm') => {
|
|
35
|
+
innerCallback?.(type);
|
|
36
|
+
popupRef.value.close();
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
onShow(() => {
|
|
40
|
+
isPageAlive.value = true;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
onHide(() => {
|
|
44
|
+
isPageAlive.value = false;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
uni.$on(OPEN_CONFIRM_BOX_NEW, (params: any) => {
|
|
48
|
+
if (!isPageAlive.value) return;
|
|
49
|
+
isShow.value = true;
|
|
50
|
+
setTimeout(() => {
|
|
51
|
+
const { title, subtitle, confirmText, cancelText, callback } = params;
|
|
52
|
+
innerCallback = callback;
|
|
53
|
+
state.title = title || '';
|
|
54
|
+
state.subtitle = subtitle || '';
|
|
55
|
+
state.confirmText = confirmText || '确定';
|
|
56
|
+
state.cancelText = cancelText || '取消';
|
|
57
|
+
popupRef.value?.open('center');
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<style scoped lang="scss">
|
|
63
|
+
::v-deep {
|
|
64
|
+
.uni-popup__wrapper {
|
|
65
|
+
border-radius: 8px;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.popup-content {
|
|
70
|
+
width: 280px;
|
|
71
|
+
border-radius: 8px;
|
|
72
|
+
background-color: #ffffff;
|
|
73
|
+
box-shadow: 0px 8px 24px rgba(0, 0, 0, 0.16);
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-direction: column;
|
|
76
|
+
overflow: hidden;
|
|
77
|
+
|
|
78
|
+
.title {
|
|
79
|
+
padding: 20px 20px 12px;
|
|
80
|
+
color: #1c202b;
|
|
81
|
+
font-family: PingFang SC;
|
|
82
|
+
font-size: 16px;
|
|
83
|
+
font-weight: 500;
|
|
84
|
+
line-height: 24px;
|
|
85
|
+
text-align: center;
|
|
86
|
+
margin: 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.subtitle {
|
|
90
|
+
padding: 0 20px 16px;
|
|
91
|
+
color: #63676f;
|
|
92
|
+
font-family: PingFang SC;
|
|
93
|
+
font-size: 14px;
|
|
94
|
+
font-weight: 400;
|
|
95
|
+
line-height: normal;
|
|
96
|
+
text-align: center;
|
|
97
|
+
margin: 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.divider {
|
|
101
|
+
height: 1px;
|
|
102
|
+
background-color: #f1f3f5;
|
|
103
|
+
width: 100%;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.submit-buttons {
|
|
107
|
+
display: flex;
|
|
108
|
+
align-items: stretch;
|
|
109
|
+
height: 47px;
|
|
110
|
+
|
|
111
|
+
.cancel-button {
|
|
112
|
+
flex: 1;
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
justify-content: center;
|
|
116
|
+
color: #1c202b;
|
|
117
|
+
font-family: PingFang SC;
|
|
118
|
+
font-size: 16px;
|
|
119
|
+
font-weight: 400;
|
|
120
|
+
line-height: normal;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.divider-vertical {
|
|
124
|
+
width: 1px;
|
|
125
|
+
background-color: #f1f3f5;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.confirm-button {
|
|
129
|
+
flex: 1;
|
|
130
|
+
display: flex;
|
|
131
|
+
align-items: center;
|
|
132
|
+
justify-content: center;
|
|
133
|
+
color: #3d73ff;
|
|
134
|
+
font-family: PingFang SC;
|
|
135
|
+
font-size: 16px;
|
|
136
|
+
font-weight: 500;
|
|
137
|
+
line-height: normal;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
</style>
|