"use strict";(wx.webpackJsonp=wx.webpackJsonp||[]).push([[5541],{4722:function(e,n,t){var c=t(4165),a=t(4942),s=t(1413),r=t(5861),l=t(9439),o=t(1515),u=t(2954),i=t.n(u),f=t(4184),d=t.n(f),h=t(7294),m=t(515),Z=t(2930),p=t(9714),_=t(6714),x=t(209),v=t(5679),g=t(4508),j=t(2711),N=t(1115),w=t(9612),C=t(4158),b=t(2890),k=t(8093),S=t(8106),G=t(4126),D=t(9194),E=t(7380),y=t(4408),T=t(5893);n.Z=function ShopCart(e){var n=e.show,t=void 0!==n&&n,u=e.onClose,f=e.intoStatus,M=void 0===f?"shop":f,O=e.default_sale_mode,I=[{value:0,title:"大货",unit:"条",eunit:"kg",step:1,digits:0,minNum:1,maxNum:1e5,defaultNum:1},{value:1,title:"剪板",unit:"米",eunit:"m",step:1,digits:2,minNum:.3,maxNum:1e5,defaultNum:.3},{value:2,title:"散剪",unit:"米",eunit:"kg",step:1,digits:2,minNum:3,maxNum:1e5,defaultNum:3}],$=(0,D.v)((function(e){return e.userInfo})),L=(0,h.useRef)(null),P=(0,h.useTransition)(),F=(0,l.Z)(P,2),U=F[0],z=F[1],A=(0,h.useState)(O||0),J=(0,l.Z)(A,2),R=J[0],B=J[1];(0,h.useEffect)((function(){U||B((function(){return O}))}),[O]);var K=(0,G.Z)().getShopCount,q=(0,h.useState)({}),H=(0,l.Z)(q,2),Q=H[0],V=H[1],W=(0,h.useState)(!1),X=(0,l.Z)(W,2),Y=X[0],ee=X[1],ne=(0,w.Lb)().fetchData,te=function(){var e=(0,r.Z)((0,c.Z)().mark((function _callee(e){var n,t,r;return(0,c.Z)().wrap((function _callee$(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,ne({id:e.id});case 2:(n=c.sent).success&&(t=n.data.color_list[0],r=(0,s.Z)((0,s.Z)({},e),{},{estimate_amount:t.estimate_amount,estimate_weight:t.estimate_weight,lab:t.lab,roll:t.roll,length:t.length,sale_offset:t.sale_offset,sale_price:t.sale_price,standard_price:t.standard_price}),V((function(n){return(0,s.Z)((0,s.Z)({},n),{},(0,a.Z)({},e.id,r))})));case 4:case"end":return c.stop()}}),_callee)})));return function getShoppingCartInfo(n){return e.apply(this,arguments)}}(),ce=(0,h.useMemo)((function(){return Object.values(Q)}),[Q]),ae=function initList(e){var n={};null==e||e.forEach((function(e){e.selected=R==e.sale_mode;var t=I[e.sale_mode],c=t.unit,a=t.eunit,r=t.step,l=t.digits,o=t.minNum,u=t.maxNum;e=(0,s.Z)((0,s.Z)({},e),{},{unit:c,eunit:a,step:r,digits:l,minNum:o,maxNum:u}),n[e.id]=e})),V((function(){return(0,s.Z)({},n)}))},se=function(){var e=(0,r.Z)((0,c.Z)().mark((function _callee2(){var e,n,t;return(0,c.Z)().wrap((function _callee2$(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,ne();case 2:e=c.sent,n=e.data,t=n.color_list||[],ae(t),ee(!1);case 7:case"end":return c.stop()}}),_callee2)})));return function getShoppingCart(){return e.apply(this,arguments)}}();(0,h.useEffect)((function(){var e;t?(ee(!0),se(),null===(e=L.current)||void 0===e||e.handleChange(!1)):(V({}),B(O||0))}),[t]);var re=(0,h.useState)(!1),le=(0,l.Z)(re,2),oe=le[0],ue=le[1];(0,h.useEffect)((function(){ue(t)}),[t]);var ie=(0,h.useState)(!1),fe=(0,l.Z)(ie,2),de=fe[0],he=fe[1];(0,h.useEffect)((function(){var e,n=0,t=0;null===(e=Object.values(Q))||void 0===e||e.forEach((function(e){R==e.sale_mode&&(n++,e.selected&&t++)})),he(t==n)}),[Q]);var me=(0,w.au)().fetchData,Ze=(0,k.Ds)(function(){var e=(0,r.Z)((0,c.Z)().mark((function _callee3(e){return(0,c.Z)().wrap((function _callee3$(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,me({id:e.id,roll:e.roll,length:e.length});case 2:n.sent.success?(console.log("item修改::",e),te(e)):V((function(e){return(0,s.Z)({},e)}));case 4:case"end":return n.stop()}}),_callee3)})));return function(n){return e.apply(this,arguments)}}(),300),pe=(0,h.useCallback)((function(e){Ze(e)}),[]),_e=(0,h.useCallback)((function(e){V((function(n){return(0,s.Z)((0,s.Z)({},n),{},(0,a.Z)({},e.id,(0,s.Z)({},e)))}))}),[]),xe=function closePopup(){null==u||u(),ue(!1)},ve=(0,h.useRef)([]),ge=function getSelectId(){var e;ve.current=[],null===(e=Object.values(Q))||void 0===e||e.forEach((function(e){R==e.sale_mode&&e.selected&&ve.current.push(e.id)}))},je=(0,w.Lf)().fetchData,Ne=(0,h.useMemo)((function(){var e,n=0,t=new Set,c=0,a=0;null===(e=Object.values(Q))||void 0===e||e.forEach((function(e){e.selected&&(n+=e.estimate_amount,t.add(e.product_id),c++,a+=0==e.sale_mode?parseFloat(e.roll):parseFloat(e.length))}));var s=0==R?"".concat(a," 条"):"".concat(a/100," 米");return console.log("text::",Q),{price:Number((0,C.yb)(n)).toFixed(2),countText:"已选 ".concat(t.size," 种面料,").concat(c," 个颜色,共 ").concat(s),color_count:c}}),[Q]),we=(0,h.useState)(!1),Ce=(0,l.Z)(we,2),be=Ce[0],ke=Ce[1],Se=function handleClose(){ke(!1)},Ge=(0,S.K9)().fetchData,De=(0,S.Dd)().fetchData,Ee=(0,k.P2)((0,r.Z)((0,c.Z)().mark((function _callee5(){var e,n,t;return(0,c.Z)().wrap((function _callee5$(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,Ge();case 2:if(3===(e=c.sent).data.order_access_status){c.next=8;break}return 1==e.data.order_access_status&&De(),null===(n=L.current)||void 0===n||n.handleChange(!0),null==u||u(),c.abrupt("return");case 8:if(!$.adminUserInfo.first_change_name){c.next=11;break}return ke(!0),c.abrupt("return");case 11:ge(),0==ve.current.length?N.Z9.error("请选择面料"):(t=ve.current.join("-"),(0,b.t4)({ids:t,sale_mode:R}),xe(),"again"==M?(0,N.jD)("/pages/order/comfirm",null,"redirectTo"):(0,N.jD)("/pages/order/comfirm"));case 13:case"end":return c.stop()}}),_callee5)}))),500),ye=(0,h.useState)(!1),Te=(0,l.Z)(ye,2),Me=Te[0],Oe=Te[1],Ie=(0,h.useState)(),$e=(0,l.Z)(Ie,2),Le=$e[0],Pe=$e[1],Fe=((0,h.useCallback)((function(e){Oe((function(){return!0})),Pe(e)}),[]),(0,h.useCallback)((function(){Oe((function(){return!1}))}),[])),Ue=(0,h.useCallback)((function(){null==u||u(),(0,N.jD)("/pages/index/index",null,"switchTab")}),[]);(0,h.useEffect)((function(){z((function(){!function resetList(){var e;null===(e=Object.values(Q))||void 0===e||e.forEach((function(e){R==e.sale_mode?e.selected=!0:e.selected=!1,Q[e.id]=(0,s.Z)({},e)})),V((function(){return(0,s.Z)({},Q)}))}(),he(!0)}))}),[R]);var ze=(0,y.Z)().getAdminUserInfo,Ae=(0,E.h)().fetchData,Je=(0,E.S)().fetchData,Re=function(){var e=(0,r.Z)((0,c.Z)().mark((function _callee6(e){var n,t;return(0,c.Z)().wrap((function _callee6$(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,Je();case 2:return n=c.sent,c.next=5,Ae((0,s.Z)((0,s.Z)({},n.data),{},{company_name:e}));case 5:(t=c.sent).success?(ze(),Se(),N.Z9.success("保存成功")):N.Z9.none(t.msg);case 7:case"end":return c.stop()}}),_callee6)})));return function handleOrganizationNameModalConfirm(n){return e.apply(this,arguments)}}();return(0,T.jsxs)(o.G7,{className:_.Z.shop_cart_main,children:[(0,T.jsx)(v.Z,{showTitle:!1,show:oe,onClose:function onClose(){return xe()},children:(0,T.jsxs)(o.G7,{className:_.Z.popup_con,children:[(0,T.jsxs)(o.G7,{className:_.Z.header,children:[(0,T.jsx)(o.G7,{onClick:function selectAll(){var e;null===(e=Object.values(Q))||void 0===e||e.forEach((function(e){R==e.sale_mode&&(e.selected=!de,Q[e.id]=(0,s.Z)({},e))})),V((function(){return(0,s.Z)({},Q)})),he(!de)},children:de?"反选":"全选"}),(0,T.jsxs)(o.G7,{onClick:function delSelect(){if(ge(),ve.current.length<=0)return N.Z9.none("请选择要删除的面料!");i().showModal({content:"删除所选商品?",success:function success(e){return(0,r.Z)((0,c.Z)().mark((function _callee4(){var n;return(0,c.Z)().wrap((function _callee4$(t){for(;;)switch(t.prev=t.next){case 0:if(!e.confirm){t.next=7;break}return t.next=3,je({id:ve.current});case 3:(n=t.sent).success?(se(),K(),i().showToast({title:"成功",icon:"success"})):i().showToast({title:n.msg,icon:"none"}),t.next=8;break;case 7:e.cancel&&console.log("用户点击取消");case 8:case"end":return t.stop()}}),_callee4)})))()}})},children:[(0,T.jsx)("text",{className:d()("iconfont","icon-shanchu",_.Z.miconfont)}),"删除所选"]})]}),(0,T.jsx)(o.G7,{className:_.Z.count_all,children:Ne.countText}),(0,T.jsx)(o.G7,{className:_.Z.search,children:I.map((function(e){return(0,T.jsx)(o.G7,{onClick:function onClick(){return function selectProduct(e){B(e)}(e.value)},className:d()(_.Z.search_item,R==e.value&&_.Z.search_item_select),children:e.title},e.value)}))}),(0,T.jsxs)(o.G7,{className:_.Z.con,children:[(Y||U)&&(0,T.jsx)(g.Z,{}),!Y&&!U&&(null==ce?void 0:ce.length)>0&&(0,T.jsx)(j.Z,{moreStatus:!1,children:(0,T.jsx)(o.G7,{className:_.Z.product_list,children:null==ce?void 0:ce.map((function(e){return(0,T.jsx)(x.Z,{sale_model:R,onChangeCount:pe,onChangeSelect:_e,item:e},e.id)}))})}),!Y&&0==(null==ce?void 0:ce.length)&&(0,T.jsxs)(o.G7,{className:_.Z.empty,children:[(0,T.jsx)(o.G7,{className:_.Z.title,children:"暂未选择商品"}),(0,T.jsx)(o.G7,{className:_.Z.btn,onClick:Ue,children:"去选购"})]})]}),(0,T.jsx)(o.G7,{className:_.Z.buy_btn,children:(0,T.jsxs)(o.G7,{className:_.Z.buy_con,children:[(0,T.jsx)(o.G7,{className:_.Z.icon,children:(0,T.jsx)(o.G7,{className:d()("iconfont","icon-gouwuche",_.Z.miconfont)})}),(0,T.jsxs)(o.G7,{className:_.Z.price_con,children:[(0,T.jsxs)(o.G7,{className:_.Z.price_real,children:[(0,T.jsx)(o.xv,{children:"¥"}),Ne.price]}),(0,T.jsx)(o.G7,{className:_.Z.price_forecast,children:"预估金额"})]}),(0,T.jsxs)(o.G7,{className:_.Z.goPay,onClick:function onClick(){return Ee()},children:["去结算(",Ne.color_count,")"]})]})})]})}),(0,T.jsx)(o.G7,{children:(0,T.jsx)(m.Z,{ref:L,onSuccess:function handleBindSalesManSuccess(){$.adminUserInfo.first_change_name&&ke(!0)}})}),(0,T.jsx)(o.G7,{children:(0,T.jsx)(Z.Z,{value:Le,show:Me,onClose:Fe})}),(0,T.jsx)(p.Z,{showModal:be,onClose:Se,onShowModalChange:function handleShowChange(e){ke(e)},onConfirm:Re})]})}}}]);