dl_uniapp/pages/components/subscribe.vue

291 lines
6.1 KiB
Vue
Raw Normal View History

2025-03-31 15:40:36 +08:00
<template>
<view class="dingyue-box">
<!-- 标题 -->
<view class="dl-title">
订阅
</view>
<!-- 操作按钮 -->
<view class="dl-opt-box">
<view class="dl-menu-box">
<view v-for="(item,index) in menus" @click="itemClick(index,item)" class="dl-menu"
:class="index==menuIndex?'dl-menu click':'dl-menu'">{{item}}</view>
</view>
2025-04-01 10:06:51 +08:00
<view class="seting" @click="goSet()">
<image src="@/static/set.png" mode="aspectFit"></image>
2025-03-31 15:40:36 +08:00
设置
</view>
</view>
2025-04-01 10:06:51 +08:00
<!-- 通告列表 -->
<view class="dl-body">
<view class="dl-item-box">
<scroll-view style="height: 100%;" scroll-y="true" @scrolltolower="onReachBottomCus" refresher-enabled
@refresherrefresh="onRefresherrefresh" :refresher-triggered="isTriggered">
<notice-item v-if="dataList.length>0" :dataList="dataList" @goDetail="goDetail()"></notice-item>
<view style="text-align: center" v-if="dataList.length==0">
<image class="" src="@/static/images/nothing.png"></image>
</view>
</scroll-view>
</view>
</view>
2025-03-31 15:40:36 +08:00
</view>
</template>
<script>
2025-04-01 10:06:51 +08:00
import noticeItem from '@/pages/components/notice-item.vue'
2025-04-07 15:14:16 +08:00
import rightsCode from '@/utils/rightsCode'
import {
getCatgByCode
} from '@/api/system/config.js'
import {
toast,
hasRights
} from '@/utils/common.js'
import {
getSubscribeList,
getLoveList
} from '@/api/business/notice.js'
2025-03-31 15:40:36 +08:00
export default {
2025-04-01 10:06:51 +08:00
components: {
noticeItem
},
2025-03-31 15:40:36 +08:00
data() {
return {
menus: ['订阅', '关注'],
menuIndex: 0,
2025-04-07 15:14:16 +08:00
dataList: [],
isTriggered: false,
2025-04-01 10:06:51 +08:00
queryParams: {
pageNum: 1,
pageSize: 10,
2025-04-07 15:14:16 +08:00
},
//是否显示搜索框
showSearch: false,
//当前焦点
chooseCondition: 9,
total: 0,
//下来刷新状态
isTriggered: false,
//平台列表
platformList: [],
//博主分类
bloggerTypeList: [],
2025-03-31 15:40:36 +08:00
}
},
2025-04-07 15:14:16 +08:00
mounted() {
this.initData("dl_platform", "platformList")
this.initData("dl_blogger_type", "bloggerTypeList")
this.selectDataList()
},
2025-03-31 15:40:36 +08:00
methods: {
2025-04-07 15:14:16 +08:00
/**
* 查看通告详情
* @param {Object} item
*/
goDetail(item) {
this.$tab.navigateTo(`/pages/notice/detail?id=${item.id}`)
},
/**
* 初始化数据
* @param {Object} code
* @param {Object} dataObj
*/
initData(code, dataObj) {
let that = this
getCatgByCode({
code: code
}).then(res => {
if (res.code == 200) {
this[dataObj] = res.data
}
}).catch((e) => {
uni.showToast({
icon: 'error',
duration: 2000,
title: e
});
})
},
/**
* 查询数据
*/
selectDataList() {
if (this.menuIndex == 0) {
getSubscribeList(this.queryParams).then(res => {
this.isTriggered = false
if (res.code == 200) {
if (this.queryParams.pageNum == 1) {
this.dataList = res.data.records
} else {
this.dataList = this.dataList.concat(res.data.records)
}
this.total = res.data.total
}
}).catch((e) => {
this.isTriggered = false
uni.showToast({
icon: 'error',
duration: 2000,
title: e
});
})
} else {
getLoveList(this.queryParams).then(res => {
this.isTriggered = false
if (res.code == 200) {
if (this.queryParams.pageNum == 1) {
this.dataList = res.data.records
} else {
this.dataList = this.dataList.concat(res.data.records)
}
this.total = res.data.total
}
}).catch((e) => {
this.isTriggered = false
uni.showToast({
icon: 'error',
duration: 2000,
title: e
});
})
}
},
2025-03-31 15:40:36 +08:00
/**
* 菜单点击
* @param {Object} index
* @param {Object} item
*/
itemClick(index, item) {
if ('订阅' == item) {
//全部
} else if ('关注' == item) {
//关注
}
2025-04-07 15:14:16 +08:00
this.queryParams = {
pageNum: 1,
pageSize: 10,
}
2025-03-31 15:40:36 +08:00
this.menuIndex = index
2025-04-07 15:14:16 +08:00
this.selectDataList()
2025-03-31 15:40:36 +08:00
},
2025-04-07 15:14:16 +08:00
2025-04-01 10:06:51 +08:00
/**
* 上滑加载数据
*/
onReachBottomCus() {
//判断 如果页码*页容量大于等于总条数,提示该页数据加载完毕
if (this.queryParams.pageNum * this.queryParams.pageSize >= this.total) {
toast("没有更多数据了")
return
}
//页码+1,调用获取数据的方法获取第二页数据
this.queryParams.pageNum++
2025-04-07 15:14:16 +08:00
this.selectDataList()
2025-04-01 10:06:51 +08:00
},
/**
* 下拉刷新数据
*/
onRefresherrefresh() {
this.isTriggered = true
this.queryParams.pageNum = 1
this.total = 0
2025-04-07 15:14:16 +08:00
this.selectDataList()
2025-04-01 10:06:51 +08:00
},
/**
* 去订阅设置页面
*/
goSet() {
this.$tab.navigateTo(`/pages/notice/subscribe-set`)
}
2025-03-31 15:40:36 +08:00
}
}
</script>
<style lang="scss">
.dingyue-box {
2025-04-02 18:34:15 +08:00
padding-top: var(--status-bar-height);
2025-03-31 15:40:36 +08:00
width: 100%;
color: #363636;
background-color: white;
2025-04-02 18:34:15 +08:00
font-size: 38rpx;
2025-03-31 15:40:36 +08:00
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
.dl-title {
2025-04-03 16:46:51 +08:00
font-size: 32rpx;
2025-03-31 15:40:36 +08:00
width: 100%;
position: relative;
text-align: center;
font-weight: bold;
z-index: 10;
2025-04-02 18:34:15 +08:00
padding: 62rpx 0 15rpx 15rpx;
2025-03-31 15:40:36 +08:00
border-bottom: 1px solid #F4F4F4;
}
.dl-opt-box {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
.dl-menu-box {
display: flex;
flex: 1;
align-items: center;
justify-content: initial;
width: 100%;
padding-top: 20rpx;
.dl-menu {
2025-04-01 10:06:51 +08:00
width: 80rpx;
2025-03-31 15:40:36 +08:00
font-size: 30rpx;
margin: 0 20rpx;
2025-04-01 10:06:51 +08:00
padding-bottom: 15rpx;
2025-03-31 15:40:36 +08:00
text-align: center;
}
.click {
color: #FF434E;
font-weight: bold;
border-bottom: 2px solid #FF434E;
}
}
.seting {
2025-04-03 16:46:51 +08:00
font-size: 30rpx;
2025-04-01 10:06:51 +08:00
width: 180rpx;
2025-03-31 15:40:36 +08:00
display: flex;
2025-04-01 10:06:51 +08:00
align-items: center;
2025-03-31 15:40:36 +08:00
justify-content: center;
2025-04-01 10:06:51 +08:00
image {
width: 30rpx;
height: 30rpx;
margin-right: 10rpx;
}
}
}
.dl-body {
flex: 1;
width: 100%;
height: 100%;
background-color: #EEEEEE;
padding: 20rpx 20rpx 0 20rpx;
.dl-item-box {
2025-04-02 18:34:15 +08:00
height: calc(100vh - var(--status-bar-height) - var(--window-bottom) - 357rpx);
2025-04-01 10:06:51 +08:00
isplay: flex;
flex-direction: column;
padding-top: 15rpx;
2025-03-31 15:40:36 +08:00
}
}
}
2025-04-07 15:14:16 +08:00
</style>