<template>
  <div>
    <div v-html="this.code"></div>
  </div>
</template>
<script>
import axios from 'axios'
import qs from 'qs'
export default {
   data() {
        return {
            code: "",
            reqMessage:'',
            reqSignature:'',
            requestDgtlEnvlp:'',
            requestSignSN:'',
            requestEncryptSN:''
        }
    },
  created() {
    axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
    var self = this;
    alert("成功！");
    console.log("成功！！！")
    self.reqMessage = this.getUrlKey("reqMessage").replaceAll(' ', '+');
    self.reqSignature = this.getUrlKey("reqSignature").replaceAll(' ', '+');
    self.requestDgtlEnvlp = this.getUrlKey("requestDgtlEnvlp").replaceAll(' ', '+');
    self.requestSignSN = this.getUrlKey("requestSignSN")
    self.requestEncryptSN = this.getUrlKey("requestEncryptSN")
    console.log("message",self.reqMessage);
    // console.log("参数===》",reqMessage,reqSignature,requestDgtlEnvlp,requestSignSN,requestEncryptSN);
    // if(code && state){
    //   location.href = state + "/userLogin?code="+code
    // }else{
    //   location.href = state + "/login"
    // }
    self.faceAuth();
  },
  render: function(h) {
    return h() // avoid warning message
  },
  methods: {
      getUrlKey(name) {
          return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null
      },
      faceAuth(){
        var self = this;
        var params={
                    message:self.reqMessage,
                    signature:self.reqSignature,
                    dgtlenvlp:self.requestDgtlEnvlp,
                    signSN:self.requestSignSN,
                    encryptSN:self.requestEncryptSN
        }
        // var params={
        //   message:'r1P/F1oAaBxzk8sM0bNFhLGM1i2lHXBH2/8fFePyDvduxekBYgke1R0VVHXVGdehCesbJ4otaKZXBFBmVUGzoiSEXdFLtTUAqbVZQAyKVPmMV06OjO8RRo77vLyyvG9beTXn7PKptnFXhNltDs55J2Ow9J1Aujhfmtb25picBZgHA2reOLgNRGRAOpEQGha4Hn5WcygnDJ5H9zfM3YtEUKrFFd8fJzp0tHHAIhKf0fjmJOvpPf7kt4Yt08C3aLti9LPkbZjX27RwcVOVEppOLPEm6CYHmSzuk874nfIynYj0S6oB3hI6mT6xT71zVqWytVA9bzlmxqiHVvmrt42A9PPmuxsXceoZj5ou7FSG+20fWmn+JDvm4z6p6yTLzXFB',
        //             signature:'179F085FDDD1B2DB3712C7E4D720899E3D3677C08F252D608C537402B22E5CB6DD922663E466CAA726F4F1D32E3D9E02BD0E0274781652F90E6D7838A9E96099D9A2567DFF5B06BB13AE990D5023739175569FFBDBEE0420A2665EA95790EEC43F5383F2E1CFB1466AFC1B819AE1FD294900FBB438FEDF5C573E546D45DA90A477B044BF15967E795F7A802BC5A08A9D4823D7B4C5E3E10AF03EEB852B65BF90460D4EE7104BD0D3B2BC0C28BC96AFC2F354B141F1140659BEE23A15F7E3D210297DDCE80B1B27E77B251A3957908D063FC5153EA23621D336C8B9856B2596404498D41BCB6ADC9DAF4E884DAFEA10F0C2A0761633FD3E6A0AA91219F45DCB79',
        //             dgtlenvlp:'HGHju6Q+kxk7C5CrkoB51qfHztzwgh4KWWG7atoVvTqmENbk4NuMcCCYkuvu9A7fKB4vnf8lxWqW/p44q1idp6ZB0y7pC71lRxiXZ3YA467s00hukvw030fLW1B5t0kH6p+eAv1NCBOyEngjUiTk+aZo4s5w1kmunTM/tpAlVfGzQlDnBew+0ZrhMXjB0nRKdb576S6HCR2V6+lqIxlJX/0kFZU6oHs2MReIIvPIcdq/zS3/+uBPF4ARhg6JEqyBqs8VKB0j6bt0Cas2AkbtrX7dFAwZXYWpbzVfF6Wv8SsygI/a4VjYk7HXr4K41huOULoY4wX+OIyBhNu9OE4jhQ==',
        //             signSN:'70214041922',
        //             encryptSN:'70214041922'
        // }
        console.log(params);
        axios({  
            method:'post',  
            url:'/face',  
            data:params,  
            headers:{'Content-Type': 'application/x-www-form-urlencoded'},  
            transformRequest: function(obj) {  
                var str = [];  
                for(var p in obj){  
                    str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));  
                }  
                return str.join("&");  
            }  
        }).then((res)=>{
          this.code = res.data;
            console.log(res.data);
        });
            
      }

  }
}
</script>
