|
|
|
@ -315,13 +315,16 @@ const throttledsubmitRefund = _.throttle(handleRefund, 5000, { |
|
|
|
trailing: false |
|
|
|
}) |
|
|
|
// 递归查找地区ID |
|
|
|
// normalizeMarketLabel 标准化地区名称,用于对比匹配 |
|
|
|
const normalizeMarketLabel = (value) => { |
|
|
|
return String(value ?? '') |
|
|
|
.trim() |
|
|
|
.toLowerCase() |
|
|
|
.replace(/[\s_-]+/g, '') |
|
|
|
} |
|
|
|
// 传入的这两个参数对比,是否有匹配的地区ID |
|
|
|
const findValueByLabel = (options, label) => { |
|
|
|
// option和label都调用normalizeMarketLabel函数 |
|
|
|
const normalizedLabel = normalizeMarketLabel(label) |
|
|
|
for (const option of options) { |
|
|
|
if (normalizeMarketLabel(option.label) === normalizedLabel) { |
|
|
|
@ -339,6 +342,7 @@ onMounted(async () => { |
|
|
|
await getMarket() |
|
|
|
|
|
|
|
// 处理从工作台跳转过来的地区参数 |
|
|
|
// 如果出现URL中的?region=a®ion=b 这种重复key,router会解析为['a','b'], 取第一个地区ID |
|
|
|
const regionName = Array.isArray(route.query.region) ? route.query.region[0] : route.query.region |
|
|
|
if (regionName && marketOptions.value.length) { |
|
|
|
const matchedId = findValueByLabel(marketOptions.value, regionName) |
|
|
|
|