1 |
- import{d as l,j as o,z as a,F as c,C as d,aS as h,B as C,g as p,w as f,aR as m}from"./index.394decd7.js";import{C as L}from"./index.9e0d46e4.js";import{u as g}from"./hooks.9e5ee122.js";import{I as S}from"./item.2362e6e9.js";const b="_useCoupon_1f0ud_1",y="_couponCount_1f0ud_5",_="_choiceCoupon_1f0ud_14",A="_couponTitle_1f0ud_20",I="_iconClose_1f0ud_32",E="_couponContent_1f0ud_39",T="_couponFooter_1f0ud_46",N="_couponSelectText_1f0ud_53",U="_btnTenant_1f0ud_62";var i={useCoupon:b,couponCount:y,choiceCoupon:_,couponTitle:A,iconClose:I,couponContent:E,couponFooter:T,couponSelectText:N,btnTenant:U},k=l({name:"choice-coupon",props:{orderAmount:{type:Number,default:0},useCoupon:{type:Array,default:()=>[]},couponCategory:{type:String,default:"UNIVERSAL"},couponList:{type:Array,default:()=>[]}},emits:["close","submit"],data(){return{list:[],dataLoading:!1}},computed:{useLength(){return this.list.filter(t=>t.checked).length||0}},async mounted(){this.couponList.forEach(e=>{this.useCoupon.forEach(s=>{e.couponIssueId===s.couponIssueId&&(e.checked=!0)})});const t=this.couponList.filter(e=>!e.disabled),u=this.couponList.filter(e=>e.disabled);this.list=[...t,...u],this.calcCoupon(),g("\u4F18\u60E0\u5238")},methods:{onSubmit(){this.$emit("submit",this.list.filter(t=>t.checked)),this.list.forEach(t=>{t.checked=!1})},onSelect(t){t.checked=!t.checked,this.calcCoupon()},calcCoupon(){const u=this.list.filter(n=>n.checked).map(n=>Number(n.useLimit||0)),e=u.length>0?u.reduce((n,r)=>n+r):0,s=this.orderAmount-e;this.list.forEach(n=>{Number(n.useLimit)>s&&!n.checked?n.disabled=!0:n.disabled=!1})}},render(){return o("div",{class:i.choiceCoupon},[o("div",{class:i.couponTitle},[o("span",null,[a("\u4F18\u60E0\u5238")]),o("i",{class:i.iconClose,onClick:()=>this.$emit("close")},null)]),o("div",{class:i.couponContent},[this.dataLoading?o(h,{size:48,color:"#2dc7aa",vertical:!0,style:{height:"100%",justifyContent:"center"}},{default:()=>[a("\u52A0\u8F7D\u4E2D...")]}):o(c,null,[this.list.length>0?o(c,null,[this.list.map(t=>o(S,{item:t,isSelect:!0,onClick:this.onSelect},null))]):o(d,{btnStatus:!1,tips:"\u6682\u65E0\u4F18\u60E0\u5238",classImgSize:"SMALL"},null)])]),o("div",{class:[i.couponFooter,"van-hairline--top"]},[o("div",{class:i.couponSelectText},[a("\u5DF2\u9009"),o("span",null,[this.useLength]),a("\u5F20")]),o(C,{type:"primary",round:!0,class:p.projectType==="tenant"&&i.btnTenant,style:{minWidth:"105px",fontSize:"16px"},onClick:this.onSubmit},{default:()=>[a("\u786E\u5B9A")]})])])}});const F={UNIVERSAL:"UNIVERSAL",VIP:"VIP",PIANO_ROOM:"PIANO",GOODS:"MALL",MUSIC:"MUSIC",PRACTICE:"SPARRING",LIVE:"LIVE",VIDEO:"VIDEO",ALBUM:"ALBUM"};var x=l({name:"use-conpon",props:{disabled:{type:Boolean,default:!1},orderAmount:{type:Number,default:0},orderType:{type:String,default:""},discountPrice:{type:Number,default:0}},emits:["couponSelect"],data(){return{popupStatus:!1,popupLoading:!1,useCouponList:[],useCouponLoading:!1,useCouponCount:0,dataLoading:!1,list:[]}},computed:{couponCount(){const t=this.useCouponList.map(e=>Number(e.discountPrice||0));let u=0;return this.disabled?u=this.discountPrice:u=t.length>0?t.reduce((e,s)=>e+s):0,u},couponCategory(){return F[this.orderType]||"UNIVERSAL"}},mounted(){this.getList()},methods:{async getList(){if(!this.dataLoading){this.dataLoading=!0;try{const t=await f.post(`${p.platformApi}/couponInfo/page`,{data:{couponCategory:this.couponCategory,couponType:"FULL_DISCOUNT",useState:"USABLE",orderUse:1,page:1,rows:100}});this.dataLoading=!1;const u=t.data||{};if(this.list.length>0&&u.pageNo===1)return;this.list=u.rows||[],this.list.forEach(s=>{s.checked=!1,s.useLimit>this.orderAmount?s.disabled=!0:s.disabled=!1});let e=0;this.list.forEach(s=>{s.disabled||e++}),this.useCouponCount=e}catch{}}},onSubmit(t){this.useCouponList=t,this.$emit("couponSelect",t),this.popupStatus=!1,this.popupLoading=!1}},render(){return o(c,null,[o(L,{title:"\u4F18\u60E0\u5238",class:i.useCoupon,style:{borderRadius:"8px"},isLink:!this.disabled,clickable:!1,onClick:()=>{this.disabled||(this.popupStatus=!0,this.popupLoading=!0)}},{value:()=>!this.useCouponLoading&&o(c,null,[this.couponCount>0?o("span",{class:i.couponCount},[o("i",null,[a("-\uFFE5")]),this.couponCount]):o(c,null,[this.useCouponCount>0?`${this.useCouponCount}\u5F20\u53EF\u4F7F\u7528`:"\u6682\u65E0\u53EF\u4F7F\u7528\u4F18\u60E0\u5238"])])}),o(m,{show:this.popupStatus,"onUpdate:show":t=>this.popupStatus=t,position:"bottom",round:!0,safeAreaInsetBottom:!0,style:{height:"75%"},onClosed:()=>{this.popupLoading=!1}},{default:()=>[this.popupLoading&&o(k,{couponCategory:this.couponCategory,useCoupon:this.useCouponList,orderAmount:this.orderAmount,couponList:this.list,onClose:()=>this.popupStatus=!1,onSubmit:t=>this.onSubmit(t)},null)]})])}});export{x as U};
|