Files
tk-mini-program/components/contentList/contentList.vue

168 lines
3.9 KiB
Vue
Raw Normal View History

2025-05-12 21:23:37 +08:00
<template>
2025-05-23 21:50:04 +08:00
<scroll-view scroll-y="true" class="scroll" refresher-enabled="true" refresher-threshold="40" @refresherrefresh="onRefresherRefresh" lower-threshold="100" @scrolltolower="onScrollToLower" >
2025-05-22 16:21:07 +08:00
<uni-card v-for="(item, index) in list">
<view class="content-list" @click="goDetail(item)">
2025-05-12 21:23:37 +08:00
<!-- `````````````````````````` -->
2025-05-22 16:21:07 +08:00
<image class="headShot" :src="item.anchorIcon" mode="scaleToFill" />
2025-05-12 21:23:37 +08:00
<!-- `````````````````````````````````````` -->
<view class="content-list-title">
2025-05-22 16:21:07 +08:00
<view class="cardname">{{ item.anchorId }}</view>
2025-05-12 21:23:37 +08:00
<view class="content-list-info">
2025-05-22 16:21:07 +08:00
<view :class="{Gendermale:item.sex === '1',Genderfemale:item.sex === '2'}">
<image v-if="item.sex === '2'" class="Genderimg" src="../../static/female.png" mode="scaleToFill" />
<image v-else class="Genderimg" src="../../static/male.png" mode="scaleToFill" />
<view class="age">{{ item.sex === '1'? "男" : "女" }}</view>
2025-05-12 21:23:37 +08:00
</view>
2025-05-22 16:21:07 +08:00
<view class="RoomID">PK时间:&nbsp;{{formatDate(item.pkTime)}}</view>
<view class="Charm">金币:</view>
<view class="charmValue"> {{item.coin+'K'}}</view>
2025-05-12 21:23:37 +08:00
</view>
</view>
<!-- `````````````````````````````````````````````````````` -->
2025-05-22 16:21:07 +08:00
</view>
2025-05-12 21:23:37 +08:00
</uni-card>
</scroll-view>
</template>
<script>
2025-05-21 22:52:33 +08:00
import request from "../../components/request.js";
2025-05-22 16:21:07 +08:00
import formatDate from "../../components/formatDate.js";
2025-05-12 21:23:37 +08:00
export default {
2025-05-22 22:05:55 +08:00
inject: ['$global'],
2025-05-12 21:23:37 +08:00
data() {
return {
2025-05-22 16:21:07 +08:00
page: 0,//页码
size: 10, //每页条数
list: [], // 列表数据
2025-05-12 21:23:37 +08:00
};
},
2025-05-21 22:52:33 +08:00
mounted() {
// 页面加载完成后请求数据
this.pkList()
2025-05-12 21:23:37 +08:00
},
methods: {
2025-05-23 21:50:04 +08:00
onRefresherRefresh() {
this.page = 0;
this.list = [];
this.pkList();
},
2025-05-22 16:21:07 +08:00
goDetail(item) {
uni.navigateTo({
url: '/pages/pkDetail/pkDetail',
success: function(res) {
res.eventChannel.emit('itemDetail', {
item: item,
});
},
})
},
2025-05-22 22:05:55 +08:00
formatDate: formatDate,
2025-05-21 22:52:33 +08:00
async pkList(){
const res = await request({
url: "pk/pkList",
method: "GET",
data: {
status: 0,
page: this.page,
2025-05-22 16:21:07 +08:00
size: this.size,
2025-05-21 22:52:33 +08:00
},
userInfo: false,
});
console.log(res);
if (res.code === 200) {
2025-05-22 16:21:07 +08:00
this.list.push(...res.data)
2025-05-21 22:52:33 +08:00
console.log(this.list)
}
},
onScrollToLower() {
this.page++;
this.pkList();
},
2025-05-12 21:23:37 +08:00
},
};
</script>
<style scoped>
.scroll {
2025-05-21 22:52:33 +08:00
height: 90%;
2025-05-12 21:23:37 +08:00
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.content-list {
display: flex;
align-items: center;
width: 712rpx;
height: 161rpx;
background: #ffffff;
border-radius: 15rpx;
margin-bottom: 12rpx;
margin-left: 20rpx;
}
.headShot {
width: 101rpx;
height: 101rpx;
border-radius: 50rpx;
margin-left: 30rpx;
margin-right: 33rpx;
}
.content-list-info {
display: flex;
align-items: center;
}
.cardname {
font-size: 31rpx;
color: #161616;
line-height: 38rpx;
}
.Genderimg {
width: 15rpx;
height: 15rpx;
margin-left: 10rpx;
margin-right: 10rpx;
}
.age {
color: #ffffff;
font-size: 14rpx;
}
.Gendermale{
background: url(../../static/maleimg.png) no-repeat center;
width: 56.3rpx;
height: 29.58rpx;
background-size: 100% 100%;
display: flex;
align-items: center;
margin-right: 10rpx;
}
.Genderfemale{
background: url(../../static/femaleimg.png) no-repeat center;
width: 56.3rpx;
height: 29.58rpx;
background-size: 100% 100%;
display: flex;
align-items: center;
margin-right: 10rpx;
}
.RoomID {
font-size: 23rpx;
color: #a3a3a3;
line-height: 38rpx;
2025-05-22 16:21:07 +08:00
2025-05-12 21:23:37 +08:00
}
.Charm {
font-size: 23rpx;
color: #a3a3a3;
line-height: 38rpx;
margin-right: 12rpx;
2025-05-22 16:21:07 +08:00
margin-left: 20rpx;
2025-05-12 21:23:37 +08:00
}
.charmValue {
font-size: 23rpx;
color: #161616;
line-height: 38rpx;
2025-05-19 18:34:04 +08:00
font-weight: 600;
2025-05-12 21:23:37 +08:00
}
</style>