| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- (function () {
- const D = window.PL.data;
- const R = window.PL.render;
- const UI = window.PL.ui;
- const h = UI.h;
- const A = UI.antd;
- const sampleMap = { standup: 'citrus', flatbottom: 'glow', coffee: 'morning', kraft: 'sunday', mailer: 'noir', garment: 'bloom' };
- const productTints = ['#e9e1d0', '#e5f0c4', '#f3ded4', '#e6d2b6', '#d9d5cc', '#dce9ee'];
- function designFor(templateId, product) {
- const size = D.sizeOf(product, product.sizes[Math.floor((product.sizes.length - 1) / 2)].id);
- return { size: size, design: R.designFromTemplate(templateId, size.w, size.h, 'front') };
- }
- function mountBag(el, productId, templateId) {
- if (!el) return;
- const product = D.productById(productId);
- const d = designFor(templateId, product);
- el.innerHTML = R.bagSVG(product, 'front', d.design, { size: d.size, card: true });
- }
- mountBag(document.getElementById('heroBag1'), 'coffee', 'morning');
- mountBag(document.getElementById('heroBag2'), 'standup', 'citrus');
- mountBag(document.getElementById('heroBag3'), 'kraft', 'sunday');
- mountBag(document.getElementById('miniBag1'), 'coffee', 'morning');
- mountBag(document.getElementById('miniBag2'), 'standup', 'citrus');
- const arrowIcon = h('span', {
- dangerouslySetInnerHTML: { __html: '<svg class="icon" viewBox="0 0 24 24" style="width:15px;height:15px"><path d="M7 17 17 7M8 7h9v9"/></svg>' }
- });
- function productCards() {
- return D.products.map(function (item, i) {
- const size = D.sizeOf(item, item.sizes[Math.floor((item.sizes.length - 1) / 2)].id);
- const template = D.templateById(sampleMap[item.id]) || D.templates[0];
- const design = R.designFromTemplate(template.id, size.w, size.h, 'front');
- const svg = R.bagSVG(item, 'front', design, { size: size, card: true });
- const price = D.price({ productId: item.id, sizeId: size.id, material: 'matte', finish: 'none', qty: 100 });
- return h(A.Card, {
- key: item.id,
- hoverable: true,
- bordered: false,
- className: 'product-card',
- onClick: function () { location.href = 'studio.html?product=' + item.id; }
- },
- h('div', { className: 'product-card-top' },
- h(A.Tag, { className: i === 0 ? 'tag-accent' : '' }, item.badge),
- h(A.Button, {
- type: 'text',
- shape: 'circle',
- icon: arrowIcon,
- className: 'card-arrow',
- onClick: function (e) { e.stopPropagation(); location.href = 'studio.html?product=' + item.id; }
- })
- ),
- h('div', {
- className: 'product-visual',
- style: { '--card-tint': productTints[i] },
- dangerouslySetInnerHTML: { __html: svg }
- }),
- h('div', { className: 'product-info' },
- h('h3', null, item.name, h('span', null, item.en)),
- h('p', null, item.desc),
- h('div', { className: 'product-meta' },
- h('span', null, h('b', null, '¥' + price.unit.toFixed(2)), h('span', null, ' / 个起')),
- h('span', null, size.w + '×' + size.h + ' mm · ' + size.label)
- )
- )
- );
- });
- }
- function templateCards() {
- return D.templates.slice(0, 8).map(function (t) {
- return h(A.Card, {
- key: t.id,
- hoverable: true,
- bordered: false,
- className: 'template-card',
- bodyStyle: { padding: 0 },
- onClick: function () { location.href = 'studio.html?template=' + t.id; }
- },
- h('div', { className: 'template-visual', style: { background: t.tint }, dangerouslySetInnerHTML: { __html: R.templatePreview(t) } }),
- h('div', { className: 'template-meta' },
- h('b', null, t.name),
- h(A.Tag, { bordered: false, className: 'template-tag' }, t.category)
- )
- );
- });
- }
- function studioSteps() {
- return h(A.Steps, {
- direction: 'vertical',
- size: 'small',
- current: -1,
- items: [
- { title: '选袋型', description: '尺寸与材质实时报价' },
- { title: '做设计', description: '模板 / 上传 / 文字 / 图形' },
- { title: '看效果', description: '3D 预览,一键下载' }
- ]
- });
- }
- function craftStats() {
- const stats = [
- { value: 300, title: 'DPI 印刷精度' },
- { value: '±0.5', title: 'MM 刀版误差' },
- { value: 12, title: '种表面工艺' }
- ];
- return h('div', { className: 'craft-stat-row' }, stats.map(function (s, i) {
- return h('div', { key: i, className: 'craft-stat' }, h(A.Statistic, { value: s.value, title: s.title }));
- }));
- }
- function craftCards() {
- const items = [
- {
- title: '精准刀版线',
- desc: '每种袋型都有独立刀版,安全区、出血位与折线自动生成,设计不会印偏。',
- icon: '<svg class="icon" viewBox="0 0 24 24"><path d="M4 8V4h4M20 8V4h-4M4 16v4h4M20 16v4h-4"/><path d="M8 12h8" stroke-dasharray="2 2"/></svg>'
- },
- {
- title: '3D 实时样机',
- desc: '设计完成即可查看立体效果,模拟袋身弧度与光泽,所见即所得。',
- icon: '<svg class="icon" viewBox="0 0 24 24"><path d="M12 3 3 8.5v7L12 21l9-5.5v-7L12 3Z"/><path d="M3 8.5 12 14l9-5.5M12 21v-7"/></svg>'
- },
- {
- title: '48 小时打样',
- desc: '数码打样快速确认颜色与材质,100 个即可开机,小批量不再将就。',
- icon: '<svg class="icon" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8"/><path d="M12 8v4l2.5 2.5"/></svg>'
- },
- {
- title: '环保材料',
- desc: '可降解膜、再生牛皮纸与大豆油墨。包装好看,也可以对地球友好。',
- icon: '<svg class="icon" viewBox="0 0 24 24"><path d="M20 4C11 4 4 9 4 17c0 2 1 3 3 3 8 0 13-7 13-16Z"/><path d="M4 21C7 15 11 10 17 6"/></svg>'
- }
- ];
- return items.map(function (item, i) {
- return h(A.Card, { key: i, bordered: false, className: 'craft-item' },
- h('div', { className: 'craft-icon', dangerouslySetInnerHTML: { __html: item.icon } }),
- h('h3', null, item.title),
- h('p', null, item.desc)
- );
- });
- }
- function processSteps() {
- return h(A.Steps, {
- direction: 'horizontal',
- current: -1,
- items: [
- { title: '选择袋型', description: '按产品与容量选袋型、尺寸与材质,价格实时计算。' },
- { title: '在线设计', description: '套用模板或从空白开始,上传 Logo,拖拽排版。' },
- { title: '确认效果', description: '3D 预览、下载效果图,检查每一个细节。' },
- { title: '下单印刷', description: '100 个起订,48 小时打样,生产进度全程可查。' }
- ]
- });
- }
- function newsletter() {
- const input = h(A.Input, { placeholder: '你的邮箱', variant: 'borderless' });
- const button = h(A.Button, {
- shape: 'circle',
- type: 'primary',
- icon: h('span', { dangerouslySetInnerHTML: { __html: '<svg class="icon" viewBox="0 0 24 24"><path d="M5 12h14M13 6l6 6-6 6"/></svg>' } }),
- onClick: function () {
- const value = input.input ? input.input.value : '';
- if (!value || value.indexOf('@') < 0) {
- UI.message.warning('请输入有效的邮箱地址');
- return;
- }
- if (input.input) input.input.value = '';
- UI.message.success('订阅成功,下一封灵感见');
- }
- });
- return h('div', { className: 'field' }, input, button);
- }
- function demoBox() {
- const W = 240;
- const H = 300;
- const DEPTH = 160;
- const p = D.productById('standup');
- const size = D.sizeOf(p, 'm');
- const design = R.designFromTemplate('citrus', size.w, size.h, 'front');
- const art = R.designSVG(design, size.w, size.h);
- const faces = [
- { id: 'front', w: W, h: H, t: 'translateZ(' + (DEPTH / 2) + 'px)', bg: 'background:#e7f385', art: art },
- { id: 'right', w: DEPTH, h: H, t: 'rotateY(90deg) translateZ(' + (W / 2) + 'px)', bg: 'background:#efe7d6' },
- { id: 'left', w: DEPTH, h: H, t: 'rotateY(-90deg) translateZ(' + (W / 2) + 'px)', bg: 'background:#e3d9c4' },
- { id: 'top', w: W, h: DEPTH, t: 'rotateX(90deg) translateZ(' + (H / 2) + 'px)', bg: 'background:#f3ecdd' },
- { id: 'bottom', w: W, h: DEPTH, t: 'rotateX(-90deg) translateZ(' + (H / 2) + 'px)', bg: 'background:#e8dfcd' }
- ];
- return '<div class="box3d" style="width:' + W + 'px;height:' + H + 'px;transform:rotateX(-16deg) rotateY(-26deg)">' +
- faces.map(function (f) {
- return '<div class="bface" style="width:' + f.w + 'px;height:' + f.h + 'px;margin-left:' + (-f.w / 2) + 'px;margin-top:' + (-f.h / 2) + 'px;' + f.bg + ';transform:' + f.t + '">' + (f.art || '') + '</div>';
- }).join('') + '</div>';
- }
- function render() {
- UI.render(document.getElementById('productsGrid'), h('div', { className: 'card-row' }, productCards()));
- UI.render(document.getElementById('templatesGrid'), h('div', { className: 'card-row' }, templateCards()));
- UI.render(document.getElementById('studioSteps'), studioSteps());
- UI.render(document.getElementById('craftStats'), craftStats());
- UI.render(document.getElementById('craftList'), h('div', { className: 'card-row craft-card-row' }, craftCards()));
- UI.render(document.getElementById('processSteps'), processSteps());
- UI.render(document.getElementById('newsletterForm'), newsletter());
- const promo = document.getElementById('boxPromoArt');
- if (promo) promo.innerHTML = '<div class="promo-shadow"></div>' + demoBox();
- UI.hydrate(document);
- }
- render();
- const io = 'IntersectionObserver' in window ? new IntersectionObserver(function (entries) {
- entries.forEach(function (entry) {
- if (entry.isIntersecting) {
- entry.target.classList.add('in');
- io.unobserve(entry.target);
- }
- });
- }, { threshold: 0.12 }) : null;
- document.querySelectorAll('.section-head, .studio-band, .craft-copy, .cta-panel, .process-wrap').forEach(function (el) {
- el.classList.add('fade-up');
- if (io) io.observe(el); else el.classList.add('in');
- });
- document.querySelectorAll('a[href^="#"]').forEach(function (a) {
- a.addEventListener('click', function (e) {
- const id = a.getAttribute('href');
- if (id.length > 1) {
- const target = document.querySelector(id);
- if (target) {
- e.preventDefault();
- target.scrollIntoView({ behavior: 'smooth', block: 'start' });
- }
- }
- });
- });
- })();
|