Commit bb08e258 by liang ce

修改解绑绑定outlook逻辑

parent 55b9f0a9
const app = getApp(); const app = getApp();
import $http from "./http"; import $http from "./http";
import $binding from "./binding"; import $binding from "./binding";
// 获取创建会议室的会议室列表
export function getMeetingRoom(data) {
return $http({
method: "get",
data: data,
url: "/meet/meeting-room/page"
});
}
// 获取会议室分类
// 办公区域
// OFFICE_LOCATION(0,"meeting_room_location")
// 会议室设施
// OFFICE_FACILITY(1,"meeting_room_facility")
// 会议室分类
// OFFICE_CATEGORY(2,"meeting_room_category")
export function getLabelTree(data) {
return $http({
method: "get",
data: data,
url: "/admin/label/tree"
});
}
// 更新办公区域,设施,分类
export function getMettingRoomLabelUpdate(data) {
return $http({
method: "POST",
data: JSON.stringify(data),
url: "/admin/label/update"
});
}
// 添加办公区域、会议室分类、会议室设置
export function getMettingRoomLabelSave(data) {
return $http({
method: "POST",
data: JSON.stringify(data),
url: "/admin/label/save"
});
}
// 删除办公区域、会议室分类、会议室设置
export function getMettingRoomLabelRemove(data) {
return $http({
method: "get",
data: data,
url: `/admin/label/remove/${data}`
});
}
// 删除会议室
export function getRemoveMeetingRoom(data) {
return $http({
method: "get",
data: "",
url: `/meet/meeting-room/remove/${data}`
});
}
// 创建会议室
export function saveMettingRoom(data) {
return $http({
method: "post",
data: JSON.stringify(data),
url: "/meet/meeting-room/save"
});
}
// 修改会议室
export function mettingRoomUpdate(data) {
return $http({
method: "post",
data: JSON.stringify(data),
url: "/meet/meeting-room/update"
});
}
// 获取会议室详情
export function getMeetingRoomVOByUuid(data) {
return $http({
method: "get",
data: "",
url: `/meet/meeting-room/getMeetingRoomVOByUuid/${data}`
});
}
// 获取我的会议
export function myMeetingPage(data) {
return $http({
method: "post",
data: JSON.stringify(data),
url: "/meet/meeting/myPage"
});
}
// 获取预定会议室列表 // 获取预定会议室列表
export function getReserveRoomList(data) { export function getReserveRoomList(data) {
return $http({ return $http({
...@@ -97,24 +11,6 @@ export function getReserveRoomList(data) { ...@@ -97,24 +11,6 @@ export function getReserveRoomList(data) {
}); });
} }
// 获取预定会议详情
export function getMyMeetingDetails(data) {
return $http({
method: "get",
data: "",
url: `/meet/meeting/${data}`
});
}
// 修改预定时间设置
export function updateGlobalSetting(data) {
return $http({
method: "post",
data: JSON.stringify(data),
url: `/meet/meeting-global-setting/update`
});
}
// 获取首页信息 // 获取首页信息
export function getHomeUserSchedule(data) { export function getHomeUserSchedule(data) {
return $http({ return $http({
...@@ -318,3 +214,12 @@ export function getThirdUserPlatForm(data) { ...@@ -318,3 +214,12 @@ export function getThirdUserPlatForm(data) {
url: `/admin/third/user/getThirdUserPlatForm` url: `/admin/third/user/getThirdUserPlatForm`
}); });
} }
// 解绑第三方app
export function unbindingApp(data) {
return $http({
method: "get",
data: "",
url: `/admin/third/user/remove/${data}`
});
}
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<view class="applicationList" a:for="{{relatedAppList}}" a:if="{{item.platform !== 'dingTalk'}}"> <view class="applicationList" a:for="{{relatedAppList}}" a:if="{{item.platform !== 'dingTalk'}}">
<view class="applicationLogo {{item.platform}}"> <view class="applicationLogo {{item.platform}}">
</view> </view>
<view class="applicationMsg"> <view class="applicationMsg" data-item="{{item}}" catchTap="toAppDetails">
<view> <view>
<view> <view>
{{item.thirdUserIdentify}} {{item.thirdUserIdentify}}
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<view class="applicationList" a:if="{{relatedAppPlatformList.indexOf('outlook') === -1}}"> <view class="applicationList" a:if="{{relatedAppPlatformList.indexOf('outlook') === -1}}">
<view class="applicationLogo outlook"> <view class="applicationLogo outlook">
</view> </view>
<view class="applicationMsg" catchTap="bindingOutlook"> <view class="applicationMsg" data-platform="outlook" catchTap="bindingOutlook">
<view> <view>
<view> <view>
Outlook日历 Outlook日历
......
import { getThirdUserPlatForm } from "../../api/request"; import { getThirdUserPlatForm } from "../../api/request";
import { throttle } from "../../utils/utils";
import create from "dd-store"; import create from "dd-store";
create.Component({ create.Component({
mixins: [], mixins: [],
...@@ -13,18 +14,34 @@ create.Component({ ...@@ -13,18 +14,34 @@ create.Component({
this.setData({ this.setData({
userInfo: JSON.parse(getApp().globalData.userInfo) userInfo: JSON.parse(getApp().globalData.userInfo)
}); });
this.getDate(); this.getData();
}, },
didUpdate() { didUpdate() {
if (this.$store.data.relatedAppNeedUpdate) { if (typeof this.$store.data.relatedAppNeedUpdate === "object") {
this.$store.data.relatedAppNeedUpdate = false; let relatedAppList = this.data.relatedAppList;
let relatedAppPlatformList = this.data.relatedAppPlatformList;
relatedAppList.push({
thirdUserIdentify: this.$store.data.relatedAppNeedUpdate.name,
platform: this.$store.data.relatedAppNeedUpdate.platform
});
relatedAppPlatformList.push(
this.$store.data.relatedAppNeedUpdate.platform
);
this.setData({
relatedAppList: relatedAppList,
relatedAppPlatformList: relatedAppPlatformList
});
this.$store.data.relatedAppNeedUpdate = "";
this.update();
} else if (this.$store.data.relatedAppNeedUpdate === "1") {
this.$store.data.relatedAppNeedUpdate = "";
this.update(); this.update();
this.getDate(); this.getData();
} }
}, },
didUnmount() { }, didUnmount() {},
methods: { methods: {
getDate() { getData() {
getThirdUserPlatForm().then(res => { getThirdUserPlatForm().then(res => {
let relatedAppPlatformList = []; let relatedAppPlatformList = [];
res.data.data.forEach(item => { res.data.data.forEach(item => {
...@@ -32,15 +49,24 @@ create.Component({ ...@@ -32,15 +49,24 @@ create.Component({
}); });
this.setData({ this.setData({
relatedAppList: res.data.data, relatedAppList: res.data.data,
relatedAppPlatformList: relatedAppPlatformList relatedAppPlatformList: res.data.data.map(it => it.platform)
}); });
}); });
}, },
preventSort() { preventSort() {
return false; return false;
}, },
bindingOutlook() { bindingOutlook(e) {
dd.navigateTo({ url: "./../bindingOutlook/bindingOutlook" }); dd.navigateTo({
url: `./../bindingOutlook/bindingOutlook?platform=${e.target.dataset.platform}`
});
},
toAppDetails(e) {
dd.navigateTo({
url: `./../outlookDetails/outlookDetails?item=${JSON.stringify(
e.target.dataset.item
)}`
});
} }
} }
}); });
...@@ -6,9 +6,13 @@ import create from "dd-store"; ...@@ -6,9 +6,13 @@ import create from "dd-store";
create.Page({ create.Page({
data: { data: {
$data: null, $data: null,
url: "" url: "",
platform: ''
}, },
onLoad() { onLoad(e) {
this.setData({
platform: e.platform
})
this.webViewContext = dd.createWebViewContext("web-view-1"); this.webViewContext = dd.createWebViewContext("web-view-1");
let data = `${getApp().globalData.userid},${dd.corpId}`; let data = `${getApp().globalData.userid},${dd.corpId}`;
getOutlookUrl(data).then(res => { getOutlookUrl(data).then(res => {
...@@ -26,7 +30,10 @@ create.Page({ ...@@ -26,7 +30,10 @@ create.Page({
}; };
authorizationCodeReplacementToken(data).then(res => { authorizationCodeReplacementToken(data).then(res => {
if (res.data.data) { if (res.data.data) {
this.$store.data.relatedAppNeedUpdate = true; this.$store.data.relatedAppNeedUpdate = {
name: res.data.data,
platform: this.data.platform
}
this.update(); this.update();
dd.navigateBack({ dd.navigateBack({
delta: 1 delta: 1
......
import { import {
getMeetingRoom,
myMeetingPage,
getReserveRoomList, getReserveRoomList,
getAllScheduleWithMeetingRoomByTime getAllScheduleWithMeetingRoomByTime
} from "../../api/request"; } from "../../api/request";
......
.relatedAppPage {
height: 100vh;
background: #FFFFFF;
}
.platformMsg {
display: flex;
padding: 34rpx 32rpx;
align-items: center;
}
.platformImg {
width: 60rpx;
height: 60rpx;
margin-right: 24rpx;
}
.outlook {
background: url(../../assests/outlookLogo.png) center /100% 100%;
}
.zoom {
background: url(../../assests/zoomLogo.png) center /100% 100%;
}
.unBinding {
width: 686rpx;
height: 96rpx;
margin: 22rpx auto;
border-radius: 48rpx;
border: 2rpx solid rgba(222, 222, 222, 1);
text-align: center;
line-height: 0.96rem;
font-size: 34rpx;
color: rgba(242, 86, 67, 1);
}
\ No newline at end of file
<view> <view class="relatedAppPage">
New Page <view class="platformMsg" a:if="{{item.platform === 'outlook'}}">
<view class="platformImg {{item.platform}}">
</view>
<view class="platformName">
{{item.thirdUserIdentify}}
</view>
</view>
<view class="platformMsg" a:if="{{item.platform === 'zoom'}}">
<view class="platformImg {{item.platform}}">
</view>
<view class="platformName">
{{item.thirdUserIdentify}}
</view>
</view>
<view class="unBinding" onTap="unbind">
取消关联
</view>
</view> </view>
\ No newline at end of file
import {} from "../../api/request"; import { unbindingApp } from "../../api/request";
import create from "dd-store"; import create from "dd-store";
create.Page({ create.Page({
data: { data: {
$data: null, $data: null,
item: ""
}, },
onLoad() {}, onLoad(e) {
this.setData({
item: JSON.parse(e.item)
});
},
unbind() {
unbindingApp(this.data.item.platform).then(res => {
if (res.data.data) {
this.$store.data.relatedAppNeedUpdate = "1";
this.update();
dd.navigateBack({
delta: 1
});
}
});
}
}); });
...@@ -5,7 +5,14 @@ import { ...@@ -5,7 +5,14 @@ import {
updateMeetingTask, updateMeetingTask,
getHomeUserSchedule1 getHomeUserSchedule1
} from "../../api/request"; } from "../../api/request";
import { getDateMap, getExcludeDate, getNextDateList, getWeekNumber, getBlankList, toLocaleDateString } from './schedule.js'; import {
getDateMap,
getExcludeDate,
getNextDateList,
getWeekNumber,
getBlankList,
toLocaleDateString
} from "./schedule.js";
import { import {
getFormatDate, getFormatDate,
throttle, throttle,
...@@ -27,17 +34,16 @@ create.Page({ ...@@ -27,17 +34,16 @@ create.Page({
todayStr: toLocaleDateString(currentDate), todayStr: toLocaleDateString(currentDate),
currentData: toLocaleDateString(currentDate), currentData: toLocaleDateString(currentDate),
currentDataIndex: 0, currentDataIndex: 0,
offset: 'stop', offset: "stop",
show: false, show: false,
loading: true, loading: true,
traceTime: '1970-03-01 00:00:00', traceTime: "1970-03-01 00:00:00",
isStopBodyScroll: false, isStopBodyScroll: false,
dynamicList: [], dynamicList: [],
current: 1, current: 1,
pages: 1, pages: 1,
listLoading: true, listLoading: true,
isFullscreen: false isFullscreen: false
}, },
scrollTop: 0, scrollTop: 0,
pageSize: 10, pageSize: 10,
...@@ -59,15 +65,15 @@ create.Page({ ...@@ -59,15 +65,15 @@ create.Page({
} }
//单次会议往DateMap中添加 //单次会议往DateMap中添加
if (this.$store.data.onceMeetingContent) { if (this.$store.data.onceMeetingContent) {
this.getScheduleList(this.$store.data.onceMeetingContent, 'once'); this.getScheduleList(this.$store.data.onceMeetingContent, "once");
} }
}, },
onLoad() { onLoad() {
this.setData({ this.setData({
isFullscreen: getApp().globalData.isFullscreen isFullscreen: getApp().globalData.isFullscreen
}) });
dd.setNavigationBar({ dd.setNavigationBar({
title: this.$store.data.tabBarIndex == '0' ? "动态" : '日程' title: this.$store.data.tabBarIndex == "0" ? "动态" : "日程"
}); });
//获取动态列表 //获取动态列表
this.getPages(1); this.getPages(1);
...@@ -79,12 +85,12 @@ create.Page({ ...@@ -79,12 +85,12 @@ create.Page({
setBodyDisableScroll(isStopBodyScroll) { setBodyDisableScroll(isStopBodyScroll) {
this.setData({ this.setData({
isStopBodyScroll isStopBodyScroll
}) });
}, },
//点击页面关闭侧滑模块 //点击页面关闭侧滑模块
closeSwipe() { closeSwipe() {
if (this.$store.closeActiveSwipe) { if (this.$store.closeActiveSwipe) {
this.$store.closeActiveSwipe() this.$store.closeActiveSwipe();
} }
}, },
getPages(current, callBack) { getPages(current, callBack) {
...@@ -95,12 +101,11 @@ create.Page({ ...@@ -95,12 +101,11 @@ create.Page({
if (!res.data.data) { if (!res.data.data) {
this.setData({ this.setData({
listLoading: false listLoading: false
}) });
return; return;
} }
const dynamicList = res.data.data.records.map((item, index) => { const dynamicList = res.data.data.records.map((item, index) => {
for (let i = 0; i < item.meetingLogDataList.length; i++) { for (let i = 0; i < item.meetingLogDataList.length; i++) {
if (item.meetingLogDataList[i].creatorInfo) { if (item.meetingLogDataList[i].creatorInfo) {
item.meetingLogDataList[i].creatorInfo = JSON.parse( item.meetingLogDataList[i].creatorInfo = JSON.parse(
item.meetingLogDataList[i].creatorInfo item.meetingLogDataList[i].creatorInfo
...@@ -113,7 +118,7 @@ create.Page({ ...@@ -113,7 +118,7 @@ create.Page({
} }
let itemData = item.meetingLogDataList[i].meetingLogResource; let itemData = item.meetingLogDataList[i].meetingLogResource;
if (itemData) { if (itemData) {
itemData.groupId = item.groupId itemData.groupId = item.groupId;
if (itemData.taskInfos || itemData.fileInfos) { if (itemData.taskInfos || itemData.fileInfos) {
if (itemData.creatorInfo) { if (itemData.creatorInfo) {
itemData.creatorInfo = JSON.parse(itemData.creatorInfo); itemData.creatorInfo = JSON.parse(itemData.creatorInfo);
...@@ -130,7 +135,7 @@ create.Page({ ...@@ -130,7 +135,7 @@ create.Page({
} }
} }
} }
return item return item;
}); });
//第一页数据会重新请求需要替换 //第一页数据会重新请求需要替换
...@@ -147,10 +152,10 @@ create.Page({ ...@@ -147,10 +152,10 @@ create.Page({
this.setData({ this.setData({
listLoading: false, listLoading: false,
current: res.data.data.current, current: res.data.data.current,
pages: res.data.data.pages, pages: res.data.data.pages
}); });
if (callBack) { if (callBack) {
callBack() callBack();
} }
}); });
}, },
...@@ -166,8 +171,8 @@ create.Page({ ...@@ -166,8 +171,8 @@ create.Page({
// 重新获取第一页的数据 // 重新获取第一页的数据
this.getPages(1, () => { this.getPages(1, () => {
dd.showToast({ dd.showToast({
content: '取消成功' content: "取消成功"
}) });
}); });
} else { } else {
//置顶 //置顶
...@@ -176,14 +181,17 @@ create.Page({ ...@@ -176,14 +181,17 @@ create.Page({
dynamicList[index].traceTime = res.data.data; dynamicList[index].traceTime = res.data.data;
dynamicList.splice(index, 1); dynamicList.splice(index, 1);
dynamicList.unshift(replaceItem); dynamicList.unshift(replaceItem);
this.setData({ this.setData(
{
dynamicList: dynamicList dynamicList: dynamicList
}, () => { },
() => {
dd.showToast({ dd.showToast({
content: '置顶成功' content: "置顶成功"
})
}); });
} }
);
}
}); });
}, },
//动态上拉加载分页数据 //动态上拉加载分页数据
...@@ -233,9 +241,10 @@ create.Page({ ...@@ -233,9 +241,10 @@ create.Page({
const centerPage = Math.floor(i / this.pageSize); const centerPage = Math.floor(i / this.pageSize);
// firstPage转为4的倍数,一次下拉加载40条 // firstPage转为4的倍数,一次下拉加载40条
const firstPage = centerPage - 2; const firstPage = centerPage - 2;
this.firstPage = firstPage % 4 == 0 ? firstPage : firstPage - firstPage % 4; this.firstPage =
firstPage % 4 == 0 ? firstPage : firstPage - (firstPage % 4);
this.currentPage = centerPage + 2; this.currentPage = centerPage + 2;
break break;
} }
} }
}, },
...@@ -253,41 +262,40 @@ create.Page({ ...@@ -253,41 +262,40 @@ create.Page({
endTime: endTime, endTime: endTime,
startTime: startTime, startTime: startTime,
planDate: getFormatDate(startTime, "yyyyMMdd", "-"), planDate: getFormatDate(startTime, "yyyyMMdd", "-"),
thisDayStartTime: getFormatDate(startTime, 'HH:mm'), thisDayStartTime: getFormatDate(startTime, "HH:mm"),
thisDayEndTime: getFormatDate(endTime, 'HH:mm'), thisDayEndTime: getFormatDate(endTime, "HH:mm"),
confirmAttendance: item.confirmAttendance, confirmAttendance: item.confirmAttendance,
title: item.title, title: item.title,
id: item.id, id: item.id,
isBeOverdue: currentDate.getTime() > endTime.getTime() ? true : false isBeOverdue: currentDate.getTime() > endTime.getTime() ? true : false
}; };
//模板会议id为空 //模板会议id为空
if (type == 'repeat') { if (type == "repeat") {
pushItem.scheduleTemplateId = item.id; pushItem.scheduleTemplateId = item.id;
pushItem.id = '' pushItem.id = "";
} }
// 如果是跨天会议,需要手动在起始天以后的其他天 添加会议日程 // 如果是跨天会议,需要手动在起始天以后的其他天 添加会议日程
const nextDateList = getNextDateList(startTime, endTime);//返回日期包括起始天 const nextDateList = getNextDateList(startTime, endTime); //返回日期包括起始天
if (nextDateList.length > 1) { if (nextDateList.length > 1) {
pushItem.isDaySpan = true; pushItem.isDaySpan = true;
pushItem.isFewDays = 1; pushItem.isFewDays = 1;
pushItem.isfirstDayOrEndDay = '0'// 0 第一天,1中间的天,2结束的天 pushItem.isfirstDayOrEndDay = "0"; // 0 第一天,1中间的天,2结束的天
pushItem.duration = nextDateList.length; pushItem.duration = nextDateList.length;
for (let i = 1; i < nextDateList.length; i++) { for (let i = 1; i < nextDateList.length; i++) {
if (DateMap.has(nextDateList[i])) { if (DateMap.has(nextDateList[i])) {
DateMap.get(nextDateList[i]).unshift({ DateMap.get(nextDateList[i]).unshift({
...pushItem, ...pushItem,
isFewDays: i + 1, isFewDays: i + 1,
isfirstDayOrEndDay: nextDateList.length - 1 === i ? "2" : "1",// 0 第一天,1中间的天,2结束的天 isfirstDayOrEndDay: nextDateList.length - 1 === i ? "2" : "1" // 0 第一天,1中间的天,2结束的天
}); });
} }
} }
} }
if (DateMap.has(toLocaleDateString(startTime))) { if (DateMap.has(toLocaleDateString(startTime))) {
DateMap.get(toLocaleDateString(startTime)).push(pushItem) DateMap.get(toLocaleDateString(startTime)).push(pushItem);
} }
}, },
// 根据接口返回数据生成填充DateMap // 根据接口返回数据生成填充DateMap
setDateMapByResponse(response) { setDateMapByResponse(response) {
...@@ -299,16 +307,22 @@ create.Page({ ...@@ -299,16 +307,22 @@ create.Page({
if (item.scheduleTemplateId) { if (item.scheduleTemplateId) {
scheduleListWithTemplateId.push(item); scheduleListWithTemplateId.push(item);
} else { } else {
this.setDateMapValue(new Date(item.startTime.replace(/-/g, '/')), new Date(item.endTime.replace(/-/g, '/')), item); this.setDateMapValue(
new Date(item.startTime.replace(/-/g, "/")),
new Date(item.endTime.replace(/-/g, "/")),
item
);
} }
}); });
// 处理重复会议 templateList // 处理重复会议 templateList
response.templateList.forEach(item => { response.templateList.forEach(item => {
//日程会议 //日程会议
const itemScheduleList = scheduleListWithTemplateId.filter(it => it.scheduleTemplateId == item.id); const itemScheduleList = scheduleListWithTemplateId.filter(
it => it.scheduleTemplateId == item.id
);
// 生成rrules规则 // 生成rrules规则
const initialTimeList = item.initialTime.split('-'); const initialTimeList = item.initialTime.split("-");
const startTimeList = item.startTime.split(":"); const startTimeList = item.startTime.split(":");
const DTSTART = `${initialTimeList[0]}${initialTimeList[1]}${initialTimeList[2]}T${startTimeList[0]}${startTimeList[1]}00Z`; const DTSTART = `${initialTimeList[0]}${initialTimeList[1]}${initialTimeList[2]}T${startTimeList[0]}${startTimeList[1]}00Z`;
const rule = RRule.fromString( const rule = RRule.fromString(
...@@ -319,14 +333,20 @@ create.Page({ ...@@ -319,14 +333,20 @@ create.Page({
//如果有日程会议则用日程会议替换 //如果有日程会议则用日程会议替换
let replaceItem = []; let replaceItem = [];
if (itemScheduleList.length > 0) { if (itemScheduleList.length > 0) {
replaceItem = itemScheduleList.filter(it => it.planDate == getFormatDate(startTime, "yyyyMMdd", "-")) replaceItem = itemScheduleList.filter(
it => it.planDate == getFormatDate(startTime, "yyyyMMdd", "-")
);
} }
if (replaceItem.length > 0) { if (replaceItem.length > 0) {
this.setDateMapValue(new Date(replaceItem[0].startTime.replace(/-/g, '/')), new Date(replaceItem[0].endTime.replace(/-/g, '/')), replaceItem[0]); this.setDateMapValue(
new Date(replaceItem[0].startTime.replace(/-/g, "/")),
new Date(replaceItem[0].endTime.replace(/-/g, "/")),
replaceItem[0]
);
} else { } else {
this.setDateMapValue(startTime, endTime, item, 'repeat'); this.setDateMapValue(startTime, endTime, item, "repeat");
}
} }
};
// 需要剔除某一天 // 需要剔除某一天
if (item.excludePlanDates) { if (item.excludePlanDates) {
const excludeData = getExcludeDate(item.excludePlanDates.split(",")); const excludeData = getExcludeDate(item.excludePlanDates.split(","));
...@@ -335,10 +355,16 @@ create.Page({ ...@@ -335,10 +355,16 @@ create.Page({
startTime.setHours(startTime.getHours() - 8); startTime.setHours(startTime.getHours() - 8);
// 生成结束时间 // 生成结束时间
const endTime = new Date(startTime); const endTime = new Date(startTime);
endTime.setMinutes(endTime.getMinutes() + item.recurrenceModel.duration); endTime.setMinutes(
endTime.getMinutes() + item.recurrenceModel.duration
);
// 剔除规则: 时间小于futureTime 时间不在单个排除日期里面 // 剔除规则: 时间小于futureTime 时间不在单个排除日期里面
if (startTime.getTime() < excludeData.minFutureTime && if (
!excludeData.excludeDateList.includes(getFormatDate(startTime, "yyyyMMdd", "-"))) { startTime.getTime() < excludeData.minFutureTime &&
!excludeData.excludeDateList.includes(
getFormatDate(startTime, "yyyyMMdd", "-")
)
) {
setDateMapValueAll(startTime, endTime, item); setDateMapValueAll(startTime, endTime, item);
} }
}); });
...@@ -350,25 +376,25 @@ create.Page({ ...@@ -350,25 +376,25 @@ create.Page({
startTime.setHours(startTime.getHours() - 8); startTime.setHours(startTime.getHours() - 8);
// 生成结束时间 // 生成结束时间
const endTime = new Date(startTime); const endTime = new Date(startTime);
endTime.setMinutes(endTime.getMinutes() + item.recurrenceModel.duration); endTime.setMinutes(
endTime.getMinutes() + item.recurrenceModel.duration
);
setDateMapValueAll(startTime, endTime, item); setDateMapValueAll(startTime, endTime, item);
}); });
} }
}); });
} }
}, },
//日程数据 //日程数据
getScheduleList(response, type) { getScheduleList(response, type) {
if (type == 'once') { if (type == "once") {
this.setDateMapValue(response.startTime, response.endTime, response); this.setDateMapValue(response.startTime, response.endTime, response);
} else { } else {
this.setDateMapByResponse(response); this.setDateMapByResponse(response);
} }
// 取出DateMap的value值平铺到DateList // 取出DateMap的value值平铺到DateList
const DateList = []; const DateList = [];
DateMap.forEach(function (value, key) { DateMap.forEach(function(value, key) {
const keyDate = new Date(key); const keyDate = new Date(key);
const year = keyDate.getFullYear(); const year = keyDate.getFullYear();
const month = keyDate.getMonth(); const month = keyDate.getMonth();
...@@ -398,7 +424,8 @@ create.Page({ ...@@ -398,7 +424,8 @@ create.Page({
const rangeDay2 = new Date(rangeDate).getDate(); const rangeDay2 = new Date(rangeDate).getDate();
DateList.push({ DateList.push({
type: "week", type: "week",
value: `第${getWeekNumber(year, month, date)}周,${month + 1}${date}日 - ${ value: `第${getWeekNumber(year, month, date)}周,${month +
1}${date}日 - ${
rangeMonth2 == month ? "" : rangeMonth2 + 1 + "月" rangeMonth2 == month ? "" : rangeMonth2 + 1 + "月"
}${rangeDay2}日`, }${rangeDay2}日`,
dateStr: `${year}/${month + 1}/${date}-week` dateStr: `${year}/${month + 1}/${date}-week`
...@@ -409,7 +436,7 @@ create.Page({ ...@@ -409,7 +436,7 @@ create.Page({
value.forEach((item, index) => { value.forEach((item, index) => {
if (index === 0) { if (index === 0) {
DateList.push({ DateList.push({
type: key !== toLocaleDateString(currentDate) ? "day" : 'today', type: key !== toLocaleDateString(currentDate) ? "day" : "today",
week: weekList[day], week: weekList[day],
hasDateLabel: padZero(date), hasDateLabel: padZero(date),
value: item, value: item,
...@@ -423,7 +450,10 @@ create.Page({ ...@@ -423,7 +450,10 @@ create.Page({
}); });
} }
}); });
} else if (value.length === 0 && key === toLocaleDateString(currentDate)) { } else if (
value.length === 0 &&
key === toLocaleDateString(currentDate)
) {
DateList.push({ DateList.push({
type: "thisday", type: "thisday",
value: "", value: "",
...@@ -438,7 +468,10 @@ create.Page({ ...@@ -438,7 +468,10 @@ create.Page({
this.getPagination(this.scheduleList); this.getPagination(this.scheduleList);
// 第一次加载 // 第一次加载
this.setData({ this.setData({
scheduleList: this.scheduleList.slice(this.firstPage * this.pageSize, this.currentPage * this.pageSize), scheduleList: this.scheduleList.slice(
this.firstPage * this.pageSize,
this.currentPage * this.pageSize
),
loading: false loading: false
}); });
}, },
...@@ -447,7 +480,10 @@ create.Page({ ...@@ -447,7 +480,10 @@ create.Page({
if (this.currentPage < this.totalPages) { if (this.currentPage < this.totalPages) {
this.currentPage++; this.currentPage++;
this.setData({ this.setData({
scheduleList: this.scheduleList.slice(this.firstPage * this.pageSize, this.currentPage * this.pageSize) scheduleList: this.scheduleList.slice(
this.firstPage * this.pageSize,
this.currentPage * this.pageSize
)
}); });
} else { } else {
//超出加载一年的数据 //超出加载一年的数据
...@@ -457,52 +493,61 @@ create.Page({ ...@@ -457,52 +493,61 @@ create.Page({
this.scheduleList.push(...yearData); this.scheduleList.push(...yearData);
this.setData({ this.setData({
scheduleList: this.scheduleList.slice(this.firstPage * this.pageSize) scheduleList: this.scheduleList.slice(this.firstPage * this.pageSize)
}) });
} }
}, },
onPullDownRefresh() { onPullDownRefresh() {
if (this.$store.data.tabBarIndex == '0') { if (this.$store.data.tabBarIndex == "0") {
this.getPages(1); this.getPages(1);
dd.stopPullDownRefresh(); dd.stopPullDownRefresh();
return return;
} }
//日程页面到顶部的时候才下拉加载数据,否则定位距离太长 //日程页面到顶部的时候才下拉加载数据,否则定位距离太长
if (this.$store.data.tabBarIndex == '1' && this.scrollTop !== 0) { if (this.$store.data.tabBarIndex == "1" && this.scrollTop !== 0) {
dd.stopPullDownRefresh(); dd.stopPullDownRefresh();
return return;
} }
// const todayStr = this.data.scheduleList[0].dateStr; // const todayStr = this.data.scheduleList[0].dateStr;
if (this.firstPage > 0) { if (this.firstPage > 0) {
this.firstPage -= 4; this.firstPage -= 4;
this.currentPage -= 4; this.currentPage -= 4;
this.setData({ this.setData(
todayStr: '', {
scheduleList: this.scheduleList.slice(this.firstPage * this.pageSize, this.currentPage * this.pageSize) todayStr: "",
}, () => { scheduleList: this.scheduleList.slice(
this.firstPage * this.pageSize,
this.currentPage * this.pageSize
)
},
() => {
this.setData({ this.setData({
todayStr: this.data.scheduleList[this.pageSize * 4 - 1].dateStr todayStr: this.data.scheduleList[this.pageSize * 4 - 1].dateStr
}); });
dd.stopPullDownRefresh(); dd.stopPullDownRefresh();
}); }
);
} else { } else {
this.minYear--; this.minYear--;
const yearData = getBlankList(this.minYear); const yearData = getBlankList(this.minYear);
this.blankDataLength += yearData.length; this.blankDataLength += yearData.length;
this.scheduleList.unshift(...yearData); this.scheduleList.unshift(...yearData);
this.totalPages = Math.ceil(this.scheduleList.length / this.pageSize); this.totalPages = Math.ceil(this.scheduleList.length / this.pageSize);
this.currentPage = Math.floor(yearData.length * 2 / this.pageSize); this.currentPage = Math.floor((yearData.length * 2) / this.pageSize);
this.setData({ this.setData(
todayStr: '', {
scheduleList: this.scheduleList.slice(0, yearData.length * 2), todayStr: "",
}, () => { scheduleList: this.scheduleList.slice(0, yearData.length * 2)
},
() => {
this.setData({ this.setData({
//加载一年的数据重定位可能会有点问题,重置一下 //加载一年的数据重定位可能会有点问题,重置一下
currentData: this.scheduleList[yearData.length - 1].dateStr, currentData: this.scheduleList[yearData.length - 1].dateStr,
currentDataIndex: yearData.length - 1, currentDataIndex: yearData.length - 1,
todayStr: this.scheduleList[yearData.length - 1].dateStr todayStr: this.scheduleList[yearData.length - 1].dateStr
}); });
dd.stopPullDownRefresh() dd.stopPullDownRefresh();
}) }
);
} }
}, },
//计算高度 //计算高度
...@@ -510,14 +555,14 @@ create.Page({ ...@@ -510,14 +555,14 @@ create.Page({
let height = 0; let height = 0;
let i = 0; let i = 0;
while (height <= scrollTop) { while (height <= scrollTop) {
if (this.data.scheduleList[i].type.indexOf('day') !== '-1') { if (this.data.scheduleList[i].type.indexOf("day") !== "-1") {
height += this.dateHeight height += this.dateHeight;
} else { } else {
height += this.otherHeight height += this.otherHeight;
} }
i++ i++;
} }
return i return i;
}, },
scroll(e) { scroll(e) {
//计算有偏差 //计算有偏差
...@@ -549,18 +594,18 @@ create.Page({ ...@@ -549,18 +594,18 @@ create.Page({
this.setData({ this.setData({
currentData: this.data.scheduleList[0].dateStr, currentData: this.data.scheduleList[0].dateStr,
currentDataIndex: 0 currentDataIndex: 0
}) });
} }
if (this.timer) { if (this.timer) {
clearTimeout(this.timer) clearTimeout(this.timer);
} }
this.timer = setTimeout(() => { this.timer = setTimeout(() => {
this.setData({ this.setData({
offset: 'stop' offset: "stop"
}) });
}, 500) }, 500);
//每次计算偏移值 //每次计算偏移值
const offset = this.getScrollOffset(e.detail.scrollTop); const offset = this.getScrollOffset(e.detail.scrollTop);
...@@ -570,51 +615,61 @@ create.Page({ ...@@ -570,51 +615,61 @@ create.Page({
offset offset
}); });
} }
this.resetToview = false this.resetToview = false;
} }
dd.createSelectorQuery().selectAll('.li').boundingClientRect().exec((rect) => { dd.createSelectorQuery()
if (offset == 'next') { .selectAll(".li")
.boundingClientRect()
.exec(rect => {
if (offset == "next") {
for (let i = this.data.currentDataIndex; i < rect[0].length; i++) { for (let i = this.data.currentDataIndex; i < rect[0].length; i++) {
if (rect[0][i].top > 0) { if (rect[0][i].top > 0) {
if (this.data.scheduleList[i].dateStr.split('/')[1] !== this.data.currentData.split('/')[1]) { if (
this.data.scheduleList[i].dateStr.split("/")[1] !==
this.data.currentData.split("/")[1]
) {
this.setData({ this.setData({
currentData: this.data.scheduleList[i].dateStr, currentData: this.data.scheduleList[i].dateStr,
currentDataIndex: i currentDataIndex: i
}) });
} }
break; break;
} }
} }
} } else if (offset == "before") {
else if (offset == 'before') { let i = Math.min(
let i = Math.min(this.data.currentDataIndex, this.data.scheduleList.length - 1); this.data.currentDataIndex,
this.data.scheduleList.length - 1
);
for (; i > 0; i--) { for (; i > 0; i--) {
if (rect[0][i].top < 50) { if (rect[0][i].top < 50) {
if (this.data.scheduleList[i].dateStr.split('/')[1] !== this.data.currentData.split('/')[1]) { if (
this.data.scheduleList[i].dateStr.split("/")[1] !==
this.data.currentData.split("/")[1]
) {
this.setData({ this.setData({
currentData: this.data.scheduleList[i].dateStr, currentData: this.data.scheduleList[i].dateStr,
currentDataIndex: i currentDataIndex: i
}) });
} }
break; break;
} }
} }
} }
}) });
}, },
//判断滚动方向 //判断滚动方向
getScrollOffset(scrollTop) { getScrollOffset(scrollTop) {
let offset = 'stop'; let offset = "stop";
if (scrollTop > this.scrollTop) { if (scrollTop > this.scrollTop) {
//向下滚动 //向下滚动
offset = 'next' offset = "next";
} else { } else {
//向上滚动 //向上滚动
offset = 'before' offset = "before";
} }
this.scrollTop = scrollTop; this.scrollTop = scrollTop;
return offset return offset;
}, },
closePop() { closePop() {
this.setData({ this.setData({
...@@ -629,15 +684,19 @@ create.Page({ ...@@ -629,15 +684,19 @@ create.Page({
createMeeting() { createMeeting() {
dd.navigateTo({ url: "./../createMeeting/createMeeting" }); dd.navigateTo({ url: "./../createMeeting/createMeeting" });
}, },
nextDetail: throttle(function (e) { nextDetail: throttle(function(e) {
dd.navigateTo({ dd.navigateTo({
url: `./../meetingDetail/meetingDetail?scheduleItem=${encodeURIComponent(JSON.stringify(e.target.dataset.item))}` url: `./../meetingDetail/meetingDetail?scheduleItem=${encodeURIComponent(
JSON.stringify(e.target.dataset.item)
)}`
}); });
}, 1000), }, 1000),
backToToday(type) { backToToday(type) {
if (!type) { if (!type) {
//如果当前的日期还没加载出来点击无效,下拉积累数据过长可以去掉 //如果当前的日期还没加载出来点击无效,下拉积累数据过长可以去掉
const isFindArr = this.data.scheduleList.filter(it => it.dateStr == toLocaleDateString(currentDate)); const isFindArr = this.data.scheduleList.filter(
it => it.dateStr == toLocaleDateString(currentDate)
);
if (isFindArr.length == 0 || this.data.scheduleList.length > 100) { if (isFindArr.length == 0 || this.data.scheduleList.length > 100) {
//去掉头部空数据 //去掉头部空数据
if (this.minYear < minYear) { if (this.minYear < minYear) {
...@@ -651,7 +710,10 @@ create.Page({ ...@@ -651,7 +710,10 @@ create.Page({
} }
this.getPagination(this.scheduleList); this.getPagination(this.scheduleList);
this.setData({ this.setData({
scheduleList: this.scheduleList.slice(this.firstPage * this.pageSize, this.currentPage * this.pageSize) scheduleList: this.scheduleList.slice(
this.firstPage * this.pageSize,
this.currentPage * this.pageSize
)
}); });
} }
} }
...@@ -678,11 +740,11 @@ create.Page({ ...@@ -678,11 +740,11 @@ create.Page({
dd.setNavigationBar({ dd.setNavigationBar({
title: title title: title
}); });
if (tabbar == '1' && lastTimeTabBarIndex == tabbar) { if (tabbar == "1" && lastTimeTabBarIndex == tabbar) {
this.backToToday(); this.backToToday();
} }
if (this.isFirstLoad) { if (this.isFirstLoad) {
this.backToToday('first'); this.backToToday("first");
this.isFirstLoad = false; this.isFirstLoad = false;
this.resetToview = true; this.resetToview = true;
} }
...@@ -692,7 +754,7 @@ create.Page({ ...@@ -692,7 +754,7 @@ create.Page({
maxClickCount--; maxClickCount--;
if (maxClickCount == 0) { if (maxClickCount == 0) {
dd.alert({ dd.alert({
content: '版本号198' content: "版本号198"
}); });
maxClickCount = 5; maxClickCount = 5;
} }
......
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