| | |
| | | return(false); |
| | | } |
| | | |
| | | function showPhotoViewer(layer, urls) { |
| | | if (!urls || urls.length === 0) { |
| | | layer.msg('暂无照片'); |
| | | return; |
| | | } |
| | | var html = '<div style="padding:16px;display:flex;flex-wrap:wrap;gap:12px;max-height:70vh;overflow:auto;background:#f7f7f7;">'; |
| | | for (var i = 0; i < urls.length; i++) { |
| | | var url = escapePhotoHtml(urls[i]); |
| | | html += '<a href="' + url + '" target="_blank" style="display:block;width:360px;max-width:100%;background:#fff;border:1px solid #e6e6e6;padding:8px;">' |
| | | + '<img src="' + url + '" style="display:block;width:100%;height:auto;max-height:360px;object-fit:contain;" alt="photo">' |
| | | + '</a>'; |
| | | } |
| | | html += '</div>'; |
| | | layer.open({ |
| | | type: 1, |
| | | title: '查看照片', |
| | | area: ['900px', '75%'], |
| | | maxmin: true, |
| | | shadeClose: true, |
| | | content: html |
| | | }); |
| | | } |
| | | |
| | | function escapePhotoHtml(value) { |
| | | if (value === undefined || value === null) { |
| | | return ''; |
| | | } |
| | | return String(value) |
| | | .replace(/&/g, '&') |
| | | .replace(/"/g, '"') |
| | | .replace(/</g, '<') |
| | | .replace(/>/g, '>'); |
| | | } |
| | | |
| | | /** |
| | | * 获取AI助手SVG图标HTML |
| | | * @param {number} width 宽度,默认48 |