cashier-mer/dist/assets/index-D2shyUWD.js

2 lines
10 KiB
JavaScript

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