web-base-pc/src/views/index/components/sidebarUserInfo.vue

451 lines
10 KiB
Vue
Raw Normal View History

2025-03-23 09:23:38 +08:00
<template>
<div class="sidebar-container">
2025-03-23 09:23:38 +08:00
<div class="sidebarTop">
<div class="sidebarHeader">
<img
:src="
userInfo.headPath ? userInfo.headPath : userInfo.countryCircularIcon
"
alt=""
/>
</div>
<div class="nameCountry">
<div class="username">{{ userInfo.memberName }}</div>
<img :src="userInfo.countrySquareIcon" alt="" />
</div>
<!-- 如果是0表示没有奖衔 只显示等级徽章!-->
<div class="gradeClass">
<img
@error="defaultSrc"
v-if="userInfo.gradeIcon || defaultSrc == true"
@click="goRouter(1)"
:src="userInfo.gradeIcon"
alt=""
/>
</div>
<div class="honor_wrapper">
<div class="honor1">
<div class="honor-title-wrapper">
<div>荣誉奖衔</div>
<div class="honor-title">{{ userInfo.pkAwardsVal }}</div>
2025-03-23 09:23:38 +08:00
</div>
</div>
</div>
</div>
<!--! 用户卡片信息 -->
<div class="awardscard">
<div class="user-cards" @click="clickTap">
<div class="user-cards-left">
<div class="progress-wrapper">
<div class="progress-wrapper__label">昨日业绩</div>
2025-03-23 09:23:38 +08:00
<div
:class="
awards.aNewPv != 0 && awards.bNewPv != 0
? 'schedule1'
: 'schedule'
"
2025-03-23 09:23:38 +08:00
>
<div
class="current-schedule"
:style="{
width: yesPercent(awards.aNewPv, awards.bNewPv),
2025-03-23 09:23:38 +08:00
}"
></div>
<div class="cha">
左区 {{ awards.aNewPv }}/右区 {{ awards.bNewPv }}
2025-03-23 09:23:38 +08:00
</div>
</div>
</div>
<div class="progress-wrapper">
<div class="progress-wrapper__label">当月业绩</div>
<div
:class="
awards.aMonthPv != 0 && awards.bMonthPv != 0
? 'schedule1'
: 'schedule'
"
>
2025-03-23 09:23:38 +08:00
<div
class="current-schedule"
:style="{
width: yesPercent(awards.aMonthPv, awards.bMonthPv),
2025-03-23 09:23:38 +08:00
}"
></div>
<div class="cha">
左区 {{ awards.aMonthPv }}/右区 {{ awards.bMonthPv }}
</div>
2025-03-23 09:23:38 +08:00
</div>
</div>
<div class="progress-wrapper">
<div class="progress-wrapper__label">历史业绩</div>
<div
:class="
awards.aSumPv != 0 && awards.bSumPv != 0
? 'schedule1'
: 'schedule'
"
>
2025-03-23 09:23:38 +08:00
<div
class="current-schedule"
:style="{
width: yesPercent(awards.aSumPv, awards.bSumPv),
}"
></div>
<div class="cha">
左区 {{ awards.aSumPv }}/右区 {{ awards.bSumPv }}
</div>
2025-03-23 09:23:38 +08:00
</div>
</div>
</div>
</div>
</div>
<!-- 会员有效!-->
<div
class="create-time"
v-if="userInfo.pkCountry == 1 && userInfo.expireDate"
>
有效期{{ userInfo.expireDate }}
</div>
<!-- 注册时间!-->
<div class="create-time">注册时间{{ userInfo.registerTime }}</div>
2025-03-23 09:23:38 +08:00
<div class="countDown">
<div class="divs">{{ userDay }}</div>
<div class="margin-s"></div>
2025-03-23 09:23:38 +08:00
<div class="divs">{{ userHr }}</div>
<div class="margin-s"></div>
2025-03-23 09:23:38 +08:00
<div class="divs">{{ userMin }}</div>
<div class="margin-s"></div>
2025-03-23 09:23:38 +08:00
<div class="divs">{{ userSec }}</div>
<div class="margin-s"></div>
2025-03-23 09:23:38 +08:00
</div>
</div>
</template>
<script>
import * as sid from "@/api/sidebaruserinfo.js";
import { mapGetters } from "vuex";
import user from "@/store/modules/user";
export default {
name: "sidebarUserInfo",
computed: {
user() {
return user;
},
...mapGetters(["userInfo"]),
},
data() {
return {
countTime: 11183423,
userDay: 0,
userHr: 0,
awards: {},
userMin: 0,
userSec: 0,
_interval: "",
toLiveBtn: "",
isHandImg: true,
};
},
created() {
this.countdown();
this.getUserAwards();
2025-03-23 09:23:38 +08:00
},
2025-03-23 09:23:38 +08:00
beforeDestroy() {
clearInterval(this._interval);
},
methods: {
clickTap() {
this.$router.push({
path: "/personal",
query: {
id: 5,
},
});
},
2025-03-23 09:23:38 +08:00
defaultSrc() {
this.isHandImg = false;
},
yesPercent(left, right) {
left = parseFloat(left);
right = parseFloat(right);
if (isNaN(left) || isNaN(right)) {
return "-";
}
return right + left == 0
? "0%"
: Math.round((left / (right + left)) * 10000) / 100.0 + "%";
},
2025-03-23 09:23:38 +08:00
// 倒计时事件
countdown() {
const that = this;
that._interval = setInterval(() => {
let time = new Date(this.userInfo.registerTime).getTime() / 1000;
let time1 = new Date().getTime() / 1000;
let time2 = parseInt(time1 - time);
that.countTime = time2;
that.countTime++;
let day = parseInt(that.countTime / 60 / 60 / 24);
let hr = parseInt((that.countTime / 60 / 60) % 24);
let min = parseInt((that.countTime / 60) % 60);
let sec = parseInt(that.countTime % 60);
day = day > 9 ? day : "0" + day;
hr = hr > 9 ? hr : "0" + hr;
min = min > 9 ? min : "0" + min;
sec = sec > 9 ? sec : "0" + sec;
// that.toLiveBtn = `${day}天${hr}时${min}分${sec}秒`
that.userDay = day;
that.userHr = hr;
that.userMin = min;
that.userSec = sec;
}, 1000);
},
2025-03-23 09:23:38 +08:00
//获取用户真实奖衔
getUserAwards() {
2025-03-23 09:23:38 +08:00
sid.getUserAwards().then((res) => {
this.awards = res.data;
});
},
goRouter(index) {
//1等级2奖衔
this.$router.push({
path: "/roadtoGrowth",
query: { index: index },
});
},
},
};
</script>
<style lang="scss" scoped>
.avatar {
img {
width: 60px;
height: 60px;
border-radius: 50%;
margin-top: 10px;
padding: 0 15px;
}
}
.user-name {
color: #333;
font-size: 18px;
//width: 100px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
2025-03-23 09:23:38 +08:00
::v-deep .el-input--suffix .el-input__inner {
background: #fff !important;
}
::v-deep .el-input--suffix .el-input__inner {
background: #fff !important;
}
.seamless-warp {
//height: 196px;
overflow: hidden;
line-height: 14px;
text-align: left;
font-size: 12px;
.item {
margin: 0;
text-align: center;
margin-left: -40px;
li {
list-style: none;
}
.title {
font-size: 12px;
line-height: 20px;
}
}
}
.sidebar-container {
2025-03-23 09:23:38 +08:00
width: 380px;
padding: 20px 0;
background: #ffffff;
box-shadow: 5px 5px 20px 0px rgba(233, 233, 233, 0.5);
border-radius: 10px 10px 10px 10px;
opacity: 1;
margin-right: 20px;
.sidebarTop {
text-align: center;
display: flex;
flex-direction: column;
align-items: center;
.sidebarHeader {
img {
width: 80px;
height: 80px;
border-radius: 50%;
}
}
.nameCountry {
margin-top: 20px;
display: flex;
align-content: center;
align-items: center;
.username {
font-size: 22px;
margin-right: 12px;
}
img {
width: 39px;
height: 26px;
}
}
.gradeClass {
display: flex;
width: 200px;
margin-top: 20px;
align-items: center;
justify-content: space-around;
img {
width: 55px;
//height: 45px;
cursor: pointer;
}
}
}
.create-time {
margin: 10px auto 10px auto;
color: #666;
font-size: 14px;
text-align: center;
}
.countDown {
display: flex;
padding: 0 40px;
line-height: 40px;
font-size: 14px;
color: #666;
.margin-s {
margin: 0 10px;
}
.divs {
padding: 0 10px;
//width: 40px;
height: 40px;
border-radius: 8px 8px 8px 8px;
opacity: 1;
border: 1px solid #979797;
color: var(--primary-color);
2025-03-23 09:23:38 +08:00
font-size: 18px;
text-align: center;
line-height: 40px;
}
}
2025-04-27 11:05:47 +08:00
2025-03-23 09:23:38 +08:00
.awardscard {
width: 346px;
margin: 0 auto;
margin-top: 10px;
background: url("~@/assets/images/id-card-bg.png") no-repeat;
background-size: 100% 100%;
//background: linear-gradient(180deg, #f8d869 0%, #f48b1f 100%);
border-radius: 10px;
position: relative;
.user-cards {
cursor: pointer;
padding: 16px 10px;
2025-03-23 09:23:38 +08:00
// position: absolute;
z-index: 1;
// display: flex;
.user-card-bg {
position: absolute;
right: 0;
top: 0;
img {
width: 145px;
height: 145px;
}
}
.user-cards-left {
.schedule {
// width: 149px;
flex: 1;
height: 16px;
background: rgba(255, 255, 255, 0.3);
border-radius: 10px 10px 10px 10px;
margin: 5px;
position: relative;
}
.schedule1 {
// width: 149px;
flex: 1;
height: 16px;
background: #fff;
border-radius: 10px 10px 10px 10px;
margin: 5px;
position: relative;
}
.current-schedule {
position: absolute;
width: 30%;
background: #fea43c;
height: 16px;
border-radius: 10px 10px 10px 10px;
}
.progress-wrapper {
2025-03-23 09:23:38 +08:00
display: flex;
align-items: center;
margin-top: 5px;
}
.progress-wrapper:first-child {
margin-top: 0px;
}
.progress-wrapper__label {
2025-03-23 09:23:38 +08:00
margin-right: 10px;
font-size: 12px;
color: #fff;
}
.cha {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 12px;
white-space: nowrap;
2025-03-23 09:23:38 +08:00
}
.state {
font-size: 10px;
color: #fff;
margin: 10px 0 0 0px;
span {
font-size: 14px;
font-weight: 600;
}
}
}
}
}
}
.honor_wrapper {
2025-03-23 09:23:38 +08:00
width: 100%;
.honor1 {
width: 100%;
font-size: 14px;
display: flex;
align-items: center;
justify-content: space-between;
margin: 10px 0 0px 0;
.honor-title-wrapper {
flex: 1;
}
.honor-title {
font-weight: 600;
font-size: 18px;
}
}
2025-03-23 09:23:38 +08:00
}
</style>