pages-coupon-list.3c9a4e19.js 3.7 KB

1
  1. import{v as a,o as t,x as o,e,f as s,w as n,a2 as i,_ as l,l as p,j as u,g as r,k as c,r as d,F as g,m,u as f,s as y,z as _,A as b,p as k,t as T,a3 as C,D as S,i as j}from"./index-9880b451.js";import{_ as x}from"./su-tabs.1ce39404.js";import{_ as v}from"./su-sticky.84aef901.js";import{_ as w}from"./s-empty.74111684.js";import{_ as z}from"./s-coupon-list.39460476.js";import{_ as N}from"./uni-load-more.aac4524a.js";import{_ as h}from"./s-layout.dfc5b0b5.js";import{r as I}from"./index.df38848e.js";import{_ as M}from"./_plugin-vue_export-helper.1b428a4d.js";/* empty css */import"./useGoods.bdd1c2ea.js";const $=M({__name:"list",setup(M){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 A(a){$.currentTab=a.index,$.type=a.value,I($.pagination),0===$.currentTab?D():F()}async function D(){$.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 F(){$.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 G(){"noMore"!==$.loadStatus&&($.pagination.pageNo++,0===$.currentTab?D():F())}return t((a=>{"all"!==a.type&&a.type?("geted"===a.type?$.currentTab=1:"used"===a.type?$.currentTab=2:$.currentTab=3,$.type=$.currentTab,F()):D()})),o((()=>{G()})),(a,t)=>{const o=p(m("su-tabs"),x),l=p(m("su-sticky"),v),M=p(m("s-empty"),w),F=S,Y=p(m("s-coupon-list"),z),Z=j,q=p(m("uni-load-more"),N),B=p(m("s-layout"),h);return e(),s(B,{title:"优惠券",bgStyle:{color:"#f2f2f2"}},{default:n((()=>[u(l,{bgColor:"#fff"},{default:n((()=>[u(o,{list:P,scrollable:!1,onChange:A,current:$.currentTab},null,8,["current"])])),_:1}),0===$.pagination.total?(e(),s(M,{key:0,icon:"/static/coupon-empty.png",text:"暂无优惠券"})):r("",!0),0===$.currentTab?(e(!0),c(g,{key:1},d($.pagination.list,(a=>(e(),s(Z,{key:a.id},{default:n((()=>[u(Y,{data:a,onClick:t=>f(y).$router.go("/pages/coupon/detail",{id:a.id})},{default:n((()=>[u(F,{class:_(["ss-reset-button card-btn ss-flex ss-row-center ss-col-center",a.canTake?"":"border-btn"]),onClick:b((t=>async function(a){const{code:t}=await i.takeCoupon(a);0===t&&(C({title:"领取成功"}),setTimeout((()=>{I($.pagination),D()}),1e3))}(a.id)),["stop"]),disabled:!a.canTake},{default:n((()=>[k(T(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(Z,{key:a.id},{default:n((()=>[u(Y,{data:a,type:"user",onClick:t=>f(y).$router.go("/pages/coupon/detail",{couponId:a.id})},{default:n((()=>[u(F,{class:_(["ss-reset-button card-btn ss-flex ss-row-center ss-col-center",1!==a.status?"disabled-btn":""]),disabled:1!==a.status,onClick:b((t=>f(y).$router.go("/pages/coupon/detail",{couponId:a.id})),["stop"])},{default:n((()=>[k(T(1===a.status?"立即使用":2===a.status?"已使用":"已过期"),1)])),_:2},1032,["class","disabled","onClick"])])),_:2},1032,["data","onClick"])])),_:2},1024)))),128)),$.pagination.total>0?(e(),s(q,{key:3,status:$.loadStatus,"content-text":{contentdown:"上拉加载更多"},onClick:G},null,8,["status"])):r("",!0)])),_:1})}}},[["__scopeId","data-v-ce30d1a5"]]);export{$ as default};