detail.js 6.2 KB

1
  1. "use strict";const e=require("../../common/vendor.js"),o=require("../../sheep/index.js"),t=require("../../sheep/api/promotion/coupon.js"),p=require("../../sheep/hooks/useGoods.js"),s=require("../../sheep/api/product/spu.js"),i=require("../../sheep/api/product/category.js"),n=require("../../sheep/util/index.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("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"))()}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 r=e.reactive({id:0,couponId:0,coupon:{},pagination:{list:[],total:0,pageNo:1,pageSize:1},categoryId:0,tabMaps:[],currentTab:0,loadStatus:""});function u(e){n.resetPagination(r.pagination),r.currentTab=e.index,r.categoryId=e.value,c()}async function c(){r.loadStatus="loading";const{code:o,data:t}=await s.SpuApi.getSpuPage({categoryId:r.categoryId,pageNo:r.pagination.pageNo,pageSize:r.pagination.pageSize});0===o&&(r.pagination.list=e._.concat(r.pagination.list,t.list),r.pagination.total=t.total,r.loadStatus=r.pagination.list.length<r.pagination.total?"more":"noMore")}async function d(){const{code:o}=await t.CouponApi.takeCoupon(r.id);0===o&&(e.index.showToast({title:"领取成功"}),setTimeout((()=>{l()}),1e3))}async function l(){const{code:e,data:o}=r.id>0?await t.CouponApi.getCouponTemplate(r.id):await t.CouponApi.getCoupon(r.couponId);0===e&&(r.coupon=o,2===r.coupon.productScope?await async function(){const{data:e,code:o}=await s.SpuApi.getSpuListByIds(r.coupon.productScopeValues.join(","));0===o&&(r.pagination.list=e)}():3===r.coupon.productScope&&await async function(){const{data:e,code:o}=await i.CategoryApi.getCategoryListByIds(r.coupon.productScopeValues.join(","));0===o&&(r.tabMaps=e.map((e=>({name:e.name,value:e.id}))),r.tabMaps.length>0&&(r.categoryId=r.tabMaps[0].value,await c()))}())}function h(){"noMore"!==r.loadStatus&&(r.pagination.pageNo++,c())}return e.onLoad((e=>{r.id=e.id,r.couponId=e.couponId,l(r.id,r.couponId)})),e.onReachBottom((()=>{h()})),(t,s)=>e.e({a:e.unref(o.sheep).$url.static("/static/images/coupon_icon.png"),b:e.t(r.coupon.name),c:e.t(e.unref(p.fen2yuan)(r.coupon.usePrice)),d:e.t(1===r.coupon.discountType?"减 "+e.unref(p.fen2yuan)(r.coupon.discountPrice)+" 元":"打 "+r.coupon.discountPercent/10+" 折"),e:r.id>0},r.id>0?{f:e.t(r.coupon.canTake?"立即领取":"已领取")}:{g:e.t(1===r.coupon.status?"立即使用":2===r.coupon.status?"已使用":"已过期")},{h:e.n(r.coupon.canTake||1===r.coupon.status?"use-btn":"disable-btn"),i:!r.coupon.canTake,j:e.o(d),k:2===r.coupon.validityType},2===r.coupon.validityType?{l:e.t(r.coupon.fixedEndTerm)}:{m:e.t(e.unref(o.sheep).$helper.timeFormat(r.coupon.validStartTime,"yyyy-mm-dd")),n:e.t(e.unref(o.sheep).$helper.timeFormat(r.coupon.validEndTime,"yyyy-mm-dd"))},{o:e.t(1===r.coupon.discountType?"满减券":"折扣券"),p:r.coupon.description},r.coupon.description?{q:e.t(r.coupon.description),r:e.p({title:"优惠券说明"})}:{},{s:1===r.coupon.productScope},1===r.coupon.productScope?{}:e.e({t:e.t(2===r.coupon.productScope?"指定商品可用":"指定分类可用"),v:3===r.coupon.productScope},3===r.coupon.productScope?{w:e.o(u),x:e.p({scrollable:!0,list:r.tabMaps,current:r.currentTab})}:{},{y:e.p({bgColor:"#fff"})}),{z:2===r.coupon.productScope},2===r.coupon.productScope?{A:e.f(r.pagination.list,((t,p,s)=>({a:e.o((p=>e.unref(o.sheep).$router.go("/pages/goods/index",{id:t.id})),p),b:"2d467455-5-"+s+",2d467455-0",c:e.p({size:"lg",data:t,goodsFields:{title:{show:!0},subtitle:{show:!0},price:{show:!0},original_price:{show:!0},sales:{show:!0},stock:{show:!1}}}),d:p})))}:{},{B:3===r.coupon.productScope},3===r.coupon.productScope?{C:e.f(r.pagination.list,((t,p,s)=>({a:e.o((p=>e.unref(o.sheep).$router.go("/pages/goods/index",{id:t.id})),p),b:"2d467455-6-"+s+",2d467455-0",c:e.p({size:"lg",data:t,goodsFields:{title:{show:!0},subtitle:{show:!0},price:{show:!0},original_price:{show:!0},sales:{show:!0},stock:{show:!1}}}),d:p})))}:{},{D:r.pagination.total>0&&3===r.coupon.productScope},r.pagination.total>0&&3===r.coupon.productScope?{E:e.o(h),F:e.p({status:r.loadStatus,"content-text":{contentdown:"上拉加载更多"}})}:{},{G:3===r.coupon.productScope&&0===r.pagination.total},3===r.coupon.productScope&&0===r.pagination.total?{H:e.p({paddingTop:"0",icon:"/static/soldout-empty.png",text:"暂无商品"})}:{},{I:e.p({title:"优惠券详情"})})}},r=e._export_sfc(a,[["__scopeId","data-v-2d467455"]]);wx.createPage(r);