landing.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. (function () {
  2. const D = window.PL.data;
  3. const R = window.PL.render;
  4. const UI = window.PL.ui;
  5. const h = UI.h;
  6. const A = UI.antd;
  7. const sampleMap = { standup: 'citrus', flatbottom: 'glow', coffee: 'morning', kraft: 'sunday', mailer: 'noir', garment: 'bloom' };
  8. const productTints = ['#e9e1d0', '#e5f0c4', '#f3ded4', '#e6d2b6', '#d9d5cc', '#dce9ee'];
  9. function designFor(templateId, product) {
  10. const size = D.sizeOf(product, product.sizes[Math.floor((product.sizes.length - 1) / 2)].id);
  11. return { size: size, design: R.designFromTemplate(templateId, size.w, size.h, 'front') };
  12. }
  13. function mountBag(el, productId, templateId) {
  14. if (!el) return;
  15. const product = D.productById(productId);
  16. const d = designFor(templateId, product);
  17. el.innerHTML = R.bagSVG(product, 'front', d.design, { size: d.size, card: true });
  18. }
  19. mountBag(document.getElementById('heroBag1'), 'coffee', 'morning');
  20. mountBag(document.getElementById('heroBag2'), 'standup', 'citrus');
  21. mountBag(document.getElementById('heroBag3'), 'kraft', 'sunday');
  22. mountBag(document.getElementById('miniBag1'), 'coffee', 'morning');
  23. mountBag(document.getElementById('miniBag2'), 'standup', 'citrus');
  24. const arrowIcon = h('span', {
  25. dangerouslySetInnerHTML: { __html: '<svg class="icon" viewBox="0 0 24 24" style="width:15px;height:15px"><path d="M7 17 17 7M8 7h9v9"/></svg>' }
  26. });
  27. function productCards() {
  28. return D.products.map(function (item, i) {
  29. const size = D.sizeOf(item, item.sizes[Math.floor((item.sizes.length - 1) / 2)].id);
  30. const template = D.templateById(sampleMap[item.id]) || D.templates[0];
  31. const design = R.designFromTemplate(template.id, size.w, size.h, 'front');
  32. const svg = R.bagSVG(item, 'front', design, { size: size, card: true });
  33. const price = D.price({ productId: item.id, sizeId: size.id, material: 'matte', finish: 'none', qty: 100 });
  34. return h(A.Card, {
  35. key: item.id,
  36. hoverable: true,
  37. bordered: false,
  38. className: 'product-card',
  39. onClick: function () { location.href = 'studio.html?product=' + item.id; }
  40. },
  41. h('div', { className: 'product-card-top' },
  42. h(A.Tag, { className: i === 0 ? 'tag-accent' : '' }, item.badge),
  43. h(A.Button, {
  44. type: 'text',
  45. shape: 'circle',
  46. icon: arrowIcon,
  47. className: 'card-arrow',
  48. onClick: function (e) { e.stopPropagation(); location.href = 'studio.html?product=' + item.id; }
  49. })
  50. ),
  51. h('div', {
  52. className: 'product-visual',
  53. style: { '--card-tint': productTints[i] },
  54. dangerouslySetInnerHTML: { __html: svg }
  55. }),
  56. h('div', { className: 'product-info' },
  57. h('h3', null, item.name, h('span', null, item.en)),
  58. h('p', null, item.desc),
  59. h('div', { className: 'product-meta' },
  60. h('span', null, h('b', null, '¥' + price.unit.toFixed(2)), h('span', null, ' / 个起')),
  61. h('span', null, size.w + '×' + size.h + ' mm · ' + size.label)
  62. )
  63. )
  64. );
  65. });
  66. }
  67. function templateCards() {
  68. return D.templates.slice(0, 8).map(function (t) {
  69. return h(A.Card, {
  70. key: t.id,
  71. hoverable: true,
  72. bordered: false,
  73. className: 'template-card',
  74. bodyStyle: { padding: 0 },
  75. onClick: function () { location.href = 'studio.html?template=' + t.id; }
  76. },
  77. h('div', { className: 'template-visual', style: { background: t.tint }, dangerouslySetInnerHTML: { __html: R.templatePreview(t) } }),
  78. h('div', { className: 'template-meta' },
  79. h('b', null, t.name),
  80. h(A.Tag, { bordered: false, className: 'template-tag' }, t.category)
  81. )
  82. );
  83. });
  84. }
  85. function studioSteps() {
  86. return h(A.Steps, {
  87. direction: 'vertical',
  88. size: 'small',
  89. current: -1,
  90. items: [
  91. { title: '选袋型', description: '尺寸与材质实时报价' },
  92. { title: '做设计', description: '模板 / 上传 / 文字 / 图形' },
  93. { title: '看效果', description: '3D 预览,一键下载' }
  94. ]
  95. });
  96. }
  97. function craftStats() {
  98. const stats = [
  99. { value: 300, title: 'DPI 印刷精度' },
  100. { value: '±0.5', title: 'MM 刀版误差' },
  101. { value: 12, title: '种表面工艺' }
  102. ];
  103. return h('div', { className: 'craft-stat-row' }, stats.map(function (s, i) {
  104. return h('div', { key: i, className: 'craft-stat' }, h(A.Statistic, { value: s.value, title: s.title }));
  105. }));
  106. }
  107. function craftCards() {
  108. const items = [
  109. {
  110. title: '精准刀版线',
  111. desc: '每种袋型都有独立刀版,安全区、出血位与折线自动生成,设计不会印偏。',
  112. 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>'
  113. },
  114. {
  115. title: '3D 实时样机',
  116. desc: '设计完成即可查看立体效果,模拟袋身弧度与光泽,所见即所得。',
  117. 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>'
  118. },
  119. {
  120. title: '48 小时打样',
  121. desc: '数码打样快速确认颜色与材质,100 个即可开机,小批量不再将就。',
  122. icon: '<svg class="icon" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8"/><path d="M12 8v4l2.5 2.5"/></svg>'
  123. },
  124. {
  125. title: '环保材料',
  126. desc: '可降解膜、再生牛皮纸与大豆油墨。包装好看,也可以对地球友好。',
  127. 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>'
  128. }
  129. ];
  130. return items.map(function (item, i) {
  131. return h(A.Card, { key: i, bordered: false, className: 'craft-item' },
  132. h('div', { className: 'craft-icon', dangerouslySetInnerHTML: { __html: item.icon } }),
  133. h('h3', null, item.title),
  134. h('p', null, item.desc)
  135. );
  136. });
  137. }
  138. function processSteps() {
  139. return h(A.Steps, {
  140. direction: 'horizontal',
  141. current: -1,
  142. items: [
  143. { title: '选择袋型', description: '按产品与容量选袋型、尺寸与材质,价格实时计算。' },
  144. { title: '在线设计', description: '套用模板或从空白开始,上传 Logo,拖拽排版。' },
  145. { title: '确认效果', description: '3D 预览、下载效果图,检查每一个细节。' },
  146. { title: '下单印刷', description: '100 个起订,48 小时打样,生产进度全程可查。' }
  147. ]
  148. });
  149. }
  150. function newsletter() {
  151. const input = h(A.Input, { placeholder: '你的邮箱', variant: 'borderless' });
  152. const button = h(A.Button, {
  153. shape: 'circle',
  154. type: 'primary',
  155. icon: h('span', { dangerouslySetInnerHTML: { __html: '<svg class="icon" viewBox="0 0 24 24"><path d="M5 12h14M13 6l6 6-6 6"/></svg>' } }),
  156. onClick: function () {
  157. const value = input.input ? input.input.value : '';
  158. if (!value || value.indexOf('@') < 0) {
  159. UI.message.warning('请输入有效的邮箱地址');
  160. return;
  161. }
  162. if (input.input) input.input.value = '';
  163. UI.message.success('订阅成功,下一封灵感见');
  164. }
  165. });
  166. return h('div', { className: 'field' }, input, button);
  167. }
  168. function demoBox() {
  169. const W = 240;
  170. const H = 300;
  171. const DEPTH = 160;
  172. const p = D.productById('standup');
  173. const size = D.sizeOf(p, 'm');
  174. const design = R.designFromTemplate('citrus', size.w, size.h, 'front');
  175. const art = R.designSVG(design, size.w, size.h);
  176. const faces = [
  177. { id: 'front', w: W, h: H, t: 'translateZ(' + (DEPTH / 2) + 'px)', bg: 'background:#e7f385', art: art },
  178. { id: 'right', w: DEPTH, h: H, t: 'rotateY(90deg) translateZ(' + (W / 2) + 'px)', bg: 'background:#efe7d6' },
  179. { id: 'left', w: DEPTH, h: H, t: 'rotateY(-90deg) translateZ(' + (W / 2) + 'px)', bg: 'background:#e3d9c4' },
  180. { id: 'top', w: W, h: DEPTH, t: 'rotateX(90deg) translateZ(' + (H / 2) + 'px)', bg: 'background:#f3ecdd' },
  181. { id: 'bottom', w: W, h: DEPTH, t: 'rotateX(-90deg) translateZ(' + (H / 2) + 'px)', bg: 'background:#e8dfcd' }
  182. ];
  183. return '<div class="box3d" style="width:' + W + 'px;height:' + H + 'px;transform:rotateX(-16deg) rotateY(-26deg)">' +
  184. faces.map(function (f) {
  185. 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>';
  186. }).join('') + '</div>';
  187. }
  188. function render() {
  189. UI.render(document.getElementById('productsGrid'), h('div', { className: 'card-row' }, productCards()));
  190. UI.render(document.getElementById('templatesGrid'), h('div', { className: 'card-row' }, templateCards()));
  191. UI.render(document.getElementById('studioSteps'), studioSteps());
  192. UI.render(document.getElementById('craftStats'), craftStats());
  193. UI.render(document.getElementById('craftList'), h('div', { className: 'card-row craft-card-row' }, craftCards()));
  194. UI.render(document.getElementById('processSteps'), processSteps());
  195. UI.render(document.getElementById('newsletterForm'), newsletter());
  196. const promo = document.getElementById('boxPromoArt');
  197. if (promo) promo.innerHTML = '<div class="promo-shadow"></div>' + demoBox();
  198. UI.hydrate(document);
  199. }
  200. render();
  201. const io = 'IntersectionObserver' in window ? new IntersectionObserver(function (entries) {
  202. entries.forEach(function (entry) {
  203. if (entry.isIntersecting) {
  204. entry.target.classList.add('in');
  205. io.unobserve(entry.target);
  206. }
  207. });
  208. }, { threshold: 0.12 }) : null;
  209. document.querySelectorAll('.section-head, .studio-band, .craft-copy, .cta-panel, .process-wrap').forEach(function (el) {
  210. el.classList.add('fade-up');
  211. if (io) io.observe(el); else el.classList.add('in');
  212. });
  213. document.querySelectorAll('a[href^="#"]').forEach(function (a) {
  214. a.addEventListener('click', function (e) {
  215. const id = a.getAttribute('href');
  216. if (id.length > 1) {
  217. const target = document.querySelector(id);
  218. if (target) {
  219. e.preventDefault();
  220. target.scrollIntoView({ behavior: 'smooth', block: 'start' });
  221. }
  222. }
  223. });
  224. });
  225. })();