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

291 lines
5.8 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-02 16:28:18 +08:00
<div class="user" @click="toSetting">
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>
<div class="my-list">
<h2>积分明细</h2>
<div class="list">
2022-11-02 17:23:17 +08:00
<div class="item" v-for="(item, index) in list" :key="index">
2022-11-01 19:18:44 +08:00
<div class="left">
2022-11-02 17:23:17 +08:00
<h2>{{ item.detail }}</h2>
<p>{{ item.createTime }}</p>
2022-11-01 19:18:44 +08:00
</div>
<div class="right">
2022-11-02 17:23:17 +08:00
<i>{{ item.calcType === '0' ? '-' : '+' }}</i>
<span>{{ item.integral || 0 }}</span>
2022-11-01 19:18:44 +08:00
<em>积分</em>
</div>
</div>
2022-11-02 17:23:17 +08:00
<AiEmpty v-if="!list.length"></AiEmpty>
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
}
},
onLoad () {
2022-11-02 16:28:18 +08:00
if (this.token) {
this.getUserInfo()
2022-11-02 17:23:17 +08:00
this.getList()
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
},
2022-11-03 16:08:39 +08:00
onShow () {
this.isMore = false
this.current = 1
this.$nextTick(() => {
this.getList()
})
},
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-02 16:28:18 +08:00
toSetting () {
if (!this.token) {
this.autoLogin()
} else {
this.$linkTo('./UserInfo')
}
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.getList()
this.getUserInfo()
})
2022-11-02 16:28:18 +08:00
} else {
this.getUserInfo()
}
2022-11-02 17:23:17 +08:00
},
getList () {
if (this.isMore) return
2022-11-03 09:52:23 +08:00
this.$instance.post(`/api/appwechatintegraldetail/list`, null, {
2022-11-02 17:23:17 +08:00
params: {
current: this.current,
2022-11-03 10:34:21 +08:00
size: 10,
openId: this.user.openId
2022-11-02 17:23:17 +08:00
}
}).then(res => {
if (res.code === 0) {
this.$hideLoading()
if (this.current > 1) {
this.list = [...this.list, ...res.data.records]
} else {
this.list = res.data.records
}
if (res.data.records.length < 10) {
this.isMore = true
return false
}
this.current = this.current + 1
} else {
this.isMore = true
}
}).catch(() => {
this.$hideLoading()
})
}
},
2022-11-03 16:08:39 +08:00
onReachBottom () {
this.getList()
}
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-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;
}
}
.my-list {
padding: 0 32px;
& > h2 {
margin-bottom: 42px;
font-weight: 600;
font-size: 34px;
color: #333333;
}
.item {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 24px;
padding: 24px;
background: #FFFFFF;
box-shadow: 0 0 8px 0 rgba(0,0,0,0.02);
border-radius: 16px;
.right {
display: flex;
align-items: baseline;
line-height: 1;
i {
color: #FFB94C;
font-size: 32px;
}
span {
color: #FFB94C;
font-size: 40px;
}
em {
font-size: 26px;
color: #999999;
}
}
.left {
flex: 1;
margin-right: 20px;
h2 {
line-height: 1.3;
margin-bottom: 10px;
font-size: 34px;
color: #333333;
}
p {
font-size: 26px;
color: #999999;
}
}
}
}
.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>