import{b as m,c as u,d as g}from"./usercenter.62709a3f.js";import{k as r,e as l}from"./index.8c202964.js";const c=r.getters.userInfo;var h={data(){return{beginTime:"",endTime:"",timeDiff:"",ip:"",infoEnterId:"",accessUuid:"",setIntervalOnline:null}},computed:{userInfo:function(){return{user:{id:"",usercName:"",email:"",isWhitelist:"",registerFrom:"",registerFromUserid:""}}}},methods:{updateDateTime(){let e=new Date;const t=e.getFullYear(),s=e.getMonth()+1,i=e.getDate(),o=e.getHours(),n=e.getMinutes()<10?"0"+e.getMinutes():e.getMinutes(),a=e.getSeconds()<10?"0"+e.getSeconds():e.getSeconds();return`${t}-${s}-${i} ${o}:${n}:${a}`},calculateTimeDifference(e,t){const s=new Date(e),o=new Date(t)-s,n=Math.floor(o/(1e3*60*60)),a=Math.floor(o%(1e3*60*60)/(1e3*60)),d=Math.floor(o%(1e3*60)/1e3)?Math.floor(o%(1e3*60)/1e3):1;return`${n+"h"}${a+"min"}${d+"s"}`},getLocalIPs(){const e=new RTCPeerConnection;e.createDataChannel("channel"),e.createOffer().then(t=>{t.sdp.split(`
`).forEach(i=>{if(i.indexOf("a=candidate:")===0){const o=i.split(" ")[4];return console.log("ipAddress",o),o}})})},accessLogFn(e){if(!Object.getOwnPropertyNames(this.userInfo).length)return!1;console.log("----------",localStorage.getItem("Ip"));let t={moduleName:"",moduleType:"",moduleLevel:2,contentSourceId:"",contentSourceType:"",contentSourceName:"",contentVolume:"",contentIdentifier:"",contentTitle:"",isRecommend:"",accessDevices:localStorage.getItem("flag")=="false"?"PC":"\u79FB\u52A8\u8BBE\u5907",loginUserId:c.id,loginUserName:c.name,loginUserEmail:this.userInfo.user.email,loginIsWhitelist:this.userInfo.user.isWhitelist,loginUserFrom:this.userInfo.user.registerFrom,loginUserFromUserid:this.userInfo.user.registerFromUserid,accessStartTime:this.beginTime,accessEndTime:this.endTime,accessDuration:this.timeDiff,accessIp:localStorage.getItem("Ip")};t={...t,...e},this.infoEnterId&&(t={...t,infoEnterId:this.infoEnterId}),this.accessUuid&&(t={...t,accessUuid:this.accessUuid}),m(t).then(s=>{this.beginTime=this.updateDateTime()}).catch(s=>{l(s)})},accessLogAddEnterFn(e){var o,n;if(console.log("moduleParam",e),!Object.getOwnPropertyNames(this.userInfo).length)return!1;let t=JSON.parse(localStorage.getItem("userIpInfo")),s=this.beginTime;console.log("----------",(o=r.state.app.userIpInfo)==null?void 0:o.ip);let i={moduleName:"",moduleType:"",moduleLevel:2,contentSourceId:"",contentSourceType:"",contentSourceName:"",contentVolume:"",contentIdentifier:"",contentTitle:"",isRecommend:"",accessDevices:localStorage.getItem("flag")=="false"?"PC":"\u79FB\u52A8\u8BBE\u5907",loginUserId:c.id,loginUserName:c.name,loginUserEmail:this.userInfo.user.email,loginIsWhitelist:this.userInfo.user.isWhitelist,loginUserFrom:this.userInfo.user.registerFrom,loginUserFromUserid:this.userInfo.user.registerFromUserid,accessStartTime:s,accessEndTime:this.endTime,accessDuration:this.timeDiff,accessIp:t?t.ip:((n=r.state.app.userIpInfo)==null?void 0:n.ip)||"127.0.0.1"};localStorage.getItem("uuid")&&(i.accessUuid=localStorage.getItem("uuid")),i={...i,...e},u(i).then(async a=>{c||await r.dispatch("setUserInfoAction",a==null?void 0:a.data),a.data&&a.data.infoEnterId&&(this.infoEnterId=a.data.infoEnterId),a.data&&a.data.accessUuid&&(this.accessUuid=a.data.accessUuid),localStorage.getItem("accessStartTime")||localStorage.setItem("accessStartTime",this.updateDateTime()),!localStorage.getItem("uuid")&&a.data.accessUuid?(new Date().getTime()+30*60*1e3,localStorage.getItem("uuid")?(localStorage.setItem("uuid",localStorage.getItem("uuid")),localStorage.setItem("uuidTime",new Date().getTime().toString())):(localStorage.setItem("uuid",a.data.accessUuid),localStorage.setItem("uuidTime",new Date().getTime().toString()))):(new Date().getTime()+30*60*1e3,localStorage.setItem("uuid",localStorage.getItem("uuid")),localStorage.setItem("uuidTime",new Date().getTime().toString())),localStorage.getItem("enterUserInfo")||localStorage.setItem("enterUserInfo",JSON.stringify(a.data)),this.accessSetIntervalOnline()}).catch(a=>{l(a)})},accessSetIntervalOnline(){let e=localStorage.getItem("enterUserInfo"),t=localStorage.getItem("uuid");if(e&&e!="undefined"){let s=JSON.parse(e),i="";localStorage.getItem("accessStartTime")?i=localStorage.getItem("accessStartTime"):i=s.accessStartTime;let o={onlineTime:this.updateDateTime(),accessIp:s.accessIp,usercId:s.loginUserId,accessStartTime:i,accessDevices:s.accessDevices,accessUuid:t,infoEnterId:s.infoEnterId,accessIpCountry:s.accessIpCountry,accessIpProvince:s.accessIpProvince,accessIpCity:s.accessIpCity};t&&g(o).then(n=>{console.log(n)})}}},created(){this.beginTime=this.updateDateTime()},mounted(){this.setIntervalOnline=setInterval(()=>{console.log(1111111111),this.accessSetIntervalOnline()},1e3*30)}};export{h as u};
