| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- <template>
- <view class="container">
- <uni-nav-bar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
- @clickLeft="toBack">
- <view style="width: 100%;display: flex;flex-direction: row;justify-content: center;align-items: center;">
- <text style="color: white;font-size: 1rem;">{{title}}</text>
- </view>
- </uni-nav-bar>
- <uni-list>
- <uni-list-item ellipsis="1" v-for="item in noticeList" :key="item.id" :title="item.title"
- :note="item.releaseTime" showArrow clickable @click="onNoticeItemClick(item.id)"></uni-list-item>
- </uni-list>
- <uni-load-more :status="status" @clickLoadMore="clickLoadMore" />
- </view>
- </template>
- <script>
- import uLoadMore from '@/uview-ui/components/u-loadmore/u-loadmore.vue'
- import uList from '@/uni_modules/uni-list/components/uni-list/uni-list.vue'
- import uListItem from '@/uni_modules/uni-list/components/uni-list-item/uni-list-item.vue'
- import uNavBar from '@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue'
- import uniDataPicker from '@/uni_modules/uni-data-picker/components/uni-data-picker/uni-data-picker.vue'
- import uGroup from '@/uni_modules/uni-group/uni-group.vue'
- import uniSection from '@/uni_modules/uni-section/uni-section.vue'
- import pageNav from '@/components/page-nav/page-nav.vue';
- import uniTable from '@/uni_modules/uni-table/components/uni-table/uni-table.vue'
- import uniPagination from '@/uni_modules/uni-pagination/components/uni-pagination/uni-pagination.vue'
- import uniBreadcrumb from '@/uni_modules/uni-breadcrumb/components/uni-breadcrumb/uni-breadcrumb.vue'
- import http from '@/http/api.js';
- export default {
- components: {
- uList,
- uListItem,
- uNavBar,
- uLoadMore,
- },
- data() {
- return {
- title: '公告消息',
- status: 'more',
- pageCurrent: 1,
- pageSize: 10,
- noticeList: [],
- totalCount: 0,
- };
- },
- onLoad() {
- this.getNotice();
- },
- onReady() {
- //let that = this;
- // uni.getSystemInfo({
- // success(e) {
- // console.log(e);
- // let {
- // windowWidth,
- // windowHeight,
- // safeArea
- // } = e;
- // const query = uni.createSelectorQuery().in(that);
- // query
- // .select('#swiperBox')
- // .boundingClientRect(data => {
- // that.swiperHeight = safeArea.bottom - data.top;
- // })
- // .exec();
- // }
- // });
- },
- onPullDownRefresh() {
- // uni.showToast({
- // icon: 'none',
- // title: "当前状态:" + this.status
- // })
- // setTimeout(() => {
- // uni.stopPullDownRefresh();
- // }, 1500);
- },
- onReachBottom() {
- // uni.showToast({
- // icon: 'none',
- // title: "当前状态:" + this.status
- // })
- if (this.totalCount > this.noticeList.length) {
- this.status = 'loading';
- setTimeout(() => {
- this.pageCurrent++
- this.getNotice(); //执行的方法
- }, 1000)
- } else { //停止加载
- this.status = 'noMore';
- }
- // 后续将改为与后端联动
- // if (this.page >= 3) return;
- // this.status = 'loading';
- // this.page = ++this.page;
- // setTimeout(() => {
- // this.list += 10;
- // if (this.page >= 3) this.status = 'nomore';
- // else this.status = 'loading';
- // this.newsList.push(...[{}, {}]);
- // }, 2000);
- },
- methods: {
- toBack() {
- uni.navigateBack({
- delta: 1
- })
- },
- clickLoadMore(e) {
- // uni.showToast({
- // icon: 'none',
- // title: "当前状态:" + e.detail.status
- // })
- // })
- if (this.totalCount > this.noticeList.length) {
- this.status = 'loading';
- setTimeout(() => {
- this.pageCurrent++
- this.getNotice(); //执行的方法
- }, 1000)
- } else { //停止加载
- this.status = 'noMore';
- }
- },
- getNotice() {
- const that = this;
- const current = this.pageCurrent;
- const size = this.pageSize;
- //const isSubmit = '0';
- http.request({
- url: '/galaxy-test/notice/list',
- method: 'GET',
- params: {
- current,
- size,
- },
- }).then(res => {
- if (res.data.records != null) {
- for (var i = 0; i < res.data.records.length; i++) {
- that.noticeList.push(res.data.records[i]);
- }
- }
- that.totalCount = res.data.total;
- if (that.totalCount > that.noticeList.length) {
- this.status = 'more';
- }
- that.viewNotice();
- }).catch(err => {
- console.log(err)
- })
- },
- viewNotice() {
- http.request({
- url: '/galaxy-test/notice/view',
- method: 'POST',
- }).then(res => {}).catch(err => {
- console.log(err)
- })
- },
- onNoticeItemClick(id) {
- console.log('执行click事件', id)
- uni.navigateTo({
- url: '/pages/news/detail?id=' + id
- })
- },
- }
- };
- </script>
- <style lang="scss">
- .message-icon {
- width: 32rpx;
- height: auto;
- margin-right: 27rpx;
- }
- .tab {
- margin: 0 0 10rpx;
- border-bottom: 1px solid #e4e7ed;
- }
- .content {
- padding: 0 0 150rpx;
- .news {
- &:not(:last-of-type) {
- border-bottom: 2rpx solid #e4e7ed;
- }
- }
- }
- .nomore {
- padding: 30rpx 20rpx;
- }
- .news {
- margin: 30rpx 30rpx 0;
- padding: 0 0 30rpx;
- .head {
- display: flex;
- .avatar {
- flex-shrink: 0;
- width: 69rpx;
- height: 69rpx;
- background: #ffffff;
- border: 1px solid #14b9c8;
- border-radius: 50%;
- }
- .info {
- flex: 1;
- margin-left: 14rpx;
- .name {
- display: flex;
- align-items: center;
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #000000;
- line-height: 36rpx;
- .tag {
- margin-left: 15rpx;
- display: inline-block;
- padding: 8rpx 10rpx;
- font-size: 14rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #4cbeca;
- line-height: 21rpx;
- border: 1px solid #0bb9c8;
- border-radius: 6px;
- }
- }
- .date {
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #a3a3a3;
- line-height: 36rpx;
- }
- }
- }
- .des {
- margin-top: 40rpx;
- font-size: 30rpx;
- font-family: PingFang SC;
- color: #000000;
- line-height: 47rpx;
- }
- }
- .swiper-box {
- height: 100vh;
- }
- </style>
|