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