From 9b09d13712c0c005891450a3bf4b6d848ec0ff37 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期三, 29 十一月 2023 10:28:24 +0800
Subject: [PATCH] 2023.11.29
---
pages/mService/behaviors/bScheduleManager.js | 148 +++++++++++++++++++++++++++----------------------
1 files changed, 82 insertions(+), 66 deletions(-)
diff --git a/pages/mService/behaviors/bScheduleManager.js b/pages/mService/behaviors/bScheduleManager.js
index e19eeb9..1704cb5 100644
--- a/pages/mService/behaviors/bScheduleManager.js
+++ b/pages/mService/behaviors/bScheduleManager.js
@@ -1,9 +1,9 @@
-import scheduleservice from '../../../service/scheduleservice'
-import sysSchedules from '../../../data/schedules'
-import moment from '../../../utils/moment.min'
-import util from '../../../utils/util'
+import scheduleservice from '../../../service/scheduleservice';
+import sysSchedules from '../../../data/schedules';
+import moment from '../../../utils/moment.min';
+import util from '../../../utils/util';
-const app = getApp()
+const app = getApp();
/**
* 鐜繚鏃ョ▼绠$悊
@@ -14,123 +14,139 @@
ledgerCompleted: {
type: Boolean,
observer(value) {
- this.checkScheduleComplete(0, value)
- }
+ this.checkScheduleComplete(0, value);
+ },
},
assessmentCompleted: {
type: Boolean,
observer(value) {
- this.checkScheduleComplete(1, value)
- }
- }
+ this.checkScheduleComplete(1, value);
+ },
+ },
},
data: {
allSchedules: [],
thisSchedule: {},
- index: 0
+ index: 0,
},
lifetimes: {
attached: function () {
- this.getRecentSchedule()
+ this.getRecentSchedule();
+ this.getSchedules();
if (app.globalData.newUser) {
- this.nextSchedules()
+ this.nextSchedules();
}
// this.getAllSchedules()
- }
+ },
},
methods: {
+ getSchedules() {
+ // let startTime = '2023-04-10';
+ // let endTime = '2023-04-10';
+ let startTime = moment().format('YYYY-MM-DD');
+ let endTime = startTime;
+ const that = this;
+ scheduleservice.getSchedules(
+ { startTime, endTime, type: 0 },
+ {
+ success(res) {
+ if (res.data.length > 0) {
+ const schedule = res.data[0];
+ schedule.time = moment(schedule.time.split('T')[0]).format(
+ 'YYYY-MM-DD',
+ );
+ that.setData({
+ thisSchedule: schedule,
+ });
+ }
+ },
+ fail(e) {
+ console.log(e);
+ },
+ },
+ );
+ },
+
//鏌ユ壘鏈�涓磋繎鐨勬棩绋�
getRecentSchedule() {
//1. 浠庢帴鍙h幏鍙栫敤鎴蜂釜浜恒�佺敤鎴蜂紒涓氱被鍨嬬殑鐩稿叧鏈�涓磋繎鏃ョ▼
//2. 鎸夌収鏈湴閫昏緫锛屽緱鍑烘渶閭昏繎鏃ョ▼
- const schedules = sysSchedules()
+ const schedules = sysSchedules();
//2.1 灏嗗彴璐︺�佽瘎浼般�佹壙璇轰笁椤笰PP鍔熻兘瀹氫箟涓烘棩绋�
- //2.2 閫夋嫨鏈�閭昏繎鐨勪簨椤逛綔涓哄綋鏃ョ殑鎻愰啋浜嬮」,
- let today = moment().hour(0).minute(0).second(0).millisecond(0)
- let diffDays = 999
- let schedule
- let index = 0
+ //2.2 閫夋嫨鏈�閭昏繎鐨勪簨椤逛綔涓哄綋鏃ョ殑鎻愰啋浜嬮」,
+ let today = moment().hour(0).minute(0).second(0).millisecond(0);
+ let diffDays = 999;
+ let schedule;
+ let index = 0;
for (let i = 0; i < schedules.length; i++) {
let s = schedules[i];
- let d = s.time.diff(today, 'days')
- s.diffDays = d
+ let d = s.time.diff(today, 'days');
+ s.diffDays = d;
if (Math.abs(d) < Math.abs(diffDays)) {
- let _index = i
+ let _index = i;
- schedule = s
- diffDays = d
- index = _index
+ schedule = s;
+ diffDays = d;
+ index = _index;
}
}
//2.3 鏃ョ▼鍦ㄦ椂闂寸淮搴︿笂鍒嗕负涓夌被鎻愰啋锛岄鍛娿�佸綋鏃ャ�佹湭瀹屾垚鐨勯�炬湡鎻愰啋
-
this.setData({
allSchedules: schedules,
- thisSchedule: {
- date: schedule.time,
- time: schedule.time.format('YYYY-MM-DD dddd'),
- type: schedule.type,
- events: schedule.events,
- diffDays: schedule.diffDays,
- },
- index
- })
+ // thisSchedule: {
+ // date: schedule.time,
+ // time: schedule.time.format('YYYY-MM-DD dddd'),
+ // type: schedule.type,
+ // events: schedule.events,
+ // diffDays: schedule.diffDays,
+ // },
+ index,
+ });
},
//鑾峰彇鎵�鏈夋棩绋�
getAllSchedules() {
- console.log('getAllSchedules');
- scheduleservice.getAllSchedules(app.globalData.accessToken.userId, {
- success(res) {
- console.log('success');
- console.log(res);
- },
- fail(e) {
- console.log('fail');
- console.log(e);
- },
- complete(res) {
- console.log('complete');
- },
- })
+ const schedules = sysSchedules();
+ this.setData({
+ allSchedules: schedules,
+ });
},
// 褰撳墠鏃ョ▼瀹屾垚锛岄『寤朵笅涓�涓棩绋�
nextSchedules() {
- let today = moment().hour(0).minute(0).second(0).millisecond(0)
+ let today = moment().hour(0).minute(0).second(0).millisecond(0);
let s = this.data.allSchedules[this.data.index + 1];
- let d = s.time.diff(today, 'days')
- s.diffDays = d
+ let d = s.time.diff(today, 'days');
+ s.diffDays = d;
this.setData({
thisSchedule: {
date: s.time,
- time: s.time.format('YYYY-MM-DD dddd'),
+ time: s.time.format('YYYY-MM-DD'),
type: s.type,
events: s.events,
diffDays: s.diffDays,
},
- index: this.data.index + 1
- })
+ index: this.data.index + 1,
+ });
},
// 妫�鏌ュ綋鍓嶆棩绋嬫槸鍚﹀畬鎴�
checkScheduleComplete(type, value) {
- debugger
// 鏂扮敤鎴蜂笉鍋氬垽鏂�
- if (app.globalData.newUser) return
+ if (app.globalData.newUser) return;
// 鏃ョ▼绫诲瀷涓嶄竴鑷存棤闇�鍒ゆ柇
- if (this.data.thisSchedule.type != type) return
+ if (this.data.thisSchedule.type != type) return;
// 鏃ョ▼涓嶅湪褰撴湀鐨勬棤闇�鍒ゆ柇
- const thisMonth = moment().month()
- const sTimeMonth = moment(this.data.thisSchedule.date).month()
- if (thisMonth != sTimeMonth) return
+ const thisMonth = moment().month();
+ const sTimeMonth = moment(this.data.thisSchedule.date).month();
+ if (thisMonth != sTimeMonth) return;
// 鏃ョ▼瀹屾垚鍒欓『寤朵笅涓棩绋�
if (value) {
- this.nextSchedules()
+ this.nextSchedules();
}
- }
- }
-})
\ No newline at end of file
+ },
+ },
+});
--
Gitblit v1.9.3