<template>
  <div>
    <van-nav-bar fixed>
      <template #title>
        <div>
          调试信息
        </div>
      </template>
    </van-nav-bar>
    <br> <br>
    <van-divider />
    <van-list
        v-model:loading="loading"
        :finished="finished"
        finished-text=""

    >
      <van-cell :title="'姓名: '+userInfo.nickName"/>
      <van-cell :title="'性别: '+(userInfo.nickName==1?'男':'女')"/>
      <van-cell :title="'账号: '+userInfo.account"/>
      <van-cell :title="'用户ID: '+userInfo.userId"/>
      <van-cell :title="'Token: '+userInfo.token"/>
      <van-cell :title="'接入地址: '+userInfo.domain"/>
    </van-list>
    <br>
    <van-button style="margin-left: 10%;width: 80%" round type="primary" color="#1989fa" @click="copyUserInfo()">
      复制
    </van-button>
    <br>    <br>
    <van-button style="margin-left: 10%;width: 80%" round type="danger" color="#EC808D" @click="handleBack()">
      关闭
    </van-button>
  </div>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      loading: true,
      finished: true,
      userInfo: JSON.parse(sessionStorage.getItem("userInfo"))||{},
    }
  },
  methods: {
    copyUserInfo(){
      let textarea = document.createElement('textarea');
      textarea.style.position = 'fixed';
      textarea.style.opacity = 0;
      textarea.value = JSON.stringify(this.userInfo);
      document.body.appendChild(textarea);
      textarea.select();
      document.execCommand('copy');
      document.body.removeChild(textarea);
      this.$toast.tips('已复制到剪贴板！');
    },
    handleBack(){
      this.$router.go(-1);
    }
  }
}
</script>
<style scoped lang="less">

</style>