<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 userid = '';
        let pName = '';
        if(r1.length!=1){
            let r2 = r1[1].split('&');
            type = r2[0].substring(5);
            //校验是否发送移动/PC,0移动1PCgdc工程云
            if(type=='gcy'){
                userCode = r2[1].substring(9).replace(/%3D/g,'=').replace(/%20/g,'+');
                userid = r2[2].substring(8).replace(/%3D/g,'=').replace(/%20/g,'+');
                actCode = r2[3].substring(8).replace(/%3D/g,'=').replace(/%20/g,'+');
                un = decodeURIComponent(r2[4].substring(3).replace(/%3D/g,'=').replace(/%20/g,'+'));
                
                
                sessionStorage.setItem('usercode',JSON.stringify(userCode));
                sessionStorage.setItem('actCode',JSON.stringify(actCode));
                sessionStorage.setItem('un',JSON.stringify(un)); 
                sessionStorage.setItem('userid',JSON.stringify(userid));
                
                // 即将跳转
                 this.$router.push('/detauils');
                
            }
            if(type=='0'){
                userCode = decodeURIComponent(r2[1].substring(9).replace(/%20/g,'+').replace(/%3D/g,'='));
                actCode = decodeURIComponent(r2[2].substring(8).replace(/%20/g,'+').replace(/%3D/g,'='));
                un = decodeURIComponent(r2[3].substring(3).replace(/%20/g,'+').replace(/%3D/g,'=').replace(/%2f/g,'/'));
                console.info(un);
                
                let key = CryptoJS.enc.Utf8.parse('absoietlj32fai12');
                let decrypt1 = CryptoJS.AES.decrypt(userCode, key, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});//解密userCode
                let decrypt2 = CryptoJS.AES.decrypt(actCode, key, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});//解密actCode
                let decrypt3 = CryptoJS.AES.decrypt(un, 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())); 
                console.log(JSON.stringify(CryptoJS.enc.Utf8.stringify(decrypt3).toString()));
                //获取userID
                let Wopinions = {
            
                actUserName:CryptoJS.enc.Utf8.stringify(decrypt1),
                               
            
                }
                
                this.$store.dispatch('GetUserVM',Wopinions).then(restPwd=>{
                  
                  sessionStorage.setItem('userid',JSON.stringify(restPwd.userID));
                // 即将跳转
                 this.$router.push('/detauils');
                })
            }
            if(type=='1'){
              userCode = decodeURIComponent(r2[1].substring(9).replace(/%20/g,'%2B'));
              frameType = decodeURIComponent(r2[2].substring(10).replace(/%20/g,'%2B'));
              caseCode = decodeURIComponent(r2[3].substring(9).replace(/%20/g,'%2B'));
              actCode = decodeURIComponent(r2[4].substring(8).replace(/%20/g,'%2B'));
              applicantion = decodeURIComponent(r2[5].substring(13).replace(/%20/g,'%2B'));
              
              pName = decodeURIComponent(r2[6].substring(6));
              
              let key = CryptoJS.enc.Utf8.parse('absoietlj32fai12');
              let decrypt1 = CryptoJS.AES.decrypt(userCode, key, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});//解密caseCode
              let decrypt2 = CryptoJS.AES.decrypt(caseCode, key, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});//解密caseCode
              let decrypt3 = CryptoJS.AES.decrypt(actCode, key, {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});//解密actCode
              let decrypt4 = CryptoJS.AES.decrypt(applicantion, 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>