bug修复
This commit is contained in:
1 parent
18b5c1e9e1
commit
654d08c8c8
4 files changed
+42
-48
No files matched your search
+1
-1
@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.shoplix.module
|
|||||||
public class InquiryFormRepositoryService {
|
public class InquiryFormRepositoryService {
|
||||||
private final InquiryFormMapper mapper; /** 注入Mapper。 */ public InquiryFormRepositoryService(InquiryFormMapper mapper){this.mapper=mapper;}
|
private final InquiryFormMapper mapper; /** 注入Mapper。 */ public InquiryFormRepositoryService(InquiryFormMapper mapper){this.mapper=mapper;}
|
||||||
/** 查询站点全部表单。 */ public List<InquiryFormEntity> list(String siteCode){return mapper.selectList(Wrappers.<InquiryFormEntity>lambdaQuery().eq(InquiryFormEntity::getSiteCode,siteCode).orderByAsc(InquiryFormEntity::getSortNo));}
|
/** 查询站点全部表单。 */ public List<InquiryFormEntity> list(String siteCode){return mapper.selectList(Wrappers.<InquiryFormEntity>lambdaQuery().eq(InquiryFormEntity::getSiteCode,siteCode).orderByAsc(InquiryFormEntity::getSortNo));}
|
||||||
/** 查询发布场景表单。 */ public Optional<InquiryFormEntity> findPublished(String siteCode,String scene){return Optional.ofNullable(mapper.selectOne(Wrappers.<InquiryFormEntity>lambdaQuery().eq(InquiryFormEntity::getSiteCode,siteCode).eq(InquiryFormEntity::getFormScene,scene).eq(InquiryFormEntity::getStatus,"PUBLISHED").orderByAsc(InquiryFormEntity::getSortNo).last("LIMIT 1")));}
|
/** 查询发布场景表单,优先使用站点默认表单。 */ public Optional<InquiryFormEntity> findPublished(String siteCode,String scene){return Optional.ofNullable(mapper.selectOne(Wrappers.<InquiryFormEntity>lambdaQuery().eq(InquiryFormEntity::getSiteCode,siteCode).eq(InquiryFormEntity::getFormScene,scene).eq(InquiryFormEntity::getStatus,"PUBLISHED").orderByDesc(InquiryFormEntity::getDefaultFlag).orderByAsc(InquiryFormEntity::getSortNo).last("LIMIT 1")));}
|
||||||
/** 按编号查询表单。 */ public Optional<InquiryFormEntity> find(String siteCode,String code){return Optional.ofNullable(mapper.selectOne(Wrappers.<InquiryFormEntity>lambdaQuery().eq(InquiryFormEntity::getSiteCode,siteCode).eq(InquiryFormEntity::getFormCode,code)));}
|
/** 按编号查询表单。 */ public Optional<InquiryFormEntity> find(String siteCode,String code){return Optional.ofNullable(mapper.selectOne(Wrappers.<InquiryFormEntity>lambdaQuery().eq(InquiryFormEntity::getSiteCode,siteCode).eq(InquiryFormEntity::getFormCode,code)));}
|
||||||
/** 清除站点其他默认表单标识。 */ public int clearDefault(String siteCode,String excludeCode){return mapper.update(null,Wrappers.<InquiryFormEntity>lambdaUpdate().eq(InquiryFormEntity::getSiteCode,siteCode).ne(InquiryFormEntity::getFormCode,excludeCode).eq(InquiryFormEntity::getDefaultFlag,1).set(InquiryFormEntity::getDefaultFlag,0));}
|
/** 清除站点其他默认表单标识。 */ public int clearDefault(String siteCode,String excludeCode){return mapper.update(null,Wrappers.<InquiryFormEntity>lambdaUpdate().eq(InquiryFormEntity::getSiteCode,siteCode).ne(InquiryFormEntity::getFormCode,excludeCode).eq(InquiryFormEntity::getDefaultFlag,1).set(InquiryFormEntity::getDefaultFlag,0));}
|
||||||
/** 新增表单。 */ public int insert(InquiryFormEntity e){return mapper.insert(e);} /** 更新表单。 */ public int update(InquiryFormEntity e){return mapper.update(e,Wrappers.<InquiryFormEntity>lambdaUpdate().eq(InquiryFormEntity::getSiteCode,e.getSiteCode()).eq(InquiryFormEntity::getFormCode,e.getFormCode()));}
|
/** 新增表单。 */ public int insert(InquiryFormEntity e){return mapper.insert(e);} /** 更新表单。 */ public int update(InquiryFormEntity e){return mapper.update(e,Wrappers.<InquiryFormEntity>lambdaUpdate().eq(InquiryFormEntity::getSiteCode,e.getSiteCode()).eq(InquiryFormEntity::getFormCode,e.getFormCode()));}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ type Field = {
|
|||||||
maxLength?: number | null;
|
maxLength?: number | null;
|
||||||
required: boolean;
|
required: boolean;
|
||||||
systemField: boolean;
|
systemField: boolean;
|
||||||
optionsJson: string;
|
optionsJson: string | null;
|
||||||
widthType: string;
|
widthType: string;
|
||||||
sortNo: number;
|
sortNo: number;
|
||||||
};
|
};
|
||||||
@@ -146,13 +146,14 @@ export default function InquirySettingsPanel() {
|
|||||||
const saveForm = async () => {
|
const saveForm = async () => {
|
||||||
if (!editing) return;
|
if (!editing) return;
|
||||||
try {
|
try {
|
||||||
|
setNotice("");
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
await post("/inquiries/forms/save", {
|
await post("/inquiries/forms/save", {
|
||||||
...editing,
|
...editing,
|
||||||
siteCode: SITE,
|
siteCode: SITE,
|
||||||
fields: editing.fields.map((field, index) => ({
|
fields: editing.fields.map((field, index) => ({
|
||||||
...field,
|
...field,
|
||||||
optionsJson: field.optionsJson.trim() || null,
|
optionsJson: field.optionsJson?.trim() || null,
|
||||||
sortNo: index,
|
sortNo: index,
|
||||||
})),
|
})),
|
||||||
});
|
});
|
||||||
@@ -212,6 +213,7 @@ export default function InquirySettingsPanel() {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{notice && <div className="notice">{notice}</div>}
|
||||||
<div className="inquiry-editor-layout">
|
<div className="inquiry-editor-layout">
|
||||||
<div className="editor-main">
|
<div className="editor-main">
|
||||||
<section className="edit-section">
|
<section className="edit-section">
|
||||||
|
|||||||
+34
-43
@@ -1,6 +1,6 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
import { ArrowRight, ChevronRight, Image as ImageIcon, Mail, Menu, Search } from "lucide-react";
|
import { ArrowRight, ChevronRight, Image as ImageIcon, Mail, Menu, Search, X } from "lucide-react";
|
||||||
import "./styles.css";
|
import "./styles.css";
|
||||||
import { initializeAnalytics, routePageCode, trackInquirySubmitted, trackPageLeave, trackPageView } from "./analytics";
|
import { initializeAnalytics, routePageCode, trackInquirySubmitted, trackPageLeave, trackPageView } from "./analytics";
|
||||||
|
|
||||||
@@ -489,6 +489,19 @@ function Collection({
|
|||||||
}
|
}
|
||||||
/** B2B 商品详情主体,集中展示主图、核心信息、参数、详情和询盘入口。 */
|
/** B2B 商品详情主体,集中展示主图、核心信息、参数、详情和询盘入口。 */
|
||||||
function ProductDetailView({ data: d }: { data: Record<string, any> }) {
|
function ProductDetailView({ data: d }: { data: Record<string, any> }) {
|
||||||
|
const [inquiryOpen, setInquiryOpen] = useState(false);
|
||||||
|
useEffect(() => {
|
||||||
|
if (!inquiryOpen) return;
|
||||||
|
const closeOnEscape = (event: KeyboardEvent) => {
|
||||||
|
if (event.key === "Escape") setInquiryOpen(false);
|
||||||
|
};
|
||||||
|
document.body.classList.add("modal-open");
|
||||||
|
window.addEventListener("keydown", closeOnEscape);
|
||||||
|
return () => {
|
||||||
|
document.body.classList.remove("modal-open");
|
||||||
|
window.removeEventListener("keydown", closeOnEscape);
|
||||||
|
};
|
||||||
|
}, [inquiryOpen]);
|
||||||
return <article className="detail product-detail">
|
return <article className="detail product-detail">
|
||||||
<Crumbs current={String(d.productName || "Product")}/>
|
<Crumbs current={String(d.productName || "Product")}/>
|
||||||
<section className="product-overview">
|
<section className="product-overview">
|
||||||
@@ -502,13 +515,20 @@ function ProductDetailView({ data: d }: { data: Record<string, any> }) {
|
|||||||
<h1>{d.productName}</h1>
|
<h1>{d.productName}</h1>
|
||||||
{d.model && <div className="product-model">Model <strong>{d.model}</strong></div>}
|
{d.model && <div className="product-model">Model <strong>{d.model}</strong></div>}
|
||||||
<p className="lead">{d.summary}</p>
|
<p className="lead">{d.summary}</p>
|
||||||
{d.inquiryEnabled && <a className="product-inquiry-cta" href="#product-inquiry"><Mail size={18}/>Request a quote</a>}
|
{d.inquiryEnabled && <button className="product-inquiry-cta" type="button" onClick={() => setInquiryOpen(true)}><Mail size={18}/>Request a quote</button>}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
{d.attributes?.length > 0 && <section className="specs product-attributes"><h2>Product attributes</h2>{d.attributes.map((a:any,i:number)=><div key={i}><span>{a.name}</span><strong>{a.value} {a.unit}</strong></div>)}</section>}
|
{d.attributes?.length > 0 && <section className="specs product-attributes"><h2>Product attributes</h2>{d.attributes.map((a:any,i:number)=><div key={i}><span>{a.name}</span><strong>{a.value} {a.unit}</strong></div>)}</section>}
|
||||||
<div className="content product-content" dangerouslySetInnerHTML={{__html:normalizeRichTextHtml(d.content)}}/>
|
<div className="content product-content" dangerouslySetInnerHTML={{__html:normalizeRichTextHtml(d.content)}}/>
|
||||||
{d.specifications?.length > 0 && <section className="specs"><h2>Technical specifications</h2>{d.specifications.map((s:any,i:number)=><div key={i}><span>{s.groupName&&`${s.groupName} · `}{s.name}</span><strong>{s.value} {s.unit}</strong></div>)}</section>}
|
{d.specifications?.length > 0 && <section className="specs"><h2>Technical specifications</h2>{d.specifications.map((s:any,i:number)=><div key={i}><span>{s.groupName&&`${s.groupName} · `}{s.name}</span><strong>{s.value} {s.unit}</strong></div>)}</section>}
|
||||||
{d.inquiryEnabled && <div id="product-inquiry"><InquiryForm scene="PRODUCT" sourceCode={d.productCode}/></div>}
|
{d.inquiryEnabled && inquiryOpen && (
|
||||||
|
<div className="inquiry-modal-backdrop" role="presentation" onMouseDown={() => setInquiryOpen(false)}>
|
||||||
|
<div className="inquiry-modal" role="dialog" aria-modal="true" aria-label="Request a quote" onMouseDown={(event) => event.stopPropagation()}>
|
||||||
|
<button className="inquiry-modal-close" type="button" aria-label="Close inquiry form" onClick={() => setInquiryOpen(false)}><X size={22}/></button>
|
||||||
|
<InquiryForm scene="PRODUCT" sourceCode={d.productCode}/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</article>;
|
</article>;
|
||||||
}
|
}
|
||||||
function Page({ slug }: { slug: string }) {
|
function Page({ slug }: { slug: string }) {
|
||||||
@@ -601,12 +621,22 @@ function InquiryForm({
|
|||||||
try {
|
try {
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
setNotice("");
|
setNotice("");
|
||||||
|
const configuredValue = (...keys: string[]) => {
|
||||||
|
const field = definition.fields.find((item) => keys.includes(item.fieldKey));
|
||||||
|
return field ? custom[field.fieldCode] || "" : "";
|
||||||
|
};
|
||||||
const result = await post("/inquiries/submit", {
|
const result = await post("/inquiries/submit", {
|
||||||
formCode: definition.formCode,
|
formCode: definition.formCode,
|
||||||
sourceType: scene,
|
sourceType: scene,
|
||||||
sourceCode,
|
sourceCode,
|
||||||
sourceUrl: location.href,
|
sourceUrl: location.href,
|
||||||
...form,
|
...form,
|
||||||
|
name: configuredValue("name", "customer_name"),
|
||||||
|
email: configuredValue("email", "customer_email"),
|
||||||
|
phone: configuredValue("phone", "customer_phone"),
|
||||||
|
company: configuredValue("company", "company_name"),
|
||||||
|
countryCode: configuredValue("country_code", "country"),
|
||||||
|
message: configuredValue("message", "requirements"),
|
||||||
fieldValues: definition.fields.map((x) => ({
|
fieldValues: definition.fields.map((x) => ({
|
||||||
fieldCode: x.fieldCode,
|
fieldCode: x.fieldCode,
|
||||||
value: custom[x.fieldCode] || "",
|
value: custom[x.fieldCode] || "",
|
||||||
@@ -636,37 +666,6 @@ function InquiryForm({
|
|||||||
<h2>Discuss your requirements</h2>
|
<h2>Discuss your requirements</h2>
|
||||||
{definition.description && <p>{definition.description}</p>}
|
{definition.description && <p>{definition.description}</p>}
|
||||||
<form onSubmit={submit}>
|
<form onSubmit={submit}>
|
||||||
<label>
|
|
||||||
<span>Name *</span>
|
|
||||||
<input
|
|
||||||
required
|
|
||||||
value={form.name}
|
|
||||||
onChange={(e) => setForm({ ...form, name: e.target.value })}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<span>Email *</span>
|
|
||||||
<input
|
|
||||||
type="email"
|
|
||||||
required
|
|
||||||
value={form.email}
|
|
||||||
onChange={(e) => setForm({ ...form, email: e.target.value })}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<span>Phone</span>
|
|
||||||
<input
|
|
||||||
value={form.phone}
|
|
||||||
onChange={(e) => setForm({ ...form, phone: e.target.value })}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<span>Company</span>
|
|
||||||
<input
|
|
||||||
value={form.company}
|
|
||||||
onChange={(e) => setForm({ ...form, company: e.target.value })}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
{definition.fields.map((field) => (
|
{definition.fields.map((field) => (
|
||||||
<label
|
<label
|
||||||
className={field.widthType === "FULL" ? "wide" : ""}
|
className={field.widthType === "FULL" ? "wide" : ""}
|
||||||
@@ -701,6 +700,7 @@ function InquiryForm({
|
|||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<input
|
<input
|
||||||
|
type={field.fieldType === "EMAIL" ? "email" : field.fieldType === "PHONE" ? "tel" : field.fieldType === "NUMBER" ? "number" : "text"}
|
||||||
required={field.required}
|
required={field.required}
|
||||||
maxLength={field.maxLength}
|
maxLength={field.maxLength}
|
||||||
placeholder={field.placeholder}
|
placeholder={field.placeholder}
|
||||||
@@ -713,15 +713,6 @@ function InquiryForm({
|
|||||||
{field.helpText && <small>{field.helpText}</small>}
|
{field.helpText && <small>{field.helpText}</small>}
|
||||||
</label>
|
</label>
|
||||||
))}
|
))}
|
||||||
<label className="wide">
|
|
||||||
<span>Message *</span>
|
|
||||||
<textarea
|
|
||||||
required
|
|
||||||
rows={6}
|
|
||||||
value={form.message}
|
|
||||||
onChange={(e) => setForm({ ...form, message: e.target.value })}
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
<input
|
<input
|
||||||
className="honeypot"
|
className="honeypot"
|
||||||
tabIndex={-1}
|
tabIndex={-1}
|
||||||
|
|||||||
@@ -287,7 +287,8 @@ nav a:hover {
|
|||||||
padding-bottom: 32px;
|
padding-bottom: 32px;
|
||||||
}
|
}
|
||||||
.product-cover { width: 100%; max-height: 560px; object-fit: contain; background: #f4f6f5; margin: 20px 0 35px; }
|
.product-cover { width: 100%; max-height: 560px; object-fit: contain; background: #f4f6f5; margin: 20px 0 35px; }
|
||||||
.product-detail{max-width:1220px}.product-detail>.crumbs{margin-bottom:30px}.product-overview{display:grid;grid-template-columns:minmax(0,1.05fr) minmax(380px,.95fr);gap:54px;align-items:start}.product-media{aspect-ratio:1/1;background:#f1f4f2;border:1px solid #e0e6e3;display:grid;place-items:center;overflow:hidden}.product-media>img{width:100%;height:100%;object-fit:contain}.product-image-placeholder{display:grid;place-items:center;gap:14px;color:#899691;text-align:center}.product-image-placeholder span{font-size:13px}.product-summary{padding:18px 0}.product-summary h1{font-size:46px;line-height:1.1;margin:12px 0 22px}.product-summary .lead{border:0;padding:0;margin:22px 0 28px;font-size:17px;line-height:1.75}.product-model{display:inline-flex;gap:10px;align-items:center;border-top:1px solid #d7dfdc;border-bottom:1px solid #d7dfdc;padding:12px 0;width:100%;font-size:13px;color:#687579}.product-model strong{color:#17211f}.product-inquiry-cta{display:inline-flex;align-items:center;justify-content:center;gap:9px;background:#176b5b;color:#fff;text-decoration:none;padding:14px 22px;min-width:190px;font-size:14px;font-weight:700}.product-attributes{margin-top:65px}.product-content{max-width:900px;margin:55px auto 0;line-height:1.75}.product-content pre,.product-content code{font:inherit;white-space:normal}.product-content pre{margin:0}.product-detail #product-inquiry{scroll-margin-top:24px}
|
.product-detail{max-width:1220px}.product-detail>.crumbs{margin-bottom:30px}.product-overview{display:grid;grid-template-columns:minmax(0,1.05fr) minmax(380px,.95fr);gap:54px;align-items:start}.product-media{aspect-ratio:1/1;background:#f1f4f2;border:1px solid #e0e6e3;display:grid;place-items:center;overflow:hidden}.product-media>img{width:100%;height:100%;object-fit:contain}.product-image-placeholder{display:grid;place-items:center;gap:14px;color:#899691;text-align:center}.product-image-placeholder span{font-size:13px}.product-summary{padding:18px 0}.product-summary h1{font-size:46px;line-height:1.1;margin:12px 0 22px}.product-summary .lead{border:0;padding:0;margin:22px 0 28px;font-size:17px;line-height:1.75}.product-model{display:inline-flex;gap:10px;align-items:center;border-top:1px solid #d7dfdc;border-bottom:1px solid #d7dfdc;padding:12px 0;width:100%;font-size:13px;color:#687579}.product-model strong{color:#17211f}.product-inquiry-cta{display:inline-flex;align-items:center;justify-content:center;gap:9px;background:#176b5b;color:#fff;border:0;padding:14px 22px;min-width:190px;font-family:inherit;font-size:14px;font-weight:700;cursor:pointer}.product-attributes{margin-top:65px}.product-content{max-width:900px;margin:55px auto 0;line-height:1.75}.product-content pre,.product-content code{font:inherit;white-space:normal}.product-content pre{margin:0}
|
||||||
|
.modal-open{overflow:hidden}.inquiry-modal-backdrop{position:fixed;inset:0;z-index:1000;background:#101a18a8;display:grid;place-items:center;padding:24px}.inquiry-modal{position:relative;width:min(860px,100%);max-height:calc(100vh - 48px);overflow:auto;background:#fff;box-shadow:0 18px 60px #07100e40}.inquiry-modal-close{position:absolute;z-index:2;top:18px;right:18px;width:42px;height:42px;border:1px solid #d5ddda;background:#fff;color:#17211f;display:grid;place-items:center;cursor:pointer}.inquiry-modal .inquiry-box{margin:0;border-top:0;padding:42px}.inquiry-modal .inquiry-box h2{padding-right:50px}
|
||||||
.content {
|
.content {
|
||||||
font-size: 17px;
|
font-size: 17px;
|
||||||
margin-top: 35px;
|
margin-top: 35px;
|
||||||
@@ -456,6 +457,6 @@ footer small {
|
|||||||
footer > div:first-child {
|
footer > div:first-child {
|
||||||
grid-column: 1/-1;
|
grid-column: 1/-1;
|
||||||
}
|
}
|
||||||
.inquiry-box form { grid-template-columns: 1fr; }
|
.inquiry-modal-backdrop{padding:0;align-items:end}.inquiry-modal{max-height:92vh}.inquiry-modal .inquiry-box{padding:28px 20px}.inquiry-modal-close{top:14px;right:14px}.inquiry-box form { grid-template-columns: 1fr; }
|
||||||
.inquiry-box .wide { grid-column: auto; }
|
.inquiry-box .wide { grid-column: auto; }
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user