Commit bfefd08c by fengzhaoyu

暂存

parents bc378e98 a075e286
...@@ -26,6 +26,9 @@ export default function http (data) { ...@@ -26,6 +26,9 @@ export default function http (data) {
login().then(res => { login().then(res => {
getApp().globalData.token = res.data.data.accessToken.access_token //'3a025eee-15ae-4805-9214-fe0599d47f17' // getApp().globalData.token = res.data.data.accessToken.access_token //'3a025eee-15ae-4805-9214-fe0599d47f17' //
// getApp().globalData.token = "157bad88-d68b-4d80-bec1-375f3756a398" // getApp().globalData.token = "157bad88-d68b-4d80-bec1-375f3756a398"
// =======
// getApp().globalData.token = res.data.data.accessToken.access_token
// >>>>>>> a075e286c28564b6fc88185eaa17672b9d65efcb
getApp().globalData.name = res.data.data.oapiUser.name getApp().globalData.name = res.data.data.oapiUser.name
getApp().globalData.userid = res.data.data.oapiUser.userid getApp().globalData.userid = res.data.data.oapiUser.userid
getApp().globalData.avatar = res.data.data.oapiUser.avatar getApp().globalData.avatar = res.data.data.oapiUser.avatar
......
<view> <scroll-view a:if="{{todayStr !== ''}}" scroll-y="{{true}}" upper-threshold="50" lower-threshold="50" onScrollToLower="lower" style="height: 100vh;" scroll-into-view="{{todayStr}}">
<block a:for="{{scheduleList}}"> <block a:for="{{scheduleList}}" a:for-item="scheduleYearList">
<block a:for="{{scheduleYearList}}">
<block a:if="{{item.type == 'year'}}"> <block a:if="{{item.type == 'year'}}">
<view class="month"> <view class="month" onTap="changMd">
{{item.value}}年 {{item.value}}年
</view> </view>
</block> </block>
...@@ -10,8 +11,8 @@ ...@@ -10,8 +11,8 @@
{{item.value}}月 {{item.value}}月
</view> </view>
</block> </block>
<block a:elif="{{item.type == 'week'}}"> <block a:elif="{{item.type == 'week'}}" >
<view class="week"> <view class="week" id="{{item.dayStr}}">
<view class="manyWeeks"> <view class="manyWeeks">
{{item.value}} {{item.value}}
</view> </view>
...@@ -26,19 +27,23 @@ ...@@ -26,19 +27,23 @@
<text>{{item.value.day}}</text> <text>{{item.value.day}}</text>
</view> </view>
<view class="dataSchedule"> <view class="dataSchedule">
<view a:for="{{item.value.value}}" a:for-item="item2" data-id="{{item2.id}}" class="overdue" onTap="nextDetail"> <view a:for="{{item.value.value}}" a:for-item="item2" data-id="{{item2.id}}" class="{{ item2.isBeOverdue ? 'overdue' : item2.confirmAttendance === 0 ? 'cancel' : '' }}" onTap="nextDetail">
<view class="dataScheduleName"> <view class="dataScheduleName">
{{item2.title}} {{item2.title}}{{item2.num ? '' : `(第${item2.isFewDays}天,共${item2.duration}天)`}}
</view> </view>
<view class="dataScheduleTime"> <view class="dataScheduleTime">
{{item2.startTime}} - {{item2.endTime}} <text a:if="{{item2.isfirstDayOrEndDay && item2.isfirstDayOrEndDay === '0'}}">{{item2.thisDayStartTime}}</text>
<text a:elif="{{item2.isfirstDayOrEndDay && item2.isfirstDayOrEndDay === '1'}}">全天</text>
<text a:elif="{{item2.isfirstDayOrEndDay && item2.isfirstDayOrEndDay === '2'}}">直到{{item2.thisDayEndTime}}</text>
<text a:else>{{item2.thisDayStartTime}} - {{item2.thisDayEndTime}}</text>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</block> </block>
</block> </block>
</view> </block>
</scroll-view>
<view class="createSchedule " onTap="nextPage"> <view class="createSchedule " onTap="nextPage">
+ +
</view> </view>
\ No newline at end of file
...@@ -2,16 +2,19 @@ import { getHomeUserSchedule } from '../../api/request.js' ...@@ -2,16 +2,19 @@ import { getHomeUserSchedule } from '../../api/request.js'
Page({ Page({
data: { data: {
AllScheduleList: [], AllScheduleList: [],
scheduleList: [] scheduleList: [],
todayStr: '',
thisYear: '',
maxYear: '',
minYear: ''
}, },
onLoad(query) { onLoad(query) {
// 页面加载 // 页面加载
dd.setNavigationBar({
title: '首页'
})
}, },
onReady() { onReady() {
},
onShow() {
// 页面显示
let data = { let data = {
"startTime": "2020-01-01 00:00:00", "startTime": "2020-01-01 00:00:00",
"endTime": "2025-12-30 23:59:59" "endTime": "2025-12-30 23:59:59"
...@@ -23,16 +26,23 @@ Page({ ...@@ -23,16 +26,23 @@ Page({
}, () => { }, () => {
let now = new Date() let now = new Date()
let year = now.getFullYear(); let year = now.getFullYear();
let scheduleList = this.returnScheduleList(year); let scheduleList = [];
for (let i = 0; i<= year - 2019; i++) {
console.log(2019 + i)
scheduleList.push(that.returnScheduleList(2019 + i))
}
const today = new Date()
const finalDate = new Date(today)
finalDate.setDate(today.getDate() - today.getDay())
that.setData({ that.setData({
scheduleList: scheduleList scheduleList: scheduleList,
todayStr: finalDate.toLocaleDateString(),
thisYear: year,
maxYear: year
}) })
}) })
}) })
}, },
onShow() {
// 页面显示
},
returnScheduleList(year) { returnScheduleList(year) {
let that = this let that = this
let weekList = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'] let weekList = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
...@@ -68,7 +78,7 @@ Page({ ...@@ -68,7 +78,7 @@ Page({
}) })
} }
} }
let num = 6 - new Date(year, 0, 366).getDate() let num = 6 - new Date(year, 0, 365).getDate()
for (let i = 0; i <= num; i++) { for (let i = 0; i <= num; i++) {
DateMap.set(`${new Date(year, 0, 366 + i).toLocaleDateString()}`, { DateMap.set(`${new Date(year, 0, 366 + i).toLocaleDateString()}`, {
scheduleList: [] scheduleList: []
...@@ -80,19 +90,30 @@ Page({ ...@@ -80,19 +90,30 @@ Page({
let date2 = this.data.AllScheduleList[y].endTime.slice(0, 10).replace(/-/g, '/') let date2 = this.data.AllScheduleList[y].endTime.slice(0, 10).replace(/-/g, '/')
let count = this.count(date1, date2) let count = this.count(date1, date2)
if (count == 0) { if (count == 0) {
DateMap.get(`${new Date(this.data.AllScheduleList[y].startTime.replace(/-/g, '/')).toLocaleDateString()}`).scheduleList.push(this.data.AllScheduleList[y]) DateMap.get(`${new Date(this.data.AllScheduleList[y].startTime.replace(/-/g, '/')).toLocaleDateString()}`).scheduleList.push({
...this.data.AllScheduleList[y],
thisDayStartTime: this.data.AllScheduleList[y].startTime.slice(11, 16),
thisDayEndTime: this.data.AllScheduleList[y].endTime.slice(11, 16),
isBeOverdue: new Date().getTime() > new Date(this.data.AllScheduleList[y].endTime.replace(/-/g, '/')).getTime() ? true : false
})
} else { } else {
for (let j = 0; j <= count; j++) { for (let j = 0; j <= count; j++) {
let time = new Date(); let time = new Date(date1);
time.setDate(time.getDate() + j) time.setDate(time.getDate() + j)
// let finalDate = day.setDate(day.getDate()+j) if (DateMap.get(new Date(time.getFullYear(), time.getMonth(), time.getDate()).toLocaleDateString())){
DateMap.get(new Date(time.getFullYear(), time.getMonth() + 1, time.getDate()).toLocaleDateString()).scheduleList.push({ DateMap.get(new Date(time.getFullYear(), time.getMonth(), time.getDate()).toLocaleDateString()).scheduleList.push({
...this.data.AllScheduleList[y], ...this.data.AllScheduleList[y],
number: j + 1 isfirstDayOrEndDay: j === 0 ? '0' : j === count ? '2' : '1', // 0 第一天,1中间的天,2结束的天
thisDayStartTime: this.data.AllScheduleList[y].startTime.slice(11, 16),
thisDayEndTime: this.data.AllScheduleList[y].endTime.slice(11, 16),
isFewDays: j + 1,
duration: count + 1,
isBeOverdue: new Date().getTime() > new Date(this.data.AllScheduleList[y].endTime.replace(/-/g, '/')).getTime() ? true : false
}) })
} }
} }
} }
}
let DateList = []; let DateList = [];
let listMonth = ''; let listMonth = '';
let listWeek = new Date(year, 0, 1).getDay() === 0 ? 0 : 1; let listWeek = new Date(year, 0, 1).getDay() === 0 ? 0 : 1;
...@@ -100,9 +121,9 @@ Page({ ...@@ -100,9 +121,9 @@ Page({
type: 'year', type: 'year',
value: year value: year
}) })
console.log(DateMap)
DateMap.forEach(function (value, key, map) { DateMap.forEach(function (value, key, map) {
console.log(key) if (new Date(key).getDay() === 0 && that.count(key, new Date(year, 0, isLeapYear ? 366 : 365).toLocaleDateString()) >7) {
if (new Date(key).getDay() === 0 && that.count(new Date(key), new Date(year, 0, isLeapYear ? 366 : 365) >= 7)) {
listWeek = listWeek + 1 listWeek = listWeek + 1
if (new Date(key).getMonth() !== listMonth) { if (new Date(key).getMonth() !== listMonth) {
listMonth = new Date(key).getMonth() listMonth = new Date(key).getMonth()
...@@ -119,6 +140,7 @@ Page({ ...@@ -119,6 +140,7 @@ Page({
DateList.push({ DateList.push({
type: 'week', type: 'week',
value: `第${listWeek}周,${rangeMonth1 + 1}${rangeDay1}日 - ${rangeMonth2 == rangeMonth1 ? '' : rangeMonth2 + 1 + '月'}${rangeDay2}日`, value: `第${listWeek}周,${rangeMonth1 + 1}${rangeDay1}日 - ${rangeMonth2 == rangeMonth1 ? '' : rangeMonth2 + 1 + '月'}${rangeDay2}日`,
dayStr: key
}) })
} else { } else {
let rangeYear1 = new Date(key).getFullYear() let rangeYear1 = new Date(key).getFullYear()
...@@ -130,13 +152,21 @@ Page({ ...@@ -130,13 +152,21 @@ Page({
DateList.push({ DateList.push({
type: 'week', type: 'week',
value: `第${listWeek}周,${rangeMonth1 + 1}${rangeDay1}日 - ${rangeMonth2 == rangeMonth1 ? '' : rangeMonth2 + 1 + '月'}${rangeDay2}日`, value: `第${listWeek}周,${rangeMonth1 + 1}${rangeDay1}日 - ${rangeMonth2 == rangeMonth1 ? '' : rangeMonth2 + 1 + '月'}${rangeDay2}日`,
dayStr: key
}) })
} }
} else if (new Date(key).getDay() === 0 && that.count(new Date(key), new Date(year, 0, isLeapYear ? 366 : 365) < 7)) { } else if (new Date(key).getDay() === 0 && that.count(new Date(key), new Date(year, 0, isLeapYear ? 366 : 365) < 7)) {
let rangeYear1 = new Date(key).getFullYear()
let rangeMonth1 = new Date(key).getMonth()
let rangeDay1 = new Date(key).getDate()
let rangeDate = new Date(rangeYear1, rangeMonth1, rangeDay1 + 6)
let rangeMonth2 = new Date(rangeDate).getMonth()
let rangeDay2 = new Date(rangeDate).getDate()
listWeek = 1 listWeek = 1
DateList.push({ DateList.push({
type: 'week', type: 'week',
value: listWeek value: `第${listWeek}周,${rangeMonth1 + 1}${rangeDay1}日 - ${rangeMonth2 == rangeMonth1 ? '' : rangeMonth2 + 1 + '月'}${rangeDay2}日`,
dayStr: key
}) })
} }
if (value.scheduleList.length !== 0) { if (value.scheduleList.length !== 0) {
...@@ -188,6 +218,15 @@ Page({ ...@@ -188,6 +218,15 @@ Page({
nextDetail(e) { nextDetail(e) {
let id = e.target.dataset.id let id = e.target.dataset.id
dd.navigateTo({ url: `./../scheduleDetail/scheduleDetail?id=${id}` }) dd.navigateTo({ url: `./../scheduleDetail/scheduleDetail?id=${id}` })
},
lower() {
let year = this.data.maxYear + 1
let DateList = this.returnScheduleList(year)
this.data.scheduleList.push(DateList)
let scheduleList = [...this.data.scheduleList]
this.setData({
scheduleList: scheduleList,
maxYear: year
})
} }
}); });
{} {
\ No newline at end of file "defaultTitle": "首页"
}
\ No newline at end of file
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