import{d as r,s as p,e as a,i as o,w as l,J as n,F as h,aQ as u}from"./index.afa1b71c.js";import{C as d}from"./index.42378eb4.js";import"./index.4b8ed396.js";import{a as m,i as w}from"./icon_checkbox_default.2fe5d57e.js";import{C as y}from"./index.ceb58f38.js";const f="_colProtocol_wgzww_1",T="_protocolText_wgzww_6",C="_boxStyle_wgzww_10";var e={colProtocol:f,protocolText:T,boxStyle:C};const g={BUY_ORDER:"\u300A\u9177\u4E50\u79C0\u5E73\u53F0\u670D\u52A1\u534F\u8BAE\u300B",REGISTER:"\u300A\u9177\u4E50\u79C0\u5E73\u53F0\u6CE8\u518C\u534F\u8BAE\u300B"};var v=r({name:"protocol",props:{showHeader:{type:Boolean,default:!1},modelValue:{type:Boolean,default:!1},prototcolType:{type:String,default:"BUY_ORDER"}},data(){return{exists:!0,checked:this.modelValue,popupStatus:!1,protocolHTML:"",protocolPopup:null,baseUrl:p.platformType==="STUDENT"?"/api-student":"/api-teacher"}},async mounted(){try{const t=await a.get(this.baseUrl+"/sysUserContractRecord/checkContractSign",{params:{contractType:this.prototcolType}});this.exists=t.data,this.checked=this.checked||this.exists,this.$emit("update:modelValue",this.checked||this.exists)}catch{}this.checked=this.modelValue,window.addEventListener("hashchange",this.onHash,!1)},unmounted(){window.removeEventListener("hashchange",this.onHash,!1)},watch:{checked(t){this.$emit("update:modelValue",t)}},methods:{async getContractDetail(){try{if(console.log("getContractDetail"),!this.protocolHTML){const t=await a.get(this.baseUrl+"/sysUserContractRecord/queryContract",{params:{contractType:this.prototcolType}});this.protocolHTML=t.data,console.log(t)}this.onPopupClose()}catch{}},onHash(){this.popupStatus=!1},onPopupClose(){if(this.popupStatus=!this.popupStatus,this.popupStatus){const t=this.$route;let s=0;for(let x in t.query)s+=1;const c=window.location.href,i=s>0?"&pto="+ +new Date:"?pto="+ +new Date;history.pushState("","",`${c}${i}`)}else window.history.go(-1);this.protocolPopup&&(this.protocolPopup.scrollTop=0)}},render(){return o("div",{class:e.colProtocol},[!this.exists&&o(d,{modelValue:this.checked,"onUpdate:modelValue":t=>this.checked=t},{default:()=>[l("\u6211\u5DF2\u9605\u8BFB\u5E76\u540C\u610F")],icon:t=>o(n,{class:e.boxStyle,name:t.checked?m:w,size:"15"},null)}),this.exists&&o(h,null,[l("\u67E5\u770B")]),o("span",{onClick:this.getContractDetail,class:e.protocolText},[g[this.prototcolType]]),o(u,{ref:this.protocolPopup,show:this.popupStatus,position:"bottom",style:{height:"100%"}},{default:()=>[this.showHeader&&o(y,{title:"\u9177\u4E50\u79C0\u5E73\u53F0\u670D\u52A1\u534F\u8BAE"},null),this.popupStatus&&o("div",{class:e.protocolContent,id:"mProtocol"},[o("div",{class:e.protocolContent,innerHTML:this.protocolHTML},null)])]})])}});export{v as C};
