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