<!--
 * @Description: file content
 * @Version: 2.0
 * @Author: ljl
 * @Date: 2022-06-21 11:56:02
 * @LastEditors: ljl
 * @LastEditTime: 2022-07-05 14:45:36
 * @FilePath: \sui-shen-ban_alipay\src\views\index.vue
-->
<template>
  <div></div>
</template>
<script>
import { setCookies, removeAllCookie } from "@/utils/auth";
import { getTestAccesstoken, getAlipayUser } from "@/api/index";
export default {
  name: "Home",
  created() {
    removeAllCookie();
    let accesstoken = this.getUrlParms("accesstoken");
      getAlipayUser({ accesstoken: accesstoken }).then((res) => {
        setCookies("myInfo", JSON.stringify(res.data));
        setCookies("idcard", res.data.idcard);
        this.$router.push({
          name: "ConsultationRecord",
        });
      });
    // getTestAccesstoken().then((res) => {
    //   let accesstoken = res.result.data;
    // });
    // var ua = navigator.userAgent.toLowerCase();
    // if (ua.indexOf("alipay") > -1) {
    //   if (ua.indexOf("miniprogram") > -1) {
    //     // alert("在支付宝小程序里");
    //   } else {
    //     // alert("在支付宝浏览器里");
    //   }
    // }
  },

  methods: {
    getUrlParms: function (name) {
      var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
      var getHref = decodeURI(window.location.search);
      var r = getHref.substr(1).match(reg);
      if (r != null) return unescape(r[2]);
      return null;
    },
  },
};
</script>