import{r as e,c as a,o as s,n as t,b as l,d as o,e as u,f as c,w as r,g as n,h as i,i as d,F as p,k as f,p as _,z as m,l as y,G as v,v as g,A as h,j as k,y as x}from"./index-DVkgSHpn.js";import{_ as j}from"./el-navbar.DVIyjZEN.js";import{_ as w}from"./el-refresh.CkIPFmzm.js";import{_ as b,a as P}from"./el-layout._U-vZTft.js";import"./el-empty.CMLN1lgh.js";import"./el-loading-icon.Bh3RKCou.js";const $=b({__name:"index",setup(b){const $=e(),H=e(0),T=e([]),C=async()=>{var e;null==(e=$.value)||e.resetPage()},R=a((()=>{const{windowHeight:e}=f();return e-H.value}));s((()=>{t((()=>{C()}))}));const S=()=>{C()},z=e=>{$.value.isMore()&&($.value.loadingPage(),setTimeout((()=>{uni.$http.get("coupon/index",{page:e.page}).then((a=>{1==a.code?(1==e.page&&(T.value=[]),$.value.setData(a.data.total,a.data.list.length),T.value=T.value.concat(a.data.list)):-1==a.code&&$.value.emptyPage()}))}),100))};return(e,a)=>{const s=l(o("el-navbar"),j),t=_,f=x,b=l(o("el-refresh"),w),C=l(o("el-layout"),P);return u(),c(C,null,{default:r((()=>[n(s,{top:H.value,"onUpdate:top":a[0]||(a[0]=e=>H.value=e),placeholder:!0,fixed:!0,border:!1,title:"优惠券中心"},null,8,["top"]),n(b,{ref_key:"refreshRef",ref:$,onRefresh:S,onScrolltolower:z,scrollHeight:R.value},{default:r((()=>[n(t,{class:"wrapper"},{default:r((()=>[n(t,{class:"coupon-list"},{default:r((()=>[(u(!0),i(p,null,d(T.value,((e,a)=>(u(),c(t,{class:"coupon-item",key:a},{default:r((()=>[n(t,{class:m(["coupon-box",{grey:y(v)(e.status,[2,3])}])},{default:r((()=>[n(t,{class:m(["top-type",{grey:y(v)(e.status,[2,3])}])},{default:r((()=>[g(h(1==e.type?"满减券":"折扣券"),1)])),_:2},1032,["class"]),n(t,{class:"l"},{default:r((()=>[n(t,{class:"price"},{default:r((()=>[1==e.type?(u(),c(f,{key:0,class:"prefix"},{default:r((()=>[g("￥")])),_:1})):k("",!0),n(f,{class:"money"},{default:r((()=>[g(h(e.amount)+h(2==e.type?"折":""),1)])),_:2},1024)])),_:2},1024),n(t,{class:"discount"},{default:r((()=>[g("满"+h(e.order_amount)+"元可用",1)])),_:2},1024)])),_:2},1024),n(t,{class:"line"}),n(t,{class:"content"},{default:r((()=>[n(t,{class:"title"},{default:r((()=>[g(h(e.name),1)])),_:2},1024),n(t,{class:"bottom"},{default:r((()=>[1==e.expire_type?(u(),c(t,{key:0,class:"time"},{default:r((()=>[g("领取后"+h(e.time)+"天内有效",1)])),_:2},1024)):k("",!0),2==e.expire_type?(u(),c(t,{key:1,class:"time"},{default:r((()=>[g(h(e.time)+"当天有效",1)])),_:2},1024)):k("",!0),1==e.status?(u(),c(t,{key:2,class:"receive",onClick:s=>((e,a)=>{uni.$http.post("coupon/receive",{id:e.id}).then((e=>{e.code?(T.value[a].status=2,uni.$layer.showToast("领取成功")):uni.$layer.showToast(e.msg)}))})(e,a)},{default:r((()=>[g("立即领券")])),_:2},1032,["onClick"])):k("",!0),2==e.status?(u(),c(t,{key:3,class:"receive"},{default:r((()=>[g("已领取")])),_:1})):k("",!0),3==e.status?(u(),c(t,{key:4,class:"receive"},{default:r((()=>[g("已过期")])),_:1})):k("",!0)])),_:2},1024)])),_:2},1024)])),_:2},1032,["class"])])),_:2},1024)))),128))])),_:1})])),_:1})])),_:1},8,["scrollHeight"])])),_:1})}}},[["__scopeId","data-v-c3cf63e5"]]);export{$ as default};
//# sourceMappingURL=pages-coupon-index.vMLTR1Fj.js.map
