import{y as a,o as t,z as o,e,f as s,w as n,a1 as i,_ as l,l as p,j as r,g as u,k as c,r as d,F as g,m,v as f,s as y,B as b,C as _,t as k,u as C,a2 as T,G as j,i as S}from"./index-9aa72eed.js";import{_ as v}from"./su-tabs.801f7709.js";import{_ as x}from"./su-sticky.8fbea04e.js";import{_ as w}from"./s-empty.3adf8b58.js";import{_ as z}from"./s-coupon-list.0d604fb0.js";import{_ as N}from"./uni-load-more.93dce372.js";import{_ as h}from"./s-layout.bffb18b8.js";import{r as I}from"./useGoods.ce02ada2.js";import{_ as M}from"./_plugin-vue_export-helper.1b428a4d.js";import"./uni-badge.cc270d88.js";/* empty css                                                                */import"./form.c66b5271.js";const $=M({__name:"list",setup(M){const $=a({currentTab:0,type:"1",pagination:{list:[],total:0,pageNo:1,pageSize:5},loadStatus:""}),G=[{name:"领券中心",value:"all"},{name:"已领取",value:"1"},{name:"已使用",value:"2"},{name:"已失效",value:"3"}];function P(a){$.currentTab=a.index,$.type=a.value,I($.pagination),0===$.currentTab?q():B()}async function q(){$.loadStatus="loading";const{data:a,code:t}=await i.getCouponTemplatePage({pageNo:$.pagination.pageNo,pageSize:$.pagination.pageSize});0===t&&($.pagination.list=l.concat($.pagination.list,a.list),$.pagination.total=a.total,$.loadStatus=$.pagination.list.length<$.pagination.total?"more":"noMore")}async function B(){$.loadStatus="loading";const{data:a,code:t}=await i.getCouponPage({pageNo:$.pagination.pageNo,pageSize:$.pagination.pageSize,status:$.type});0===t&&($.pagination.list=l.concat($.pagination.list,a.list),$.pagination.total=a.total,$.loadStatus=$.pagination.list.length<$.pagination.total?"more":"noMore")}function F(){"noMore"!==$.loadStatus&&($.pagination.pageNo++,0===$.currentTab?q():B())}return t((a=>{"all"!==a.type&&a.type?("geted"===a.type?$.currentTab=1:"used"===a.type?$.currentTab=2:$.currentTab=3,$.type=$.currentTab,B()):q()})),o((()=>{F()})),(a,t)=>{const o=p(m("su-tabs"),v),l=p(m("su-sticky"),x),M=p(m("s-empty"),w),B=j,A=p(m("s-coupon-list"),z),D=S,E=p(m("uni-load-more"),N),H=p(m("s-layout"),h);return e(),s(H,{title:"优惠券",bgStyle:{color:"#f2f2f2"}},{default:n((()=>[r(l,{bgColor:"#fff"},{default:n((()=>[r(o,{list:G,scrollable:!1,onChange:P,current:$.currentTab},null,8,["current"])])),_:1}),0===$.pagination.total?(e(),s(M,{key:0,icon:"/static/coupon-empty.png",text:"暂无优惠券"})):u("",!0),0===$.currentTab?(e(!0),c(g,{key:1},d($.pagination.list,(a=>(e(),s(D,{key:a.id},{default:n((()=>[r(A,{data:a,onClick:t=>f(y).$router.go("/pages/coupon/detail",{id:a.id})},{default:n((()=>[r(B,{class:b(["ss-reset-button card-btn ss-flex ss-row-center ss-col-center",a.canTake?"":"border-btn"]),onClick:_((t=>async function(a){const{code:t}=await i.takeCoupon(a);0===t&&(T({title:"领取成功"}),setTimeout((()=>{I($.pagination),q()}),1e3))}(a.id)),["stop"]),disabled:!a.canTake},{default:n((()=>[k(C(a.canTake?"立即领取":"已领取"),1)])),_:2},1032,["class","onClick","disabled"])])),_:2},1032,["data","onClick"])])),_:2},1024)))),128)):(e(!0),c(g,{key:2},d($.pagination.list,(a=>(e(),s(D,{key:a.id},{default:n((()=>[r(A,{data:a,type:"user",onClick:t=>f(y).$router.go("/pages/coupon/detail",{couponId:a.id})},{default:n((()=>[r(B,{class:b(["ss-reset-button card-btn ss-flex ss-row-center ss-col-center",1!==a.status?"disabled-btn":""]),disabled:1!==a.status,onClick:_((t=>f(y).$router.go("/pages/coupon/detail",{couponId:a.id})),["stop"])},{default:n((()=>[k(C(1===a.status?"立即使用":2===a.status?"已使用":"已过期"),1)])),_:2},1032,["class","disabled","onClick"])])),_:2},1032,["data","onClick"])])),_:2},1024)))),128)),$.pagination.total>0?(e(),s(E,{key:3,status:$.loadStatus,"content-text":{contentdown:"上拉加载更多"},onClick:F},null,8,["status"])):u("",!0)])),_:1})}}},[["__scopeId","data-v-ce30d1a5"]]);export{$ as default};
