forked from EaxMov/xixunyun-auto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
70 lines (65 loc) · 2 KB
/
app.js
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
const axios = require('axios')
const qs = require('./utils/qs')
const sendEmail = require('./utils/email') //需要邮件通知请配置CODE和EMAIL,自己发给自己,并且下面注释打开
const data = qs.data
const signdata = qs.signdata
const headers = qs.headers
const loginApi = qs.loginApi
// 签到并提交每日体温报告
login().then((token) => {
sign(token)
studentReportInfo(token)
})
//登录
function login() {
return new Promise((resolve, reject) => {
axios.post(loginApi, data, { headers }).then((res) => {
if (res && res.data && res.data.data) {
resolve(res.data.data.token)
} else {
reject()
}
})
})
}
//签到提交
function sign(token) {
const signApi = qs.signApi(token)
axios.post(signApi, signdata, { headers }).then((res) => {
if (res && res.data) {
console.log(res.data.code + ',' + res.data.message)
wechatSend('习讯云签到提交', res.data.message)
// sendEmail('习讯云签到提交', res.data.message)
}
})
}
//日报提交
function studentReportInfo(token) {
const studentReportApi = qs.studentReportApi(token)
const studentReportCommitApi = qs.studentReportCommitApi(token)
axios.get(studentReportApi).then((res) => {
if (res.data.code === 20000) {
const { family_name, family_phone } = res.data.data.list[0]
const reportForm = qs.reportdata(family_name, family_phone)
axios.post(studentReportCommitApi, reportForm).then((res) => {
console.log(res.data.code + ',' + res.data.message)
wechatSend('习讯云日报提交', res.data.message)
// sendEmail('习讯云日报提交', res.data.message)
})
}
})
}
//推送微信通知
function wechatSend(type, msg) {
const params = {
token: qs.token,
title: type,
content: msg
}
axios.get('http://www.pushplus.plus/send', { params }).then((res) => {
console.log(res)
if (res && res.data && res.data.code === 200) {
console.log(type + ',发送微信推送成功')
}
})
}