guozhi-wechat/pages/index/news-list.vue
2025-07-30 19:58:32 +08:00

199 lines
4.3 KiB
Vue

<template>
<view class="message tn-safe-area-inset-bottom">
<view v-if="list.length > 0">
<view class="wallpaper-shadow tn-margin tn-padding" v-for="(item, index) in list" :key="index"
@click="goDetail(item.id)">
<view class="tn-flex tn-flex-col-top">
<!-- 这个是图片形式,自己看需要去使用 -->
<view class="" v-if="item.images">
<view class="logo-pic">
<view class="logo-image">
<!-- <view class="" style="width: 100%;height: 100%;;background-size: cover;"
:style="{backgroundImage:'url('+item.images+')'}">
</view> -->
<image :src="item.images" style="width: 100%;height: 100%;object-fit: cover"></image>
</view>
</view>
</view>
<view class="tn-padding-left-sm" style="width: 100%;height: 200rpx;;position: relative;">
<view class="tn-flex tn-flex-row-between tn-flex-col-between">
<view class="justify-content-item">
<text class="tn-color-wallpaper tn-text-lg tn-text-bold">{{ item.name }}</text>
</view>
</view>
<view class="tn-padding-top-xs" style="position: absolute;bottom: 0;">
<view class="justify-content-item tn-color-gray tn-color-gray">
<text class="tn-icon-time tn-padding-right-xs tn-text-df"></text>
<text class="tn-text-sm">{{ item.create_time_text }}</text>
</view>
</view>
</view>
</view>
</view>
</view>
<view v-else>
<tui-no-data imgUrl="/static/img/img_noorder_3x.png">暂无数据</tui-no-data>
</view>
<view class="tn-tabbar-height"></view>
<!-- 底部导航栏组件 -->
<tabbar :theme="tabbarStyle"></tabbar>
</view>
</template>
<script>
import newsApi from "@/common/api/news.js"
export default {
name: 'Message',
data() {
return {
list: [],
hasMore: false,
currentPage: 1,
loadFlag: 'loading',
}
},
onLoad() {
this.getData()
},
async onReachBottom() {
console.log("onReachBottom")
if (this.hasMore) {
this.currentPage++
this.getData()
}
},
methods: {
getData() {
this.loadFlag = 'loading'
let params = {
page: this.current_page
}
newsApi.getNewsList(this, params).then(res => {
if (res && res.data) {
this.list = this.list.concat(res.data.list.data)
this.hasMore = res.data.list.has_more
this.currentPage = res.data.list.current_page
this.loadFlag = 'over'
}
})
},
// 跳转详情
goDetail(id) {
this.utils.goto('news-detail?id=' + id)
},
}
}
</script>
<style lang="scss">
page {
background-color: #fff;
}
.message {
max-height: 100vh;
}
/* 自定义导航栏内容 start */
.custom-nav {
height: 100%;
&__back {
margin: auto 30rpx;
font-size: 40rpx;
margin-right: 10rpx;
flex-basis: 5%;
width: 100rpx;
position: absolute;
}
}
/* 自定义导航栏内容 end */
/* 底部安全边距 start*/
.tn-tabbar-height {
min-height: 20rpx;
height: calc(40rpx + env(safe-area-inset-bottom) / 2);
height: calc(40rpx + constant(safe-area-inset-bottom));
}
.tn-color-wallpaper {
color: #1D2541;
}
/* 页面阴影 start*/
.wallpaper-shadow {
border-radius: 15rpx;
box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.07);
}
/* 图标容器15 start */
.icon15 {
&__item {
width: 30%;
background-color: #FFFFFF;
border-radius: 10rpx;
padding: 30rpx;
margin: 20rpx 10rpx;
transform: scale(1);
transition: transform 0.3s linear;
transform-origin: center center;
&--icon {
width: 105rpx;
height: 105rpx;
font-size: 60rpx;
border-radius: 50%;
margin-bottom: 18rpx;
position: relative;
z-index: 1;
&::after {
content: " ";
position: absolute;
z-index: -1;
width: 100%;
height: 100%;
left: 0;
bottom: 0;
border-radius: inherit;
opacity: 1;
transform: scale(1, 1);
background-size: 100% 100%;
}
}
}
}
/* 用户头像 start */
.logo-image {
width: 300rpx;
height: 200rpx;
position: relative;
}
.logo-pic {
background-size: cover;
background-repeat: no-repeat;
// background-attachment:fixed;
background-position: top;
border: 1rpx solid rgba(255, 255, 255, 0.05);
box-shadow: 0rpx 0rpx 80rpx 0rpx rgba(0, 0, 0, 0.05);
overflow: hidden;
// background-color: #FFFFFF;
}
</style>