import{C as a,p as t,D as e,o as s,e as o,w as n,s as i,_ as u,b as r,i as l,k as c,f as d,h as p,F as _,d as g,u as f,G as m,j as b,y,z as k,Z as x,B as C,m as j}from"./index-520dfaee.js";import{_ as S}from"./su-tabs.251eecb0.js";import{_ as T}from"./su-sticky.4736fd36.js";import{_ as v}from"./s-empty.b6c95127.js";import{_ as w}from"./s-coupon-list.26ded2df.js";import{_ as $}from"./uni-load-more.ba4f287c.js";import{a as h}from"./s-layout.5146c957.js";import{_ as M}from"./_plugin-vue_export-helper.1b428a4d.js";/* empty css                                                                */const q=M({__name:"list",setup(M){const q={data:[],current_page:1,total:1,last_page:1},z=a({currentTab:0,pagination:{data:[],current_page:1,total:1,last_page:1},loadStatus:"",type:""}),B=[{name:"领券中心",value:"all"},{name:"已领取",value:"geted"},{name:"已使用",value:"used"},{name:"已失效",value:"expired"}];function D(a){z.pagination=q,z.currentTab=a.index,z.type=a.value,0==z.currentTab?F():G()}async function F(a=1,t=5){z.loadStatus="loading";const e=await i.$api.coupon.list({list_rows:t,page:a});if(1===e.code){let a=u.concat(z.pagination.data,e.data.data);z.pagination={...e.data,data:a},z.pagination.current_page<z.pagination.last_page?z.loadStatus="more":z.loadStatus="noMore"}}async function G(a=1,t=5){z.loadStatus="loading";let e=await i.$api.coupon.userCoupon({type:z.type,list_rows:t,page:a});if(1===e.code){let a=u.concat(z.pagination.data,e.data.data);z.pagination={...e.data,data:a},z.pagination.current_page<z.pagination.last_page?z.loadStatus="more":z.loadStatus="noMore"}}function I(){"noMore"!==z.loadStatus&&(0==z.currentTab?F(z.pagination.current_page+1):G(z.pagination.current_page+1))}return t((a=>{"all"!==a.type&&a.type?(z.type=a.type,"geted"===a.type?z.currentTab=1:"used"===a.type?z.currentTab=2:z.currentTab=3,G()):F()})),e((()=>{I()})),(a,t)=>{const e=r(g("su-tabs"),S),u=r(g("su-sticky"),T),M=r(g("s-empty"),v),G=C,Z=r(g("s-coupon-list"),w),A=j,E=r(g("uni-load-more"),$),H=r(g("s-layout"),h);return s(),o(H,{title:"优惠券",bgStyle:{color:"#f2f2f2"}},{default:n((()=>[l(u,{bgColor:"#fff"},{default:n((()=>[l(e,{list:B,scrollable:!1,onChange:D,current:z.currentTab},null,8,["current"])])),_:1}),0===z.pagination.total?(s(),o(M,{key:0,icon:"/static/coupon-empty.png",text:"暂无优惠券"})):c("",!0),"0"==z.currentTab?(s(!0),d(_,{key:1},p(z.pagination.data,(a=>(s(),o(A,{key:a.id},{default:n((()=>[l(Z,{data:a,onClick:t=>f(i).$router.go("/pages/coupon/detail",{id:a.id})},{default:n((()=>[l(G,{class:m(["ss-reset-button card-btn ss-flex ss-row-center ss-col-center","can_get"!=a.get_status?"border-btn":""]),onClick:b((t=>async function(a){const{code:t,msg:e}=await i.$api.coupon.get(a);1===t&&(x({title:e}),setTimeout((()=>{z.pagination=q,F()}),1e3))}(a.id)),["stop"]),disabled:"can_get"!=a.get_status},{default:n((()=>[y(k(a.get_status_text),1)])),_:2},1032,["class","onClick","disabled"])])),_:2},1032,["data","onClick"])])),_:2},1024)))),128)):(s(!0),d(_,{key:2},p(z.pagination.data,(a=>(s(),o(A,{key:a.id},{default:n((()=>[l(Z,{data:a,type:"user",onClick:t=>f(i).$router.go("/pages/coupon/detail",{id:a.coupon_id,user_coupon_id:a.id})},{default:n((()=>[l(G,{class:m(["ss-reset-button card-btn ss-flex ss-row-center ss-col-center","can_get"==a.status||"can_use"==a.status?"":"used"==a.status||"expired"==a.status?"disabled-btn":"border-btn"]),disabled:"can_get"!=a.status&&"can_use"!=a.status,onClick:b((t=>f(i).$router.go("/pages/coupon/detail",{id:a.coupon_id,user_coupon_id:a.id})),["stop"])},{default:n((()=>[y(k(a.status_text),1)])),_:2},1032,["class","disabled","onClick"])])),_:2},1032,["data","onClick"])])),_:2},1024)))),128)),z.pagination.total>0?(s(),o(E,{key:3,status:z.loadStatus,"content-text":{contentdown:"上拉加载更多"},onClick:I},null,8,["status"])):c("",!0)])),_:1})}}},[["__scopeId","data-v-b51c7eff"]]);export{q as default};
