mall-uniapp/pages/users/commission_rank/index.vue

245 lines
33 KiB
Vue
Raw Permalink Normal View History

2020-08-13 08:12:57 +00:00
<template>
<view>
<view class="CommissionRank">
<view class="header">
<view class="rank" v-if="position"><text class="num">{{position}}</text></view>
2020-08-13 08:12:57 +00:00
<view class="rank" v-else></view>
</view>
<view class="wrapper">
<view class="nav acea-row row-around">
2023-09-05 13:36:10 +00:00
<view class="item" :class="active === index ? 'font-color' : ''" v-for="(item,index) in navList"
:key="index" @click="switchTap(index)">
2020-08-13 08:12:57 +00:00
{{ item }}
</view>
</view>
<view class="list">
<view class="item acea-row row-between-wrapper" v-for="(item,index) in rankList" :key="index">
<view class="num" v-if="index <= 2">
2023-09-05 13:36:10 +00:00
<image :src="'/static/images/medal0' + (index+1) + '.png'" />
2020-08-13 08:12:57 +00:00
</view>
<view class="num" v-else>
2023-09-05 13:36:10 +00:00
{{index + 1}}
2020-08-13 08:12:57 +00:00
</view>
<view class="picTxt acea-row row-between-wrapper">
<view class="pictrue">
<image :src="item.avatar"></image>
</view>
2023-09-05 13:36:10 +00:00
<view class="text line1">{{ item.nickname }}</view>
2020-08-13 08:12:57 +00:00
</view>
2023-09-05 13:36:10 +00:00
<view class="people font-color">{{ fen2yuan(item.brokeragePrice) }}</view>
2020-08-13 08:12:57 +00:00
</view>
</view>
2023-09-05 13:36:10 +00:00
<view class='noCommodity' v-if="rankList.length === 0 && (page !== 1 || active === 0)">
<emptyPage title="暂无排行~"></emptyPage>
</view>
2020-08-13 08:12:57 +00:00
</view>
</view>
<home></home>
2020-08-13 08:12:57 +00:00
</view>
</template>
<script>
2023-09-05 13:36:10 +00:00
import { toLogin } from '@/libs/login.js';
import home from '@/components/home';
import emptyPage from '@/components/emptyPage.vue'
2023-09-05 13:36:10 +00:00
import { mapGetters } from "vuex";
import * as BrokerageAPI from '@/api/trade/brokerage.js'
import dayjs from "@/plugin/dayjs/dayjs.min.js";
import * as DateUtil from '@/utils/date.js';
import * as Util from '@/utils/util.js';
export default {
2020-08-13 08:12:57 +00:00
components: {
emptyPage,
home,
2020-08-13 08:12:57 +00:00
},
data() {
return {
navList: ["周排行", "月排行"],
active: 0,
rankList: [],
page: 1,
limit: 20,
2020-08-13 08:12:57 +00:00
loadend: false,
loading: false,
loadTitle: '加载更多',
type: 'week',
position: 0,
};
},
computed: mapGetters(['isLogin']),
watch:{
isLogin:{
2023-09-05 13:36:10 +00:00
handler:function(newV, oldV) {
if (newV) {
this.getBrokerageRankList();
this.getBrokerageRankNumber(this.type);
}
},
deep:true
}
},
2020-08-13 08:12:57 +00:00
onLoad() {
2023-09-05 13:36:10 +00:00
if (!this.isLogin) {
toLogin();
return;
2020-08-13 08:12:57 +00:00
}
2023-09-05 13:36:10 +00:00
this.calculateTimes();
this.getBrokerageRankList();
this.getBrokerageRankNumber(this.type);
2020-08-13 08:12:57 +00:00
},
methods: {
switchTap: function(index) {
this.active = index;
this.type = index ? 'month' : 'week';
this.page = 1;
this.loadend = false;
this.$set(this, 'rankList', []);
2023-09-05 13:36:10 +00:00
this.calculateTimes();
2020-08-13 08:12:57 +00:00
this.getBrokerageRankList();
this.getBrokerageRankNumber(this.type);
2020-08-13 08:12:57 +00:00
},
2023-09-05 13:36:10 +00:00
getBrokerageRankNumber() {
BrokerageAPI.getBrokerageUserRankByPrice({
// 'startTime': this.times[0],
// 'endTime': this.times[1],
'times': this.times
2020-08-13 08:12:57 +00:00
}).then(res => {
this.position = res.data;
})
},
getBrokerageRankList: function() {
2023-09-05 13:36:10 +00:00
if (this.loadend || this.loading) {
return;
}
2020-08-13 08:12:57 +00:00
this.loading = true;
this.loadTitle = '';
2023-09-05 13:36:10 +00:00
BrokerageAPI.getBrokerageUserRankPageByPrice({
pageNo: this.page,
pageSize: this.limit,
'times[0]': this.times[0],
'times[1]': this.times[1],
2020-08-13 08:12:57 +00:00
}).then(res => {
2023-09-05 13:36:10 +00:00
let list = res.data.list;
let loadend = list.length <= this.limit;
this.rankList.push.apply(this.rankList, list);
this.loading = false;
this.loadend = loadend;
this.loadTitle = loadend ? '😕我也是有底线的' : '加载更多';
this.$set(this, 'rankList', this.rankList);
2020-08-13 08:12:57 +00:00
}).catch(err => {
this.loading = false;
2023-09-05 13:36:10 +00:00
this.loadTitle = '加载更多';
2020-08-13 08:12:57 +00:00
})
2023-09-05 13:36:10 +00:00
},
calculateTimes: function() {
let times;
if (this.type === 'week') {
times = DateUtil.getWeekTimes();
} else {
times = DateUtil.getMonthTimes();
}
this.times = [ this.formatDate(times[0]), this.formatDate(times[1]) ]
},
formatDate: function(date) {
return dayjs(date).format("YYYY-MM-DD HH:mm:ss");
},
fen2yuan(price) {
return Util.fen2yuan(price)
},
2020-08-13 08:12:57 +00:00
},
onReachBottom: function() {
this.getBrokerageRankList();
}
}
</script>
<style scoped lang="scss">
.CommissionRank .header {
background: url("data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wgARCAFYAu4DAREAAhEBAxEB/8QAHAABAAIDAQEBAAAAAAAAAAAAAAIDAQQFBwYI/8QAGwEBAAIDAQEAAAAAAAAAAAAAAAECAwQFBgf/2gAMAwEAAhADEAAAAPnvKfaQAAAAAAAAAAAAAAAAAAAAAAAAAAAAImAYRgGDBiYGAYAAAMgyZETkyZBlOQSAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAImAYRgwYMTGDBgxMDAMAAyAZMwykZMmYnJkyZTkEgAAAAAAAAAAAAAAAAAAAAAAAAAAACIMGEYMGJiJgwYmMEQjEsGYXY6TrXJGZqvau9hkzE5MmTMTIyZicmTJlOSQAAAAAAAAAAAAAAAAAAAAAAAAAABEwYRgwYmImCMxgiYmMQ7WhqfScnR73N0+xo6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Xp7mHXvpjFc2rtk427v8/Y3Ozpc6m+TZ2MfTjT3KYL4x5iBtb+Dv+q5ny3hu2QK5vq3zaN9jlYdy3FSi+Tlbm99byODZWs60nEV2tq5c23u4tjSw14L+H/TfaAAAAAAAAAAAAAAAAAAAARMEUQmIFcxXMX4cPvXz
width: 100%;
height: 344rpx;
background-size: 100% 100%;
}
.CommissionRank .header .rank {
font-size: 33rpx;
color: #fff;
position: absolute;
top: 160rpx;
left: 48rpx;
}
.CommissionRank .header .rank .num {
font-size: 51rpx;
font-weight: bold;
margin: 0 10rpx;
}
.CommissionRank .wrapper {
width: 710rpx;
background-color: #fff;
border-radius: 14rpx;
2020-08-13 08:12:57 +00:00
margin: -76rpx auto 0 auto;
}
.CommissionRank .wrapper .nav {
height: 99rpx;
border-bottom: 2.5rpx solid #f3f3f3;
font-size: 30rpx;
font-weight: bold;
color: #999;
line-height: 99rpx;
}
.CommissionRank .wrapper .nav .item.font-color {
border-bottom: 4rpx solid $theme-color;
margin-top: -2rpx;
2020-08-13 08:12:57 +00:00
}
.CommissionRank .wrapper .list {
padding: 0 30rpx;
}
.CommissionRank .wrapper .list .item {
border-bottom: 1px solid #f3f3f3;
height: 101rpx;
font-size: 28rpx;
}
.CommissionRank .wrapper .list .item .num {
color: #666;
width: 70rpx;
}
.CommissionRank .wrapper .list .item .num image {
width: 34rpx;
height: 40rpx;
display: block;
}
.CommissionRank .wrapper .list .item .picTxt {
width: 350rpx;
}
.CommissionRank .wrapper .list .item .picTxt .pictrue {
width: 68rpx;
height: 68rpx;
}
.CommissionRank .wrapper .list .item .picTxt .pictrue image {
width: 100%;
height: 100%;
display: block;
border-radius: 50%;
}
.CommissionRank .wrapper .list .item .picTxt .text {
width: 262rpx;
color: #333;
}
.CommissionRank .wrapper .list .item .people {
width: 175rpx;
text-align: right;
}
</style>