| | |
| | | <view class="container"> |
| | | <u-tabs :list="list" :is-scroll="false" :current="current" active-color="#14B9C8" inactive-color="#595959" |
| | | height="100" @change="change"></u-tabs> |
| | | <u-search v-model="keyword" shape="round" class="u-search" input-align="center" height="70" :show-action="false"></u-search> |
| | | <view class="inTmain" v-for="(item,index) in dataList"> |
| | | <u-card :title="item.title" v-show="item.category == current + 1"> |
| | | <view class="" slot="body"> |
| | | <view> |
| | | <view style="margin-bottom: 10px;" class="u-body-item-title u-line-1"> |
| | | 通知类型:{{item.category == 1 ? '单位公告' : '公安公告'}}</view> |
| | | <u-search v-model='keyValue' placeholder='请输入公告内容' shape="round" class="u-search" input-align="center" |
| | | height="70" @search='searchValue' @custom='searchValue' @clear='clearValue' @change='changeValue'> |
| | | </u-search> |
| | | |
| | | <view v-show="current == 0 && newsList.length > 0"> |
| | | <view class="inTmain" v-for="(item,index) in newsList"> |
| | | <u-card :title="item.title" @click="goDetail(item)"> |
| | | <view class="" slot="body"> |
| | | <view> |
| | | <view style="margin-bottom: 10px;" class="u-body-item-title u-line-1"> |
| | | 通知类型:{{item.category == 1 ? '单位公告' : '公安公告'}}</view> |
| | | </view> |
| | | <view> |
| | | <view class="u-body-item-title u-line-1">通知日期:{{item.releaseTime}}</view> |
| | | </view> |
| | | </view> |
| | | <view> |
| | | <view class="u-body-item-title u-line-1">通知日期:{{item.releaseTime}}</view> |
| | | </view> |
| | | </view> |
| | | <view class="" slot="foot"> |
| | | </u-icon>发布单位:{{item.depName}}</view> |
| | | </u-card> |
| | | <view class="" slot="foot"> |
| | | </u-icon>发布单位:{{item.depName}}</view> |
| | | </u-card> |
| | | </view> |
| | | <u-loadmore class='msg' :status="status" /> |
| | | </view> |
| | | |
| | | <view v-show="current == 1 && newsList.length > 0"> |
| | | <view class="inTmain" v-for="(item,index) in newsList"> |
| | | <u-card :title="item.title" @click="goDetail(item)"> |
| | | <view class="" slot="body"> |
| | | <view> |
| | | <view style="margin-bottom: 10px;" class="u-body-item-title u-line-1"> |
| | | 通知类型:{{item.category == 1 ? '单位公告' : '公安公告'}}</view> |
| | | </view> |
| | | <view> |
| | | <view class="u-body-item-title u-line-1">通知日期:{{item.releaseTime}}</view> |
| | | </view> |
| | | </view> |
| | | <view class="" slot="foot"> |
| | | </u-icon>发布单位:{{item.depName}}</view> |
| | | </u-card> |
| | | </view> |
| | | <u-loadmore class='msg' :status="status" /> |
| | | </view> |
| | | |
| | | <view class="msg" v-show='newsList.length == 0'> |
| | | 暂无数据 |
| | | </view> |
| | | |
| | | </view> |
| | | </template> |
| | | |
| | |
| | | export default { |
| | | data() { |
| | | return { |
| | | dataList: [], |
| | | list: [{ |
| | | name: '单位公告' |
| | | }, |
| | |
| | | } |
| | | ], |
| | | current: 0, |
| | | keyword: '' |
| | | dataList: [], |
| | | newsList: [], |
| | | status: 'loadmore', |
| | | keyValue: '', |
| | | pagelist: 0, |
| | | flag: true |
| | | }; |
| | | }, |
| | | onLoad() { |
| | | |
| | | }, |
| | | onReachBottom() { |
| | | var that = this; |
| | | |
| | | if (that.dataList.length - 1 == that.pagelist && this.status != 'nomore' && that.flag == true) { |
| | | that.newsList.push(that.dataList[that.pagelist]); |
| | | this.status = 'nomore'; |
| | | that.flag = false; |
| | | return; |
| | | } else { |
| | | if (that.flag == false) { |
| | | this.status = 'nomore'; |
| | | return |
| | | } |
| | | // 后续将改为与后端联动 |
| | | this.status = 'loading'; |
| | | |
| | | setTimeout(() => { |
| | | var flag = true; |
| | | |
| | | for (var i = 0; i < 5; i++) { |
| | | |
| | | if (that.pagelist <= that.dataList.length - 2 && flag == true) { |
| | | |
| | | that.newsList.push(that.dataList[that.pagelist++]) |
| | | |
| | | if (that.dataList.length - 1 == that.pagelist) flag == false |
| | | |
| | | } |
| | | |
| | | } |
| | | }, 2000); |
| | | |
| | | } |
| | | |
| | | }, |
| | | mounted() { |
| | | this.getCompany(); |
| | | this.getReceive(); |
| | | }, |
| | | methods: { |
| | | getCompany() { |
| | | getReceive() { |
| | | var that = this; |
| | | uni.request({ |
| | | url: this.$store.state.piAPI + "/blade-desk/notice/page", |
| | | url: this.$store.state.piAPI + "/blade-desk/notice/page?category=1", |
| | | method: "get", |
| | | data: { |
| | | |
| | | }, |
| | | success: (res) => { |
| | | var resdata = res.data.data.records; |
| | | that.pagelist = 0; |
| | | that.newsList = []; |
| | | that.flag = true; |
| | | that.dataList = resdata; |
| | | |
| | | var flag = true; |
| | | |
| | | for (var i = 0; i < 5; i++) { |
| | | |
| | | if (that.pagelist <= that.dataList.length - 2) { |
| | | |
| | | that.newsList.push(that.dataList[that.pagelist++]); |
| | | |
| | | } else { |
| | | |
| | | if (that.dataList.length - 1 == that.pagelist && flag == true) { |
| | | |
| | | that.newsList.push(that.dataList[that.pagelist]); |
| | | flag = false; |
| | | that.flag = false; |
| | | this.status = 'nomore'; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | }); |
| | | }, |
| | | getIssue() { |
| | | var that = this; |
| | | uni.request({ |
| | | url: this.$store.state.piAPI + "/blade-desk/notice/page?category=2", |
| | | method: "get", |
| | | data: { |
| | | |
| | | }, |
| | | success: (res) => { |
| | | var resdata = res.data.data.records; |
| | | that.pagelist = 0; |
| | | that.newsList = []; |
| | | that.flag = true; |
| | | that.dataList = resdata; |
| | | |
| | | var flag = true; |
| | | |
| | | for (var i = 0; i < 5; i++) { |
| | | |
| | | if (that.pagelist <= that.dataList.length - 2) { |
| | | |
| | | that.newsList.push(that.dataList[that.pagelist++]); |
| | | |
| | | } else { |
| | | |
| | | if (that.dataList.length - 1 == that.pagelist && flag == true) { |
| | | |
| | | that.newsList.push(that.dataList[that.pagelist]); |
| | | flag = false; |
| | | that.flag = false; |
| | | this.status = 'nomore'; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | }); |
| | | }, |
| | | goDetail(item) { |
| | | return; |
| | | uni.navigateTo({ |
| | | url: './lookDetail?detailData=' + JSON.stringify(item) |
| | | }); |
| | | }, |
| | | change(index) { |
| | | if (this.current == index) return; |
| | | if (index == 0) { |
| | | this.getReceive(); |
| | | } else { |
| | | this.getIssue(); |
| | | } |
| | | this.current = index; |
| | | }, |
| | | searchValue(value) { |
| | | var that = this; |
| | | var str = value.replace(/\s*/g, ""); |
| | | if (str == '') { |
| | | return |
| | | } else { |
| | | that.newsList = []; |
| | | that.dataList.forEach(item => { |
| | | if (item.title.indexOf(str) != -1) { |
| | | that.newsList.push(item) |
| | | } |
| | | }) |
| | | that.status = 'nomore'; |
| | | } |
| | | }, |
| | | clearValue() { |
| | | this.keyValue = '' |
| | | this.newsList = []; |
| | | for (var i = 0; i < this.pagelist; i++) { |
| | | this.newsList.push(this.dataList[i]) |
| | | } |
| | | |
| | | if (this.flag == false) { |
| | | this.newsList.push(this.dataList[this.pagelist]); |
| | | } |
| | | }, |
| | | changeValue(value) { |
| | | if (value == '') { |
| | | this.newsList = []; |
| | | for (var i = 0; i < this.pagelist; i++) { |
| | | this.newsList.push(this.dataList[i]) |
| | | } |
| | | |
| | | if (this.flag == false) { |
| | | this.newsList.push(this.dataList[this.pagelist]); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | |
| | | } |
| | | |
| | | .inTmain {} |
| | | |
| | | .msg { |
| | | height: 72rpx; |
| | | line-height: 72rpx; |
| | | text-align: center; |
| | | color: #999; |
| | | } |
| | | </style> |