123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <template>
- <view>
- <cc-pullScroolView class="pullScrollView" ref="pullScroll" :pullDown="pullDown" :isDownLoading="true">
- <view class="notice" v-for="(item,index) in list" :key="index">
- <view class="justify-content">
- <view class="font-forty">
- {{item.noticeTitle}}
- </view>
-
- <view class="font-thirty-two black" style="margin: 30rpx 0;">
- <rich-text :nodes="item.noticeContent"></rich-text>
- </view>
- <view class="font-twenty-eight gray">
- {{item.createTime}}
- </view>
- </view>
- </view>
- </cc-pullScroolView>
-
- </view>
- </template>
- <script>
-
- import CCBProjectList from '../../uni_modules/cc-pullScroolView/components/cc-pullScroolView/cc-pullScroolView.vue';
- import {
- getNoticeList,
- } from '@/api/common'
- export default {
- components: {
- CCBProjectList,
- },
- data() {
- return {
- list: [],
- pageSize: 10, // 条数
- totalNum: '',
- pageNum: 1, // 页数
- }
- },
- onLoad() {
- this.getList()
- },
- // 上拉加载
- onReachBottom() {
- // 数据全部加载完
- if (this.pageNum * 10 >= this.totalNum) {
- } else {
- // 显示加载中
- this.$refs.pullScroll.showUpLoading();
- this.pageNum++;
- this.requestData();
- }
- },
- methods: {
- // goDetails(item) {
- // uni.navigateTo({
- // url: '/pages/notice/noticeDetail?params=' + encodeURIComponent(JSON.stringify(
- // item))
- // })
- // },
- // 下拉刷新
- pullDown(pullScroll) {
- this.pageNum = 1;
- setTimeout(() => {
- this.requestData(pullScroll);
- }, 1000);
- },
- getList() {
- let myThis = this;
- this.$nextTick(() => {
- myThis.$refs.pullScroll.refresh();
- });
- },
- requestData() {
- uni.showLoading()
- getNoticeList('1', this.pageNum, this.pageSize).then(res => {
- this.totalNum = res.total
- if (res.code == '200') {
- uni.hideLoading()
- if (res.rows.length !== 0) {
- //首次加载10条数据,后进行拼接
- if (this.pageNum == 1) {
- this.list = [];
- this.list = res.rows
- } else {
- this.list = this.list.concat(res.rows)
- }
- // 如果是最后一页
- if (this.pageNum * 10 >= this.totalNum) {
- this.$refs.pullScroll.finish();
- } else {
- // 不是最后一页
- this.$refs.pullScroll.success();
- }
- } else {
- this.$modal.msg("暂无数据")
- }
- } else {
- this.$modal.msg(res.msg + "")
- }
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- display: flex;
- margin-left: 10px;
- margin-top: 10px;
- margin-right: 10px;
- align-items: flex-start;
- justify-content: space-between;
- }
- .notice {
- margin: 20rpx;
- padding: 20rpx;
- background: #FFFFFF;
- box-shadow: 0rpx 8rpx 17rpx 0rpx rgba(0, 0, 0, 0.04);
- border-radius: 10rpx;
- }
- .text {
- border-left: 15rpx solid #3857F3;
- padding-left: 20rpx;
- }
- </style>
|