diff --git a/epdc-resident-mp-yushan/pages/index/index.js b/epdc-resident-mp-yushan/pages/index/index.js index 8574d29..1799c9c 100644 --- a/epdc-resident-mp-yushan/pages/index/index.js +++ b/epdc-resident-mp-yushan/pages/index/index.js @@ -10,15 +10,10 @@ Page({ statusHeight: 0, // 自定义头部状态栏高度 navigationHeight: 0, // 自定义头部导航栏高度 bannerList: [], // banner列表 - newsList: [], // 新闻列表 projectList: [], // 项目列表 infoList: [], // 消息列表 noticeList: [], // 通知公告列表 unReadNum: 0, // 未读数量 - loadMoreType: 'none', - loadMoreVisible: false, - pageNo: 1, // 新闻列表-分页页码 - pageSize: 10, // 新闻列表-分页页长 timestamp: '', // 时间戳 sudokuState: { // 九宫格显隐状态 consultAvailable: '0', // 网格专员 @@ -40,7 +35,15 @@ Page({ { icon: 'https://epdc-yushan.elinkservice.cn/files-pro/20210914/b884f294e3634f66b7ff36be682046a2.png', tip: '社会组织', module: 'societyOrg' } ], serviceImgUrl: '', - servicePhone: '' + servicePhone: '', + tabList: [], + currentTab: '', + loadMoreType: 'none', + loadMoreVisible: false, + newsList: [], + pageNo: 1, + pageSize: 10, + currentView: 'item' }, onLoad(options) { if (options.scene) { @@ -82,7 +85,7 @@ Page({ }) if (this.data.loadMoreType === 'loading') { this.data.pageNo += 1 - this.getNewsList() + this.contentList() } }, swiperChange: function (e) { @@ -158,28 +161,6 @@ Page({ }) }) }, - // 获取新闻列表 - getNewsList() { - let para = { - pageIndex: this.data.pageNo, - pageSize: this.data.pageSize, - timestamp: this.data.timestamp, - categoryCode: "" - } - api.newsList(para).then((res) => { - console.log('首页新闻列表', res) - this.setData({ - loadMoreType: res.data.length === this.data.pageSize ? 'loading' : 'none', - newsList: this.data.newsList.concat(res.data) - }) - }).catch(() => { - console.log('首页新闻列表获取失败') - this.setData({ - loadMoreType: 'none', - newsList: [] - }) - }) - }, // 获取项目列表 getProjectList() { const para = { @@ -273,10 +254,10 @@ Page({ this.getInfoList() this.getNoticeList() this.getUnreadNum() - this.getNewsList() this.gridmanList() - this.contentList() this.getImgUrl() + this.contentList() + this.contentModuleList() }, // 切换网格,跳转到网格列表 changeGrid() { @@ -452,5 +433,60 @@ Page({ wx.makePhoneCall({ phoneNumber: phone }) + }, + changeTab(e) { + const { tab } = e.currentTarget.dataset + this.setData({ + currentTab: tab, + loadMoreType: 'none', + loadMoreVisible: false, + newsList: [], + currentView: `item${tab}` + }) + this.data.pageNo = 1 + wx.showLoading({ + title: '加载中...' + }) + this.contentList() + }, + // 获取资讯列表 + contentList() { + const params = { + pageIndex: this.data.pageNo, + pageSize: this.data.pageSize, + typeId: this.data.currentTab + } + homeApi.contentList(params).then(res => { + console.log('社区最新资讯', res) + this.setData({ + newsList: this.data.newsList.concat(res.data), + loadMoreType: res.data.length === this.data.pageSize ? 'loading' : 'none' + }) + wx.hideLoading() + }).catch(err => { + console.error(err) + wx.hideLoading() + }) + }, + // 获取栏目列表 + contentModuleList() { + homeApi.contentModuleList().then(res => { + console.log('栏目列表', res) + const tabList = [] + res.data.forEach(item => { + tabList.push({ label: item.typeName, value: item.id }) + }) + this.setData({ + tabList: [...[{ label: '最新资讯', value: '' }], ...tabList] + }) + }).catch(err => { + console.error('', err) + }) + }, + navigateToDetail(e) { + const { id } = e.currentTarget.dataset + wx.navigateTo({ + url: `/subpages/communityNews/pages/detail/detail?id=${id}` + }) } }) \ No newline at end of file diff --git a/epdc-resident-mp-yushan/pages/index/index.wxml b/epdc-resident-mp-yushan/pages/index/index.wxml index c5da8e8..ae8c30c 100644 --- a/epdc-resident-mp-yushan/pages/index/index.wxml +++ b/epdc-resident-mp-yushan/pages/index/index.wxml @@ -80,7 +80,36 @@ - + + + + + + {{item.label}} + + + + + + + + + + + {{item.noticeTitle}} + + {{item.releaseTime}} + + + + + {{item.readingAmount}} + + + + + + diff --git a/epdc-resident-mp-yushan/pages/index/index.wxss b/epdc-resident-mp-yushan/pages/index/index.wxss index f20250a..83092da 100644 --- a/epdc-resident-mp-yushan/pages/index/index.wxss +++ b/epdc-resident-mp-yushan/pages/index/index.wxss @@ -300,4 +300,165 @@ page { font-size: 28rpx; color: #3f3f3f; line-height: 50 rpx; +} + +image { + width: 100%; + height: 100%; + float: left; +} + + +::-webkit-scrollbar{ + width: 0; + height: 0; + color: transparent; + display:none; +} + +.community-news { + width: 100%; + min-height: 100vh; + overflow-y: auto; + background: #f7f7f7; + margin-top: 16rpx; +} + +.community-news scroll-view { + width: 100%; + height: 90rpx; + background: #fff; +} + +.community-news scroll-view .tab-list { + display: flex; + align-items: center; +} + +.community-news scroll-view .tab-item { + font-size: 28rpx; + color: #999; + line-height: 90rpx; + height: 90rpx; + padding: 0 29rpx; + flex-shrink: 0; + position: relative; +} + +.item-hover { + background: #ddd; +} + +.community-news scroll-view .tab-item.active { + font-size: 30rpx; + color: #bb0300; +} + +.community-news scroll-view .tab-item .select-tab { + width: 40rpx; + height: 6rpx; + background-color: #bb0300; + border-radius: 3rpx; + position: absolute; + bottom: 0px; + left: calc(50% - 20rpx); + display: none; +} + +.community-news scroll-view .tab-item.active .select-tab { + display: block; +} + +.community-news scroll-view .tab-item + .tab-item { + margin-left: 19rpx; +} + +.news-list { + width: 100%; + background: #fff; + box-sizing: border-box; + padding: 0 30rpx; +} + +.news-list .list-item { + width: 100%; + box-sizing: border-box; + padding: 30rpx 0; + display: flex; + align-items: center; +} + +.news-list .list-item + .list-item { + border-top: 1rpx solid #eaeaea; +} + +.news-list .list-item .news-img { + width: 210rpx; + height: 150rpx; + border-radius: 8rpx; + overflow: hidden; + margin-right: 20rpx; +} + +.news-list .list-item .detail { + width: calc(100% - 210rpx - 20rpx); + height: 150rpx; + display: flex; + flex-direction: column; + justify-content: space-between; +} + +.news-list .list-item .detail .title { + font-size: 34rpx; + color: #3f3f3f; + line-height: 44rpx; + width: 100%; + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; +} + +.news-list .list-item .bottom-detail { + width: 100%; + display: flex; + align-items: center; + justify-content: space-between; +} + +.news-list .list-item .bottom-detail .time { + font-size: 22rpx; + letter-spacing: 1px; + color: #aaa; +} + +.news-list .list-item .bottom-detail .page-view { + display: flex; + align-items: center; + justify-content: flex-start; +} +.news-list .list-item .bottom-detail .page-view .page-view-img { + width: 30rpx; + height: 24rpx; + margin-right: 12rpx; +} + +.news-list .list-item .bottom-detail .page-view .num { + font-size: 24rpx; + letter-spacing: 1px; + color: #aaa; +} + +.no-data { + width: 100%; + height:calc(100vh - 90rpx - 100rpx - 20rpx); + display: flex; + align-items: center; + justify-content: center; +} + +.no-data .no-data-container { + width: 534rpx; + height: 258rpx; } \ No newline at end of file diff --git a/epdc-resident-mp-yushan/subpages/communityNews/images/avatar.jpg b/epdc-resident-mp-yushan/subpages/communityNews/images/avatar.jpg deleted file mode 100644 index 09ad485..0000000 Binary files a/epdc-resident-mp-yushan/subpages/communityNews/images/avatar.jpg and /dev/null differ diff --git a/epdc-resident-mp-yushan/utils/config.js b/epdc-resident-mp-yushan/utils/config.js index a235be8..0918b71 100644 --- a/epdc-resident-mp-yushan/utils/config.js +++ b/epdc-resident-mp-yushan/utils/config.js @@ -7,8 +7,8 @@ module.exports = { function BASEURL() { // return 'http://192.168.51.31:9094/epdc-api/api/' // 测试环境 接口地址 - return "https://epdc-api-test.elinkservice.cn/epdc-api/api/" // 测试环境 ip接口地址 - // return 'https://epdc-yushan.elinkservice.cn/epdc-api/api/' // 现代榆山正式环境 + // return "https://epdc-api-test.elinkservice.cn/epdc-api/api/" // 测试环境 ip接口地址 + return 'https://epdc-yushan.elinkservice.cn/epdc-api/api/' // 现代榆山正式环境 } function WEBROOT() {