vant/v3/assets/index.c717f3a8.js
2024-04-20 08:49:23 +00:00

3 lines
7.0 KiB
JavaScript

import{c as M,i as U,W as j,R as q,r as z,a as Q}from"./use-translate.d2900b8c.js";import{t as D,b as H,m as S,c as X,w as N,d as ee,a as I}from"./with-install.19a35764.js";import{C as oe}from"./index.bbd81525.js";import{z as _,e as o,D as m,C as g,u as F,N as ne,j as te,v as ae,q as se,r as ue,o as ce,c as le,w as G,B as C}from"./vue-libs.b44bc779.js";import{V as ie}from"./index.e6e790ed.js";import{u as re}from"./use-refs.b3168e03.js";import{T as de,a as O}from"./index.29a2ad88.js";import{E as me}from"./index.59330ba3.js";import{F as pe}from"./index.da0ad0e1.js";import{B as W}from"./index.8e37fe56.js";import{C as he}from"./index.af271955.js";import{T as ge}from"./function-call.509e41a7.js";import"./use-route.82f2be69.js";import"./index.b70c9b40.js";import"./constant.80c6de18.js";import"./interceptor.f0c85874.js";import"./use-expose.c942d5f8.js";import"./use-touch.04ca7093.js";import"./use-lazy-render.f712e85e.js";import"./on-popup-reopen.138c77eb.js";import"./index.d46e53a8.js";import"./use-id.46df47b7.js";import"./index.1461a543.js";import"./index.99afab90.js";import"./index.4e4daaac.js";import"./Checker.862ecffc.js";import"./mount-component.f3744995.js";const[ve,Y,R]=M("coupon-cell"),Ce={title:String,border:D,editable:D,coupons:H(),currency:S("\xA5"),chosenCoupon:X(-1)};function be({coupons:e,chosenCoupon:t,currency:l}){const s=e[+t];if(s){let n=0;return U(s.value)?{value:n}=s:U(s.denominations)&&(n=s.denominations),`-${l} ${(n/100).toFixed(2)}`}return e.length===0?R("noCoupon"):R("count",e.length)}const fe=_({name:ve,props:Ce,setup(e){return()=>{const t=e.coupons[+e.chosenCoupon];return o(oe,{class:Y(),value:be(e),title:e.title||R("title"),border:e.border,isLink:e.editable,valueClass:Y("value",{selected:t})},null)}}}),xe=N(fe),Be=xe;function Z(e){const t=new Date(e*1e3);return`${t.getFullYear()}.${j(t.getMonth()+1)}.${j(t.getDate())}`}const we=e=>(e/10).toFixed(e%10===0?0:1),J=e=>(e/100).toFixed(e%100===0?0:e%10===0?1:2),[ye,r,V]=M("coupon"),De=_({name:ye,props:{chosen:Boolean,coupon:ee(Object),disabled:Boolean,currency:S("\xA5")},setup(e){const t=m(()=>{const{startAt:n,endAt:u}=e.coupon;return`${Z(n)} - ${Z(u)}`}),l=m(()=>{const{coupon:n,currency:u}=e;if(n.valueDesc)return[n.valueDesc,o("span",null,[n.unitDesc||""])];if(n.denominations){const c=J(n.denominations);return[o("span",null,[u]),` ${c}`]}return n.discount?V("discount",we(n.discount)):""}),s=m(()=>{const n=J(e.coupon.originCondition||0);return n==="0"?V("unlimited"):V("condition",n)});return()=>{const{chosen:n,coupon:u,disabled:c}=e,h=c&&u.reason||u.description;return o("div",{class:r({disabled:c})},[o("div",{class:r("content")},[o("div",{class:r("head")},[o("h2",{class:r("amount")},[l.value]),o("p",{class:r("condition")},[u.condition||s.value])]),o("div",{class:r("body")},[o("p",{class:r("name")},[u.name]),o("p",{class:r("valid")},[t.value]),!c&&o(he,{class:r("corner"),modelValue:n},null)])]),h&&o("p",{class:r("description")},[h])])}}}),K=N(De),[Te,d,x]=M("coupon-list"),ke={code:S(""),coupons:H(),currency:S("\xA5"),showCount:D,emptyImage:String,chosenCoupon:I(-1),enabledTitle:String,disabledTitle:String,disabledCoupons:H(),showExchangeBar:D,showCloseButton:D,closeButtonText:String,inputPlaceholder:String,exchangeMinLength:I(1),exchangeButtonText:String,displayedCouponIndex:I(-1),exchangeButtonLoading:Boolean,exchangeButtonDisabled:Boolean},Ee=_({name:Te,props:ke,emits:["change","exchange","update:code"],setup(e,{emit:t,slots:l}){const[s,n]=re(),u=g(),c=g(),h=g(0),B=g(0),i=g(e.code),T=m(()=>!e.exchangeButtonLoading&&(e.exchangeButtonDisabled||!i.value||i.value.length<e.exchangeMinLength)),k=()=>{const p=z(u).height,f=z(c).height+44;B.value=(p>f?p:q.value)-f},L=()=>{t("exchange",i.value),e.code||(i.value="")},E=a=>{se(()=>{var p;return(p=s.value[a])==null?void 0:p.scrollIntoView()})},v=()=>o(me,{image:e.emptyImage},{default:()=>[o("p",{class:d("empty-tip")},[x("noCoupon")])]}),b=()=>{if(e.showExchangeBar)return o("div",{ref:c,class:d("exchange-bar")},[o(pe,{modelValue:i.value,"onUpdate:modelValue":a=>i.value=a,clearable:!0,border:!1,class:d("field"),placeholder:e.inputPlaceholder||x("placeholder"),maxlength:"20"},null),o(W,{plain:!0,type:"danger",class:d("exchange"),text:e.exchangeButtonText||x("exchange"),loading:e.exchangeButtonLoading,disabled:T.value,onClick:L},null)])},P=()=>{const{coupons:a}=e,p=e.showCount?` (${a.length})`:"",f=(e.enabledTitle||x("enable"))+p;return o(O,{title:f},{default:()=>{var w;return[o("div",{class:d("list",{"with-bottom":e.showCloseButton}),style:{height:`${B.value}px`}},[a.map((y,A)=>o(K,{key:y.id,ref:n(A),coupon:y,chosen:A===e.chosenCoupon,currency:e.currency,onClick:()=>t("change",A)},null)),!a.length&&v(),(w=l["list-footer"])==null?void 0:w.call(l)])]}})},$=()=>{const{disabledCoupons:a}=e,p=e.showCount?` (${a.length})`:"",f=(e.disabledTitle||x("disabled"))+p;return o(O,{title:f},{default:()=>{var w;return[o("div",{class:d("list",{"with-bottom":e.showCloseButton}),style:{height:`${B.value}px`}},[a.map(y=>o(K,{disabled:!0,key:y.id,coupon:y,currency:e.currency},null)),!a.length&&v(),(w=l["disabled-list-footer"])==null?void 0:w.call(l)])]}})};return F(()=>e.code,a=>{i.value=a}),F(q,k),F(i,a=>t("update:code",a)),F(()=>e.displayedCouponIndex,E),ne(()=>{k(),E(e.displayedCouponIndex)}),()=>o("div",{ref:u,class:d()},[b(),o(de,{active:h.value,"onUpdate:active":a=>h.value=a,class:d("tab")},{default:()=>[P(),$()]}),o("div",{class:d("bottom")},[te(o(W,{round:!0,block:!0,type:"danger",class:d("close"),text:e.closeButtonText||x("close"),onClick:()=>t("change",-1)},null),[[ae,e.showCloseButton]])])])}}),$e=N(Ee),Fe=$e,to=_({__name:"index",setup(e){const t=Q({"zh-CN":{coupon:{name:"\u4F18\u60E0\u5238\u540D\u79F0",reason:"\u4F18\u60E0\u5238\u4E0D\u53EF\u7528\u539F\u56E0",description:"\u63CF\u8FF0\u4FE1\u606F"},exchange:"\u5151\u6362\u6210\u529F"},"en-US":{coupon:{name:"Coupon name",reason:"Coupon unavailable reason",description:"Description"},exchange:"Success"}}),l=(v=999999)=>String(Math.floor(Math.random()*v)+1),s=g(!1),n=g(-1),u=g([]),c=m(()=>({id:1,condition:`\u65E0\u95E8\u69DB
\u6700\u591A\u4F18\u60E012\u5143`,reason:"",value:150,name:t("coupon.name"),description:t("coupon.description"),startAt:1489104e3,endAt:1514592e3,valueDesc:"1.5",unitDesc:"\u5143"})),h=m(()=>({...c.value,id:2,value:12,valueDesc:"8.8",unitDesc:"\u6298"})),B=m(()=>({...c.value,id:3,reason:t("coupon.reason")})),i=m(()=>({...h.value,valueDesc:"1",unitDesc:"\u6298",id:4,reason:t("coupon.reason")})),T=m(()=>[c.value,h.value,...u.value]),k=m(()=>[B.value,i.value]),L=v=>{s.value=!1,n.value=v},E=()=>{ge(t("exchange")),u.value.push({...c.value,id:l()})};return(v,b)=>{const P=ue("demo-block");return ce(),le(P,{title:C(t)("basicUsage")},{default:G(()=>[o(C(Be),{coupons:C(T),"chosen-coupon":n.value,onClick:b[0]||(b[0]=$=>s.value=!0)},null,8,["coupons","chosen-coupon"]),o(C(ie),{show:s.value,"onUpdate:show":b[1]||(b[1]=$=>s.value=$),round:"",position:"bottom",style:{height:"90%","padding-top":"4px"}},{default:G(()=>[o(C(Fe),{coupons:C(T),"chosen-coupon":n.value,"disabled-coupons":C(k),onChange:L,onExchange:E},null,8,["coupons","chosen-coupon","disabled-coupons"])]),_:1},8,["show"])]),_:1},8,["title"])}}});export{to as default};