pages-coupon-list.1381b294.js 6.2 KB

1
  1. import{z as a,c as t,f as e,g as s,w as o,k as l,E as n,u as i,v as d,i as u,x as c,s as r,ah as p,B as f,j as g,o as y,A as m,aQ as b,_,m as v,l as k,r as T,F as x,n as S,G as j,ao as w,J as C}from"./index-a116b7fa.js";import{_ as h}from"./su-tabs.cd675673.js";import{_ as z}from"./su-sticky.41b75182.js";import{_ as $}from"./s-empty.4d7f5239.js";import{f as N,r as P}from"./useGoods.6b315a78.js";import{_ as I}from"./_plugin-vue_export-helper.1b428a4d.js";import{_ as E}from"./uni-load-more.2682655d.js";import{_ as F}from"./s-layout.4ae51839.js";import"./uni-badge.9d757a16.js";/* empty css */import"./phone-international-input.b9f6c8e6.js";const G=I({__name:"s-coupon-list",props:{data:{type:Object,default:{}},disabled:{type:Boolean,default:!1},type:{type:String,default:"coupon"}},setup(y){a({});const m=t((()=>"coupon"!==b.type&&1!==b.data.status)),b=y;return(a,t)=>{const b=g;return e(),s(b,{class:"ss-m-20",style:f({opacity:y.disabled?"0.5":"1"})},{default:o((()=>[l(b,{class:"content"},{default:o((()=>[l(b,{class:n(["tag ss-flex ss-row-center",m.value?"disabled-bg-color":"info-bg-color"])},{default:o((()=>[i(d(1===y.data.discountType?"满减券":"折扣券"),1)])),_:1},8,["class"]),l(b,{class:"title ss-m-x-30 ss-p-t-18"},{default:o((()=>[l(b,{class:"ss-flex ss-row-between"},{default:o((()=>[l(b,{class:n(["value-text ss-flex-1 ss-m-r-10",m.value?"disabled-color":"info-color"])},{default:o((()=>[i(d(y.data.name),1)])),_:1},8,["class"]),l(b,null,{default:o((()=>[l(b,{class:n(["ss-flex ss-col-bottom",m.value?"disabled-color":"price-text"])},{default:o((()=>[1===y.data.discountType?(e(),s(b,{key:0,class:"value-reduce ss-m-b-10"},{default:o((()=>[i("¥")])),_:1})):u("",!0),l(b,{class:"value-price"},{default:o((()=>[i(d(1===y.data.discountType?c(N)(y.data.discountPrice):y.data.discountPercent/10),1)])),_:1}),2===y.data.discountType?(e(),s(b,{key:1,class:"value-discount ss-m-b-10 ss-m-l-4"},{default:o((()=>[i("折")])),_:1})):u("",!0)])),_:1},8,["class"])])),_:1})])),_:1}),l(b,{class:"ss-flex ss-row-between ss-m-t-16"},{default:o((()=>[2===y.data.validityType?(e(),s(b,{key:0,class:n(["sellby-text",m.value?"disabled-color":"subtitle-color"])},{default:o((()=>[i(" 有效期:领取后 "+d(y.data.fixedEndTerm)+" 天内可用 ",1)])),_:1},8,["class"])):(e(),s(b,{key:1,class:n(["sellby-text",m.value?"disabled-color":"subtitle-color"])},{default:o((()=>[i(" 有效期: "+d(c(r).$helper.timeFormat(y.data.validStartTime,"yyyy-mm-dd"))+" 至 "+d(c(r).$helper.timeFormat(y.data.validEndTime,"yyyy-mm-dd")),1)])),_:1},8,["class"])),l(b,{class:n(["value-enough",m.value?"disabled-color":"subtitle-color"])},{default:o((()=>[i(" 满 "+d(c(N)(y.data.usePrice))+" 可用 ",1)])),_:1},8,["class"])])),_:1})])),_:1})])),_:1}),l(b,{class:"desc ss-flex ss-row-between"},{default:o((()=>[l(b,null,{default:o((()=>[l(b,{class:"desc-title"},{default:o((()=>[i(d(y.data.description),1)])),_:1}),l(b,null,{default:o((()=>[p(a.$slots,"reason",{},void 0,!0)])),_:3})])),_:3}),l(b,null,{default:o((()=>[p(a.$slots,"default",{},void 0,!0)])),_:3})])),_:3})])),_:3},8,["style"])}}},[["__scopeId","data-v-b112a8a9"]]),M=I({__name:"list",setup(t){const p=a({currentTab:0,type:"1",pagination:{list:[],total:0,pageNo:1,pageSize:5},loadStatus:""}),f=[{name:"领券中心",value:"all"},{name:"已领取",value:"1"},{name:"已使用",value:"2"},{name:"已失效",value:"3"}];function N(a){p.currentTab=a.index,p.type=a.value,P(p.pagination),0===p.currentTab?I():M()}async function I(){p.loadStatus="loading";const{data:a,code:t}=await b.getCouponTemplatePage({pageNo:p.pagination.pageNo,pageSize:p.pagination.pageSize});0===t&&(p.pagination.list=_.concat(p.pagination.list,a.list),p.pagination.total=a.total,p.loadStatus=p.pagination.list.length<p.pagination.total?"more":"noMore")}async function M(){p.loadStatus="loading";const{data:a,code:t}=await b.getCouponPage({pageNo:p.pagination.pageNo,pageSize:p.pagination.pageSize,status:p.type});0===t&&(p.pagination.list=_.concat(p.pagination.list,a.list),p.pagination.total=a.total,p.loadStatus=p.pagination.list.length<p.pagination.total?"more":"noMore")}function B(){"noMore"!==p.loadStatus&&(p.pagination.pageNo++,0===p.currentTab?I():M())}return y((a=>{"all"!==a.type&&a.type?("geted"===a.type?p.currentTab=1:"used"===a.type?p.currentTab=2:p.currentTab=3,p.type=p.currentTab,M()):I()})),m((()=>{B()})),(a,t)=>{const y=v(S("su-tabs"),h),m=v(S("su-sticky"),z),_=v(S("s-empty"),$),M=C,A=v(S("s-coupon-list"),G),H=g,J=v(S("uni-load-more"),E),O=v(S("s-layout"),F);return e(),s(O,{title:"优惠券",bgStyle:{color:"#f2f2f2"}},{default:o((()=>[l(m,{bgColor:"#fff"},{default:o((()=>[l(y,{list:f,scrollable:!1,onChange:N,current:p.currentTab},null,8,["current"])])),_:1}),0===p.pagination.total?(e(),s(_,{key:0,icon:"/static/coupon-empty.png",text:"暂无优惠券"})):u("",!0),0===p.currentTab?(e(!0),k(x,{key:1},T(p.pagination.list,(a=>(e(),s(H,{key:a.id},{default:o((()=>[l(A,{data:a,onClick:t=>c(r).$router.go("/pages/coupon/detail",{id:a.id})},{default:o((()=>[l(M,{class:n(["ss-reset-button card-btn ss-flex ss-row-center ss-col-center",a.canTake?"":"border-btn"]),onClick:j((t=>async function(a){const{code:t}=await b.takeCoupon(a);0===t&&(w({title:"领取成功"}),setTimeout((()=>{P(p.pagination),I()}),1e3))}(a.id)),["stop"]),disabled:!a.canTake},{default:o((()=>[i(d(a.canTake?"立即领取":"已领取"),1)])),_:2},1032,["class","onClick","disabled"])])),_:2},1032,["data","onClick"])])),_:2},1024)))),128)):(e(!0),k(x,{key:2},T(p.pagination.list,(a=>(e(),s(H,{key:a.id},{default:o((()=>[l(A,{data:a,type:"user",onClick:t=>c(r).$router.go("/pages/coupon/detail",{couponId:a.id})},{default:o((()=>[l(M,{class:n(["ss-reset-button card-btn ss-flex ss-row-center ss-col-center",1!==a.status?"disabled-btn":""]),disabled:1!==a.status,onClick:j((t=>c(r).$router.go("/pages/coupon/detail",{couponId:a.id})),["stop"])},{default:o((()=>[i(d(1===a.status?"立即使用":2===a.status?"已使用":"已过期"),1)])),_:2},1032,["class","disabled","onClick"])])),_:2},1032,["data","onClick"])])),_:2},1024)))),128)),p.pagination.total>0?(e(),s(J,{key:3,status:p.loadStatus,"content-text":{contentdown:"上拉加载更多"},onClick:B},null,8,["status"])):u("",!0)])),_:1})}}},[["__scopeId","data-v-ce30d1a5"]]);export{M as default};