<!--
 * @Description: file content
 * @Version: 2.0
 * @Author: ljl
 * @Date: 2022-06-21 11:56:02
 * @LastEditors: ljl
 * @LastEditTime: 2022-07-05 15:37:35
 * @FilePath: \sui-shen-ban_wechat\src\views\index.vue
-->
<template>
  <div></div>
</template>
<script>
import { setCookies, removeAllCookie } from "@/utils/auth";
import { getTestAccesstoken, getWeChatUser } from "@/api/index";
export default {
  name: "Home",
  created() {
    removeAllCookie();
    let accesstoken = this.getUrlParms("accesstoken");
    getWeChatUser({ 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.match(/MicroMessenger/i) == "micromessenger") {
    //   //ios的ua中无miniProgram，但都有MicroMessenger（表示是微信浏览器）
    //   wx.miniProgram.getEnv((res) => {
    //     if (res.miniprogram) {
    //       //   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>