You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zhishifufei_uniapp/pages/material/my_material.vue

186 lines
3.8 KiB

10 months ago
<template>
<BaseContainer class="user-material" :fixedNav="false">
<NavBarTitle title="我的资料" :height="200"/>
<view v-if="materialList.length" class="list">
<navigator
v-for="item in materialList"
:key="item.id"
:url="`/pages/special/data_details?id=${item.id}`"
hover-class="none"
>
<view>
<image mode="aspectFit" :src="item.image" alt="" />
</view>
<view>
<view>{{ item.title }}</view>
<view>
<view :class="{ money: item.pay_type }">
<template v-if="item.pay_type">
<text>{{ item.money }}</text>
</template>
<template v-else> 免费 </template>
</view>
<view>{{ item.ficti + item.sales }}人已下载</view>
</view>
</view>
</navigator>
</view>
<view v-if="finished && materialList.length" class="finished">已全部加载完</view>
<view v-if="finished && !materialList.length" class="empty">
<image
mode="aspectFit"
:src="getImgPath('/wap/first/zsff/images/empty.png')"
alt=""
/>
<view>暂无数据</view>
</view>
</BaseContainer>
</template>
<script>
import { getMaterialList } from "@/api/material";
export default {
data() {
return {
page: 1,
limit: 16,
loading: false,
finished: false,
materialList: [],
};
},
onLoad() {
this.getMaterialList();
},
onReachBottom() {
this.getMaterialList();
},
methods: {
// 获取资料列表
async getMaterialList() {
if (this.loading || this.finished) return;
this.loading = true;
uni.showLoading({ mask: true });
try {
const { data: materialList } = await getMaterialList({
page: this.page++,
limit: this.limit,
});
uni.hideLoading();
this.materialList = this.materialList.concat(materialList);
this.finished = this.limit > materialList.length;
} catch (err) {
uni.hideLoading();
this.$util.showMsg(err);
}
this.loading = false;
},
},
};
</script>
<style>
page{
background: #F7F8F9;
}
</style>
<style scoped lang="scss">
.list{
position: absolute;
left: 0;
right: 0;
margin: 0 auto;
margin-top: calc(128rpx + var(--safe-top));
width: 686rpx;
background: #FFFFFF;
border-radius: 24rpx;
z-index: 999;
}
/* 我的资料 */
.user-material navigator {
display: flex;
padding: 20rpx 30rpx;
font-size: 22rpx;
color: #999999;
}
.user-material navigator image {
display: block;
width: 250rpx;
height: 140rpx;
border-radius: 10rpx;
object-fit: cover;
}
.user-material navigator > view:last-child {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
min-width: 0;
margin-left: 22rpx;
}
.user-material navigator > view > view:first-child {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
font-size: 30rpx;
color: #333;
}
.user-material navigator > view > view:last-child {
display: flex;
justify-content: space-between;
align-items: center;
}
.user-material navigator > view > view > view:first-child {
font-weight: bold;
font-size: 28rpx;
color: #ff6b00;
}
.user-material navigator > view > view > view.money {
font-size: 22rpx;
}
.user-material .money text {
font-size: 32rpx;
}
.user-material .empty {
margin-top: 400rpx;
font-size: 28rpx;
text-align: center;
color: #bbb;
}
.user-material .empty image {
display: block;
width: 414rpx;
height: 305rpx;
margin: 0 auto;
}
.user-material .loading,
.user-material .finished {
font-size: 28rpx;
line-height: 100rpx;
text-align: center;
color: #bbb;
}
.user-material .fa-spin {
animation-duration: 1s;
}
</style>