import{d as m,u,w as o,D as y,j as t,M as c,z as n,B as d,C as g,aR as _,b1 as T,Z as S}from"./index.394decd7.js";import{S as v}from"./index.3bbf4ddb.js";import"./index.f1b52763.js";import{T as b,a as h}from"./index.ae00317c.js";import{A as C}from"./index.4b9edf44.js";import{C as l}from"./index.9e0d46e4.js";import{C as D}from"./index.9462d7c5.js";import"./index.cf474e9d.js";import{L}from"./index.dc786267.js";import{o as x,g as N}from"./index.68f32c85.js";import{t as w}from"./tradeOrder.ba7e9856.js";import{D as P}from"./index.44f74499.js";import{u as k}from"./hooks.9e5ee122.js";import{C as Y}from"./index.e6e212d8.js";import{T as A}from"./index.88270f6d.js";import"./use-id.e2f22365.js";import"./use-tab-status.723110ee.js";import"./use-refs.09b2d19c.js";import"./orderStatus.535346ee.js";import"./utils.ae753603.js";import"./index.1dcc495a.js";import"./index.75a0444f.js";import"./index.b9aedd1d.js";const O="_tradeRecord_k8m2o_1",F="_tab_k8m2o_11";var R={tradeRecord:O,tab:F};const M="_tradeList_ums1x_1",B="_searchTime_ums1x_1",E="_searchType_ums1x_2",I="_list_ums1x_14",$="_tradeLogo_ums1x_17",z="_tradeType_ums1x_24",j="_title_ums1x_27",H="_content_ums1x_28",V="_desc_ums1x_37",U="_num_ums1x_38",q="_btnList_ums1x_43";var a={tradeList:M,searchTime:B,searchType:E,list:I,tradeLogo:$,tradeType:z,title:j,content:H,desc:V,num:U,btnList:q};function G(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!S(e)}var p=m({name:"list",props:{type:{type:String,default:"buy"},height:{type:Number,default:44}},data(){return{timeStatus:!1,currentDate:new Date,typeStatus:!1,actions:[{name:"\u5168\u90E8"},{name:"\u5F85\u652F\u4ED8",status:"WAIT_PAY"},{name:"\u652F\u4ED8\u4E2D",status:"PAYING"},{name:"\u5DF2\u4ED8\u6B3E",status:"PAID"},{name:"\u5DF2\u5173\u95ED",status:"CLOSE"},{name:"\u652F\u4ED8\u5931\u8D25",status:"FAIL"}],list:[],dataShow:!0,loading:!1,finished:!1,searchName:"\u5168\u90E8",params:{status:"",page:1,rows:20}}},methods:{async getList(){if(!this.loading){this.loading=!0;try{const e={...this.params,searchDate:u(this.currentDate).format("YYYY-MM")},s=this.type==="buy"?"/api-student/userOrder/page":"/api-student/userOrderRefunds/page",{code:r,data:f}=await o.post(s,{data:{...e,dateTime:this.type==="refund"?e.searchDate:void 0,timeType:this.type==="refund"?"MONTH":void 0}});if(r===200){const i=f||{};this.list=this.list.concat(i.rows||[]),this.finished=i.pageNo>=i.totalPage,this.params.page=i.pageNo+1,this.dataShow=this.list.length>0}}catch{this.dataShow=!1,this.finished=!0}this.loading=!1}},onDetail(e){this.type!=="refund"&&this.$router.push({path:"/tradeDetail",query:{orderNo:e.orderNo,path:"tradeRecord"}})},onConfirm(e){this.currentDate=e,this.timeStatus=!1,this.onSearch()},onSelect(e){this.params.status=e.status,this.searchName=e.name,this.onSearch()},onSearch(){this.dataShow=!0,this.loading=!1,this.finished=!1,this.list=[],this.params.page=1,this.getList()},async onCancelPay(e){y.confirm({message:"\u662F\u5426\u53D6\u6D88\u8BA2\u5355\uFF1F",confirmButtonText:"\u786E\u5B9A",confirmButtonColor:"var(--van-primary)",cancelButtonText:"\u53D6\u6D88"}).then(async()=>{try{await o.post("/api-student/userOrder/orderCancel",{data:{orderNo:e.orderNo}}),this.onSearch()}catch{}})},async onPay(e){try{const r=(await o.get(`/api-student/userOrder/detailByOrderNo/${e.orderNo}`)).data;w(r,()=>{this.$router.push({path:"/orderDetail",query:{orderType:r.orderType}})})}catch{}}},render(){let e;return console.log(this.height,"height"),t("div",{class:a.tradeList},[t(v,{position:"top",offsetTop:this.height},{default:()=>[t(l,{center:!0,style:{backgroundColor:"#F7F8F9"}},{title:()=>t("div",{class:a.searchTime,onClick:()=>{this.timeStatus=!0}},[t("span",null,[this.$filters.dateFormat(this.currentDate,"YYYY-MM")]),t(c,{classPrefix:"iconfont",name:"down",size:12,color:"var(--van-primary)"},null)]),value:()=>this.type==="buy"?t("div",{class:a.searchType,onClick:()=>{this.typeStatus=!0}},[t("span",null,[this.searchName]),t(c,{classPrefix:"iconfont",name:"down",size:12,color:"var(--van-primary)"},null)]):null})]}),this.dataShow?t(L,{loading:this.loading,finished:this.finished,finishedText:" ",class:[a.list],onLoad:this.getList},G(e=this.list.map(s=>t(D,{border:!1,onClick:()=>{this.onDetail(s)}},{default:()=>[t(l,{title:u(s.createTime).format("YYYY-MM-DD HH:mm"),value:this.type==="buy"?x[s.status]:s.operateReason,valueClass:a.tradeType},null),t(l,{border:!1},{title:()=>t("div",{class:a.title},[t("span",null,[s.orderName]),t("span",{class:a.desc},[N[s.orderType]])]),default:()=>t("div",{class:a.content},[t("span",{class:a.price},[n("\uFFE5"),this.type==="buy"?this.$filters.moneyFormat(s.actualPrice):this.$filters.moneyFormat(s.actualAmount)])])}),s.status==="PAYING"||s.status==="WAIT_PAY"?t("div",{class:a.btnList},[t(d,{size:"small",round:!0,onClick:r=>{r.stopPropagation(),this.onCancelPay(s)}},{default:()=>[n("\u53D6\u6D88\u8BA2\u5355")]}),t(d,{size:"small",round:!0,type:"primary",onClick:r=>{r.stopPropagation(),this.onPay(s)}},{default:()=>[n("\u7EE7\u7EED\u652F\u4ED8")]})]):null]})))?e:{default:()=>[e]}):t(g,{btnStatus:!1,classImgSize:"SMALL",tips:this.type==="buy"?"\u6682\u65E0\u8D2D\u4E70\u8BB0\u5F55":"\u6682\u65E0\u9000\u6B3E\u8BB0\u5F55"},null),t(_,{show:this.timeStatus,"onUpdate:show":s=>this.timeStatus=s,position:"bottom",round:!0,closeOnPopstate:!0},{default:()=>[t(P,{type:"year-month",modelValue:this.currentDate,"onUpdate:modelValue":s=>this.currentDate=s,formatter:T,onCancel:()=>{this.timeStatus=!1},onConfirm:this.onConfirm},null)]}),t(C,{show:this.typeStatus,"onUpdate:show":s=>this.typeStatus=s,actions:this.actions,closeOnClickAction:!0,cancelText:"\u53D6\u6D88",onSelect:this.onSelect,onCancel:()=>{this.typeStatus=!1}},null)])}}),gt=m({name:"tradeRecord",data(){return{active:"buy",height:44}},mounted(){k("\u4EA4\u6613\u8BB0\u5F55")},render(){return t("div",{class:R.tradeRecord},[t(A,{position:"top",onBarHeight:e=>{this.height=e}},{default:()=>[t(Y,{isFixed:!1},null),t(b,{active:this.active,"onUpdate:active":e=>this.active=e,color:"var(--van-primary)",sticky:!0,lineWidth:28},{default:()=>[t(h,{name:"buy",title:"\u8D2D\u4E70\u8BB0\u5F55"},null),t(h,{name:"refund",title:"\u9000\u8D39\u8BB0\u5F55"},null)]})]}),this.active==="buy"&&t(p,{height:this.height,key:"buy"},null),this.active==="refund"&&t(p,{height:this.height,type:"refund",key:"refund"},null)])}});export{gt as default};