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