2 lines
3.7 KiB
JavaScript
2 lines
3.7 KiB
JavaScript
"use strict";var t=(t,e,o)=>new Promise(((a,n)=>{var i=t=>{try{p(o.next(t))}catch(e){n(e)}},s=t=>{try{p(o.throw(t))}catch(e){n(e)}},p=t=>t.done?a(t.value):Promise.resolve(t.value).then(i,s);p((o=o.apply(t,e)).next())}));const e=require("../../../common/vendor.js"),o=require("../sheep/index.js"),a=require("../sheep/util/index.js"),n=require("../sheep/api/promotion/coupon.js");if(!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")+e.resolveComponent("layout-default-uni"))()}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:""}),p=[{name:"领券中心",value:"all"},{name:"已领取",value:"1"},{name:"已使用",value:"2"},{name:"已失效",value:"3"}];function l(t){s.currentTab=t.index,s.type=t.value,a.resetPagination(s.pagination),0===s.currentTab?u():r()}function u(){return t(this,null,(function*(){s.loadStatus="loading";const{data:t,code:o}=yield n.CouponApi.getCouponTemplatePage({pageNo:s.pagination.pageNo,pageSize:s.pagination.pageSize});0===o&&(s.pagination.list=e.lodash.concat(s.pagination.list,t.list),s.pagination.total=t.total,s.loadStatus=s.pagination.list.length<s.pagination.total?"more":"noMore")}))}function r(){return t(this,null,(function*(){s.loadStatus="loading";const{data:t,code:o}=yield n.CouponApi.getCouponPage({pageNo:s.pagination.pageNo,pageSize:s.pagination.pageSize,status:s.type});0===o&&(s.pagination.list=e.lodash.concat(s.pagination.list,t.list),s.pagination.total=t.total,s.loadStatus=s.pagination.list.length<s.pagination.total?"more":"noMore")}))}function c(){"noMore"!==s.loadStatus&&(s.pagination.pageNo++,0===s.currentTab?u():r())}return e.onLoad((t=>{"all"!==t.type&&t.type?("geted"===t.type?s.currentTab=1:"used"===t.type?s.currentTab=2:s.currentTab=3,s.type=s.currentTab,r()):u()})),e.onReachBottom((()=>{c()})),(i,r)=>e.e({a:e.o(l),b:e.p({list:p,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,p,l)=>({a:e.t(i.canTake?"立即领取":"已领取"),b:e.n(i.canTake?"":"border-btn"),c:e.o((o=>function(o){return t(this,null,(function*(){const{code:t}=yield n.CouponApi.takeCoupon(o);0===t&&(e.index.showToast({title:"领取成功"}),setTimeout((()=>{a.resetPagination(s.pagination),u()}),1e3))}))}(i.id)),i.id),d:!i.canTake,e:e.o((t=>e.unref(o.sheep).$router.go("/modules/mall/coupon/detail",{id:i.id})),i.id),f:"b0e3dbf4-5-"+l+",b0e3dbf4-1",g:e.p({data:i}),h:i.id})))}:{h:e.f(s.pagination.list,((t,a,n)=>({a:e.t(1===t.status?"立即使用":2===t.status?"已使用":"已过期"),b:e.n(1!==t.status?"disabled-btn":""),c:1!==t.status,d:e.o((a=>e.unref(o.sheep).$router.go("/modules/mall/coupon/detail",{couponId:t.id})),t.id),e:e.o((a=>e.unref(o.sheep).$router.go("/modules/mall/coupon/detail",{couponId:t.id})),t.id),f:"b0e3dbf4-6-"+n+",b0e3dbf4-1",g:e.p({data:t,type:"user"}),h:t.id})))},{i:s.pagination.total>0},s.pagination.total>0?{j:e.o(c),k:e.p({status:s.loadStatus,"content-text":{contentdown:"上拉加载更多"}})}:{},{l:e.p({title:"优惠券",bgStyle:{color:"#f2f2f2"}})})}},s=e._export_sfc(i,[["__scopeId","data-v-b0e3dbf4"]]);wx.createPage(s);
|