<template>
  <div class="items-center row">
    <img src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Goods/1713433759000_282.png"
                style="height: 33px" @click="forwardProduct" class="cusor-pointer"/>
    <div class="primary-link-button q-ml-lg cusor-pointer no-select" @click="addVisible=true">创建设计</div>
    <el-dropdown trigger="click">
      <el-avatar
        :size="size"
        :src="userInfo.photo"
        shape="square"
        style="background-color: #e6ddf5; color: #7b35ef"
        class="q-mx-lg cusor-pointer"
        ></el-avatar>
      <template #dropdown>
        <div class="MarketfigurePopover shrink">
          <div class="row">
            <!-- <div class="MarketfigureMin pointer shrink">
              <img class="reactive" src="../../assets/img/figure.png" />
            </div> -->
            <el-avatar
                :size="40"
                shape="square"
                :src="userInfo.photo"
                style="background-color: #e6ddf5; color: #7b35ef"
                class="q-mr-lg cusor-pointer shrink"
                ></el-avatar>
            <div>
              <div class="row items-center MarketfigureName">
                <span>{{ userInfo.nickname }}</span>
                <img
                  src="../../assets/img/homeVip.png"
                  width="65"
                  height="16"
                />
              </div>
              <div class="row MarketfigurePhon">
                <span>ID：123453789</span>
                <span>电话：180****1613</span>
              </div>
            </div>
          </div>
          <div class="MarketEquity">
            <div class="MarketEquityNum">
              <span>功能权益</span>
              <span>5+</span>
            </div>
            <div class="MarketEquityTime">有效期至2024.07.03</div>
          </div>
          <div class="MarketCapacity">
            <div>
              <el-progress
                :percentage="100"
                color="#0A5EF9"
                :stroke-width="8"
                text-inside
                :format="format"
              >
              </el-progress>
            </div>
            <div class="MarketCapacityNum row flex-between">
              <span>7.88 GB / 1.34 TB</span>
              <span>容量管理</span>
            </div>
          </div>
          <div class="MarketFootmark row items-center flex-between">
            <div>
              <span>足迹</span>
              <b>10</b>
            </div>
            <div>
              <span>收藏</span>
              <b>10</b>
            </div>
            <div>
              <span>共享</span>
              <b>10</b>
            </div>
          </div>
          <div class="TranLine"></div>
          <div class="MarketSettings row flex-between">
            <!-- <span>账号设置</span> -->
            <el-button link class="pingfangr" style="font-size: 14px" @click="forwardUserCenter">账号设置</el-button>
            <span class="pointer" @click="loginOutHandler">退出登录</span>
          </div>
        </div>
      </template>
    </el-dropdown>
    <el-dropdown trigger="click">
      <el-icon class="pointer" size="21" color="#070707"
        ><MoreFilled
      /></el-icon>
      <template #dropdown>
        <div class="MarketPopoverMore row wrap pointer">
          <div class="column" v-for="(item, index) in moreList" @click="forward(item.Url)">
            <div>
              <img :src="item.icon" width="34" height="34" />
            </div>
            <span>{{ item.Name }}</span>
          </div>
        </div>
      </template>
    </el-dropdown>
  </div>
  <!-- 创建设计 -->
  <temDesign :addTem="addVisible" @close="addVisible=false"/>
</template>
<script lang="ts" setup>
import { ref } from "vue";
import { useUserStore } from "@/store";
import { storeToRefs } from "pinia";
import { useRouter } from "vue-router";
import { openNewBlank } from "@/utils/common";
import temDesign from "@/components/home/temDesign.vue";
const props = defineProps({
    size: {
      type: Number,
      default: 33,
    },
});
const addVisible = ref(false)
const forwardProduct = () => router.push('/p/show')
const router = useRouter()
const useUser = useUserStore();
const { userInfo } = storeToRefs(useUser);
const format = (percentage: number) => {
    return percentage == 100 ? '' : ``
}
const moreList = [
  { icon: require("@/assets/img/homeMore0.png"), Name: "添加到桌面" },
  { icon: require("@/assets/img/homeMore1.png"), Name: "关注公众号" },
  { icon: require("@/assets/img/homeMore2.png"), Name: "我的订单", Url:'/u/order' },
  { icon: require("@/assets/img/homeMore3.png"), Name: "意见反馈" },
];

const forwardUserCenter = ()=>{
  router.push('/u')
}
const forward = (url:string|undefined)=>{
  if(url){
    if(url.includes('http://')||url.includes('https://')) openNewBlank(url)
    else router.push(url)
  }
}
const loginOutHandler = ()=>{
    useUser.setUserLoginOut()
}
</script>
<style scoped>
.MarketfigureName {
  font-family: PingFang SC;
  font-weight: bold;
  font-size: 18px;
  color: #000000;
  margin-top: 3px;
}
.MarketfigureMin img {
  margin-top: 18px;
}
.MarketCapacityNum span:last-child {
  font-family: PingFang SC;
  font-weight: 500;
  font-size: 14px;
  color: #5f68e5;
}
.MarketCapacityNum span:first-child {
  font-family: PingFang SC;
  font-weight: bold;
  font-size: 14px;
  color: #4e4e4e;
}
.MarketCapacityNum {
  margin-top: 10px;
}
.MarketfigurePhon span:last-child {
  margin-left: 20px;
}
.MarketfigurePhon {
  font-family: PingFang SC;
  font-weight: 400;
  font-size: 14px;
  color: #b4b4b4;
  margin-top: 5px;
}
.MarketfigureMin {
  background: #e6ddf5;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  text-align: center;
  margin-right: 10px;
  overflow: hidden;
}
.MarketfigurePopover {
  width: 380px;
  padding: 24px 30px 0 30px;
}
.MarketfigurePopover .el-button{
  font-size: 14px !important;
  font-weight: bold;
}
/* .Marketfigure:hover img {
  animation: myfirst 1s;
  -webkit-animation: myfirst 1s;
} */
.Marketfigure img {
  margin-top: 6px;
}
/* @keyframes myfirst {
  from {
    margin-top: 25px;
  }
  to {
    margin-top: 6px;
  }
}

@-webkit-keyframes myfirst {
  from {
    margin-top: 25px;
  }
  to {
    margin-top: 6px;
  }
} */
.Marketfigure {
  background: #e6ddf5;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  text-align: center;
  margin-left: 30px;
  margin-right: 22px;
  overflow: hidden;
}
.MarketPopoverMore > div span {
  text-align: right;
  padding-right: 17px;
  font-family: PingFang SC;
  font-weight: 400;
  font-size: 14px;
  color: #000000;
}
.MarketPopoverMore > div div {
  padding: 20px 0 22px 20px;
}
.MarketPopoverMore > div:first-child,
.MarketPopoverMore > div:nth-child(2) {
  margin-bottom: 25px;
}
.MarketPopoverMore > div:nth-child(2n) {
  margin-left: 28px;
}
.MarketPopoverMore > div {
  width: 140px;
  height: 105px;
  border-radius: 8px;
  background: #f3f6fb;
}
.MarketPopoverMore {
  width: 368px;
  padding: 30px;
}
.MarketEquityTime {
  font-family: PingFang SC;
  font-weight: 400;
  font-size: 14px;
  color: #8aa3cc;
}
.MarketEquityNum span:last-child {
  margin-left: 12px;
}
.MarketEquityNum {
  height: 14px;
  font-family: PingFang SC;
  font-weight: bold;
  font-size: 14px;
  color: #000000;
  margin-bottom: 12px;
}
.MarketEquity {
  height: 68px;
  background: url("../../assets/img/home-quanyi.png") no-repeat;
  background-size: 100% 100%;
  padding: 18px 13px;
  margin-top: 29px;
  margin-bottom: 30px;
}
.MarketFootmark b {
  color: #0a5ef9;
  margin-left: 5px;
}
.MarketFootmark span {
  font-size: 14px;
  color: #000000;
  font-family: PingFang SC;
}
.MarketFootmark {
  width: 100%;
  padding: 18px 21px;
  background: #eee;
  border-radius: 8px;
  margin-top: 28px;
  margin-bottom: 39px;
}
.MarketSettings span:last-child {
  font-weight: 400;
  color: #b4b4b4;
}
.MarketSettings span:first-child {
  font-weight: 500;
  color: #000000;
  padding: 10px 0 20px 0;
}
.MarketSettings span {
  font-family: PingFang SC;
  font-size: 14px;
  padding: 10px 0 20px 20px;
}
.MarketSettings {
  margin-top: 9px;
}
</style>
