Merge branch 'develop' of http://25.13.9.101:9000/K17_AITS/tra-app into develop

This commit is contained in:
田岩
2025-07-22 10:46:34 +08:00
7 changed files with 102 additions and 72 deletions
+15 -15
View File
@@ -4,46 +4,46 @@ export default function showDialog(options) {
left: '0',
height: '100%',
width: '100%',
backgroundColor: 'rgba(0,0,0,0.5)',
backgroundColor: 'rgba(0,0,0,0.1)',
position: 'fixed'
});
const screenWidth = plus.screen.resolutionWidth;
const screenHeight = plus.screen.resolutionHeight;
const borderRadius = 10;
const contentPadding = 20; // 内容左右内边距
const lineHeight = 24; // 单行文本行高
const contentPadding = 12; // 内容左右内边距
const lineHeight = 17; // 单行文本行高
const maxLines = 2; // 最大行数
const fontSize = 16; // 字体大小
const fontSize = 14; // 字体大小
// 判断内容和标题是否存在
const hasContent = options.content && options.content.trim() !== '';
const hasTitle = options.title && options.title.trim() !== '';
// 弹窗宽度计算
const modalWidth = Math.min(0.8 * screenWidth, 500);
const modalWidth = Math.min(0.65 * screenWidth, 500);
const modalLeft = (screenWidth - modalWidth) / 2;
// 内容区域可用宽度
const contentAvailableWidth = modalWidth - 2 * contentPadding - 10;
// 动态计算各部分高度
const titleHeight = hasTitle ? 30 : 0;
const titleHeight = hasTitle ? 20 : 0;
const titleToContentSpacing = (hasTitle && hasContent) ? 10 : 0;
const contentHeight = hasContent ? (lineHeight * maxLines) : 0;
const contentToBtnSpacing = 10;
const btnHeight = 50;
const btnHeight = 46;
// 弹窗总高度
let modalHeight = contentPadding + titleHeight + titleToContentSpacing + contentHeight + contentToBtnSpacing + btnHeight;
let modalHeight = contentPadding + 6 + titleHeight + titleToContentSpacing + contentHeight + contentToBtnSpacing + btnHeight;
modalHeight = options.showCancel ? Math.min(modalHeight, 300) : Math.min(modalHeight, 250);
// 位置计算
const modalTop = (screenHeight - modalHeight) / 2;
const contentAreaTop = modalTop + contentPadding;
const contentAreaTop = modalTop + contentPadding + 6;
const titleTop = hasTitle ? contentAreaTop : 0;
// Fix: Calculate contentTop properly when there's no content
let contentTop;
if (hasContent) {
contentTop = hasTitle ? (titleTop + titleHeight + titleToContentSpacing) : contentAreaTop;
@@ -77,7 +77,7 @@ export default function showDialog(options) {
position: { top: titleTop + 'px', left: modalLeft + 'px', width: modalWidth + 'px', height: titleHeight + 'px' },
textStyles: {
color: '#000',
size: '20px',
size: '18px',
align: 'center',
fontWeight: 'bold',
verticalAlign: 'middle'
@@ -146,7 +146,7 @@ export default function showDialog(options) {
height: lineHeightPx + 'px'
},
textStyles: {
color: '#666',
color: '#111',
size: fontSizePx + 'px',
align: 'center',
verticalAlign: 'top',
@@ -165,19 +165,19 @@ export default function showDialog(options) {
elements.push({
tag: 'rect',
id: 'divider',
position: { top: btnTop + 'px', left: modalLeft + 'px', width: modalWidth + 'px', height: '1px' },
position: { top: btnTop + 'px', left: modalLeft + 'px', width: modalWidth + 'px', height: '0.5px' },
rectStyles: { color: '#b3b3b3' }
});
view.draw(elements);
// 绘制按钮(不变)
if (options.showCancel) {
const btnWidth = Math.floor((modalWidth - 2 * borderRadius) / 2);
view.draw([
{ tag: 'rect', id: 'cancelBtn', position: { top: (btnTop + 2) + 'px', left: (modalLeft + borderRadius) + 'px', width: btnWidth + 'px', height: (btnHeight - 3) + 'px' }, rectStyles: { color: '#fff' } },
{ tag: 'font', id: 'cancelText', text: options.cancelText || '取消', position: { top: btnTop + 'px', left: (modalLeft + borderRadius) + 'px', width: btnWidth + 'px', height: btnHeight + 'px' }, textStyles: { color: '#007AFF', size: '16px', align: 'center', verticalAlign: 'middle' } },
{ tag: 'rect', id: 'btnDivider', position: { top: btnTop + 'px', left: (modalLeft + borderRadius + btnWidth) + 'px', width: '1px', height: btnHeight + 'px' }, rectStyles: { color: '#b3b3b3' } },
{ tag: 'rect', id: 'btnDivider', position: { top: btnTop + 'px', left: (modalLeft + borderRadius + btnWidth) + 'px', width: '0.5px', height: btnHeight + 'px' }, rectStyles: { color: '#b3b3b3' } },
{ tag: 'rect', id: 'confirmBtn', position: { top: (btnTop + 2) + 'px', left: (modalLeft + borderRadius + btnWidth + 1) + 'px', width: btnWidth + 'px', height: (btnHeight - 3) + 'px' }, rectStyles: { color: '#fff' } },
{ tag: 'font', id: 'confirmText', text: options.confirmText || '确定', position: { top: btnTop + 'px', left: (modalLeft + borderRadius + btnWidth + 1) + 'px', width: btnWidth + 'px', height: btnHeight + 'px' }, textStyles: { color: '#007AFF', size: '16px', align: 'center', verticalAlign: 'middle' } }
]);