cashier-mer/build/assets/index-XOXGnPgL.js

2 lines
10 KiB
JavaScript

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