import{c as W,a as X,b as B,d as Y,p as Z,o as ee}from"./pay-lz1-aziY.js";import{_ as U,r as u,a as _,o as g,c as q,w as y,b as e,d as n,e as v,t as V,f as C,F as O,g as M,h as j,i as te,j as G,k as J,p as K,l as T,m as oe,n as se,u as ae}from"./index-Cpj04_tS.js";import{p as le}from"./padding-CUL9ZbA7.js";import{g as ne,s as ce}from"./shop-CWcaSfoY.js";const ie={class:"price"},re={class:"flex"},ue={style:{margin:"10px","padding-bottom":"40px"}},de={style:{color:"#f5222d","font-weight":"bold","margin-left":"1rem"}},_e={class:"dialog-footer"},pe={__name:"price",emits:["submit"],setup(w,{expose:x,emit:m}){const s=u(!1),r=u(0),o=(b,p=0)=>{s.value=b,r.value=p},c=u({nowPrice:"",percentage:""}),h=b=>{c.value.percentage=(b/r.value*100).toFixed(2)},$=b=>{c.value.nowPrice=(r.value*b/100).toFixed(2)},k=m,S=()=>{k("submit",c.value.nowPrice),s.value=!1};return x({show:o}),(b,p)=>{const A=_("el-input"),f=_("el-button"),I=_("el-dialog");return g(),q(I,{modelValue:s.value,"onUpdate:modelValue":p[2]||(p[2]=a=>s.value=a),title:"订单改价",width:"650"},{footer:y(()=>[e("div",_e,[n(f,{class:"ok-btn",type:"primary",onClick:S},{default:y(()=>[v(" 确定 ")]),_:1})])]),default:y(()=>[e("div",ie,[e("div",re,[n(A,{style:{flex:"3",margin:"10px",height:"2.5rem"},modelValue:c.value.nowPrice,"onUpdate:modelValue":p[0]||(p[0]=a=>c.value.nowPrice=a),placeholder:"请输入改价后的价格",onInput:h},{suffix:y(()=>[v("元")]),_:1},8,["modelValue"]),n(A,{style:{flex:"2",margin:"10px",height:"2.5rem"},modelValue:c.value.percentage,"onUpdate:modelValue":p[1]||(p[1]=a=>c.value.percentage=a),placeholder:"请输入比例",onInput:$},{suffix:y(()=>[v("%")]),_:1},8,["modelValue"])]),e("div",ue,[v("改价后金额: "),e("span",de,"¥"+V(c.value.nowPrice||r.value||" - - "),1)])])]),_:1},8,["modelValue"])}}},ve=U(pe,[["__scopeId","data-v-518d9bc5"]]),me={class:"my-order"},he={class:"header-nav"},fe={class:"nav-item"},ge={class:"order-list"},ye={class:"order-item-info"},ke={class:"order-item-title"},be={class:"title"},$e=["onClick"],we={class:"order-item-sku"},xe=["onClick"],Ie={class:"order-item-price"},Ve={class:"order-footer"},Ce={class:"order-total"},Ae={class:"price"},Pe={class:"total-item"},Se={style:{"font-size":"1.4rem"}},Le={class:"total-item"},Fe={class:"update-price"},De={class:"order-btn"},Re={__name:"order",emits:["goPay","editAttr"],setup(w,{expose:x,emit:m}){const s=u([]),r=u(0),o=u(0),c=()=>{let l=[];s.value.map(t=>{l.push(t.cart_id)}),l.length!=0&&$(l)},h=l=>{s.value=s.value.filter(t=>t.cart_id!=l),$([l])},$=l=>{W({cart_id:l}).then(t=>{console.log(t),k()})},k=()=>{r.value=0,o.value=0,X({source:300}).then(l=>{var t,i;((i=(t=l.data)==null?void 0:t.list)==null?void 0:i.length)>0?(s.value=l.data.list[0].list,s.value.forEach(d=>{r.value+=d.productAttr.price*d.cart_num})):s.value=[]})};k();const S=m,b=()=>{S("goPay")},p=(l,t)=>{B(l.cart_id,{cart_num:l.cart_num}).then(i=>{r.value=0,s.value.forEach(d=>{r.value+=d.productAttr.price*d.cart_num})})},A=l=>{S("editPupop",l)},f=(l,t)=>{B(l,t).then(i=>{k()})},I=l=>{o.value=r.value-l,r.value=+l};u(0);const a=u(null),D=()=>{a.value.show(!0,r.value)};return x({getList:k,list:s,editItem:f,discounts:o,allPrice:r}),(l,t)=>{const i=_("Delete"),d=_("el-icon"),F=_("el-empty"),R=_("el-image"),L=_("ArrowDown"),E=_("el-input-number"),N=_("el-button");return g(),C("div",me,[e("div",he,[e("div",fe,[v(" 已选购 "),e("span",null,V(s.value.length),1),v(" 件 ")]),e("div",{class:"nav-item-clear",onClick:c},[n(d,null,{default:y(()=>[n(i)]),_:1}),v("清空 ")])]),e("div",ge,[s.value.length==0?(g(),q(F,{key:0,description:"请点击右侧添加商品"})):(g(!0),C(O,{key:1},M(s.value,(P,Q)=>(g(),C("div",{class:"order-item",key:Q},[n(R,{loading:"lazy",class:"order-item-img",src:P.productAttr&&P.productAttr.image||P.product.image},null,8,["src"]),e("div",ye,[e("div",ke,[e("div",be,V(P.spu.store_name),1),e("div",{class:"delete",onClick:z=>h(P.cart_id)},"删除",8,$e)]),e("div",we,[e("span",{style:{display:"flex","align-items":"center"},onClick:z=>A(P)},[v("商品规格: "+V(P.productAttr.sku||"默认规格"),1),n(d,{size:"16",style:{"margin-left":"0.2rem"}},{default:y(()=>[n(L)]),_:1})],8,xe)]),e("div",Ie,[e("div",null,[v(" ¥"),e("span",null,V(P.productAttr.price),1)]),e("div",null,[n(E,{modelValue:P.cart_num,"onUpdate:modelValue":z=>P.cart_num=z,"step-strictly":"",min:1,step:1,onChange:z=>p(P)},null,8,["modelValue","onUpdate:modelValue","onChange"])])])])]))),128))]),e("div",Ve,[e("div",Ce,[e("div",Ae,[e("div",Pe,[v(" 实付: "),e("span",null,[v("¥"),e("span",Se,V(r.value.toFixed(2)),1)])]),e("div",Le,[v(" 优惠: "),e("span",null,[v("¥"),e("span",null,V(o.value.toFixed(2)),1)])])]),e("div",Fe,[n(N,{class:"btn",type:"primary",onClick:D},{default:y(()=>[v("改价")]),_:1})])]),e("div",De,[n(N,{class:"btn",type:"primary",onClick:b,disabled:s.value.length==0},{default:y(()=>[v("立即结账")]),_:1},8,["disabled"])])]),n(ve,{ref_key:"priceRef",ref:a,onSubmit:I},null,512)])}}},ze=U(Re,[["__scopeId","data-v-19078e04"]]),H=w=>(K("data-v-f3cb5c55"),w=w(),T(),w),Ue={class:"my-order"},Ee={class:"header-nav"},Ne=H(()=>e("div",{class:"nav-item-label"},"搜索",-1)),qe={class:"nav-item-input"},Oe={class:"shop-list","infinite-scroll-distance":"100","infinite-scroll-delay":"500",style:{overflow:"auto"}},Me=["onClick"],Be={class:"shop-name"},je={class:"shop-price"},Ge={key:0,class:"no-stock"},Je=H(()=>e("div",null,[e("span",null,"暂无"),e("span",null,"库存")],-1)),Ke=[Je],Te={__name:"shop",props:{storeList:{type:Array,default:()=>[]}},emits:["getStoreList","changeItem","loadMore"],setup(w,{emit:x}){const m=x,s=u(""),r=()=>{m("loadMore",{bar_code:s.value})},o=h=>{m("changeItem",h)},c=()=>{m("getStoreList",{bar_code:s.value})};return(h,$)=>{const k=_("el-input"),S=_("Search"),b=_("el-icon"),p=_("el-button"),A=_("el-image"),f=_("el-space"),I=j("infinite-scroll");return g(),C("div",Ue,[e("div",Ee,[Ne,e("div",qe,[n(k,{modelValue:s.value,"onUpdate:modelValue":$[0]||($[0]=a=>s.value=a),placeholder:"搜索商品名称/ID/唯一码或点击聚焦扫码",clearable:"",onKeyup:te(c,["enter"])},null,8,["modelValue"])]),e("div",{class:"nav-item-btn",onClick:c},[n(p,{class:"btn",type:"primary"},{default:y(()=>[n(b,null,{default:y(()=>[n(S)]),_:1})]),_:1})])]),G((g(),C("div",Oe,[n(f,{wrap:"",size:20},{default:y(()=>[(g(!0),C(O,null,M(w.storeList,(a,D)=>(g(),C("div",{class:"shop-item",key:D,onClick:l=>o(a)},[n(A,{loading:"lazy",src:a.image},null,8,["src"]),e("div",Be,V(a.store_name),1),e("div",je,[v(" ¥"),e("span",null,V(a.price),1)]),a.stock==0?(g(),C("div",Ge,Ke)):J("",!0)],8,Me))),128))]),_:1})])),[[I,r]])])}}},He=U(Te,[["__scopeId","data-v-f3cb5c55"]]),Qe=w=>(K("data-v-9ba07525"),w=w(),T(),w),We={class:"shop"},Xe={key:0,class:"shop-info"},Ye={class:"shop-info-left"},Ze={class:"shop-info-right"},et={class:"shop-info-right-top"},tt={class:"shop-info-right-center"},ot={class:"shop-info-right-price"},st={class:"shop-sku"},at=Qe(()=>e("div",{class:"title"},"产品",-1)),lt={class:"sku"},nt=["onClick"],ct={class:"dialog-footer"},it={__name:"pupop",emits:["changeItem"],setup(w,{expose:x,emit:m}){const s=u(!1),r=f=>{s.value=f},o=u({}),c=u(null),h=u(!1),$=u("add"),k=u({}),S=(f,I="add")=>{$.value=I,I=="add"?(o.value=f,c.value=f.attr[0]):(h.value=!0,k.value=f,ne(f.product_id).then(a=>{a.data.attrValue=JSON.parse(JSON.stringify(a.data.attr)),a.data.attr=Object.keys(a.data.sku),o.value=a.data,c.value=a.data.attr[0],h.value=!1}).catch(a=>{h.value=!1}))},b=m,p=()=>{$.value=="add"?b("changeItem",o.value,c.value):b("editItem",k.value.cart_id,{cart_num:k.value.cart_num,product_attr_unique:o.value.sku[c.value].unique}),s.value=!1},A=f=>{c.value=f};return x({show:r,setForm:S}),(f,I)=>{const a=_("el-image"),D=_("el-space"),l=_("el-button"),t=_("el-dialog"),i=j("loading");return g(),q(t,{modelValue:s.value,"onUpdate:modelValue":I[0]||(I[0]=d=>s.value=d),title:"商品规格",width:"650"},oe({default:y(()=>{var d,F,R;return[G((g(),C("div",We,[o.value.sku?(g(),C("div",Xe,[e("div",Ye,[n(a,{loading:"lazy",src:((d=o.value.sku[c.value])==null?void 0:d.image)||o.value.image},null,8,["src"])]),e("div",Ze,[e("div",et,V(o.value.store_name),1),e("div",tt,"库存"+V(((F=o.value.sku[c.value])==null?void 0:F.stock)||0),1),e("div",ot,[v("¥"),e("span",null,V(((R=o.value.sku[c.value])==null?void 0:R.price)||o.value.price),1)])])])):J("",!0),e("div",st,[at,e("div",lt,[n(D,{wrap:"",size:20},{default:y(()=>[(g(!0),C(O,null,M(o.value.attr,(L,E)=>(g(),C("div",{class:se(["sku-item",{"sku-item_active":c.value==L}]),onClick:N=>A(L),key:E},V(L||"默认规格"),11,nt))),128))]),_:1})])])])),[[i,h.value]])]}),_:2},[$.value!="add"&&o.value.attr&&o.value.attr.length==1?void 0:{name:"footer",fn:y(()=>[e("div",ct,[n(l,{class:"ok-btn",type:"primary",onClick:p},{default:y(()=>[v(" 确定 ")]),_:1})])]),key:"0"}]),1032,["modelValue"])}}},rt=U(it,[["__scopeId","data-v-9ba07525"]]),ut={class:"my-card"},mt={__name:"index",setup(w){const x=u(null),m=u(null),s=u(null),r=u(null),o=u([]),c=ae(),h=u({page:0,limit:30}),$=t=>{h.value={source:300,...h.value,...t},ce(c.userInfo.service.mer_id,h.value).then(i=>{var F,R;((R=(F=i.data)==null?void 0:F.list)==null?void 0:R.length)(L.attr=Object.keys(L.sku),L));o.value=o.value.concat(d),t.bar_code&&o.value.length==1&&b(t.bar_code)&&p(o.value[0],o.value[0].attr[0])})},k=u(!1),S=t=>{k.value||(h.value.page++,$(t))};function b(t){return/^\d+$/.test(t)}const p=(t,i="")=>{let d={is_new:0,product_id:t.product_id,cart_num:1,product_attr_unique:t.sku[i]!==void 0?t.sku[i].unique:"",source:300,product_type:0};Y(d).then(F=>{m.value.getList()})},A=(t,i)=>{if(!t.attr||t.attr.length==0||t.attr.length==1)return p(t,t.attr[0]?t.attr[0]:"");if(i)return p(t,i);x.value.setForm(t,"add"),x.value.show(!0)},f=(t,i)=>{m.value.editItem(t,i)},I=t=>{x.value.setForm(t,"edit"),x.value.show(!0)},a=()=>{let t=m.value.list.map(d=>d.cart_id),i={takes:[],use_coupon:{},use_integral:!1,cart_id:t};m.value.discounts>0&&(i.deduction_price=m.value.discounts.toFixed(2),i.pay_type="micropay"),ee(i).then(d=>{r.value.setForm({data:d.data,cart_id:t})})},D=()=>{a(),r.value.drawer=!0},l=()=>{m.value.getList()};return(t,i)=>(g(),C("div",ut,[n(ze,{ref_key:"orderRef",ref:m,onGoPay:D,onEditPupop:I},null,512),n(le),n(He,{ref_key:"shopRef",ref:s,style:{flex:"1"},storeList:o.value,onGetStoreList:$,onChangeItem:A,onLoadMore:S},null,8,["storeList"]),n(rt,{ref_key:"pupopRef",ref:x,onChangeItem:A,onEditItem:f},null,512),n(Z,{ref_key:"payRef",ref:r,onPaySuccess:l},null,512)]))}};export{mt as default};