"use strict";const e=require("../../common/vendor.js"),t=require("../../sheep/index.js"),a=require("../../sheep/util/index.js"),o=require("../../sheep/api/promotion/coupon.js");if(require("../../sheep/url/index.js"),require("../../sheep/store/index.js"),require("../../sheep/store/app.js"),require("../../sheep/api/promotion/diy.js"),require("../../sheep/request/index.js"),require("../../sheep/config/index.js"),require("../../sheep/platform/index.js"),require("../../sheep/platform/provider/wechat/index.js"),require("../../sheep/platform/provider/wechat/miniProgram.js"),require("../../sheep/api/member/auth.js"),require("../../sheep/api/member/social.js"),require("../../sheep/api/member/user.js"),require("../../sheep/platform/provider/apple/index.js"),require("../../sheep/platform/share.js"),require("../../sheep/router/index.js"),require("../../sheep/hooks/useModal.js"),require("../../sheep/helper/index.js"),require("../../sheep/helper/test.js"),require("../../sheep/helper/digit.js"),require("../../sheep/api/member/signin.js"),require("../../sheep/helper/throttle.js"),require("../../sheep/platform/pay.js"),require("../../sheep/api/pay/order.js"),require("../../sheep/store/user.js"),require("../../sheep/store/cart.js"),require("../../sheep/api/trade/cart.js"),require("../../sheep/api/pay/wallet.js"),require("../../sheep/api/trade/order.js"),require("../../sheep/store/sys.js"),require("../../sheep/store/modal.js"),require("../../sheep/config/zIndex.js"),!Array){(e.resolveComponent("su-tabs")+e.resolveComponent("su-sticky")+e.resolveComponent("s-empty")+e.resolveComponent("s-coupon-list")+e.resolveComponent("uni-load-more")+e.resolveComponent("s-layout"))()}Math||((()=>"../../sheep/ui/su-tabs/su-tabs.js")+(()=>"../../sheep/ui/su-sticky/su-sticky.js")+(()=>"../../sheep/components/s-empty/s-empty.js")+(()=>"../../sheep/components/s-coupon-list/s-coupon-list.js")+(()=>"../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js")+(()=>"../../sheep/components/s-layout/s-layout.js"))();const i={__name:"list",setup(i){const s=e.reactive({currentTab:0,type:"1",pagination:{list:[],total:0,pageNo:1,pageSize:5},loadStatus:""}),n=[{name:"领券中心",value:"all"},{name:"已领取",value:"1"},{name:"已使用",value:"2"},{name:"已失效",value:"3"}];function r(e){s.currentTab=e.index,s.type=e.value,a.resetPagination(s.pagination),0===s.currentTab?p():u()}async function p(){s.loadStatus="loading";const{data:t,code:a}=await o.CouponApi.getCouponTemplatePage({pageNo:s.pagination.pageNo,pageSize:s.pagination.pageSize});0===a&&(s.pagination.list=e._.concat(s.pagination.list,t.list),s.pagination.total=t.total,s.loadStatus=s.pagination.list.length<s.pagination.total?"more":"noMore")}async function u(){s.loadStatus="loading";const{data:t,code:a}=await o.CouponApi.getCouponPage({pageNo:s.pagination.pageNo,pageSize:s.pagination.pageSize,status:s.type});0===a&&(s.pagination.list=e._.concat(s.pagination.list,t.list),s.pagination.total=t.total,s.loadStatus=s.pagination.list.length<s.pagination.total?"more":"noMore")}function l(){"noMore"!==s.loadStatus&&(s.pagination.pageNo++,0===s.currentTab?p():u())}return e.onLoad((e=>{"all"!==e.type&&e.type?("geted"===e.type?s.currentTab=1:"used"===e.type?s.currentTab=2:s.currentTab=3,s.type=s.currentTab,u()):p()})),e.onReachBottom((()=>{l()})),(i,u)=>e.e({a:e.o(r),b:e.p({list:n,scrollable:!1,current:s.currentTab}),c:e.p({bgColor:"#fff"}),d:0===s.pagination.total},0===s.pagination.total?{e:e.p({icon:"/static/coupon-empty.png",text:"暂无优惠券"})}:{},{f:0===s.currentTab},0===s.currentTab?{g:e.f(s.pagination.list,((i,n,r)=>({a:e.t(i.canTake?"立即领取":"已领取"),b:e.n(i.canTake?"":"border-btn"),c:e.o((t=>async function(t){const{code:i}=await o.CouponApi.takeCoupon(t);0===i&&(e.index.showToast({title:"领取成功"}),setTimeout((()=>{a.resetPagination(s.pagination),p()}),1e3))}(i.id)),i.id),d:!i.canTake,e:e.o((a=>e.unref(t.sheep).$router.go("/pages/coupon/detail",{id:i.id})),i.id),f:"ce30d1a5-4-"+r+",ce30d1a5-0",g:e.p({data:i}),h:i.id})))}:{h:e.f(s.pagination.list,((a,o,i)=>({a:e.t(1===a.status?"立即使用":2===a.status?"已使用":"已过期"),b:e.n(1!==a.status?"disabled-btn":""),c:1!==a.status,d:e.o((o=>e.unref(t.sheep).$router.go("/pages/coupon/detail",{couponId:a.id})),a.id),e:e.o((o=>e.unref(t.sheep).$router.go("/pages/coupon/detail",{couponId:a.id})),a.id),f:"ce30d1a5-5-"+i+",ce30d1a5-0",g:e.p({data:a,type:"user"}),h:a.id})))},{i:s.pagination.total>0},s.pagination.total>0?{j:e.o(l),k:e.p({status:s.loadStatus,"content-text":{contentdown:"上拉加载更多"}})}:{},{l:e.p({title:"优惠券",bgStyle:{color:"#f2f2f2"}})})}},s=e._export_sfc(i,[["__scopeId","data-v-ce30d1a5"]]);wx.createPage(s);
