<!-- vip权益 -->
<template>
  <view class="box">
    <!-- vip信息 -->
    <view class="vipBox">
      <view class="avatar">
        <img :src="getUserAvatar(baseInfo?.avatar, baseInfo?.sex)" alt="" class="img-box">
        <image src="/static/svg/vip.svg" class="vipIcon"></image>
      </view>
      <view class="nameBox">
				<view class="name font-weight-bold font-size-16">{{ baseInfo?.name || userInfo?.phone }}</view>
				<view class="vipInfo font-size-14">
          14天双周卡将于{{ remaining }}后过期
        </view>
      </view>
    </view>
    <view style="height: 20rpx; background-color: #f8f8fa;"></view>
    <view class="card">
      <uni-list>
        <uni-list-item
          v-for="item in list"
          :clickable="true"
          :key="item.title"
          :title="item.title"
          showArrow
          :rightText="item.rightTex || ''"
          @click="handleToLink(item)"
        >
        </uni-list-item>
      </uni-list>
    </view>
  </view>
</template>

<script setup>
import { userStore } from '@/store/user'
import { ref, computed } from 'vue'
import { getUserAvatar } from '@/utils/avatar'


const useUserStore = userStore()
const baseInfo = computed(() => useUserStore?.baseInfo)
const userInfo = computed(() => useUserStore?.userInfo)

const remaining = computed(() => {
  if (!userInfo.value?.vipExpireDate) return '0'
  const diffInMs =  (userInfo.value?.vipExpireDate-0) - new Date().getTime()
  const day = diffInMs / (1000 * 60 * 60 * 24)
  return day < 1 ? '今天' : Math.floor(day) + '天'
})

const list = ref([
	{	title: '简历模板',	path: '/pagesA/vip/template/index'	},					
	// {	title: '屏蔽企业',	path: '/pagesA/vip/blockEnt/index'	},			
])

// 列表跳转
const handleToLink = (item) => {
	uni.navigateTo({
		url: item.path
	})
}


</script>
<style lang="scss" scoped>
.vipBox {
	// color: #a18a0f;
  padding: 80rpx 50rpx;
  display: flex;
  background: linear-gradient(121deg,#fde2c2 29.02%,#c19164 104.03%);
  .avatar{
    position: relative;
    width: 100rpx;
    height: 100rpx;
    margin: 0;
    .img-box {
      width: 100%;
      height: 100%;
      border: 2rpx solid #ccc;
      border-radius: 50%;
      border: 1px solid gold;
    }
    .vipIcon {
      position: absolute;
      width: 50%;
      height: 50%;
      bottom: 0;
      right: 0;
      transform: translate(0, 30%);
    }
  }
  .nameBox {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    margin-left: 30rpx;
    .name {
      color: #724d2b;
    }
    .vipInfo {
      color: #211000;
    }
  }
}

:deep(.uni-list-item) {
	height: 120rpx !important;
	line-height: 120rpx !important;
}
:deep(.uni-list-item__content-title) {
	font-size: 32rpx !important;
	font-weight: 500;
}
</style>
