ModalToQueueControl.js
2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
let modalQueue = [];
import api from "~/api.js";
// async checkDailyReport() {
const checkDailyReport = () => {
let eventRequest = [];
// 判读是否要填写日报
eventRequest.push(this.staffDailyReport(wx.$util.getUserInfo()));
return new Promise((resolve) => {
Promise.all(eventRequest).then(() => {
this.showNextModal();
});
});
};
const staffDailyReport = (userInfo) => {
return new Promise((resolve, reject) => {
api
.staffDailyReportMerchantValid({
merchantId: userInfo.shopMerchantId,
yqMerchantId: userInfo.merchantId,
staffUuid: userInfo.uuid,
sceneType: 1,
})
.then((res) => {
if (res.data) {
// 获取当前日期
let currentDate = new Date();
// 获取上一天的日期
let previousDate = new Date(currentDate);
previousDate.setDate(currentDate.getDate() - 1);
// toISOString 方法会丢失时区 导致与北京时间差八小时
let hour = previousDate.getHours() + 8;
previousDate.setHours(hour);
// 格式化日期为"yyyy-mm-dd"
let formattedDate = previousDate.toISOString().split("T")[0];
if (
wx.__HAS_NOTLOGIN_MODAL ||
userInfo?.isSuper ||
userInfo?.loginRole == 3
)
return false;
addModalToQueue(
"日报提醒",
"您有未填写的日报,请点击前往。",
"前往填写",
false,
2,
(res) => {
if (res.confirm) {
wx.$router.go("tabWorkOrder.upgradeStaffDaily", {
reportDate: formattedDate,
});
}
}
);
}
resolve();
})
.catch((err) => {
resolve();
console.log(err);
});
});
};
const addModalToQueue = (
title,
content,
confirmText,
showCancel,
priority,
eventCallback
) => {
if (modalQueue.findIndex((val) => val.content == content) < 0)
modalQueue.push({
title,
content,
confirmText,
showCancel,
priority,
eventCallback,
});
modalQueue.sort((a, b) => a.priority - b.priority);
};
export default {
checkDailyReport,
staffDailyReport,
addModalToQueue,
};