diff --git a/api/index/indexApi.js b/api/index/indexApi.js index 0c6a1a0..3780098 100644 --- a/api/index/indexApi.js +++ b/api/index/indexApi.js @@ -251,4 +251,28 @@ export function listCommunityMarketGoods(dataObj) { }); }) } +/** + * 查询通知 + * @param {Object} dataObj + */ +export function queryNotices(dataObj) { + return new Promise( + (resolve, reject) => { + requestNoAuth({ + url: url.GetNoticeListUrl, + method: "GET", + data: dataObj, + //动态数据 + success: function(res) { + res.data.notices.forEach(function(item, index) { + item.timeStr = item.startTime.replace(/:\d{1,2}$/, ' '); + }); + resolve(res.data.notices); + }, + fail: function(e) { + reject(); + } + }); + }) +} diff --git a/components/index/index-menu.vue b/components/index/index-menu.vue index 71b0b28..03fe78f 100644 --- a/components/index/index-menu.vue +++ b/components/index/index-menu.vue @@ -6,8 +6,9 @@ {{item.name}} - + + 功能服务更多 @@ -16,12 +17,13 @@ + + + + - - - - + @@ -79,8 +81,11 @@ import { getCommunityName, getCommunityTel, - getCommunityQrCode - } from '../../api/community/communityApi.js'; + getCommunityQrCode, + getCommunityId + } from '@/api/community/communityApi.js'; + + import {queryNotices} from '@/api/index/indexApi.js'; export default { name: "indexMenu", @@ -90,25 +95,27 @@ serve_list: [], callPropertyModal: false, property: {}, + noticeText:'暂无公告', new_list: [{ src: this.imgUrl + '/h5/images/serve/new1.png', name: '报事报修', desc: '一键维修', href: '/pages/repair/repair', - ownerAuth:true + ownerAuth: true }, { src: this.imgUrl + '/h5/images/serve/new2.png', name: '联系物业', desc: '一键搞定', href: '_callPropertyTel', - ownerAuth:false + ownerAuth: false }, ], }; }, created() { this._loadFunc(); + this._loadNotices(); }, components: { authOwnerDialog @@ -116,9 +123,9 @@ methods: { _loadFunc: function() { this.home_list = [{ - name: '社区公告', - src: this.imgUrl + '/h5/images/serve/7.png', - href: '/pages/notice/index', + name: '投诉咨询', + src: this.imgUrl + '/h5/images/serve/12.png', + href: '/pages/complaint/complaint', ownerAuth: false }, { @@ -223,10 +230,32 @@ _cancleCall: function() { this.callPropertyModal = false; }, + _loadNotices: function() { + this.loadingStatus = 'more'; + let that = this; + queryNotices({ + communityId: getCommunityId(), + page: 1, + row: 3, + noticeTypeCd: '1000,1003', + clientType: 'H5' + }).then((_notices) => { + let _notice = ""; + for(let _nIndex = 0;_nIndex < _notices.length; _nIndex++){ + _notice +=("【公告"+(_nIndex+1)+"】"+_notices[_nIndex].title+"; "); + } + that.noticeText = _notice; + }); + }, more: function() { uni.switchTab({ url: '/pages/homemaking/homemaking' }) + }, + _toNoticePage:function(){ + this.vc.navigateTo({ + url: '/pages/notice/index' + }); } } } diff --git a/pages/notice/index.vue b/pages/notice/index.vue index df7f188..8335db5 100644 --- a/pages/notice/index.vue +++ b/pages/notice/index.vue @@ -2,7 +2,7 @@ + @click="gotoDetail(notice)"> @@ -10,7 +10,8 @@ {{notice.title}} - 发布时间: {{notice.timeStr}} + 发布时间: {{notice.timeStr}} + @@ -35,11 +36,17 @@ import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue'; /** index.js **/ import context from '../../lib/java110/Java110Context.js'; - import { getCommunityId } from '../../api/community/communityApi.js'; + import { + getCommunityId + } from '../../api/community/communityApi.js'; const constant = context.constant; //获取app实例 //获取app实例 const app = getApp().globalData; + import { + queryNotices + } from '@/api/index/indexApi.js'; + export default { data() { return { @@ -48,7 +55,7 @@ currPageIndex: 0, pageSize: 10, page: 1, - loadingStatus : 'loading', + loadingStatus: 'loading', loadingContentText: { contentdown: '上拉加载更多', contentrefresh: '加载中', @@ -68,44 +75,35 @@ onShow: function() { let that = this; }, - onReachBottom : function(){ - if(this.loadingStatus == 'noMore'){ + onReachBottom: function() { + if (this.loadingStatus == 'noMore') { return; } this._loadApply(); }, methods: { - _loadNotices: function(){ + _loadNotices: function() { this.loadingStatus = 'more'; let that = this; - context.request({ - header: context.getHeaders(), - url: constant.url.GetNoticeListUrl, - method: "GET", - data: { - communityId: that.communityId, - page: that.page, - row: 10, - noticeTypeCd:'1000,1003', - clientType: 'H5' - }, - success: function(res) { - // TODO 判断 - res.data.notices.forEach(function(item, index) { - item.timeStr = item.startTime.replace(/:\d{1,2}$/, ' '); - }); - that.notices = that.notices.concat(res.data.notices); - if(that.notices.length == res.data.total){ - that.loadingStatus = 'noMore'; - return; - } + queryNotices({ + communityId: that.communityId, + page: that.page, + row: 10, + noticeTypeCd: '1000,1003', + clientType: 'H5' + }).then((_notices) => { + that.notices = that.notices.concat(_notices); + if (that.notices.length == res.data.total) { + that.loadingStatus = 'noMore'; + return; } }); }, gotoDetail: function(_notice) { let that = this; this.vc.navigateTo({ - url: "/pages/notice/detail/detail?noticeId=" + _notice.noticeId+"&communityId="+that.communityId + url: "/pages/notice/detail/detail?noticeId=" + _notice.noticeId + "&communityId=" + that + .communityId }); }, } @@ -113,7 +111,8 @@ + \ No newline at end of file