import{d as f,x as l,e as n,D as g,i as t,N as c,A as o,B as d,C as _,aT as T,b2 as S,$ as b,Y as v}from"./index.6b776f4b.js";import{S as D}from"./index.998c3386.js";import"./index.570314c1.js";import{T as C,a as h}from"./index.21339447.js";import{A as x}from"./index.1d37754d.js";import{C as u}from"./index.7486196c.js";import{C as L}from"./index.aa464e80.js";import"./index.cb54f81c.js";import{L as N}from"./index.9b1da5d2.js";import{o as P,g as w}from"./index.e6c57a63.js";import{t as Y}from"./tradeOrder.021d4979.js";import{D as A}from"./index.cd21c278.js";import{u as k}from"./hooks.ad006126.js";import"./use-id.40b6af6b.js";import"./use-tab-status.ad41a764.js";import"./use-refs.a68d4385.js";import"./orderStatus.d66eca14.js";import"./utils.98263d8b.js";import"./index.e13f12a0.js";const O="_tradeRecord_k8m2o_1",F="_tab_k8m2o_11";var p={tradeRecord:O,tab:F};const $="_tradeList_ums1x_1",R="_searchTime_ums1x_1",B="_searchType_ums1x_2",E="_list_ums1x_14",I="_tradeLogo_ums1x_17",M="_tradeType_ums1x_24",z="_title_ums1x_27",V="_content_ums1x_28",j="_desc_ums1x_37",U="_num_ums1x_38",q="_btnList_ums1x_43";var a={tradeList:$,searchTime:R,searchType:B,list:E,tradeLogo:I,tradeType:M,title:z,content:V,desc:j,num:U,btnList:q};function G(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!b(e)}var m=f({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:l(this.currentDate).format("YYYY-MM")},s=this.type==="buy"?"/api-student/userOrder/page":"/api-student/userOrderRefunds/page",{code:r,data:y}=await n.post(s,{data:{...e,dateTime:this.type==="refund"?e.searchDate:void 0,timeType:this.type==="refund"?"MONTH":void 0}});if(r===200){const i=y||{};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){g.confirm({message:"\u662F\u5426\u53D6\u6D88\u8BA2\u5355\uFF1F",confirmButtonText:"\u786E\u5B9A",confirmButtonColor:"var(--van-primary)",cancelButtonText:"\u53D6\u6D88"}).then(async()=>{try{await n.post("/api-student/userOrder/orderCancel",{data:{orderNo:e.orderNo}}),this.onSearch()}catch{}})},async onPay(e){try{const r=(await n.get(`/api-student/userOrder/detailByOrderNo/${e.orderNo}`)).data;Y(r,()=>{this.$router.push({path:"/orderDetail",query:{orderType:r.orderType}})})}catch{}}},render(){let e;return t("div",{class:a.tradeList},[t(D,{position:"top",offsetTop:this.height},{default:()=>[t(u,{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(N,{loading:this.loading,finished:this.finished,finishedText:" ",class:[a.list],onLoad:this.getList},G(e=this.list.map(s=>t(L,{border:!1,onClick:()=>{this.onDetail(s)}},{default:()=>[t(u,{title:l(s.createTime).format("YYYY-MM-DD HH:mm"),value:this.type==="buy"?P[s.status]:s.operateReason,valueClass:a.tradeType},null),t(u,{border:!1},{title:()=>t("div",{class:a.title},[t("span",null,[s.orderName]),t("span",{class:a.desc},[w[s.orderType]])]),default:()=>t("div",{class:a.content},[t("span",{class:a.price},[o("\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:()=>[o("\u53D6\u6D88\u8BA2\u5355")]}),t(d,{size:"small",round:!0,type:"primary",onClick:r=>{r.stopPropagation(),this.onPay(s)}},{default:()=>[o("\u7EE7\u7EED\u652F\u4ED8")]})]):null]})))?e:{default:()=>[e]}):t(_,{btnStatus:!1,classImgSize:"SMALL",tips:this.type==="buy"?"\u6682\u65E0\u8D2D\u4E70\u8BB0\u5F55":"\u6682\u65E0\u9000\u6B3E\u8BB0\u5F55"},null),t(T,{show:this.timeStatus,"onUpdate:show":s=>this.timeStatus=s,position:"bottom",round:!0,closeOnPopstate:!0},{default:()=>[t(A,{type:"year-month",modelValue:this.currentDate,"onUpdate:modelValue":s=>this.currentDate=s,formatter:S,onCancel:()=>{this.timeStatus=!1},onConfirm:this.onConfirm},null)]}),t(x,{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)])}}),ht=f({name:"tradeRecord",data(){return{active:"buy",height:44}},mounted(){this.$nextTick(()=>{const{height:e}=v(this.$refs.tabs);this.height=e}),k("\u4EA4\u6613\u8BB0\u5F55")},render(){return t("div",{class:p.tradeRecord},[t(C,{active:this.active,"onUpdate:active":e=>this.active=e,color:"var(--van-primary)",sticky:!0,lineWidth:28},{default:()=>[t(h,{name:"buy"},{default:()=>[t(m,{height:this.height},null)],title:()=>t("div",{class:p.tab,ref:"tabs"},[o("\u8D2D\u4E70\u8BB0\u5F55")])}),t(h,{name:"refund",title:"\u9000\u8D39\u8BB0\u5F55"},{default:()=>[t(m,{height:this.height,type:"refund"},null)]})]})])}});export{ht as default};