优化代码

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

@ -6,8 +6,9 @@
<view class="text">{{item.name}}</view> <view class="text">{{item.name}}</view>
</view> </view>
</view> </view>
<view class="serve_box"> <view class="serve_box">
<view class="serve_title">功能服务<text class="more" @click="more()">更多</text></view> <view class="serve_title">功能服务<text class="more" @click="more()">更多</text></view>
<view class="serve_list"> <view class="serve_list">
<view class="serve_item" v-for="(item,index) in serve_list" :key="index" @click="to(item)"> <view class="serve_item" v-for="(item,index) in serve_list" :key="index" @click="to(item)">
@ -16,12 +17,13 @@
</view> </view>
</view> </view>
</view> </view>
<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_box">
<view class="margin-bottom-xs">
<uni-notice-bar showIcon="true" scrollable="true" single="true" speed="30" text="欢迎访问智慧物业">
</uni-notice-bar>
</view>
<view class="new_list"> <view class="new_list">
<view class="new_item" v-for="(item,index) in new_list" :key="index" @click="to(item)"> <view class="new_item" v-for="(item,index) in new_list" :key="index" @click="to(item)">
<view class="new_wrap"> <view class="new_wrap">
@ -79,8 +81,11 @@
import { import {
getCommunityName, getCommunityName,
getCommunityTel, getCommunityTel,
getCommunityQrCode getCommunityQrCode,
} from '../../api/community/communityApi.js'; getCommunityId
} from '@/api/community/communityApi.js';
import {queryNotices} from '@/api/index/indexApi.js';
export default { export default {
name: "indexMenu", name: "indexMenu",
@ -90,25 +95,27 @@
serve_list: [], serve_list: [],
callPropertyModal: false, callPropertyModal: false,
property: {}, property: {},
noticeText:'暂无公告',
new_list: [{ new_list: [{
src: this.imgUrl + '/h5/images/serve/new1.png', src: this.imgUrl + '/h5/images/serve/new1.png',
name: '报事报修', name: '报事报修',
desc: '一键维修', desc: '一键维修',
href: '/pages/repair/repair', href: '/pages/repair/repair',
ownerAuth:true ownerAuth: true
}, },
{ {
src: this.imgUrl + '/h5/images/serve/new2.png', src: this.imgUrl + '/h5/images/serve/new2.png',
name: '联系物业', name: '联系物业',
desc: '一键搞定', desc: '一键搞定',
href: '_callPropertyTel', href: '_callPropertyTel',
ownerAuth:false ownerAuth: false
}, },
], ],
}; };
}, },
created() { created() {
this._loadFunc(); this._loadFunc();
this._loadNotices();
}, },
components: { components: {
authOwnerDialog authOwnerDialog
@ -116,9 +123,9 @@
methods: { methods: {
_loadFunc: function() { _loadFunc: function() {
this.home_list = [{ this.home_list = [{
name: '社区公告', name: '投诉咨询',
src: this.imgUrl + '/h5/images/serve/7.png', src: this.imgUrl + '/h5/images/serve/12.png',
href: '/pages/notice/index', href: '/pages/complaint/complaint',
ownerAuth: false ownerAuth: false
}, },
{ {
@ -223,10 +230,32 @@
_cancleCall: function() { _cancleCall: function() {
this.callPropertyModal = false; 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() { more: function() {
uni.switchTab({ uni.switchTab({
url: '/pages/homemaking/homemaking' url: '/pages/homemaking/homemaking'
}) })
},
_toNoticePage:function(){
this.vc.navigateTo({
url: '/pages/notice/index'
});
} }
} }
} }

View File

@ -2,7 +2,7 @@
<view class="user-container"> <view class="user-container">
<block v-if="notices.length > 0"> <block v-if="notices.length > 0">
<view class="cu-list menu" v-for="(notice, idx) in notices" :key="idx" :data-item="notice" <view class="cu-list menu" v-for="(notice, idx) in notices" :key="idx" :data-item="notice"
@click="gotoDetail(notice)"> @click="gotoDetail(notice)">
<view class="cu-item arrow"> <view class="cu-item arrow">
<view class="content padding-tb-sm"> <view class="content padding-tb-sm">
<view> <view>
@ -10,7 +10,8 @@
<view class="text-cut" style="width:220px">{{notice.title}}</view> <view class="text-cut" style="width:220px">{{notice.title}}</view>
</view> </view>
<view class="text-gray text-sm"> <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> </view>
</view> </view>
@ -35,11 +36,17 @@
import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue'; import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
/** index.js **/ /** index.js **/
import context from '../../lib/java110/Java110Context.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 const constant = context.constant; //app
//app //app
const app = getApp().globalData; const app = getApp().globalData;
import {
queryNotices
} from '@/api/index/indexApi.js';
export default { export default {
data() { data() {
return { return {
@ -48,7 +55,7 @@
currPageIndex: 0, currPageIndex: 0,
pageSize: 10, pageSize: 10,
page: 1, page: 1,
loadingStatus : 'loading', loadingStatus: 'loading',
loadingContentText: { loadingContentText: {
contentdown: '上拉加载更多', contentdown: '上拉加载更多',
contentrefresh: '加载中', contentrefresh: '加载中',
@ -68,44 +75,35 @@
onShow: function() { onShow: function() {
let that = this; let that = this;
}, },
onReachBottom : function(){ onReachBottom: function() {
if(this.loadingStatus == 'noMore'){ if (this.loadingStatus == 'noMore') {
return; return;
} }
this._loadApply(); this._loadApply();
}, },
methods: { methods: {
_loadNotices: function(){ _loadNotices: function() {
this.loadingStatus = 'more'; this.loadingStatus = 'more';
let that = this; let that = this;
context.request({ queryNotices({
header: context.getHeaders(), communityId: that.communityId,
url: constant.url.GetNoticeListUrl, page: that.page,
method: "GET", row: 10,
data: { noticeTypeCd: '1000,1003',
communityId: that.communityId, clientType: 'H5'
page: that.page, }).then((_notices) => {
row: 10, that.notices = that.notices.concat(_notices);
noticeTypeCd:'1000,1003', if (that.notices.length == res.data.total) {
clientType: 'H5' that.loadingStatus = 'noMore';
}, return;
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;
}
} }
}); });
}, },
gotoDetail: function(_notice) { gotoDetail: function(_notice) {
let that = this; let that = this;
this.vc.navigateTo({ 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 @@
</script> </script>
<style> <style>
@import "./index.css"; @import "./index.css";
.cu-list+.cu-list { .cu-list+.cu-list {
margin-top: 10px; margin-top: 10px;
} }
</style> </style>