"use strict";var o=(o,e,t)=>new Promise(((n,p)=>{var i=o=>{try{u(t.next(o))}catch(e){p(e)}},s=o=>{try{u(t.throw(o))}catch(e){p(e)}},u=o=>o.done?n(o.value):Promise.resolve(o.value).then(i,s);u((t=t.apply(o,e)).next())}));const e=require("../../../common/vendor.js"),t=require("../../../sheep/index.js"),n=require("../../../sheep/api/promotion/coupon.js"),p=require("../../../sheep/hooks/useGoods.js"),i=require("../../../sheep/api/product/spu.js"),s=require("../../../sheep/api/product/category.js"),u=require("../../../sheep/util/index.js");if(!Array){(e.resolveComponent("uni-collapse-item")+e.resolveComponent("uni-collapse")+e.resolveComponent("su-tabs")+e.resolveComponent("su-sticky")+e.resolveComponent("s-goods-column")+e.resolveComponent("uni-load-more")+e.resolveComponent("s-empty")+e.resolveComponent("s-layout")+e.resolveComponent("layout-default-uni"))()}Math||((()=>"../../../uni_modules/uni-collapse/components/uni-collapse-item/uni-collapse-item.js")+(()=>"../../../uni_modules/uni-collapse/components/uni-collapse/uni-collapse.js")+(()=>"../../../sheep/ui/su-tabs/su-tabs.js")+(()=>"../../../sheep/ui/su-sticky/su-sticky.js")+(()=>"../../../sheep/components/s-goods-column/s-goods-column.js")+(()=>"../../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js")+(()=>"../../../sheep/components/s-empty/s-empty.js")+(()=>"../../../sheep/components/s-layout/s-layout.js"))();const a={__name:"detail",setup(a){const c=e.reactive({id:0,couponId:0,coupon:{},pagination:{list:[],total:0,pageNo:1,pageSize:1},categoryId:0,tabMaps:[],currentTab:0,loadStatus:""});function d(o){u.resetPagination(c.pagination),c.currentTab=o.index,c.categoryId=o.value,l()}function l(){return o(this,null,(function*(){c.loadStatus="loading";const{code:o,data:t}=yield i.SpuApi.getSpuPage({categoryId:c.categoryId,pageNo:c.pagination.pageNo,pageSize:c.pagination.pageSize});0===o&&(c.pagination.list=e.lodash.concat(c.pagination.list,t.list),c.pagination.total=t.total,c.loadStatus=c.pagination.list.length{m()}),1e3))}))}function m(){return o(this,null,(function*(){const{code:e,data:t}=c.id>0?yield n.CouponApi.getCouponTemplate(c.id):yield n.CouponApi.getCoupon(c.couponId);0===e&&(c.coupon=t,2===c.coupon.productScope?yield function(){return o(this,null,(function*(){const{data:o,code:e}=yield i.SpuApi.getSpuListByIds(c.coupon.productScopeValues.join(","));0===e&&(c.pagination.list=o)}))}():3===c.coupon.productScope&&(yield function(){return o(this,null,(function*(){const{data:o,code:e}=yield s.CategoryApi.getCategoryListByIds(c.coupon.productScopeValues.join(","));0===e&&(c.tabMaps=o.map((o=>({name:o.name,value:o.id}))),c.tabMaps.length>0&&(c.categoryId=c.tabMaps[0].value,yield l()))}))}()))}))}function g(){"noMore"!==c.loadStatus&&(c.pagination.pageNo++,l())}return e.onLoad((o=>{c.id=o.id,c.couponId=o.couponId,m(c.id,c.couponId)})),e.onReachBottom((()=>{g()})),(o,n)=>e.e({a:e.unref(t.sheep).$url.static("/static/img/shop/app/coupon_icon.png"),b:e.t(c.coupon.name),c:e.t(e.unref(p.fen2yuan)(c.coupon.usePrice)),d:e.t(1===c.coupon.discountType?"减 "+e.unref(p.fen2yuan)(c.coupon.discountPrice)+" 元":"打 "+c.coupon.discountPercent/10+" 折"),e:c.id>0},c.id>0?{f:e.t(c.coupon.canTake?"立即领取":"已领取")}:{g:e.t(1===c.coupon.status?"立即使用":2===c.coupon.status?"已使用":"已过期")},{h:e.n(c.coupon.canTake||1===c.coupon.status?"use-btn":"disable-btn"),i:!c.coupon.canTake,j:e.o(r),k:2===c.coupon.validityType},2===c.coupon.validityType?{l:e.t(c.coupon.fixedEndTerm)}:{m:e.t(e.unref(t.sheep).$helper.timeFormat(c.coupon.validStartTime,"yyyy-mm-dd")),n:e.t(e.unref(t.sheep).$helper.timeFormat(c.coupon.validEndTime,"yyyy-mm-dd"))},{o:e.t(1===c.coupon.discountType?"满减券":"折扣券"),p:c.coupon.description},c.coupon.description?{q:e.t(c.coupon.description),r:e.p({title:"优惠券说明"})}:{},{s:1===c.coupon.productScope},1===c.coupon.productScope?{}:e.e({t:e.t(2===c.coupon.productScope?"指定商品可用":"指定分类可用"),v:3===c.coupon.productScope},3===c.coupon.productScope?{w:e.o(d),x:e.p({scrollable:!0,list:c.tabMaps,current:c.currentTab})}:{},{y:e.p({bgColor:"#fff"})}),{z:2===c.coupon.productScope},2===c.coupon.productScope?{A:e.f(c.pagination.list,((o,n,p)=>({a:e.o((n=>e.unref(t.sheep).$router.go("/modules/mall/goods/index",{id:o.id})),n),b:"4d54e2c7-6-"+p+",4d54e2c7-1",c:e.p({size:"lg",data:o,goodsFields:{title:{show:!0},subtitle:{show:!0},price:{show:!0},original_price:{show:!0},sales:{show:!0},stock:{show:!1}}}),d:n})))}:{},{B:3===c.coupon.productScope},3===c.coupon.productScope?{C:e.f(c.pagination.list,((o,n,p)=>({a:e.o((n=>e.unref(t.sheep).$router.go("/modules/mall/goods/index",{id:o.id})),n),b:"4d54e2c7-7-"+p+",4d54e2c7-1",c:e.p({size:"lg",data:o,goodsFields:{title:{show:!0},subtitle:{show:!0},price:{show:!0},original_price:{show:!0},sales:{show:!0},stock:{show:!1}}}),d:n})))}:{},{D:c.pagination.total>0&&3===c.coupon.productScope},c.pagination.total>0&&3===c.coupon.productScope?{E:e.o(g),F:e.p({status:c.loadStatus,"content-text":{contentdown:"上拉加载更多"}})}:{},{G:3===c.coupon.productScope&&0===c.pagination.total},3===c.coupon.productScope&&0===c.pagination.total?{H:e.p({paddingTop:"0",icon:"/static/soldout-empty.png",text:"暂无商品"})}:{},{I:e.p({title:"优惠券详情"})})}},c=e._export_sfc(a,[["__scopeId","data-v-4d54e2c7"]]);wx.createPage(c);