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