You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

282 lines
7.2 KiB
Vue

4 years ago
<template>
<div class="usercenter-container">
<div class="usercontent w">
<div class="leftlist">
4 years ago
<!-- <div class="userbaseinfo">
4 years ago
<ul>
<li
@click="pushto('/userinfo/usercenter/townsman')"
:class="{ tagactive: activelist === 1 }"
>
<span><i class="iconfont icon-laoxiang"></i>我的老乡</span
><i class="iconfont icon-youjiantou"></i>
</li>
<li
@click="pushto('/userinfo/usercenter/mybill')"
:class="{ tagactive: activelist === 2 }"
>
<span><i class="iconfont icon-gongdan"></i>我的工单</span
><i class="iconfont icon-youjiantou"></i>
</li>
</ul>
4 years ago
</div> -->
4 years ago
<div class="priceinfo">
4 years ago
<ul style="">
4 years ago
<li
@click="pushto('/userinfo/usercenter/myintegral')"
:class="{ tagactive: activelist === 3 }"
>
<span><i class="iconfont icon-jifen"></i>我的积分</span
><span
4 years ago
><span>{{ userpoint >= 0 ? userpoint : "--" }}</span
4 years ago
><i class="iconfont icon-youjiantou"></i
4 years ago
></span>
</li>
<li
@click="pushto('/userinfo/usercenter/mycard')"
:class="{ tagactive: activelist === 4 }"
>
<span><i class="iconfont icon-kaquan"></i>我的卡券</span
><span
4 years ago
><span
>{{
4 years ago
cardinfo.recordCount ? cardinfo.recordCount : "0"
4 years ago
}}</span
><i class="iconfont icon-youjiantou"></i
4 years ago
></span>
</li>
<li
@click="pushto('/userinfo/usercenter/mybalance')"
:class="{ tagactive: activelist === 5 }"
>
<span><i class="iconfont icon-yue"></i>我的余额</span
><span
4 years ago
><span>{{ userbalance >= 0 ? userbalance : "0" }}</span>
4 years ago
<i class="iconfont icon-youjiantou"></i
4 years ago
></span>
</li>
</ul>
</div>
</div>
<div class="rightcontent">
4 years ago
<router-view
:userpoint="userpoint"
:userbalance="userbalance"
></router-view>
4 years ago
</div>
</div>
</div>
</template>
<script>
4 years ago
import {
userBalanceApi,
getPointApi,
userCardApi,
} from "../../../api/userinfo";
4 years ago
export default {
// 组件名称
4 years ago
name: "usercenter-container",
4 years ago
// 局部注册的组件
components: {},
// 组件参数 接收来自父组件的数据
props: {},
// 组件状态值
data() {
return {
activelist: "",
4 years ago
userbalance: "",
4 years ago
userpoint: "",
cardinfo: {},
4 years ago
// path:,
};
},
// 计算属性
computed: {
path() {
return this.$route.fullPath;
},
},
// 侦听器
watch: {
path() {
this.listactive();
},
},
// 生命周期钩子 注:没用到的钩子请自行删除
/**
* 组件实例创建完成属性已绑定但DOM还未生成$ el属性还不存在
*/
created() {
this.listactive();
4 years ago
this.getUserBalanceInfo();
4 years ago
this.getPoint();
this.getcardcount();
4 years ago
},
/**
* el 被新创建的 vm.el 替换并挂载到实例上去之后调用该钩子
* 如果 root 实例挂载了一个文档内元素 mounted 被调用时 vm.el 也在文档内
*/
mounted() {},
// 组件方法
methods: {
pushto(url) {
this.$router.push(url);
},
listactive() {
console.log(this.path);
console.log(1);
if (this.path.indexOf("/townsman") > -1) {
this.activelist = 1;
} else if (this.path.indexOf("/mybill") > -1) {
this.activelist = 2;
} else if (this.path.indexOf("/myintegral") > -1) {
this.activelist = 3;
} else if (this.path.indexOf("/mycard") > -1) {
this.activelist = 4;
} else if (this.path.indexOf("/mybalance") > -1) {
this.activelist = 5;
}
},
4 years ago
async getUserBalanceInfo() {
try {
const { data } = await userBalanceApi();
4 years ago
this.userbalance = data.data.balance / 100;
4 years ago
console.log(data);
4 years ago
console.log(this.userbalance);
} catch (error) {
console.log(error);
}
},
async getPoint() {
try {
const { data } = await getPointApi();
console.log(data);
this.userpoint = data.data.pointTotal;
} catch (error) {
console.log(error);
}
},
async getcardcount() {
try {
const { data } = await userCardApi();
console.log(data);
this.cardinfo = data.data;
4 years ago
} catch (error) {
console.log(error);
}
},
4 years ago
},
};
</script>
<style scoped lang="less">
.usercontent {
4 years ago
// height: 1000px;
4 years ago
margin-top: 16px;
// background-color: pink;
display: flex;
.leftlist {
width: 346px;
4 years ago
// height: 500px;
// background-color: skyblue;
4 years ago
margin-right: 16px;
.userbaseinfo {
ul {
// padding-left: 50px;
background-color: #fff;
border-radius: 4px;
overflow: hidden;
li {
position: relative;
display: flex;
4 years ago
padding: 16px;
4 years ago
line-height: 24px;
justify-content: space-between;
background-color: #fff;
// border-bottom: 1px solid #f3f4f4;
cursor: pointer;
&:nth-child(1):after {
position: absolute;
content: "";
display: inline-block;
height: 1px;
width: 314px;
4 years ago
bottom: -1px;
4 years ago
left: 16px;
background-color: #f3f4f4;
}
span {
font-size: 16px;
i {
margin-right: 12px;
font-size: 20px;
}
}
> i {
color: #888;
font-size: 22px;
}
}
}
}
.priceinfo {
ul {
4 years ago
// margin-top: 16px;
4 years ago
// padding: 0 16px;
background-color: #fff;
border-radius: 4px;
overflow: hidden;
li {
position: relative;
display: flex;
padding: 16px 16px 16px 16px;
line-height: 24px;
justify-content: space-between;
// border-bottom: 1px solid #f3f4f4;
cursor: pointer;
&:nth-child(-n + 2):after {
position: absolute;
content: "";
display: inline-block;
height: 1px;
width: 314px;
4 years ago
bottom: -1px;
4 years ago
left: 16px;
background-color: #f3f4f4;
}
span:first-of-type {
font-size: 16px;
i:first-of-type {
margin-right: 12px;
font-size: 20px;
vertical-align: middle;
}
}
span:last-of-type {
span {
color: #999999;
font-size: 14px;
}
i {
color: #888;
font-size: 22px;
vertical-align: middle;
}
}
}
}
}
}
.rightcontent {
width: 838px;
4 years ago
min-height: 600px;
4 years ago
// height: 600px;
padding: 0 16px;
4 years ago
background-color: #fff;
}
}
</style>