<template>
    <div>
    </div>
</template>

<script>
import CryptoJS from "crypto-js";
export default {
    data() {
        return {
        }
    },    
    created() {
        //获取url参数
        let roterS = window.location.href.toString();
        let r1 = roterS.split('?');
        let frameType = '';let caseCode = '';let actCode='';let applicantion='';let type = '';
        let userCode = '';let un = '';
        let caseCode1 = '';let actCode1 ='';let applicantion1 ='';
        let userCode1 = '';let un1 = '';
        let caseCode2 = '';let actCode2 ='';let applicantion2 ='';
        let userCode2 = '';let un2 = '';
        let pName = '';
        if(r1.length!=1){
            let r2 = r1[1].split('&');
            type = r2[0].substring(5);
            //校验是否发送移动/PC,0移动1PC
            if(type=='0'){
                userCode = r2[1].substring(9).replace('%3D','=');
                actCode = r2[2].substring(8).replace('%3D','=');
                un = r2[3].substring(3).replace('%3D','=');
                userCode1 = (userCode.replace('%3D','=').replace('%20','+'));
                actCode1 = (actCode.replace('%3D','=').replace('%20','+'));
                un1 = (un.replace('%3D','=').replace('%20','+'));
                userCode2 = (userCode1.replace('%2F','/').replace('%20','+'));
                actCode2 = (actCode1.replace('%2F','/').replace('%20','+'));
                un2 = (un1.replace('%2F','/').replace('%20','+'));
                let key = CryptoJS.enc.Utf8.parse('absoietlj32fai12');
                let decrypt1 = CryptoJS.AES.decrypt(userCode2, key, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});//解密userCode
                let decrypt2 = CryptoJS.AES.decrypt(actCode2, key, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});//解密actCode
                let decrypt3 = CryptoJS.AES.decrypt(un2, key, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});//解密userName
                sessionStorage.setItem('usercode',JSON.stringify(CryptoJS.enc.Utf8.stringify(decrypt1).toString()));
                sessionStorage.setItem('actCode',JSON.stringify(CryptoJS.enc.Utf8.stringify(decrypt2).toString()));
                sessionStorage.setItem('un',JSON.stringify(CryptoJS.enc.Utf8.stringify(decrypt3).toString())); 
                
                //获取userID
                let Wopinions = {
            
                actUserName:CryptoJS.enc.Utf8.stringify(decrypt1),
                               
            
                }
                
                this.$store.dispatch('GetUserVM',Wopinions).then(restPwd=>{
                  console.log(restPwd.userID);
                  sessionStorage.setItem('userid',JSON.stringify(restPwd.userID));
                // 即将跳转
                 this.$router.push('/detauils');
                })
            }
            else{
              userCode = r2[1].substring(9).replace('%3D','=');
              frameType = r2[2].substring(10);
              caseCode = r2[3].substring(9).replace('%3D','=');
              actCode = r2[4].substring(8).replace('%3D','=');
              applicantion = r2[5].substring(13).replace('%3D','=');
              pName = decodeURIComponent(r2[6].substring(6));
              caseCode1 = caseCode.replace('%3D','=').replace('%20','+');
              actCode1 = actCode.replace('%3D','=').replace('%20','+');
              userCode1 = (userCode.replace('%3D','=').replace('%20','+'));
              applicantion1 = applicantion.replace('%3D','=').replace('%20','+');
              caseCode2 = caseCode1.replace('%2F','/').replace('%20','+');
              actCode2 = actCode1.replace('%2F','/').replace('%20','+');
              userCode2 = (userCode1.replace('%2F','/').replace('%20','+'));
              applicantion2 = applicantion1.replace('%2F','/').replace('%20','+');
              let key = CryptoJS.enc.Utf8.parse('absoietlj32fai12');
              let decrypt1 = CryptoJS.AES.decrypt(userCode2, key, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});//解密caseCode
              let decrypt2 = CryptoJS.AES.decrypt(caseCode2, key, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});//解密caseCode
              let decrypt3 = CryptoJS.AES.decrypt(actCode2, key, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});//解密actCode
              let decrypt4 = CryptoJS.AES.decrypt(applicantion2, key, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});//解密applicantion
              // 即将跳转
              let SystemUser ={
                UserCode:'',
                UserID:'移动端解析调到服务器系统地址',
                UserName:pName,
                URL:'',
                PWD:'',
              }
              this.$store.dispatch('GetWorkFlowProcedure',SystemUser).then(r=>{
                window.location.href = `${r.url}?&userCode=${CryptoJS.enc.Utf8.stringify(decrypt1).toString()}&ApplicationCode=${CryptoJS.enc.Utf8.stringify(decrypt4).toString()}&CaseCode=${CryptoJS.enc.Utf8.stringify(decrypt2).toString()}&ActCode=${CryptoJS.enc.Utf8.stringify(decrypt3).toString()}&ApplicationPath=${r.applicationCode}`;    
              })
            }
        }
    },
  }
</script>