1 |
- import{y as a,c as t,e,f as s,w as o,j as l,B as n,t as i,u as d,g as u,v as c,s as r,a9 as p,A as f,i as g,o as y,z as m,aw as b,_,l as k,k as v,r as T,F as x,m as w,C,ad as S,G as j}from"./index-b48a414d.js";import{_ as h}from"./su-tabs.a383f815.js";import{_ as z}from"./su-sticky.aabc6a00.js";import{_ as $}from"./s-empty.6d3471cc.js";import{f as N,r as P,_ as I}from"./s-layout.d6dcdc81.js";import{_ as F}from"./_plugin-vue_export-helper.1b428a4d.js";import{_ as M}from"./uni-load-more.647920f4.js";import"./uni-badge.78cdef34.js";/* empty css */import"./phone-international-input.feef99c7.js";const A=F({__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"]]),B=F({__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?F():B()}async function F(){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 B(){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 E(){"noMore"!==p.loadStatus&&(p.pagination.pageNo++,0===p.currentTab?F():B())}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,B()):F()})),m((()=>{E()})),(a,t)=>{const y=k(w("su-tabs"),h),m=k(w("su-sticky"),z),_=k(w("s-empty"),$),B=j,G=k(w("s-coupon-list"),A),O=g,q=k(w("uni-load-more"),M),D=k(w("s-layout"),I);return e(),s(D,{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),v(x,{key:1},T(p.pagination.list,(a=>(e(),s(O,{key:a.id},{default:o((()=>[l(G,{data:a,onClick:t=>c(r).$router.go("/pages/coupon/detail",{id:a.id})},{default:o((()=>[l(B,{class:n(["ss-reset-button card-btn ss-flex ss-row-center ss-col-center",a.canTake?"":"border-btn"]),onClick:C((t=>async function(a){const{code:t}=await b.takeCoupon(a);0===t&&(S({title:"领取成功"}),setTimeout((()=>{P(p.pagination),F()}),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),v(x,{key:2},T(p.pagination.list,(a=>(e(),s(O,{key:a.id},{default:o((()=>[l(G,{data:a,type:"user",onClick:t=>c(r).$router.go("/pages/coupon/detail",{couponId:a.id})},{default:o((()=>[l(B,{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:C((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(q,{key:3,status:p.loadStatus,"content-text":{contentdown:"上拉加载更多"},onClick:E},null,8,["status"])):u("",!0)])),_:1})}}},[["__scopeId","data-v-ce30d1a5"]]);export{B as default};
|