fix(盘点+退件): 修复货主乱码与库位展示,优化导出二维码真机兼容

盘点:
- 货主名称安全解码,修复真机显示百分号编码乱码
- 盘点类型补充 store/all 文案与色调
- 库位与库位名称展示位置互换(宫格/明细/登记弹窗/盘点记录)
- 商品记录副标题改为显示条码
- 列表携带货主名称到详情页兜底,移除库位卡片冗余行

退件:
- 导出二维码改为纯 JS 生成 PNG data URL,兼容旧 WebView 缺失 TextEncoder 与无 canvas 环境
- 长按二维码支持保存到系统相册
This commit is contained in:
zm2000 2026-10-07 18:21:06 +08:00
parent db90efa0cb
commit 17787988d3
6 changed files with 303 additions and 36 deletions

View File

@ -439,6 +439,6 @@ export default {
.loc-detail__row-qty {
margin-top: 6rpx;
font-size: 28rpx;
color: #606266;
color: #000000;
}
</style>

View File

@ -18,6 +18,23 @@ export function firstValue(source, keys) {
return '';
}
/** 安全解码 URL 编码文本(后端可能返回百分号编码的货主名等);无 % 或解码失败时原样返回 */
export function decodeTextValue(value) {
if (value === null || value === undefined) return '';
const text = String(value).trim();
if (!text || text.indexOf('%') === -1) return text;
try {
return decodeURIComponent(text);
} catch (error) {
return text;
}
}
/** 取货主名称并安全解码(兼容 store_name / storeName 及百分号编码) */
export function storeNameValue(source) {
return decodeTextValue(firstValue(source, ['store_name', 'storeName']));
}
/** 状态文案 */
export function statusText(status) {
const map = {
@ -55,21 +72,23 @@ export function detailStatusText(status) {
return map[key] || '';
}
/** 盘点类型文案:goods=商品盘点 / location=库位盘点 */
/** 盘点类型文案:goods=商品盘点 / store=商品盘点(货主)/ location=库位盘点 / all=库位盘点(全仓) */
export function typeText(type) {
const map = {
goods: '商品盘点',
location: '库位盘点'
store: '商品盘点(货主)',
location: '库位盘点',
all: '库位盘点(全仓)'
};
const key = String(type || '').trim().toLowerCase();
return map[key] || (type ? String(type) : '--');
}
/** 盘点类型色调:goods/location */
/** 盘点类型色调:goods/store→商品盘点,location/all→库位盘点 */
export function typeTone(type) {
const key = String(type || '').trim().toLowerCase();
if (key === 'goods') return 'goods';
if (key === 'location') return 'location';
if (key === 'goods' || key === 'store') return 'goods';
if (key === 'location' || key === 'all') return 'location';
return '';
}
@ -247,6 +266,8 @@ export function normalizeCheckRecords(list, fallbackPage = 1) {
const source = item && typeof item === 'object' ? item : {};
const checkNo = firstValue(source, ['check_no', 'checkNo', 'bill_no', 'billNo', 'code', 'no']);
const title = firstValue(source, ['title', 'name']);
// 货主名称(check.list 行内返回,跳详情页时一并携带)
const storeName = storeNameValue(source);
const typeValue = firstValue(source, ['check_type', 'checkType', 'type']);
const modeValue = firstValue(source, ['mode', 'check_mode', 'checkMode']);
const operator = firstValue(source, [
@ -268,6 +289,7 @@ export function normalizeCheckRecords(list, fallbackPage = 1) {
id,
checkNo,
title,
storeName,
type: typeValue,
typeText: composeType(typeValue, modeValue),
typeLabel: typeText(typeValue),
@ -285,8 +307,9 @@ export function normalizeCheckRecords(list, fallbackPage = 1) {
// ===== 详情页:单头与明细归一化 =====
/** 单头信息归一化(check.detail / check.workData / check.result 的 check 同口径,覆盖全部字段) */
export function normalizeCheckTaskInfo(check) {
/** 单头信息归一化(check.detail / check.workData / check.result 的 check 同口径,覆盖全部字段)
* storeNameFallback:check.detail 可能不返回 store_name,由调用方用 check.list 的 rows[x].store_name 兜底 */
export function normalizeCheckTaskInfo(check, storeNameFallback = '') {
const source = check && typeof check === 'object' ? check : {};
const id = firstValue(source, ['id']);
const checkNo = firstValue(source, ['check_no', 'checkNo', 'bill_no', 'billNo', 'code', 'no']);
@ -299,7 +322,7 @@ export function normalizeCheckTaskInfo(check) {
const diffItems = Number(firstValue(source, ['diff_items', 'diffItems'])) || 0;
const detailStatus = firstValue(source, ['detail_status', 'detailStatus']);
const storeIdRaw = firstValue(source, ['store_id', 'storeId']);
const storeName = firstValue(source, ['store_name', 'storeName']);
const storeName = storeNameValue(source);
const creatorId = firstValue(source, ['creator_id', 'creatorId']);
const creatorName = firstValue(source, ['creator_name', 'creatorName', 'creator']);
const remark = firstValue(source, ['remark']);
@ -314,7 +337,7 @@ export function normalizeCheckTaskInfo(check) {
mode: modeValue,
modeText: modeText(modeValue),
storeId: storeIdRaw === '' ? null : storeIdRaw,
storeName,
storeName: storeName || decodeTextValue(storeNameFallback),
status,
statusText: statusText(status),
statusClass: tone ? `summary-panel__value--${tone}` : '',
@ -589,7 +612,7 @@ function normalizeSpaceWorkRow(item, index, open) {
return {
key: `${spaceCode}-${detailId || goodIndex + 1}`,
title: firstValue(good, ['item_name', 'itemName']) || '--',
subtitle: joinText([firstValue(good, ['barcode']), firstValue(good, ['spec']), firstValue(good, ['store_name', 'storeName'])]),
subtitle: joinText([firstValue(good, ['barcode']), firstValue(good, ['spec']), storeNameValue(good)]),
statusText: done ? '已盘' : '未盘',
statusClass: done ? 'work-card__tag--done' : 'work-card__tag--todo',
amount: buildWorkAmount(good.system_quantity !== undefined ? good.system_quantity : good.systemQuantity, checkedRaw, null, open),
@ -606,8 +629,12 @@ function normalizeSpaceWorkRow(item, index, open) {
return {
key: `space-${firstValue(source, ['id']) || spaceCode}`,
view: 'space',
title: spaceCode,
subtitle: joinText([spaceName, firstValue(source, ['custom_barcode', 'customBarcode'])]),
// 标题优先显示库位名称,副标题显示库位编码(库位/库位名称互换)
title: spaceName || spaceCode,
subtitle: joinText([
spaceName && spaceName !== spaceCode ? spaceCode : '',
firstValue(source, ['custom_barcode', 'customBarcode'])
]),
statusText: '',
statusClass: '',
meta: children.length ? [] : [{ label: '商品', value: '该库位暂无任务商品' }],
@ -672,7 +699,7 @@ function normalizeGoodsWorkRow(item, index, open) {
detailId: detailId ? String(detailId) : '',
stockId: firstValue(source, ['stock_id', 'stockId']) === undefined || firstValue(source, ['stock_id', 'stockId']) === null ? '' : String(firstValue(source, ['stock_id', 'stockId'])),
title: firstValue(source, ['item_name', 'itemName']) || '--',
subtitle: joinText([firstValue(source, ['spec']), firstValue(source, ['barcode']), firstValue(source, ['store_name', 'storeName'])]),
subtitle: joinText([firstValue(source, ['spec']), firstValue(source, ['barcode']), storeNameValue(source)]),
statusText: done ? '已盘' : '未盘',
statusClass: done ? 'work-card__tag--done' : 'work-card__tag--todo',
meta: children.length ? [] : [{ label: '库位', value: '暂无作业记录' }],
@ -686,7 +713,7 @@ function normalizeGoodsWorkRow(item, index, open) {
itemCode: firstValue(source, ['item_code', 'itemCode']) || '',
barcode: firstValue(source, ['barcode']) || '',
spec: firstValue(source, ['spec']) || '',
storeName: firstValue(source, ['store_name', 'storeName']) || '',
storeName: storeNameValue(source),
checked: done,
recordCount,
locationCount: rawLocations.length,
@ -710,6 +737,8 @@ function normalizeLocationWorkRow(item, index, open) {
const stockIdRaw = good.stock_id !== undefined && good.stock_id !== null ? good.stock_id : good.stockId;
const unknown = stockIdRaw === undefined || stockIdRaw === null || String(stockIdRaw).trim() === '';
const itemCode = firstValue(good, ['item_code', 'itemCode', 'barcode']);
// 商品记录展示条码(barcode),而非商品编码(item_code)
const barcode = firstValue(good, ['barcode', 'bar_code']) || itemCode;
const checkerName = firstValue(good, ['checker_name', 'checkerName']);
// 用 record_id 做稳定 key:删记录后剩下的项不会因下标位移而复用旧的左滑节点
const recordId = firstValue(good, ['record_id', 'recordId']);
@ -719,7 +748,7 @@ function normalizeLocationWorkRow(item, index, open) {
stockId: unknown ? '' : String(stockIdRaw),
title: firstValue(good, ['item_name', 'itemName']) || itemCode || (unknown ? '未知商品' : '--'),
subtitle: joinText([
itemCode,
barcode,
unknown ? '未知商品' : firstValue(good, ['store_name', 'storeName']),
checkerName ? `盘点人 ${checkerName}` : ''
]),
@ -750,8 +779,9 @@ function normalizeLocationWorkRow(item, index, open) {
view: 'location',
detailId: detailId ? String(detailId) : '',
location: locationCode,
title: locationCode,
subtitle: locationName && locationName !== locationCode ? locationName : '',
// 库位明细面板:标题优先显示库位名称,副标题显示库位编码(与库位/库位名称互换)
title: locationName || locationCode,
subtitle: locationName && locationName !== locationCode ? locationCode : '',
// 原始 location_name(跳转库位明细页时携带)
locationName: locationName || locationCode,
statusText: done ? '已盘' : '未盘',
@ -900,6 +930,7 @@ export function normalizeGoodsDetailInfo(row, mode) {
const locations = rawLocations.map((item, index) => {
const loc = item && typeof item === 'object' ? item : {};
const locationCode = firstValue(loc, ['location_code', 'locationCode']) || '';
const locationName = firstValue(loc, ['location_name', 'locationName']) || '';
const recordIds = Array.isArray(loc.record_ids) ? loc.record_ids.filter(id => id !== null && id !== undefined && id !== '') : [];
const systemQuantity = toNumberOrNull(loc.system_quantity !== undefined ? loc.system_quantity : loc.systemQuantity);
const quantity = toNumberOrNull(loc.quantity);
@ -916,7 +947,7 @@ export function normalizeGoodsDetailInfo(row, mode) {
locationCode,
systemQuantity,
quantity,
title: locationCode || '未指定库位',
title: locationName || locationCode || '未指定库位',
subtitle: joinText([
checkerName ? `盘点人 ${checkerName}` : '',
checkedAt ? formatDateTime(checkedAt) : ''
@ -1048,17 +1079,18 @@ export function normalizeStockSearchRows(response) {
}).filter(item => item.id !== '');
}
/** 库位搜索结果归一化 */
/** 库位搜索结果归一化(主标题=库位名称,副标题=库位编码/条码) */
export function normalizeSpaceSearchRows(response) {
return pickResponseRows(response).map((row, index) => {
const source = row && typeof row === 'object' ? row : {};
const code = source.space_code || source.spaceCode || '';
const name = source.custom_name || '';
return {
key: `space-${source.id || code || index}`,
id: source.id === undefined || source.id === null ? '' : source.id,
code,
title: code || `库位 #${index + 1}`,
subtitle: [source.custom_name, source.custom_barcode ? `条码:${source.custom_barcode}` : ''].filter(Boolean).join(' · ')
title: name || code || `库位 #${index + 1}`,
subtitle: [name ? code : '', source.custom_barcode ? `条码:${source.custom_barcode}` : ''].filter(Boolean).join(' · ')
};
}).filter(item => item.id !== '');
}

View File

@ -204,7 +204,10 @@ export default {
},
handleRecordClick(item) {
if (!item || !item.id) return;
this.$tools.routerTo(`/pages/warehouse/inventoryCountDetail?id=${encodeURIComponent(item.id)}`);
const query = [`id=${encodeURIComponent(item.id)}`];
// 货主名称从 check.list 行内携带到详情页
if (item.storeName) query.push(`storeName=${encodeURIComponent(item.storeName)}`);
this.$tools.routerTo(`/pages/warehouse/inventoryCountDetail?${query.join('&')}`);
},
async loadRecordList(page = this.currentPage) {
const targetPage = Math.max(1, Number(page || 1));

View File

@ -179,6 +179,8 @@ export default {
data() {
return {
taskId: '',
// 列表页(check.list rows[x].store_name)携带的货主名称,check.detail 未返回时兜底
routeStoreName: '',
taskInfo: {},
scanKeyword: '',
focusKey: '',
@ -292,6 +294,7 @@ export default {
},
onLoad(options = {}) {
this.taskId = String(options.id || options.taskId || '').trim();
this.routeStoreName = String(options.storeName || '').trim();
if (this.taskId) {
this.loadTaskDetail();
}
@ -586,7 +589,7 @@ export default {
const response = await this.$http('check.workData', params);
const payload = extractObjectPayload(response);
if (payload.check) {
this.taskInfo = normalizeCheckTaskInfo(payload.check);
this.taskInfo = normalizeCheckTaskInfo(payload.check, this.routeStoreName);
}
const rows = extractListPayload(payload, response);
this.workList = normalizeWorkRows(rows, this.workView, this.taskInfo.mode);
@ -782,7 +785,7 @@ export default {
// 明细 tab 只需任务信息(check.detail 已不再返回 rows)
const response = await this.$http('check.detail', { id: Number(this.taskId) });
const payload = extractObjectPayload(response);
this.taskInfo = normalizeCheckTaskInfo(payload.check);
this.taskInfo = normalizeCheckTaskInfo(payload.check, this.routeStoreName);
// 状态已知后再确定是否需要接收扫码
this.syncBroadcastWithMode();
} catch (error) {

View File

@ -26,10 +26,6 @@
@refresherrestore="handleRefresherRestore"
>
<view class="inv-space-card">
<view class="inv-space-card__row">
<text class="inv-space-card__label">库位</text>
<text class="inv-space-card__value">{{ locationCode || '--' }}</text>
</view>
<view class="inv-space-card__row">
<text class="inv-space-card__label">商品进度</text>
<text class="inv-space-card__value">{{ progressText }}</text>
@ -106,10 +102,6 @@ export default {
if (!status) return true;
return status === 'approved' || status === 'checking';
},
// 库位编码/名称全部取接口数据(名称在下方卡片副标题里展示)
locationCode() {
return String((this.row && this.row.location) || '');
},
progressText() {
if (!this.row) return '--';
return this.row.gridProgressText || `${this.row.goodsCount || 0} 项`;

View File

@ -241,7 +241,7 @@
:src="exportQrImage"
mode="aspectFit"
@click="previewExportQr"
@longpress="previewExportQr"
@longpress="saveExportQr"
></image>
<text class="export-popup__hint">{{ exportQrHint }}</text>
<text class="export-popup__url">{{ exportUrl || '--' }}</text>
@ -297,6 +297,189 @@ import {
const REMARK_STORAGE_KEY = 'return_received_remarks';
const REMARK_MAX_COUNT = 50;
/**
* 部分旧版 Android WebView 缺少全局 TextEncoder,而 qrcode 依赖它做 UTF-8 编码,
* 真机上会抛 ReferenceError: TextEncoder is not defined。此处注入最小 UTF-8 实现兜底。
*/
function ensureTextEncoder() {
const g = typeof globalThis !== 'undefined'
? globalThis
: (typeof window !== 'undefined' ? window : null);
if (!g || g.TextEncoder) return;
g.TextEncoder = function TextEncoder() {};
g.TextEncoder.prototype.encode = function encode(str) {
const s = String(str == null ? '' : str);
const utf8 = unescape(encodeURIComponent(s));
const bytes = new Uint8Array(utf8.length);
for (let i = 0; i < utf8.length; i += 1) bytes[i] = utf8.charCodeAt(i);
return bytes;
};
}
// ===== 纯 JS 生成二维码 PNG data URL =====
// App 逻辑层(app-service)没有 document/canvas,QRCode.toDataURL 会报
// 「You need to specify a canvas element」。这里改用 QRCode.create(纯 JS)拿到点阵后,
// 用最小的 PNG 编码器(zlib stored 块 + CRC32 + Adler32)直接拼出 base64 图片。
const BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
const CRC32_TABLE = (() => {
const table = new Int32Array(256);
for (let n = 0; n < 256; n += 1) {
let c = n;
for (let k = 0; k < 8; k += 1) {
c = (c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1);
}
table[n] = c;
}
return table;
})();
function crc32(bytes) {
let crc = -1;
for (let i = 0; i < bytes.length; i += 1) {
crc = (crc >>> 8) ^ CRC32_TABLE[(crc ^ bytes[i]) & 0xff];
}
return (crc ^ -1) >>> 0;
}
function adler32(bytes) {
let a = 1;
let b = 0;
const MOD = 65521;
for (let i = 0; i < bytes.length; i += 1) {
a = (a + bytes[i]) % MOD;
b = (b + a) % MOD;
}
return ((b << 16) | a) >>> 0;
}
function toBase64(bytes) {
let out = '';
for (let i = 0; i < bytes.length; i += 3) {
const b1 = bytes[i];
const b2 = i + 1 < bytes.length ? bytes[i + 1] : 0;
const b3 = i + 2 < bytes.length ? bytes[i + 2] : 0;
out += BASE64_CHARS[b1 >> 2];
out += BASE64_CHARS[((b1 & 3) << 4) | (b2 >> 4)];
out += i + 1 < bytes.length ? BASE64_CHARS[((b2 & 15) << 2) | (b3 >> 6)] : '=';
out += i + 2 < bytes.length ? BASE64_CHARS[b3 & 63] : '=';
}
return out;
}
function writeUint32BE(out, offset, value) {
out[offset] = (value >>> 24) & 0xff;
out[offset + 1] = (value >>> 16) & 0xff;
out[offset + 2] = (value >>> 8) & 0xff;
out[offset + 3] = value & 0xff;
}
function buildPngChunk(type, data) {
const typeBytes = new Uint8Array(4);
typeBytes[0] = type.charCodeAt(0);
typeBytes[1] = type.charCodeAt(1);
typeBytes[2] = type.charCodeAt(2);
typeBytes[3] = type.charCodeAt(3);
const chunk = new Uint8Array(12 + data.length);
writeUint32BE(chunk, 0, data.length);
chunk.set(typeBytes, 4);
chunk.set(data, 8);
const crcInput = new Uint8Array(4 + data.length);
crcInput.set(typeBytes, 0);
crcInput.set(data, 4);
writeUint32BE(chunk, 8 + data.length, crc32(crcInput));
return chunk;
}
function buildZlibStored(data) {
// zlib 头(CMF=0x78, FLG=0x01)+ 若干 DEFLATE stored 块 + Adler32 校验
const parts = [];
const header = new Uint8Array(2);
header[0] = 0x78;
header[1] = 0x01;
parts.push(header);
const MAX = 65535;
for (let i = 0; i < data.length; i += MAX) {
const end = Math.min(i + MAX, data.length);
const isFinal = end >= data.length;
const len = end - i;
const block = new Uint8Array(5 + len);
block[0] = isFinal ? 1 : 0;
block[1] = len & 0xff;
block[2] = (len >>> 8) & 0xff;
const nlen = (~len) & 0xffff;
block[3] = nlen & 0xff;
block[4] = (nlen >>> 8) & 0xff;
block.set(data.subarray(i, end), 5);
parts.push(block);
}
const trailer = new Uint8Array(4);
writeUint32BE(trailer, 0, adler32(data));
parts.push(trailer);
const total = parts.reduce((sum, p) => sum + p.length, 0);
const out = new Uint8Array(total);
let offset = 0;
for (let i = 0; i < parts.length; i += 1) {
out.set(parts[i], offset);
offset += parts[i].length;
}
return out;
}
function buildQrPngDataUrl(content, opts) {
const qr = QRCode.create(content, {
errorCorrectionLevel: opts.errorCorrectionLevel || 'M'
});
const size = qr.modules.size;
const margin = opts.margin == null ? 4 : opts.margin;
const total = size + margin * 2;
const scale = Math.max(1, Math.floor((opts.width || 420) / total));
const px = total * scale;
const raw = new Uint8Array(px * (px * 4 + 1));
let p = 0;
for (let y = 0; y < px; y += 1) {
raw[p] = 0; // 每行 filter type 0(None)
p += 1;
const my = Math.floor(y / scale) - margin;
for (let x = 0; x < px; x += 1) {
const mx = Math.floor(x / scale) - margin;
const dark = mx >= 0 && my >= 0 && mx < size && my < size && qr.modules.get(my, mx);
raw[p] = dark ? 0 : 255;
raw[p + 1] = dark ? 0 : 255;
raw[p + 2] = dark ? 0 : 255;
raw[p + 3] = 255;
p += 4;
}
}
const sig = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]);
const ihdr = new Uint8Array(13);
writeUint32BE(ihdr, 0, px);
writeUint32BE(ihdr, 4, px);
ihdr[8] = 8; // bit depth
ihdr[9] = 6; // color type: RGBA
ihdr[10] = 0; // compression
ihdr[11] = 0; // filter
ihdr[12] = 0; // interlace
const chunks = [
sig,
buildPngChunk('IHDR', ihdr),
buildPngChunk('IDAT', buildZlibStored(raw)),
buildPngChunk('IEND', new Uint8Array(0))
];
const totalLen = chunks.reduce((sum, c) => sum + c.length, 0);
const png = new Uint8Array(totalLen);
let offset = 0;
for (let i = 0; i < chunks.length; i += 1) {
png.set(chunks[i], offset);
offset += chunks[i].length;
}
return `data:image/png;base64,${toBase64(png)}`;
}
export default {
name: 'ReturnScanPanel',
props: {
@ -688,9 +871,10 @@ export default {
const content = String(this.exportUrl || '').trim();
if (!content) return;
try {
this.exportQrImage = await QRCode.toDataURL(content, {
ensureTextEncoder();
this.exportQrImage = buildQrPngDataUrl(content, {
width: 420,
margin: 1,
margin: 4,
errorCorrectionLevel: 'M'
});
} catch (error) {
@ -710,6 +894,59 @@ export default {
}
});
},
/** 长按:保存二维码到系统相册(App 端先 base64 转临时文件) */
saveExportQr() {
const dataUrl = this.exportQrImage;
if (!dataUrl) return;
// H5 等非 App 环境:没有 plus.io,交给浏览器长按保存
if (typeof plus === 'undefined' || !plus.io || !plus.io.resolveLocalFileSystemURL) {
this.previewExportQr();
return;
}
this.dataUrlToTempFile(dataUrl)
.then((filePath) => new Promise((resolve, reject) => {
uni.saveImageToPhotosAlbum({
filePath,
success: () => resolve(),
fail: (err) => reject(err)
});
}))
.then(() => {
uni.showToast({ title: '已保存到相册', icon: 'success' });
})
.catch((error) => {
console.warn('[退件登记] 保存二维码到相册失败:', error);
uni.showToast({ title: '保存失败,可点「复制下载链接」', icon: 'none' });
});
},
/** base64 data URL 写入 App 本地临时文件,返回可保存的文件路径 */
dataUrlToTempFile(dataUrl) {
return new Promise((resolve, reject) => {
const match = String(dataUrl || '').match(/^data:image\/([a-zA-Z0-9+]+);base64,(.+)$/);
if (!match) {
reject(new Error('无效的图片数据'));
return;
}
const ext = match[1] === 'jpeg' ? 'jpg' : match[1];
const base64 = match[2];
const fileName = `export_qr_${Date.now()}_${Math.floor(Math.random() * 100000)}.${ext}`;
plus.io.resolveLocalFileSystemURL('_doc', (dirEntry) => {
dirEntry.getFile(fileName, { create: true, exclusive: false }, (fileEntry) => {
fileEntry.createWriter((writer) => {
writer.onwrite = () => {
const filePath = typeof fileEntry.toLocalURL === 'function'
? fileEntry.toLocalURL()
: `_doc/${fileName}`;
resolve(filePath);
};
writer.onerror = (e) => reject(e || new Error('写文件失败'));
writer.seek(0);
writer.writeAsBinary(base64);
}, reject);
}, reject);
}, reject);
});
},
handleCopyExportUrl() {
const url = String(this.exportUrl || '').trim();
if (!url) return;