优化代码

This commit is contained in:
wuxw 2024-11-19 22:27:10 +08:00
parent 3a76409221
commit aed35786ea
3 changed files with 95 additions and 43 deletions

View File

@ -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();
}
});
})
}

View File

@ -8,6 +8,7 @@
</view>
<view class="serve_box">
<view class="serve_title">功能服务<text class="more" @click="more()">更多</text></view>
<view class="serve_list">
<view class="serve_item" v-for="(item,index) in serve_list" :key="index" @click="to(item)">
@ -16,12 +17,13 @@
</view>
</view>
</view>
<view class="new_box">
<view class="margin-bottom-xs">
<uni-notice-bar showIcon="true" scrollable="true" single="true" speed="30" text="欢迎访问智慧物业">
<view class="margin-bottom-xs" @click="_toNoticePage()">
<uni-notice-bar showIcon="true" scrollable="true" single="true" speed="30" :text="noticeText">
</uni-notice-bar>
</view>
<view class="new_box">
<view class="new_list">
<view class="new_item" v-for="(item,index) in new_list" :key="index" @click="to(item)">
<view class="new_wrap">
@ -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,6 +95,7 @@
serve_list: [],
callPropertyModal: false,
property: {},
noticeText:'暂无公告',
new_list: [{
src: this.imgUrl + '/h5/images/serve/new1.png',
name: '报事报修',
@ -109,6 +115,7 @@
},
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'
});
}
}
}

View File

@ -10,7 +10,8 @@
<view class="text-cut" style="width:220px">{{notice.title}}</view>
</view>
<view class="text-gray text-sm">
<text class="margin-right-xs">发布时间</text> {{notice.timeStr}}</view>
<text class="margin-right-xs">发布时间</text> {{notice.timeStr}}
</view>
</view>
</view>
</view>
@ -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 {
@ -78,34 +85,25 @@
_loadNotices: function() {
this.loadingStatus = 'more';
let that = this;
context.request({
header: context.getHeaders(),
url: constant.url.GetNoticeListUrl,
method: "GET",
data: {
queryNotices({
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);
}).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,6 +111,7 @@
</script>
<style>
@import "./index.css";
.cu-list+.cu-list {
margin-top: 10px;
}