Commit 69aad08e by xiexiaoqin

fix: 刷新时不跳到当前日期

parent 19646474
......@@ -3,7 +3,6 @@ Component({
data: {},
props: {},
didMount() {
console.log(this.props.centerPopupList)
},
didUpdate() { },
didUnmount() { },
......
......@@ -86,7 +86,7 @@
</view>
<view>{{item.hasDateLabel}}</view>
</view>
<view class="scheduleBox {{item.value.isBeOverdue ? 'overdue' : item.value.confirmAttendance === 0 ? 'cancel' : ''}}" data-item="{{item.value}}" onTap="nextDetail">
<view class="scheduleBox {{item.value.isBeOverdue ? 'overdue' : item.value.confirmAttendance === 0 ? 'cancel' : ''}}" data-item="{{item.value}}" data-index="{{index}}" onTap="nextDetail">
<view class="scheduleTitle">
<text>{{item.value.title}}{{item.value.isDaySpan ? `(第${item.value.isFewDays}天,共${item.value.duration}天)` : '' }}</text>
</view>
......
......@@ -46,7 +46,8 @@ create.Page({
current: 1,
pages: 1,
listLoading: true,
isIPX: checkFullScren()
isIPX: checkFullScren(),
scheduleListIndex: ''
},
scrollTop: 0,
pageSize: 10,
......@@ -63,23 +64,16 @@ create.Page({
todayIndex: 0,
onShow() {
//如果是重复会议重新算
if (this.$store.data.indexNeedUpdate) {
//单次会议往DateMap中添加
if (this.$store.data.onceMeetingContent) {
dd.setNavigationBar({
title: "日程"
});
DateMap = getDateMap(this.minYear, this.maxYear);
this.getData();
this.isFirstLoad = true;
this.$store.data.indexNeedUpdate = false;
this.update();
}
//单次会议往DateMap中添加
if (this.$store.data.onceMeetingContent) {
this.getScheduleList(this.$store.data.onceMeetingContent, "once");
this.$store.data.onceMeetingContent = null;
this.update();
}
//刷新动态列表
if (this.$store.data.isIndexAffairListNeedUpdate) {
this.getPages(1);
......@@ -91,6 +85,31 @@ create.Page({
this.getData()
}, 30000)
},
//修改重复会议
modifyErpeatMeeting() {
this.getData();
},
//修改会议,除单次会议修改成重复会议
modifyOnceMeetingContent(content) {
this.getData(true);
const scheduleListIndex = `scheduleList[${this.data.scheduleListIndex}].value`;
const item = this.data.scheduleList[this.data.scheduleListIndex].value
this.setData({
[scheduleListIndex]: {
...item,
...content
}
});
for (let i = 0; i < this.scheduleList.length; i++) {
if (typeof this.scheduleList[i].value !== 'string') {
if (this.scheduleList[i].value.id === item.id) {
this.scheduleList[i].value = { ...this.scheduleList[i].value, ...content };
break;
}
}
}
},
onHide() {
clearInterval(this.timer);
this.timer = null;
......@@ -114,11 +133,19 @@ create.Page({
dd.setNavigationBar({
title: "动态"
});
this.isFirstLoad = true;
//获取动态列表
this.getPages(1);
//获取日程列表
this.getData();
this.isFirstLoad = true;
this.$store.modifyOnceMeetingContent = (content) => {
this.modifyOnceMeetingContent(content);
}
this.$store.modifyErpeatMeeting = () => {
this.modifyErpeatMeeting()
}
this.update();
},
//动态列表侧滑的时候禁止页面上下滑动
setBodyDisableScroll(isStopBodyScroll) {
......@@ -298,19 +325,50 @@ create.Page({
}
}
},
getData() {
getData(onlyChangeSign) {
getHomeUserSchedule1({
startTime: "2020-01-01 00:00:00",
endTime: "2025-12-30 23:59:59"
}).then(res => {
//是否刷新页面
if (this.data.sign && res.data.data.sign !== this.data.sign) {
DateMap = getDateMap(this.minYear, this.maxYear);
//只修改sign, 防止30S后刷新页面
if (onlyChangeSign) {
console.log('只修改sign')
this.setData({
sign: res.data.data.sign
})
return
}
if (res.data.data.sign !== this.data.sign) {
//第一次加载
if (this.isFirstLoad) {
console.log('第一次加载')
this.getScheduleList(res.data.data);
this.getPagination(this.scheduleList);
this.setData({
scheduleList: this.scheduleList.slice(
this.firstPage * this.pageSize,
this.currentPage * this.pageSize
),
loading: false
});
this.backToToday("first");
}
//定时任务是否刷新页面
if (this.data.sign && res.data.data.sign !== this.data.sign) {
console.log('刷新页面')
DateMap = getDateMap(this.minYear, this.maxYear);
this.getScheduleList(res.data.data);
this.setData({
scheduleList: this.scheduleList.slice(
this.firstPage * this.pageSize,
this.currentPage * this.pageSize
),
loading: false
});
}
this.setData({
sign: res.data.data.sign
})
......@@ -452,7 +510,7 @@ create.Page({
}
},
//日程数据
getScheduleList(response, type) {
getScheduleList(response, type, changePagination) {
if (type == "once") {
this.setDateMapValue(response.startTime, response.endTime, response);
} else {
......@@ -534,17 +592,28 @@ create.Page({
});
this.scheduleList = DateList;
this.getPagination(this.scheduleList);
// 第一次加载
this.setData({
scheduleList: this.scheduleList.slice(
this.firstPage * this.pageSize,
this.currentPage * this.pageSize
),
loading: false
});
//定位到当前日期
this.backToToday("first");
// if (changePagination) {
// this.setData({
// scheduleList: this.scheduleList.slice(
// this.firstPage * this.pageSize,
// this.currentPage * this.pageSize
// ),
// loading: false
// });
// return
// }
// this.getPagination(this.scheduleList);
// // 第一次加载
// this.setData({
// scheduleList: this.scheduleList.slice(
// this.firstPage * this.pageSize,
// this.currentPage * this.pageSize
// ),
// loading: false
// });
// //定位到当前日期
// this.backToToday("first");
},
//日程上拉加载
lower() {
......@@ -728,9 +797,15 @@ create.Page({
dd.navigateTo({ url: "./../createMeeting/createMeeting" });
},
nextDetail: throttle(function (e) {
const { item, index } = e.target.dataset;
if (index) {
this.setData({
scheduleListIndex: index
})
}
dd.navigateTo({
url: `./../meetingDetail/meetingDetail?scheduleItem=${encodeURIComponent(
JSON.stringify(e.target.dataset.item)
JSON.stringify(item)
)}`
});
}, 1000),
......
......@@ -651,8 +651,14 @@ create.Page({
return new Promise((resolve, rejects) => {
modifySchedule(Object.assign(data, obj)).then(res => {
if (res.data.code === 0) {
that.$store.data.indexNeedUpdate = true
that.update()
// that.$store.data.indexNeedUpdate = true
// that.update()
if (data.modifyContent !== 'title') {
if (this.$store.modifyErpeatMeeting) {
this.$store.modifyErpeatMeeting()
}
}
if (this.$store.data.originalData.repeatable === 1 && !!res.data.data) {
observer.notice(res.data.data)
}
......@@ -748,12 +754,21 @@ create.Page({
}
isParticipate(data1).then(res => {
if (res.data.code === 0) {
this.$store.data.indexNeedUpdate = true
this.update()
// this.$store.data.indexNeedUpdate = true
// this.update()
this.setData({
confirmAttendance: 0
})
this.conflictPeople()
if (data1.type === 'only') {
if (this.$store.modifyOnceMeetingContent) {
this.$store.modifyOnceMeetingContent({ confirmAttendance: 0 })
}
} else {
if (this.$store.modifyErpeatMeeting) {
this.$store.modifyErpeatMeeting()
}
}
}
})
break
......@@ -767,14 +782,23 @@ create.Page({
}
isParticipate(data).then(res => {
if (res.data.code === 0) {
this.$store.data.indexNeedUpdate = true
this.update()
// this.$store.data.indexNeedUpdate = true
// this.update()
this.setData({
aheadTimes: [15],
'comListData.aheadTimesListId': [15],
confirmAttendance: 1
})
this.conflictPeople()
if (data.type === 'only') {
if (this.$store.modifyOnceMeetingContent) {
this.$store.modifyOnceMeetingContent({ confirmAttendance: 1 })
}
} else {
if (this.$store.modifyErpeatMeeting) {
this.$store.modifyErpeatMeeting()
}
}
}
})
break
......@@ -794,7 +818,10 @@ create.Page({
planDate: this.data.scheduleItem.planDate
}
deleteSchedule(data).then(res => {
_that.$store.data.indexNeedUpdate = true;
if (this.$store.modifyErpeatMeeting) {
this.$store.modifyErpeatMeeting()
}
// _that.$store.data.indexNeedUpdate = true;
_that.$store.data.isIndexAffairListNeedUpdate = true;
_that.update()
dd.navigateBack({
......@@ -903,8 +930,21 @@ create.Page({
modifyContent: 'title'
}
this.modifySchedule(dataTitle).then(res => {
this.$store.data.isIndexAffairListNeedUpdate = true
this.$store.data.isIndexAffairListNeedUpdate = true;
this.$store.data.originalData.title = this.data.title
if (this.data.repeatable == 0) {
if (this.$store.modifyOnceMeetingContent) {
this.$store.modifyOnceMeetingContent({
title: this.data.title
})
}
} else {
if (this.$store.modifyErpeatMeeting) {
this.$store.modifyErpeatMeeting()
}
}
this.update()
}).catch(err => {
this.setData({
......@@ -1214,7 +1254,11 @@ create.Page({
deleteModel: 'only'
}
deleteSchedule(data).then(res => {
_that.$store.data.indexNeedUpdate = true;
// _that.$store.data.indexNeedUpdate = true;
if (this.$store.modifyErpeatMeeting) {
this.$store.modifyErpeatMeeting()
}
_that.$store.data.isIndexAffairListNeedUpdate = true;
_that.update()
dd.navigateBack({
......@@ -1241,14 +1285,20 @@ create.Page({
} else {
isParticipate(data).then(res => {
if (res.data.code === 0) {
this.$store.data.indexNeedUpdate = true
this.update()
// this.$store.data.indexNeedUpdate = true
// this.update()
this.setData({
aheadTimes: [15],
'comListData.aheadTimesListId': [15],
confirmAttendance: 1
})
this.conflictPeople()
if (this.$store.modifyOnceMeetingContent) {
this.$store.modifyOnceMeetingContent({ confirmAttendance: 1 })
}
}
})
}
......@@ -1268,12 +1318,15 @@ create.Page({
} else {
isParticipate(data).then(res => {
if (res.data.code === 0) {
this.$store.data.indexNeedUpdate = true
this.update()
// this.$store.data.indexNeedUpdate = true
// this.update()
this.setData({
confirmAttendance: 0
})
this.conflictPeople()
if (this.$store.modifyOnceMeetingContent) {
this.$store.modifyOnceMeetingContent({ confirmAttendance: 0 })
}
}
})
}
......@@ -1294,12 +1347,22 @@ create.Page({
}
isParticipate(data).then(res => {
if (res.data.code === 0) {
this.$store.data.indexNeedUpdate = true
this.update()
// this.$store.data.indexNeedUpdate = true
// this.update()
this.setData({
confirmAttendance: -9
})
this.conflictPeople()
if (this.data.repeatable === 1) {
if (this.$store.modifyErpeatMeeting) {
this.$store.modifyErpeatMeeting()
}
} else {
if (this.$store.modifyOnceMeetingContent) {
this.$store.modifyOnceMeetingContent({ confirmAttendance: -9 })
}
}
}
})
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment