From ab70c6eb4a181b282af0eb200275cd8a4d2ab172 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期三, 13 十一月 2024 16:41:32 +0800
Subject: [PATCH] 2024.11.13
---
pages/mService/behaviors/bScheduleManager.js | 109 ++++++++++++++++++++++++++++--------------------------
1 files changed, 57 insertions(+), 52 deletions(-)
diff --git a/pages/mService/behaviors/bScheduleManager.js b/pages/mService/behaviors/bScheduleManager.js
index 1704cb5..156adee 100644
--- a/pages/mService/behaviors/bScheduleManager.js
+++ b/pages/mService/behaviors/bScheduleManager.js
@@ -12,37 +12,47 @@
// behaviors: [bLoadingStatus],
properties: {
ledgerCompleted: {
- type: Boolean,
- observer(value) {
- this.checkScheduleComplete(0, value);
- },
- },
- assessmentCompleted: {
- type: Boolean,
+ type: Number,
observer(value) {
this.checkScheduleComplete(1, value);
},
},
+ assessmentCompleted: {
+ type: Number,
+ observer(value) {
+ this.checkScheduleComplete(2, value);
+ },
+ },
},
data: {
+ // 鍏ㄩ儴鐜繚鏃ョ▼
allSchedules: [],
+ // 褰撳墠鐢ㄦ埛鏈�涓磋繎鏈畬鎴愭棩绋�
thisSchedule: {},
+ // 褰撳墠鐢ㄦ埛鏈�涓磋繎鏈畬鎴愭棩绋嬬储寮�
index: 0,
+ // 鍙拌处鍜岃嚜璇勬湰鏈熷畬鎴愭儏鍐�
+ scheduleComplete: new Map(),
+ // 闇�瑕佸仛鏃ョ▼鏄惁瀹屾垚鍒ゆ柇鐨勬棩绋嬩釜鏁帮紙鍙拌处鍜岃嚜璇勶級
+ scheduleCount: 2,
},
lifetimes: {
attached: function () {
- this.getRecentSchedule();
- this.getSchedules();
- if (app.globalData.newUser) {
- this.nextSchedules();
- }
- // this.getAllSchedules()
+ this.setData({
+ scheduleComplete: new Map(),
+ });
+ this.getAllSchedules().then(() => {
+ this.getRecentSchedule();
+ if (app.globalData.newUser) {
+ this.nextSchedules();
+ }
+ });
+ // this.getSchedules();
},
},
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;
@@ -51,6 +61,9 @@
{
success(res) {
if (res.data.length > 0) {
+ res.data.sort(
+ (a, b) => Math.abs(a.diffDays) - Math.abs(b.diffDays),
+ );
const schedule = res.data[0];
schedule.time = moment(schedule.time.split('T')[0]).format(
'YYYY-MM-DD',
@@ -71,7 +84,7 @@
getRecentSchedule() {
//1. 浠庢帴鍙h幏鍙栫敤鎴蜂釜浜恒�佺敤鎴蜂紒涓氱被鍨嬬殑鐩稿叧鏈�涓磋繎鏃ョ▼
//2. 鎸夌収鏈湴閫昏緫锛屽緱鍑烘渶閭昏繎鏃ョ▼
- const schedules = sysSchedules();
+ const schedules = this.data.allSchedules;
//2.1 灏嗗彴璐︺�佽瘎浼般�佹壙璇轰笁椤笰PP鍔熻兘瀹氫箟涓烘棩绋�
//2.2 閫夋嫨鏈�閭昏繎鐨勪簨椤逛綔涓哄綋鏃ョ殑鎻愰啋浜嬮」,
let today = moment().hour(0).minute(0).second(0).millisecond(0);
@@ -80,8 +93,8 @@
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.diffDays;
+ // if (d == -8) {
if (Math.abs(d) < Math.abs(diffDays)) {
let _index = i;
@@ -93,60 +106,52 @@
//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,
- // },
+ thisSchedule: schedule,
index,
});
},
//鑾峰彇鎵�鏈夋棩绋�
getAllSchedules() {
- const schedules = sysSchedules();
- this.setData({
- allSchedules: schedules,
+ return sysSchedules().then(res => {
+ this.setData({
+ allSchedules: res,
+ });
});
},
// 褰撳墠鏃ョ▼瀹屾垚锛岄『寤朵笅涓�涓棩绋�
nextSchedules() {
- 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;
-
this.setData({
- thisSchedule: {
- date: s.time,
- time: s.time.format('YYYY-MM-DD'),
- type: s.type,
- events: s.events,
- diffDays: s.diffDays,
- },
+ thisSchedule: s,
index: this.data.index + 1,
});
},
- // 妫�鏌ュ綋鍓嶆棩绋嬫槸鍚﹀畬鎴�
- checkScheduleComplete(type, value) {
+ // 妫�鏌ュ綋鍓嶆棩绋嬫槸鍚﹀畬鎴�(2023.8.24 鐩墠鍙秹鍙婂彴璐﹀拰鑷瘎涓ょ被鏃ョ▼)
+ checkScheduleComplete(scId, value) {
+ const { scheduleComplete, scheduleCount } = this.data;
+ scheduleComplete.set(scId, value);
+ // 鍙拌处鍜岃嚜璇勭殑缁撴灉鍏ㄩ儴浼犲叆鍚庡啀鍋氬垽鏂�
+ if (scheduleComplete.size < scheduleCount) return;
// 鏂扮敤鎴蜂笉鍋氬垽鏂�
if (app.globalData.newUser) return;
- // 鏃ョ▼绫诲瀷涓嶄竴鑷存棤闇�鍒ゆ柇
- if (this.data.thisSchedule.type != type) return;
- // 鏃ョ▼涓嶅湪褰撴湀鐨勬棤闇�鍒ゆ柇
- const thisMonth = moment().month();
- const sTimeMonth = moment(this.data.thisSchedule.date).month();
- if (thisMonth != sTimeMonth) return;
- // 鏃ョ▼瀹屾垚鍒欓『寤朵笅涓棩绋�
- if (value) {
- this.nextSchedules();
- }
+ let index = 0;
+ const thisMonth = moment().month();
+ do {
+ const { thisSchedule } = this.data;
+ // 鏃ョ▼涓嶅湪褰撴湀鐨勬棤闇�鍒ゆ柇
+ const sTimeMonth = moment(thisSchedule.time).month();
+ if (thisMonth != sTimeMonth) return;
+
+ // 鍒ゆ柇褰撴湀璇ユ棩绋嬫槸鍚﹀畬鎴愶紝瀹屾垚鍒欏皢褰撳墠鏃ョ▼椤哄欢鑷充笅涓�涓�
+ if (scheduleComplete.get(thisSchedule.id) == 2) {
+ this.nextSchedules();
+ }
+ index++
+ } while (index < scheduleCount);
},
},
});
--
Gitblit v1.9.3