<template>
  <div class="my">
    <van-nav-bar title="我的" class="van-nav-bar-my-fixed" fixed />
    <!-- right-text="登出"
       -->
    <div class="mine-resume">
      <div class="mine-resume-main">
        <ul class="clear">
          <li v-if="userData === null">
            <p class="title"><span>登录</span></p>
          </li>
          <li v-else>
            <p class="title">
              <span>您好,{{ userData.nickname }}</span>
            </p>
            <p>
              <span
                >有效期至{{
                  userData.expiretime
                }}</span
              >
            </p>
          </li>
          <li>
            <img :src="header" alt="" />
          </li>
        </ul>
      </div>
      <div class="top">
        <ul class="vip-box">
          <li class="vip-bg">
            <img :src="this.vip_text" alt="">
          </li>
        </ul>
        <div class="open-btn">
          <span>立即开通</span>
        </div>
          <!-- 我的页面下待收，待发、售后盒子 -->
          
          <ul class="cell-vip">
            <li v-for="(item,index) in cellVip" :key="item.n + index"
              class="vip-item">
              <img class="cell-my-img" :src="item.i" alt="" />
              <span class="vip-title">{{ item.n }}</span>
            </li>
          </ul>
      </div>
      

      <div class="bottom">
        <h1 class="common">常用功能</h1>
        <div class="cell-list">
          <div
            class="box-detaile"
            is-link
            v-for="(item, index) in cellList"
            :key="item.n + index"
            @click="goto(item.r)">
            <div class="detaile-box">
              <img class="cell-my-img" :src="item.i" alt="" />
              <span class="custom-title">{{ item.n }}</span>
            </div>
          </div>
        </div>
        <div class="my-btn-main">
          <van-button
            class="my-button"
            block
            type="info"
            @click.native="logout()">
            退出登录
          </van-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import asyncRequest from "@/apis/my/index";
import resToken from "@/mixins/resToken";
export default {
  mixins: [resToken],
  data() {
    return {
      header: require("@/assets/images/my/header.png"),//用户头像
      userData: null,
      ad: require("@/assets/images/my/ad.png"),//地理定位
      order: require("@/assets/images/my/order.png"),//用户订单
      unshipped:require("@/assets/images/my/unshipped.png"),//待发货
      shipped:require("@/assets/images/my/shipped.png"),//待收货
      service:require("@/assets/images/my/service.png"),//客户服务
      vip_bg:require("@/assets/images/my/vip_bg.png"),//vip盒子背景图
      vip_text:require("@/assets/images/my/vip_text.png"),//vip
      saleAfter:require("@/assets/images/my/saleAfter.png"),//售后服务
      loading: false,
      cellList: [],
      cellVip:[],
    };
  },
  async created() {
    this.cellList = [
      {
        r: "/address",
        i: this.ad,
        n: "我的地址",
      },
      {
        r: "/order",
        i: this.order,
        n: "我的订单",
      },
      {
        r: "/aboutUs",
        i: this.service,
        n: "联系我们",
      },
    ];
    // await this.getUserInfor();
    this.cellVip = [
      {
        r: "/address",
        i: this.unshipped,
        n: "待发货",
      },
      {
        r: "/order",
        i: this.shipped,
        n: "待收货",
      },
      {
        r: "/aboutUs",
        i: this.saleAfter,
        n: "售后",
      },
      
    ];
  },
  mounted() {
    this.getStock();
  },
  methods: {
    goto(url) {
      window.vm.$router.push({
        path: url,
      });
    },

    async getStock() {
      if (!this.loading) {
        let res = await asyncRequest.detail({});
        if (res && res.code == 0) {
          this.userData = res.data;
        } else if (res && res.code >= 100 && res.code <= 104) {
          await this.logout();
        } else {
          this.show_title(res.msg);
        }
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.my {
  position: relative;
  width: 100%;
  height: 100%;
  .mine-resume {
    padding-top: 46px;
    position: relative;
    box-sizing: border-box;
    width: 100%;

    .mine-resume-main {
      // background: transparent;
      // background-color: red;
      // background: linear-gradient(180deg, #F3CF23 0%, #FFFFFF 100%);
      padding: 0 0 10px 0;
      ul {
        padding: 16px;
        background: transparent;
        li {
          float: left;
          &:first-child {
            width: calc(100% - 60px);
            p {
              padding: 0 16px 0 0;
              margin: 0;
              color: #1a1a1a;
              font-size: 12px;
              line-height: 16px;
              color: #999999;
              &.title {
                color: #1a1a1a;
                font-weight: bolder;
                font-size: 16px;
                height: 30px;
                line-height: 21px;
                padding: 0 16px 0 0;
              }
            }
          }
          &:last-child {
            width: 60px;
            text-align: center;
            img {
              display: inline-block;
              width: 60px;
            }
          }
        }
      }
    }
    /**vip开通框 */
    .vip-box{
      width: 100%;
      height: 50px;
      position: relative;
      
      .vip-bg{
        border-top-left-radius: 13px;
        border-top-right-radius: 13px;
        width: 80%;
        height: 49px;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        background-color: #292F46 ;
        img{
          width: 44px;
          height: 19px;
          display: block;
          position: absolute;
          left: 26px;
          top: 18px;
        }
      }
      .vip-text{
        width: 100px;
        img{
          width: 100%;
        }
      }
    }
   /**vip服务区域样式 */

    .cell-vip {
      width: 305px;
      top: 25px;
      display: flex;
      position: relative;
      left: 50%;
      transform: translateX(-50%);
      .cell-my-img {
        display: block;
        width: 25px;
        height: 24px;
      }
      .vip-item{
        // margin-left: 25px;
        height: 50px;
        display: block;
        flex: 1 1 auto;
        text-align: center;
        font-size: 12px;
        color: #4D4D4D;
        line-height: 6px;
        font-family: Source Han Sans CN;
        padding-left:16px ;
        position: relative;
        img{
          width: 30px;
          height: 28px;
          display: block;
          position: absolute;
          left: 50%;
          transform: translateX(-50%);
        }
        span{
          height: 28px;
          display: block;
          position: absolute;
          top: 80%;
          left: 50%;
          transform: translateX(-50%);
        }
      }
    }
    .my-btn-main {
      width: 100%;
      margin: 18vh 0 0 0;
      // padding: 0 16px;
      box-sizing: border-box;
      .my-button {
        box-sizing: border-box;
        display: inline-block;
        border-radius: 20px;
        background: #dbdbdb;
        border: 0;
      }
    }
/**地址栏收获样式 */
    .cell-list {
      display: flex;
      background-color: #fff;
      .van-cell__title{
        width: 200px;
        position: relative;
        left: 0;
        top: 0;
        text-align: center;
        img{
          margin: 0 44px;
        }
      }
      .cell-my-img {
        display: block;
        width: 22px;
        height: 27px;
        margin: 0 5vh 4px 6vh;
      }
      
      
    }
    .my-btn-main {
      width: 100%;
      margin: 18vh 0 0 0;
      padding: 0 16px;
      box-sizing: border-box;
      .my-button {
        box-sizing: border-box;
        display: inline-block;
        border-radius: 20px;
        background: #dbdbdb;
        border: 0;
      }
    }
  }
}
.van-icon.van-icon-arrow.van-cell__right-icon{
  display: none;
}
.common{
  margin: 10px;
  width: 110px;
  height: 26px;
  font-size: 14px;
  font-family: Source Han Sans CN;
  font-weight: 600;
  color: #333333;
  line-height: 26px;
  position: relative;
  top: 0;
  left: 0;
  padding: 8px 609px 18px 15px;
}
.top{
  width: 100%;
  height:140px;
  position: relative;
  top: 0;
  .open-btn{
    width: 64px;
    height: 22px;
    background: linear-gradient(90deg, #DFA460 0%, #F0D0A1 100%);
    border-radius: 10px;
    text-align: center;
    line-height: 22px;
    position: absolute;
    left: 65%;
    top: 13px;
    span{
      width: 43px;
      height: 11px;
      font-size: 10px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: #FFFFFF;
      line-height:11px;
    }
  }
}
.bottom{
  width: 100%;
  position: relative;
  left: 0;
  box-sizing: border-box;
  background-color: #FFF;
}
.custom-title{
  font-size: 12px;
}
//常用功能下的按钮
.box-detaile{
  .detaile.box{
    width: 48px;
    height: 12px;
    .custom-title{
      font-size: 22px;      
    }
  }
}
</style>
