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