feat: add dual-store actions to price comparison
This commit is contained in:
@@ -956,7 +956,7 @@
|
||||
</div>
|
||||
<div class="price-note">
|
||||
<i class="fas fa-info-circle me-1"></i>
|
||||
Excel 需包含「商品名稱」和「售價」欄位。可選包含「商品編號」和「連結」。
|
||||
Excel 至少要有商品名稱與售價;有賣場連結時會一起帶入雙開比對。
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
@@ -979,9 +979,8 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="price-note py-2">
|
||||
<i class="fas fa-info-circle me-1"></i>
|
||||
<strong>格式說明:</strong> 每行一筆商品,用<strong>逗號</strong>或 <strong>Tab</strong> 分隔<br>
|
||||
<code>商品名稱,價格</code> 或 <code>商品名稱,價格,商品連結(選填)</code>
|
||||
<i class="fas fa-bullseye me-1"></i>
|
||||
貼上 MOMO 商品、售價與賣場連結;系統會整理成可比價清單。
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">商品資料</label>
|
||||
@@ -1314,7 +1313,7 @@ La Roche-Posay 安得利防曬液 50ml,920
|
||||
parts = line.split('\t');
|
||||
}
|
||||
if (parts.length < 2) {
|
||||
showToast(`第 ${i + 1} 行格式錯誤,請使用「商品名稱,價格」,例如:理膚寶水 B5修復霜,680。`, 'warning');
|
||||
showToast(`第 ${i + 1} 行缺商品名稱或售價,請補齊後再加入比價清單。`, 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1699,10 +1698,20 @@ La Roche-Posay 安得利防曬液 50ml,920
|
||||
// 處理 URL (可能是 url 或 product_url)
|
||||
const pchomeUrl = toSafeUrl(m.pchome?.url || m.pchome?.product_url || '');
|
||||
const momoUrl = toSafeUrl(m.momo?.url || m.momo?.product_url || '');
|
||||
const dualOpenButton = pchomeUrl && momoUrl
|
||||
? `<button type="button"
|
||||
class="btn btn-sm btn-outline-primary mt-2"
|
||||
data-pchome-url="${escapeHtml(pchomeUrl)}"
|
||||
data-momo-url="${escapeHtml(momoUrl)}"
|
||||
onclick="openComparisonStores(this)">
|
||||
<i class="fas fa-up-right-from-square me-1"></i>雙開賣場
|
||||
</button>`
|
||||
: '';
|
||||
|
||||
row.innerHTML = `
|
||||
<td>
|
||||
${actionBadge}
|
||||
${dualOpenButton}
|
||||
</td>
|
||||
<td>
|
||||
<div class="d-flex align-items-start">
|
||||
@@ -1757,6 +1766,22 @@ La Roche-Posay 安得利防曬液 50ml,920
|
||||
document.getElementById('resultSection').style.display = 'block';
|
||||
}
|
||||
|
||||
function openComparisonStores(button) {
|
||||
const pchomeUrl = toSafeUrl(button?.dataset?.pchomeUrl || '');
|
||||
const momoUrl = toSafeUrl(button?.dataset?.momoUrl || '');
|
||||
const opened = [];
|
||||
if (pchomeUrl) opened.push(window.open(pchomeUrl, `pchome_compare_${Date.now()}`));
|
||||
if (momoUrl) opened.push(window.open(momoUrl, `momo_compare_${Date.now()}`));
|
||||
for (const win of opened) {
|
||||
if (win) {
|
||||
try { win.opener = null; } catch (_) {}
|
||||
}
|
||||
}
|
||||
if (opened.some((win) => !win)) {
|
||||
showToast('瀏覽器擋住了其中一個視窗;請用商品旁的 PChome / MOMO 按鈕分別開啟。', 'warning');
|
||||
}
|
||||
}
|
||||
|
||||
function getResultActionBadge(match) {
|
||||
if (match.cheaper_at === 'momo') {
|
||||
return '<span class="price-action-pill is-urgent">檢查售價</span>';
|
||||
|
||||
Reference in New Issue
Block a user