Files
dvcp_v2_wechat_app/src/project/tianfuxing/AppMy/AppMy.vue

212 lines
4.4 KiB
Vue
Raw Normal View History

2022-11-01 18:30:12 +08:00
<template>
2022-11-01 19:18:44 +08:00
<div class="my">
2022-11-07 14:46:23 +08:00
<div class="user">
2022-11-02 17:23:17 +08:00
<image :src="user.avatarUrl || 'https://cdn.cunwuyun.cn/wxmp/tianfuxing/avatar.png'" />
2022-11-02 10:38:06 +08:00
<div class="right" v-if="isLogin">
2022-11-02 17:23:17 +08:00
<h2>{{ user.nickName }}</h2>
<p v-if="user.levelTitle">{{ user.levelTitle }}</p>
2022-11-01 19:18:44 +08:00
</div>
2022-11-02 10:38:06 +08:00
<div class="right" v-else @click="toLogin">
<h2>登录</h2>
<p>点击进行登录</p>
</div>
2022-11-01 19:18:44 +08:00
</div>
<div class="info">
<div class="info-item">
<h3>积分总额</h3>
2022-11-03 09:52:23 +08:00
<span>{{ user.integral || 0 }}</span>
2022-11-02 17:23:17 +08:00
<image src="https://cdn.cunwuyun.cn/wxmp/tianfuxing/nav2.png" />
2022-11-01 19:18:44 +08:00
</div>
<div class="info-item">
<h3>积分排名</h3>
2022-11-03 09:52:23 +08:00
<span>{{ user.integralOrder || 0 }}</span>
2022-11-02 17:23:17 +08:00
<image src="https://cdn.cunwuyun.cn/wxmp/tianfuxing/nav1.png" />
2022-11-01 19:18:44 +08:00
</div>
</div>
2022-11-07 14:46:23 +08:00
<div class="my-group">
<div class="group-item" hover-class="bg-hover" @click="linkTo('./UserInfo')">
<image src="https://cdn.cunwuyun.cn/wxmp/tianfuxing/banshijindu@2x.png" />
<span>个人中心</span>
</div>
2022-11-08 18:10:21 +08:00
<div class="group-item" hover-class="bg-hover" @click="linkTo('./Merchants')" v-if="user.merchantInfo && user.merchantInfo.status === '1'">
2022-11-07 14:46:23 +08:00
<image src="https://cdn.cunwuyun.cn/wxmp/tianfuxing/chaoshidingdan@2x.png" />
<span>商户中心</span>
</div>
<div class="group-item" hover-class="bg-hover" @click="linkTo('./Integral')">
<image src="https://cdn.cunwuyun.cn/wxmp/tianfuxing/wodejifen@2x.png" />
<span>积分明细</span>
2022-11-01 19:18:44 +08:00
</div>
</div>
2022-11-01 18:30:12 +08:00
</div>
</template>
<script>
2022-11-02 10:38:06 +08:00
import { mapActions, mapState } from 'vuex'
2022-11-01 18:30:12 +08:00
export default {
appName: '我的',
2022-11-02 10:38:06 +08:00
name: 'AppMy',
data () {
return {
2022-11-02 17:23:17 +08:00
list: [],
current: 1,
isMore: false
2022-11-02 10:38:06 +08:00
}
},
computed: {
...mapState(['user', 'token']),
isLogin () {
return !!this.user.id
}
},
2022-11-15 14:33:01 +08:00
onShow () {
if (this.token) {
this.getUserInfo()
}
},
2022-11-02 10:38:06 +08:00
onLoad () {
2022-11-02 16:28:18 +08:00
if (this.token) {
this.getUserInfo()
2022-11-03 14:55:37 +08:00
} else {
this.autoLogin()
2022-11-02 16:28:18 +08:00
}
2022-11-03 10:34:21 +08:00
uni.$on('updateUserInfo', () => {
this.getUserInfo()
})
2022-11-02 10:38:06 +08:00
},
methods: {
2022-11-02 16:28:18 +08:00
...mapActions(['autoLogin', 'getUserInfo']),
2022-11-02 10:38:06 +08:00
2022-11-07 14:46:23 +08:00
linkTo (url) {
2022-11-02 16:28:18 +08:00
if (!this.token) {
this.autoLogin()
} else {
2022-11-07 14:46:23 +08:00
this.$linkTo(url)
2022-11-02 16:28:18 +08:00
}
2022-11-02 10:38:06 +08:00
},
toLogin () {
2022-11-02 16:28:18 +08:00
if (!this.token) {
2022-11-03 09:52:23 +08:00
this.autoLogin().then(() => {
this.getUserInfo()
})
2022-11-02 16:28:18 +08:00
} else {
this.getUserInfo()
}
2022-11-02 17:23:17 +08:00
}
2022-11-03 16:08:39 +08:00
}
2022-11-01 18:30:12 +08:00
}
</script>
<style lang="scss" scoped>
2022-11-01 19:18:44 +08:00
.my {
2022-11-02 10:38:06 +08:00
padding-top: 32px;
padding-bottom: 30px;
2022-11-02 17:23:17 +08:00
div {
box-sizing: border-box;
}
2022-11-07 14:46:23 +08:00
.my-group {
margin: 0 32px;
.group-item {
display: flex;
align-items: center;
height: 100px;
margin-bottom: 24px;
padding: 0 16px;
box-shadow: 0 0 8px 0 rgba(0,0,0,0.02);
border-radius: 16px;
background: #fff;
image {
width: 48px;
height: 48px;
margin-right: 18px;
}
span {
color: #666666;
font-size: 30px;
}
}
}
2022-11-02 10:38:06 +08:00
.user, .info {
display: flex;
align-items: center;
padding: 0 48px;
}
.user {
line-height: 1;
margin-bottom: 48px;
image {
width: 112px;
height: 112px;
margin-right: 32px;
border-radius: 50%;
border: 4px solid #FFFFFF;
}
p {
2022-11-03 10:34:21 +08:00
margin-top: 18px;
2022-11-02 10:38:06 +08:00
color: #8891A1;
font-size: 26px;
}
h2 {
font-weight: 600;
font-size: 34px;
color: #1D2229;
}
}
.info {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 58px;
.info-item {
display: flex;
2022-11-02 17:23:17 +08:00
position: relative;
2022-11-02 10:38:06 +08:00
align-items: center;
justify-content: space-between;
font-size: 28px;
2022-11-02 17:23:17 +08:00
width: 318px;
2022-11-02 10:38:06 +08:00
height: 112px;
2022-11-02 17:23:17 +08:00
padding: 0 24px;
2022-11-02 10:38:06 +08:00
color: #4D5596;
2022-11-02 17:23:17 +08:00
box-sizing: border-box;
2022-11-01 18:30:12 +08:00
2022-11-02 17:23:17 +08:00
&:last-child {
2022-11-02 10:38:06 +08:00
color: #316568;
}
2022-11-02 17:23:17 +08:00
h3, span {
position: relative;
z-index: 2;
}
image {
position: absolute;
left: 0;
top: 0;
z-index: 1;
width: 318px;
height: 112px;
}
2022-11-02 10:38:06 +08:00
}
}
2022-11-01 19:18:44 +08:00
}
2022-11-01 18:30:12 +08:00
</style>