123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <template>
- <view class="list">
- <view class="selectParam">
- <uni-search-bar :focus="false" v-model="title" @input="search" @cancel="cancel" clearButton="auto" cancelButton="none"></uni-search-bar>
- </view>
- <view v-for="(item, index) in list" :key="item.id" class="item">
- <img :src="loadImgSrcLocalhost(`${item.announcementImg}`)" class="avatar" />
- <view class="info" style="height: 5em;">
- <view class="name" @click="handleNavigate(item)">
- 标题:{{ item.announcementTitle }}
- <view class="unread-dot" v-if="item.readType == 0"></view>
- </view>
- </view>
- <em class="iconfont icon-xiangyoujiantou" @click="handleNavigate(item)"></em>
- </view>
- </view>
- </template>
- <script>
- import { getList } from '@/api/index/index.js';
- export default {
- data() {
- return {
- queryParam: {
- pageNum: 1,
- pageSize: 10,
- announcementTitle: '',
- userId: getApp().globalData.userId
- },
- total: null,
- title:'',
- list: [],
- flag: true,
- };
- },
- onLoad() {
- this.queryParam.pageNum = 1
- this.queryParam.pageSize = 10
- this.flag=true
- this.getAnnoList();
- },
- onReachBottom() {
- let pageNum = this.queryParam.pageNum;
- let pageSize = this.queryParam.pageSize;
- let total = this.total;
- if (pageNum * pageSize >= total) {
- uni.showToast({
- title: '暂无更多数据'
- });
- return;
- } else {
- this.queryParam.pageNum += 1;
- this.flag=true
- this.getAnnoList();
- }
- },
- methods: {
- cancel(){
- this.queryParam.pageNum = 1
- this.queryParam.pageSize = 10
- this.queryParam.announcementTitle = ''
- },
- search(){
- this.queryParam.pageNum = 1
- this.queryParam.pageSize = 10
- this.queryParam.announcementTitle = this.title
- this.flag=false
- this.getAnnoList()
- },
- getAnnoList() {
- getList(this.queryParam).then((res) => {
- if(this.flag){
- this.list = [...this.list,...res.rows]
- // this.list = res.rows;
- this.total = res.total
- }else{
- this.list = res.rows
- this.total = res.total
- }
- });
- },
- handleNavigate(item) {
- item.readType = 1;
- uni.navigateTo({
- url: '/pages/index/announcementDetails?id=' + item.id
- });
- }
- }
- };
- </script>
- <style>
- .list {
- padding: 20rpx;
- }
- .item {
- display: flex;
- align-items: center;
- margin-bottom: 20rpx;
- }
- .avatar {
- width: 60rpx;
- height: 60rpx;
- border-radius: 50%;
- }
- .info {
- display: flex;
- align-items: center;
- }
- .name {
- font-size: 28rpx;
- font-weight: bold;
- margin-right: 10rpx; /* 添加间距 */
- position: relative;
- }
- .unread-dot {
- width: 10rpx;
- height: 10rpx;
- background-color: red;
- border-radius: 50%;
- position: absolute;
- right: -15rpx; /* 相对于父容器位置调整 */
- top: 50%;
- transform: translateY(-50%);
- }
- </style>
|