From 190e59af94a2fa76a11a07e07c68ac6a9f1393ba Mon Sep 17 00:00:00 2001 From: lhmin0604 Date: Sat, 12 Sep 2026 20:00:17 +0800 Subject: [PATCH] =?UTF-8?q?revert(diy):=20=E6=92=A4=E9=94=80=E8=B4=B4?= =?UTF-8?q?=E7=BA=B8=E5=9D=90=E6=A0=87=E9=92=B3=E5=88=B6=EF=BC=8C=E6=81=A2?= =?UTF-8?q?=E5=A4=8D=E5=8F=AF=E6=8B=96=E5=87=BA=E7=94=BB=E5=B8=83=E5=A4=96?= =?UTF-8?q?=E8=87=AA=E7=94=B1=E6=91=86=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 需求决定(2026-09-12):负坐标/超出画布为合法摆放状态; 重叠误报根因是尺寸语义(已由归一化修复),坐标钳制一并移除。 文档同步标注该决策。 Co-Authored-By: Claude --- dist/pages/diy/index.js | 2 +- docs/diy-fix-workflow.md | 8 +++++--- src/pages/diy/index.tsx | 21 +++------------------ 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/dist/pages/diy/index.js b/dist/pages/diy/index.js index 126f68b..c2848b1 100644 --- a/dist/pages/diy/index.js +++ b/dist/pages/diy/index.js @@ -1 +1 @@ -"use strict";(wx["webpackJsonp"]=wx["webpackJsonp"]||[]).push([[95],{8955:function(e,a,t){var s=t(7842),n=t(1212),i=t(467),c=t(9379),r=t(436),o=t(5544),d=t(118),u=t(758),l=t.n(u),h=t(6540),m=t(5234),g=t(1457),p=t(6845),f=t(9703),x=t(9201),v=t(5414),j=t(9674),N=t(3053),w=t(9513),y=t(4848);function S(){var e=(0,f.wR)(),a=(e.theme,e.resolvedTheme),t=(0,x.c)();(0,v.l)(a);var s=(0,h.useState)(null),u=(0,o.A)(s,2),S=u[0],k=u[1],A=(0,h.useState)(1),b=(0,o.A)(A,2),M=(b[0],b[1],(0,h.useState)("")),T=(0,o.A)(M,2),E=T[0],Y=T[1],I=(0,h.useState)(1),D=(0,o.A)(I,2),P=D[0],_=D[1],O=(0,h.useState)([]),F=(0,o.A)(O,2),R=F[0],B=F[1],q=(0,h.useState)(null),z=(0,o.A)(q,2),V=z[0],C=z[1],H=(0,h.useState)(!1),J=(0,o.A)(H,2),X=J[0],G=J[1],L=(0,h.useState)({x:0,y:0}),K=(0,o.A)(L,2),Q=K[0],U=K[1],W=(0,h.useState)(!1),Z=(0,o.A)(W,2),$=Z[0],ee=Z[1],ae=(0,h.useState)(!1),te=(0,o.A)(ae,2),se=te[0],ne=te[1],ie=function(e,a){(0,p.x9)({productId:e.id,productName:e.name,unitPrice:e.price,count:a}).then(function(e){return(0,g.Fu)([e].concat((0,r.A)((0,g.p_)()))),Y(e.id),(0,p.i5)(e.id,{status:"designing"}).then(function(a){(0,g.Fu)((0,g.p_)().map(function(t){return t.id===e.id?(0,c.A)((0,c.A)({},t),{},{status:a.status}):t}))}).catch(function(){(0,g.Fu)((0,g.p_)().map(function(a){return a.id===e.id?(0,c.A)((0,c.A)({},a),{},{status:"designing"}):a}))})}).catch(function(){var t={id:"DSG"+Date.now(),productId:e.id,productName:e.name,productIcon:e.icon,unitPrice:e.price,count:a,status:"designing",createdAt:(new Date).toISOString().slice(0,10)};(0,g.Fu)([].concat((0,r.A)((0,g.p_)()),[t])),Y(t.id)})};(0,h.useEffect)(function(){var e=l().getCurrentInstance().router,a=e?e.params:void 0,t=a?a.source:void 0,s=a&&a.productId||a&&a.category;if("product"===t&&s){var n=(0,m.y9)(s);if(n){k(n);var i=Number(a?a.quantity:void 0)||1;_(i),ie(n,i)}}else if("designList"===t&&a&&a.designId){var r=a.designId,o=(0,g.p_)(),d=o.find(function(e){return e.id===r});if(d){Y(r),_(d.count);var u=(0,m.y9)(d.productId);u&&k(u);var h=d.designData,f=h?h.stickers:void 0;if(f){var x=h&&h.category&&h.category.mask||(u?u.mask:void 0),v=x?f.map(function(e){if(e.width>x.width||e.height>x.height){var a=.6*Math.min(x.width,x.height)/Math.max(e.width,e.height);return(0,c.A)((0,c.A)({},e),{},{width:Math.round(e.width*a),height:Math.round(e.height*a)})}return e}):f;B(v)}else if(h?h.imageSrc:void 0){var j={id:"legacy_"+Date.now(),src:h.imageSrc,x:h.imagePos&&h.imagePos.x||0,y:h.imagePos&&h.imagePos.y||0,scale:h.imagePos&&h.imagePos.scale||1,width:200,height:200,isOverlapping:!1};B([j])}"undesigned"===d.status&&((0,g.i5)(r,{status:"designing"}),(0,p.i5)(r,{status:"designing"}).catch(function(){}))}}else if(s){var N=(0,m.y9)(s);N&&(k(N),ie(N,1))}},[]);var ce=(0,h.useRef)(null),re=(0,h.useRef)({designId:"",quantity:1,category:null,stickers:[]});re.current={designId:E,quantity:P,category:S,stickers:R};var oe=function(){var e=re.current,a=e.designId,t=e.quantity,s=e.category,n=e.stickers;if(a&&s){var i=(0,g.p_)().find(function(e){return e.id===a}),r=(0,c.A)((0,c.A)({},i&&i.designData?i.designData:{}),{},{version:1,category:(0,c.A)({id:s.id,mask:s.mask},s.tone?{tone:s.tone}:{}),stickers:n});(0,g.i5)(a,{designData:r}),(0,p.i5)(a,{item:{productId:s.id,productName:s.name,unitPrice:s.price,count:t,designData:r}}).catch(function(){})}},de=function(){ce.current&&(clearTimeout(ce.current),ce.current=null),oe()};l().useDidHide(de),(0,h.useEffect)(function(){return de},[]);var ue=(0,h.useRef)(!0);(0,h.useEffect)(function(){ue.current?ue.current=!1:(ce.current&&clearTimeout(ce.current),ce.current=setTimeout(oe,800))},[R]);var le=(0,h.useRef)(!0);l().useDidShow(function(){if(le.current)le.current=!1;else{var e=re.current.designId;if(e){var a=(0,g.p_)().find(function(a){return a.id===e}),t=a&&a.designData?a.designData.stickers:void 0;t&&t.length&&B(he(t))}}});var he=function(e){for(var a=e.map(function(e){return(0,c.A)((0,c.A)({},e),{},{isOverlapping:!1})}),t=0;ti.x&&n.yi.y&&(a[t].isOverlapping=!0,a[s].isOverlapping=!0)}var l=a.some(function(e){return e.isOverlapping});return ne(l),a},me=function(){l().chooseImage({count:1,sizeType:["compressed"],sourceType:["album","camera"],success:function(e){var a=e.tempFilePaths[0];l().getImageInfo({src:a,success:function(e){var t=Math.min(S.mask.width,S.mask.height),s=.6*t/Math.max(e.width,e.height),n={id:"stk_"+Date.now(),src:a,x:0,y:0,scale:1,width:Math.round(e.width*s),height:Math.round(e.height*s),isOverlapping:!1},i=[].concat((0,r.A)(R),[n]),c=he(i);B(c),C(n.id)},fail:function(){var e=Math.min(S.mask.width,S.mask.height),t=.6*e/200,s={id:"stk_"+Date.now(),src:a,x:0,y:0,scale:1,width:Math.round(200*t),height:Math.round(200*t),isOverlapping:!1},n=[].concat((0,r.A)(R),[s]),i=he(n);B(i),C(s.id)}})}})},ge=function(e){var a=R.filter(function(a){return a.id!==e}),t=he(a);B(t),V===e&&C(null)},pe=function(e,a){var t=e.touches[0],s=R.find(function(e){return e.id===a});s&&(C(a),G(!0),U({x:t.clientX-s.x,y:t.clientY-s.y}))},fe=function(e){if(X&&V){var a=e.touches[0],t=R.map(function(e){if(e.id!==V)return e;var t=Math.max(0,S.mask.width-e.width*e.scale),s=Math.max(0,S.mask.height-e.height*e.scale);return(0,c.A)((0,c.A)({},e),{},{x:Math.min(Math.max(a.clientX-Q.x,0),t),y:Math.min(Math.max(a.clientY-Q.y,0),s)})}),s=he(t);B(s)}},xe=function(){return G(!1)},ve=function(){V&&E&&(de(),l().navigateTo({url:"/pages/diy/stickerEdit/index?designId=".concat(E,"&stickerId=").concat(V)}))},je=function(e,a){var t=R.map(function(t){if(t.id!==e)return t;var s=Math.max(.3,Math.min(3,t.scale+a)),n=Math.max(0,S.mask.width-t.width*s),i=Math.max(0,S.mask.height-t.height*s);return(0,c.A)((0,c.A)({},t),{},{scale:s,x:Math.min(Math.max(t.x,0),n),y:Math.min(Math.max(t.y,0),i)})}),s=he(t);B(s)},Ne=function(e){var a=e.edits;if(a){var t=a.brightness||0,s=a.hue||0,n=a.contrast||0;if(0!==t||0!==s||0!==n)return"brightness(".concat(100+t,"%) hue-rotate(").concat(s,"deg) contrast(").concat(100+n,"%)")}},we=function(){l().navigateBack()},ye=function(){if(!S)return{width:300,height:420};var e={width:S.mask.width,height:S.mask.height};return"rect"===S.mask.shape&&(e.borderRadius=S.mask.borderRadius||0),"circle"===S.mask.shape&&(e.borderRadius="50%"),e},Se=function(){var e=(0,i.A)((0,n.A)().m(function e(){var a,t,s,i;return(0,n.A)().w(function(e){while(1)switch(e.p=e.n){case 0:if(!se){e.n=1;break}return l().showToast({title:"\u8d34\u7eb8\u4e0d\u80fd\u91cd\u53e0",icon:"none"}),e.a(2);case 1:if(!E||!S){e.n=6;break}return e.n=2,(0,p.x5)({stickers:R,category:S,version:1});case 2:return a=e.v,t=(0,c.A)({id:S.id,mask:S.mask},S.tone?{tone:S.tone}:{}),s=(0,g.p_)().find(function(e){return e.id===E}),i=(0,c.A)((0,c.A)({},s&&s.designData?s.designData:{}),{},{version:1,category:t,stickers:a.stickers||R}),(0,g.i5)(E,{status:"designing",designData:i}),e.p=3,e.n=4,(0,p.i5)(E,{status:"designing",item:{productId:S.id,productName:S.name,unitPrice:S.price,count:P,designData:i}});case 4:e.n=6;break;case 5:e.p=5,e.v,l().showToast({title:"\u7f51\u7edc\u4e0d\u53ef\u7528\uff0c\u5df2\u6682\u5b58\u5230\u672c\u5730",icon:"none"});case 6:ee(!1),l().navigateTo({url:"/pages/checkout/index?designId=".concat(E)});case 7:return e.a(2)}},e,null,[[3,5]])}));return function(){return e.apply(this,arguments)}}(),ke=V?R.find(function(e){return e.id===V}):void 0,Ae=ke?ke.scale:1;return S?(0,y.jsxs)(d.Ss,{className:"theme-".concat(a),children:[(0,y.jsx)(j.A,{}),(0,y.jsx)(N.A,{title:"\u8bbe\u8ba1\u5de5\u4f5c\u53f0",targetSelector:".page-header.surface-card",showBack:!0}),(0,y.jsxs)(d.Ss,{className:"diy-page",children:[(0,y.jsx)(d.Ss,{className:"page-header surface-card",style:{paddingTop:"".concat(t.statusBarHeight+12,"px")},children:(0,y.jsxs)(d.Ss,{className:"flex-between",style:{width:"100%"},children:[(0,y.jsx)(d.EY,{className:"back-btn",onTap:we,children:"\u2190"}),(0,y.jsx)(d.EY,{className:"page-title",children:"\u8bbe\u8ba1\u5de5\u4f5c\u53f0"}),(0,y.jsx)(d.Ss,{className:"header-spacer"})]})}),(0,y.jsx)(d.Ss,{className:"canvas-wrapper surface-card mt-20",catchMove:!0,children:(0,y.jsxs)(d.Ss,{className:"canvas-area",style:ye(),children:[R.map(function(e){return(0,y.jsx)(d._V,{className:"canvas-image ".concat(e.isOverlapping?"overlap":""," ").concat(V===e.id?"active":""),src:e.src,style:{transform:"translate(".concat(e.x,"px, ").concat(e.y,"px) scale(").concat(e.scale,")"),opacity:X&&V===e.id?.8:1,zIndex:V===e.id?10:5,filter:Ne(e),width:e.width||200,height:e.height||200},onTouchStart:function(a){return pe(a,e.id)},onTouchMove:fe,onTouchEnd:xe,onTap:function(){return C(e.id)},mode:"aspectFit"},e.id)}),(0,y.jsx)(d.Ss,{className:"mask-border",style:ye()})]})}),(0,y.jsxs)(d.Ss,{className:"sticker-panel surface-card mt-20",children:[(0,y.jsx)(d.EY,{className:"section-title",children:"\u8d34\u7eb8"}),(0,y.jsxs)(d.Ss,{className:"sticker-list",children:[R.map(function(e){return(0,y.jsxs)(d.Ss,{className:"sticker-thumb ".concat(e.isOverlapping?"overlap":""," ").concat(V===e.id?"active":""),children:[(0,y.jsx)(d._V,{src:e.src,className:"sticker-thumb-img",mode:"aspectFit",onTap:function(){return C(e.id)}}),(0,y.jsx)(d.Ss,{className:"sticker-del",onTap:function(){return ge(e.id)},children:(0,y.jsx)(d.EY,{className:"del-icon",children:"\xd7"})})]},e.id)}),(0,y.jsxs)(d.Ss,{className:"sticker-add-btn",onTap:me,children:[(0,y.jsx)(d.EY,{className:"add-icon",children:"+"}),(0,y.jsx)(d.EY,{className:"add-label",children:"\u6dfb\u52a0"})]})]}),se&&(0,y.jsx)(d.EY,{className:"overlap-hint",children:"\u6709\u8d34\u7eb8\u91cd\u53e0\uff0c\u8bf7\u8c03\u6574\u4f4d\u7f6e"})]}),V&&(0,y.jsxs)(d.Ss,{className:"toolbar surface-card mt-20",children:[(0,y.jsxs)(d.Ss,{className:"tool-row",children:[(0,y.jsx)(d.EY,{className:"tool-label",children:"\u7f29\u653e"}),(0,y.jsxs)(d.Ss,{className:"flex-center",style:{gap:"20px"},children:[(0,y.jsx)(d.Ss,{className:"tool-btn",onTap:function(){return je(V,-.1)},children:"\uff0d"}),(0,y.jsxs)(d.EY,{className:"tool-value",children:[Math.round(100*Ae),"%"]}),(0,y.jsx)(d.Ss,{className:"tool-btn",onTap:function(){return je(V,.1)},children:"\uff0b"})]})]}),(0,y.jsxs)(d.Ss,{className:"tool-row",children:[(0,y.jsx)(d.EY,{className:"tool-label",children:"\u63d0\u793a"}),(0,y.jsx)(d.EY,{className:"tool-hint",children:"\u62d6\u52a8\u8c03\u6574\u4f4d\u7f6e\uff0c\u8d34\u7eb8\u4e0d\u53ef\u91cd\u53e0"})]})]}),(0,y.jsx)(d.Ss,{className:"edit-btn-bar mt-20",children:(0,y.jsx)(d.Ss,{className:"edit-btn ".concat(V?"active":"disabled"),onTap:ve,children:(0,y.jsx)(d.EY,{children:"\u7f16\u8f91"})})}),(0,y.jsxs)(w.A,{children:[(0,y.jsx)(d.Ss,{className:"btn-primary",onTap:function(){return ee(!0)},children:(0,y.jsx)(d.EY,{children:"\u9884\u89c8\u6548\u679c"})}),(0,y.jsx)(d.Ss,{className:"btn-secondary",onTap:me,children:(0,y.jsx)(d.EY,{children:"\u6dfb\u52a0\u8d34\u7eb8"})})]}),$&&(0,y.jsx)(d.Ss,{className:"preview-overlay",children:(0,y.jsxs)(d.Ss,{className:"preview-card surface-card",children:[(0,y.jsx)(d.EY,{className:"preview-title",children:"\u786e\u8ba4\u6548\u679c"}),(0,y.jsx)(d.Ss,{className:"preview-canvas",style:ye(),children:R.map(function(e){return(0,y.jsx)(d._V,{className:"preview-image ".concat(e.isOverlapping?"overlap":""),src:e.src,style:{transform:"translate(".concat(e.x,"px, ").concat(e.y,"px) scale(").concat(e.scale,")"),filter:Ne(e),width:e.width||200,height:e.height||200},mode:"aspectFit"},e.id)})}),(0,y.jsxs)(d.Ss,{className:"product-info",children:[(0,y.jsx)(d.EY,{className:"product-name",children:S.name}),(0,y.jsxs)(d.EY,{className:"product-size",children:["\u753b\u5e03\u5c3a\u5bf8: ",S.mask.width," \xd7 ",S.mask.height," px"]}),se&&(0,y.jsx)(d.EY,{className:"overlap-hint",children:"\u8d34\u7eb8\u6709\u91cd\u53e0\uff0c\u4e0d\u53ef\u63d0\u4ea4"})]}),(0,y.jsxs)(d.Ss,{className:"preview-actions",children:[(0,y.jsx)(d.Ss,{className:"btn-secondary",onTap:function(){return ee(!1)},children:(0,y.jsx)(d.EY,{children:"\u8fd4\u56de\u4fee\u6539"})}),(0,y.jsx)(d.Ss,{className:"btn-primary ".concat(se?"disabled":""),onTap:Se,children:(0,y.jsx)(d.EY,{children:"\u786e\u8ba4\u5b8c\u6210"})})]})]})}),(0,y.jsx)(d.Ss,{className:"safe-bottom-placeholder"})]})]}):(0,y.jsxs)(d.Ss,{className:"theme-".concat(a),children:[(0,y.jsx)(j.A,{}),(0,y.jsx)(N.A,{title:"\u8bbe\u8ba1\u5de5\u4f5c\u53f0",targetSelector:".page-header.surface-card",showBack:!0}),(0,y.jsx)(d.Ss,{className:"diy-page",children:(0,y.jsx)(d.EY,{className:"page-title",children:"\u52a0\u8f7d\u4e2d..."})})]})}var k={navigationStyle:"custom",enablePageMeta:!0,navigationBarTitleText:"DIY\u5de5\u4f5c\u53f0"};Page((0,s.createPageConfig)(S,"pages/diy/index",{root:{cn:[]}},k||{}))}},function(e){var a=function(a){return e(e.s=a)};e.O(0,[907,96,76],function(){return a(8955)});e.O()}]); \ No newline at end of file +"use strict";(wx["webpackJsonp"]=wx["webpackJsonp"]||[]).push([[95],{8955:function(e,t,a){var s=a(7842),n=a(1212),i=a(467),c=a(9379),r=a(436),o=a(5544),d=a(118),u=a(758),l=a.n(u),h=a(6540),m=a(5234),p=a(1457),g=a(6845),f=a(9703),x=a(9201),v=a(5414),j=a(9674),N=a(3053),y=a(9513),S=a(4848);function w(){var e=(0,f.wR)(),t=(e.theme,e.resolvedTheme),a=(0,x.c)();(0,v.l)(t);var s=(0,h.useState)(null),u=(0,o.A)(s,2),w=u[0],k=u[1],A=(0,h.useState)(1),b=(0,o.A)(A,2),T=(b[0],b[1],(0,h.useState)("")),E=(0,o.A)(T,2),Y=E[0],I=E[1],D=(0,h.useState)(1),M=(0,o.A)(D,2),P=M[0],_=M[1],O=(0,h.useState)([]),F=(0,o.A)(O,2),R=F[0],B=F[1],q=(0,h.useState)(null),z=(0,o.A)(q,2),V=z[0],C=z[1],H=(0,h.useState)(!1),J=(0,o.A)(H,2),X=J[0],G=J[1],L=(0,h.useState)({x:0,y:0}),K=(0,o.A)(L,2),Q=K[0],U=K[1],W=(0,h.useState)(!1),Z=(0,o.A)(W,2),$=Z[0],ee=Z[1],te=(0,h.useState)(!1),ae=(0,o.A)(te,2),se=ae[0],ne=ae[1],ie=function(e,t){(0,g.x9)({productId:e.id,productName:e.name,unitPrice:e.price,count:t}).then(function(e){return(0,p.Fu)([e].concat((0,r.A)((0,p.p_)()))),I(e.id),(0,g.i5)(e.id,{status:"designing"}).then(function(t){(0,p.Fu)((0,p.p_)().map(function(a){return a.id===e.id?(0,c.A)((0,c.A)({},a),{},{status:t.status}):a}))}).catch(function(){(0,p.Fu)((0,p.p_)().map(function(t){return t.id===e.id?(0,c.A)((0,c.A)({},t),{},{status:"designing"}):t}))})}).catch(function(){var a={id:"DSG"+Date.now(),productId:e.id,productName:e.name,productIcon:e.icon,unitPrice:e.price,count:t,status:"designing",createdAt:(new Date).toISOString().slice(0,10)};(0,p.Fu)([].concat((0,r.A)((0,p.p_)()),[a])),I(a.id)})};(0,h.useEffect)(function(){var e=l().getCurrentInstance().router,t=e?e.params:void 0,a=t?t.source:void 0,s=t&&t.productId||t&&t.category;if("product"===a&&s){var n=(0,m.y9)(s);if(n){k(n);var i=Number(t?t.quantity:void 0)||1;_(i),ie(n,i)}}else if("designList"===a&&t&&t.designId){var r=t.designId,o=(0,p.p_)(),d=o.find(function(e){return e.id===r});if(d){I(r),_(d.count);var u=(0,m.y9)(d.productId);u&&k(u);var h=d.designData,f=h?h.stickers:void 0;if(f){var x=h&&h.category&&h.category.mask||(u?u.mask:void 0),v=x?f.map(function(e){if(e.width>x.width||e.height>x.height){var t=.6*Math.min(x.width,x.height)/Math.max(e.width,e.height);return(0,c.A)((0,c.A)({},e),{},{width:Math.round(e.width*t),height:Math.round(e.height*t)})}return e}):f;B(v)}else if(h?h.imageSrc:void 0){var j={id:"legacy_"+Date.now(),src:h.imageSrc,x:h.imagePos&&h.imagePos.x||0,y:h.imagePos&&h.imagePos.y||0,scale:h.imagePos&&h.imagePos.scale||1,width:200,height:200,isOverlapping:!1};B([j])}"undesigned"===d.status&&((0,p.i5)(r,{status:"designing"}),(0,g.i5)(r,{status:"designing"}).catch(function(){}))}}else if(s){var N=(0,m.y9)(s);N&&(k(N),ie(N,1))}},[]);var ce=(0,h.useRef)(null),re=(0,h.useRef)({designId:"",quantity:1,category:null,stickers:[]});re.current={designId:Y,quantity:P,category:w,stickers:R};var oe=function(){var e=re.current,t=e.designId,a=e.quantity,s=e.category,n=e.stickers;if(t&&s){var i=(0,p.p_)().find(function(e){return e.id===t}),r=(0,c.A)((0,c.A)({},i&&i.designData?i.designData:{}),{},{version:1,category:(0,c.A)({id:s.id,mask:s.mask},s.tone?{tone:s.tone}:{}),stickers:n});(0,p.i5)(t,{designData:r}),(0,g.i5)(t,{item:{productId:s.id,productName:s.name,unitPrice:s.price,count:a,designData:r}}).catch(function(){})}},de=function(){ce.current&&(clearTimeout(ce.current),ce.current=null),oe()};l().useDidHide(de),(0,h.useEffect)(function(){return de},[]);var ue=(0,h.useRef)(!0);(0,h.useEffect)(function(){ue.current?ue.current=!1:(ce.current&&clearTimeout(ce.current),ce.current=setTimeout(oe,800))},[R]);var le=(0,h.useRef)(!0);l().useDidShow(function(){if(le.current)le.current=!1;else{var e=re.current.designId;if(e){var t=(0,p.p_)().find(function(t){return t.id===e}),a=t&&t.designData?t.designData.stickers:void 0;a&&a.length&&B(he(a))}}});var he=function(e){for(var t=e.map(function(e){return(0,c.A)((0,c.A)({},e),{},{isOverlapping:!1})}),a=0;ai.x&&n.yi.y&&(t[a].isOverlapping=!0,t[s].isOverlapping=!0)}var l=t.some(function(e){return e.isOverlapping});return ne(l),t},me=function(){l().chooseImage({count:1,sizeType:["compressed"],sourceType:["album","camera"],success:function(e){var t=e.tempFilePaths[0];l().getImageInfo({src:t,success:function(e){var a=Math.min(w.mask.width,w.mask.height),s=.6*a/Math.max(e.width,e.height),n={id:"stk_"+Date.now(),src:t,x:0,y:0,scale:1,width:Math.round(e.width*s),height:Math.round(e.height*s),isOverlapping:!1},i=[].concat((0,r.A)(R),[n]),c=he(i);B(c),C(n.id)},fail:function(){var e=Math.min(w.mask.width,w.mask.height),a=.6*e/200,s={id:"stk_"+Date.now(),src:t,x:0,y:0,scale:1,width:Math.round(200*a),height:Math.round(200*a),isOverlapping:!1},n=[].concat((0,r.A)(R),[s]),i=he(n);B(i),C(s.id)}})}})},pe=function(e){var t=R.filter(function(t){return t.id!==e}),a=he(t);B(a),V===e&&C(null)},ge=function(e,t){var a=e.touches[0],s=R.find(function(e){return e.id===t});s&&(C(t),G(!0),U({x:a.clientX-s.x,y:a.clientY-s.y}))},fe=function(e){if(X&&V){var t=e.touches[0],a=R.map(function(e){return e.id!==V?e:(0,c.A)((0,c.A)({},e),{},{x:t.clientX-Q.x,y:t.clientY-Q.y})}),s=he(a);B(s)}},xe=function(){return G(!1)},ve=function(){V&&Y&&(de(),l().navigateTo({url:"/pages/diy/stickerEdit/index?designId=".concat(Y,"&stickerId=").concat(V)}))},je=function(e,t){var a=R.map(function(a){return a.id!==e?a:(0,c.A)((0,c.A)({},a),{},{scale:Math.max(.3,Math.min(3,a.scale+t))})}),s=he(a);B(s)},Ne=function(e){var t=e.edits;if(t){var a=t.brightness||0,s=t.hue||0,n=t.contrast||0;if(0!==a||0!==s||0!==n)return"brightness(".concat(100+a,"%) hue-rotate(").concat(s,"deg) contrast(").concat(100+n,"%)")}},ye=function(){l().navigateBack()},Se=function(){if(!w)return{width:300,height:420};var e={width:w.mask.width,height:w.mask.height};return"rect"===w.mask.shape&&(e.borderRadius=w.mask.borderRadius||0),"circle"===w.mask.shape&&(e.borderRadius="50%"),e},we=function(){var e=(0,i.A)((0,n.A)().m(function e(){var t,a,s,i;return(0,n.A)().w(function(e){while(1)switch(e.p=e.n){case 0:if(!se){e.n=1;break}return l().showToast({title:"\u8d34\u7eb8\u4e0d\u80fd\u91cd\u53e0",icon:"none"}),e.a(2);case 1:if(!Y||!w){e.n=6;break}return e.n=2,(0,g.x5)({stickers:R,category:w,version:1});case 2:return t=e.v,a=(0,c.A)({id:w.id,mask:w.mask},w.tone?{tone:w.tone}:{}),s=(0,p.p_)().find(function(e){return e.id===Y}),i=(0,c.A)((0,c.A)({},s&&s.designData?s.designData:{}),{},{version:1,category:a,stickers:t.stickers||R}),(0,p.i5)(Y,{status:"designing",designData:i}),e.p=3,e.n=4,(0,g.i5)(Y,{status:"designing",item:{productId:w.id,productName:w.name,unitPrice:w.price,count:P,designData:i}});case 4:e.n=6;break;case 5:e.p=5,e.v,l().showToast({title:"\u7f51\u7edc\u4e0d\u53ef\u7528\uff0c\u5df2\u6682\u5b58\u5230\u672c\u5730",icon:"none"});case 6:ee(!1),l().navigateTo({url:"/pages/checkout/index?designId=".concat(Y)});case 7:return e.a(2)}},e,null,[[3,5]])}));return function(){return e.apply(this,arguments)}}(),ke=V?R.find(function(e){return e.id===V}):void 0,Ae=ke?ke.scale:1;return w?(0,S.jsxs)(d.Ss,{className:"theme-".concat(t),children:[(0,S.jsx)(j.A,{}),(0,S.jsx)(N.A,{title:"\u8bbe\u8ba1\u5de5\u4f5c\u53f0",targetSelector:".page-header.surface-card",showBack:!0}),(0,S.jsxs)(d.Ss,{className:"diy-page",children:[(0,S.jsx)(d.Ss,{className:"page-header surface-card",style:{paddingTop:"".concat(a.statusBarHeight+12,"px")},children:(0,S.jsxs)(d.Ss,{className:"flex-between",style:{width:"100%"},children:[(0,S.jsx)(d.EY,{className:"back-btn",onTap:ye,children:"\u2190"}),(0,S.jsx)(d.EY,{className:"page-title",children:"\u8bbe\u8ba1\u5de5\u4f5c\u53f0"}),(0,S.jsx)(d.Ss,{className:"header-spacer"})]})}),(0,S.jsx)(d.Ss,{className:"canvas-wrapper surface-card mt-20",catchMove:!0,children:(0,S.jsxs)(d.Ss,{className:"canvas-area",style:Se(),children:[R.map(function(e){return(0,S.jsx)(d._V,{className:"canvas-image ".concat(e.isOverlapping?"overlap":""," ").concat(V===e.id?"active":""),src:e.src,style:{transform:"translate(".concat(e.x,"px, ").concat(e.y,"px) scale(").concat(e.scale,")"),opacity:X&&V===e.id?.8:1,zIndex:V===e.id?10:5,filter:Ne(e),width:e.width||200,height:e.height||200},onTouchStart:function(t){return ge(t,e.id)},onTouchMove:fe,onTouchEnd:xe,onTap:function(){return C(e.id)},mode:"aspectFit"},e.id)}),(0,S.jsx)(d.Ss,{className:"mask-border",style:Se()})]})}),(0,S.jsxs)(d.Ss,{className:"sticker-panel surface-card mt-20",children:[(0,S.jsx)(d.EY,{className:"section-title",children:"\u8d34\u7eb8"}),(0,S.jsxs)(d.Ss,{className:"sticker-list",children:[R.map(function(e){return(0,S.jsxs)(d.Ss,{className:"sticker-thumb ".concat(e.isOverlapping?"overlap":""," ").concat(V===e.id?"active":""),children:[(0,S.jsx)(d._V,{src:e.src,className:"sticker-thumb-img",mode:"aspectFit",onTap:function(){return C(e.id)}}),(0,S.jsx)(d.Ss,{className:"sticker-del",onTap:function(){return pe(e.id)},children:(0,S.jsx)(d.EY,{className:"del-icon",children:"\xd7"})})]},e.id)}),(0,S.jsxs)(d.Ss,{className:"sticker-add-btn",onTap:me,children:[(0,S.jsx)(d.EY,{className:"add-icon",children:"+"}),(0,S.jsx)(d.EY,{className:"add-label",children:"\u6dfb\u52a0"})]})]}),se&&(0,S.jsx)(d.EY,{className:"overlap-hint",children:"\u6709\u8d34\u7eb8\u91cd\u53e0\uff0c\u8bf7\u8c03\u6574\u4f4d\u7f6e"})]}),V&&(0,S.jsxs)(d.Ss,{className:"toolbar surface-card mt-20",children:[(0,S.jsxs)(d.Ss,{className:"tool-row",children:[(0,S.jsx)(d.EY,{className:"tool-label",children:"\u7f29\u653e"}),(0,S.jsxs)(d.Ss,{className:"flex-center",style:{gap:"20px"},children:[(0,S.jsx)(d.Ss,{className:"tool-btn",onTap:function(){return je(V,-.1)},children:"\uff0d"}),(0,S.jsxs)(d.EY,{className:"tool-value",children:[Math.round(100*Ae),"%"]}),(0,S.jsx)(d.Ss,{className:"tool-btn",onTap:function(){return je(V,.1)},children:"\uff0b"})]})]}),(0,S.jsxs)(d.Ss,{className:"tool-row",children:[(0,S.jsx)(d.EY,{className:"tool-label",children:"\u63d0\u793a"}),(0,S.jsx)(d.EY,{className:"tool-hint",children:"\u62d6\u52a8\u8c03\u6574\u4f4d\u7f6e\uff0c\u8d34\u7eb8\u4e0d\u53ef\u91cd\u53e0"})]})]}),(0,S.jsx)(d.Ss,{className:"edit-btn-bar mt-20",children:(0,S.jsx)(d.Ss,{className:"edit-btn ".concat(V?"active":"disabled"),onTap:ve,children:(0,S.jsx)(d.EY,{children:"\u7f16\u8f91"})})}),(0,S.jsxs)(y.A,{children:[(0,S.jsx)(d.Ss,{className:"btn-primary",onTap:function(){return ee(!0)},children:(0,S.jsx)(d.EY,{children:"\u9884\u89c8\u6548\u679c"})}),(0,S.jsx)(d.Ss,{className:"btn-secondary",onTap:me,children:(0,S.jsx)(d.EY,{children:"\u6dfb\u52a0\u8d34\u7eb8"})})]}),$&&(0,S.jsx)(d.Ss,{className:"preview-overlay",children:(0,S.jsxs)(d.Ss,{className:"preview-card surface-card",children:[(0,S.jsx)(d.EY,{className:"preview-title",children:"\u786e\u8ba4\u6548\u679c"}),(0,S.jsx)(d.Ss,{className:"preview-canvas",style:Se(),children:R.map(function(e){return(0,S.jsx)(d._V,{className:"preview-image ".concat(e.isOverlapping?"overlap":""),src:e.src,style:{transform:"translate(".concat(e.x,"px, ").concat(e.y,"px) scale(").concat(e.scale,")"),filter:Ne(e),width:e.width||200,height:e.height||200},mode:"aspectFit"},e.id)})}),(0,S.jsxs)(d.Ss,{className:"product-info",children:[(0,S.jsx)(d.EY,{className:"product-name",children:w.name}),(0,S.jsxs)(d.EY,{className:"product-size",children:["\u753b\u5e03\u5c3a\u5bf8: ",w.mask.width," \xd7 ",w.mask.height," px"]}),se&&(0,S.jsx)(d.EY,{className:"overlap-hint",children:"\u8d34\u7eb8\u6709\u91cd\u53e0\uff0c\u4e0d\u53ef\u63d0\u4ea4"})]}),(0,S.jsxs)(d.Ss,{className:"preview-actions",children:[(0,S.jsx)(d.Ss,{className:"btn-secondary",onTap:function(){return ee(!1)},children:(0,S.jsx)(d.EY,{children:"\u8fd4\u56de\u4fee\u6539"})}),(0,S.jsx)(d.Ss,{className:"btn-primary ".concat(se?"disabled":""),onTap:we,children:(0,S.jsx)(d.EY,{children:"\u786e\u8ba4\u5b8c\u6210"})})]})]})}),(0,S.jsx)(d.Ss,{className:"safe-bottom-placeholder"})]})]}):(0,S.jsxs)(d.Ss,{className:"theme-".concat(t),children:[(0,S.jsx)(j.A,{}),(0,S.jsx)(N.A,{title:"\u8bbe\u8ba1\u5de5\u4f5c\u53f0",targetSelector:".page-header.surface-card",showBack:!0}),(0,S.jsx)(d.Ss,{className:"diy-page",children:(0,S.jsx)(d.EY,{className:"page-title",children:"\u52a0\u8f7d\u4e2d..."})})]})}var k={navigationStyle:"custom",enablePageMeta:!0,navigationBarTitleText:"DIY\u5de5\u4f5c\u53f0"};Page((0,s.createPageConfig)(w,"pages/diy/index",{root:{cn:[]}},k||{}))}},function(e){var t=function(t){return e(e.s=t)};e.O(0,[907,96,76],function(){return t(8955)});e.O()}]); \ No newline at end of file diff --git a/docs/diy-fix-workflow.md b/docs/diy-fix-workflow.md index f931628..422357e 100644 --- a/docs/diy-fix-workflow.md +++ b/docs/diy-fix-workflow.md @@ -27,8 +27,9 @@ mask.h) × 0.6`,`scale=1` 起步——从此 `width/height` 语义 =「画布显示像素」, 渲染、碰撞、WCD 打包三者自洽; 2. `canvas-image` 保留 max 钳制作为兜底,但归一化后不再触发; -3. 拖动时把 `x/y` 钳制在 `[0, mask.w - 显示宽]` / `[0, mask.h - 显示高]` 区间内, - 杜绝负坐标和拖出画布。 +3. ~~拖动时把 `x/y` 钳制在 `[0, mask.w - 显示宽]` / `[0, mask.h - 显示高]` 区间内~~ + (**已按需求撤销**,2026-09-12:贴纸允许拖出画布外自由摆放,负坐标为合法状态; + 误报根因是尺寸语义而非坐标,归一化后已消除)。 **契约影响**:`designData.stickers[].width/height` 的**语义**从「原始像素」变为 「画布显示像素」。这不是字段增删,但 WCD 打包按 `width × scale` 还原布局,语义必须 @@ -220,7 +221,8 @@ R4 派单前持久化回写)直接矛盾,且真机落库数据即为 wxfile: **建议批次**:① 问题 2+3+4(同一文件、一次回归)✅ 已实施(2026-09-12,commit eea6c3f, `build:weapp` 通过,tsc 无新增错误)→ ② 问题 1(含兼容验证)✅ 已实施(2026-09-12, -commit 3b224cf:归一化 + 坐标钳制 + 读端兼容 + transform-origin)→ +commit 3b224cf:归一化 + 坐标钳制 + 读端兼容 + transform-origin; +**坐标钳制后经需求确认撤销**,commit 见后续,贴纸恢复可拖出画布)→ ③ 问题 5(改动面最大,单独一批)✅ 已实施(2026-09-12,commit 2e3676a: TouchSlider 组件化 + Image/CSS filter 预览 + edits 参数化保存 + DIY 渲染端 消费 edits;checkout 预览消费 edits 仍记 R3 待办)。 diff --git a/src/pages/diy/index.tsx b/src/pages/diy/index.tsx index f9f0308..74ad7cc 100644 --- a/src/pages/diy/index.tsx +++ b/src/pages/diy/index.tsx @@ -297,16 +297,10 @@ export default function DIYPage() { const handleStickerTouchMove = (e: any) => { if (!isDragging || !activeStickerId) return const touch = e.touches[0] + // 需求决定(2026-09-12):贴纸允许拖出画布外自由摆放,不做坐标钳制 const next = stickers.map(s => { if (s.id !== activeStickerId) return s - // 问题1 修正:坐标钳制在画布内,杜绝负坐标与拖出画布(碰撞盒 = x/y + 显示宽高) - const maxX = Math.max(0, category.mask.width - s.width * s.scale) - const maxY = Math.max(0, category.mask.height - s.height * s.scale) - return { - ...s, - x: Math.min(Math.max(touch.clientX - startPos.x, 0), maxX), - y: Math.min(Math.max(touch.clientY - startPos.y, 0), maxY) - } + return { ...s, x: touch.clientX - startPos.x, y: touch.clientY - startPos.y } }) const checked = checkOverlap(next) setStickers(checked) @@ -325,16 +319,7 @@ export default function DIYPage() { const handleScale = (id: string, delta: number) => { const next = stickers.map(s => { if (s.id !== id) return s - const scale = Math.max(0.3, Math.min(3, s.scale + delta)) - // 问题1 修正:缩放后把位置钳回画布内 - const maxX = Math.max(0, category.mask.width - s.width * scale) - const maxY = Math.max(0, category.mask.height - s.height * scale) - return { - ...s, - scale, - x: Math.min(Math.max(s.x, 0), maxX), - y: Math.min(Math.max(s.y, 0), maxY) - } + return { ...s, scale: Math.max(0.3, Math.min(3, s.scale + delta)) } }) const checked = checkOverlap(next) setStickers(checked)