-
Notifications
You must be signed in to change notification settings - Fork 0
/
mssvc.js
106 lines (84 loc) · 3.03 KB
/
mssvc.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const axios = require('axios');
const qs = require('qs');
const util = require('./util');
require('./statics');
function login(account, pwd, callback) {
var url = DOMAIN_PREFIX + `/passport/login_s`;
var headers = util.login_header_model();
var form = util.login_form_model();
form.account_name = util.param_encrypt(account);
form.user_pwd = util.param_encrypt(pwd);
headers.date = util.current_date_string();
headers['x-mssvc-signature'] = util.login_signature(url, headers.date, form);
axios({
method: 'post',
url: url,
headers: headers,
data: qs.stringify(form)
}).then(res => {
// console.log(res.data);
callback(res.data);
});
}
function cc_list_joined(access_id, access_secret, sec_ts, user_id, callback) {
var url = DOMAIN_PREFIX + `/cc/list_joined`;
var headers = util.cc_list_joined_header_model();
headers['x-mssvc-access-id'] = access_id;
headers['x-mssvc-sec-ts'] = sec_ts;
headers.date = util.current_date_string();
headers['x-mssvc-signature'] = util.pure_post_signature(url, headers.date, user_id, access_secret, []);
axios({
method: 'post',
url: url,
headers: headers
}).then(res => {
callback(res.data);
});
}
function current_open_checkin(course_id, access_id, access_secret, sec_ts, user_id, callback) {
var url = DOMAIN_PREFIX + `/checkin/current_open`;
var headers = util.checkin_current_open_header_model();
var form = util.checkin_current_open_form_model();
form.clazz_course_id = course_id;
headers['x-mssvc-access-id'] = access_id;
headers['x-mssvc-sec-ts'] = sec_ts;
headers.date = util.current_date_string();
headers['x-mssvc-signature'] = util.pure_post_signature(url, headers.date, user_id, access_secret, [util.md5('clazz_course_id=' + course_id)]);
axios({
method: 'post',
url: url,
headers: headers,
data: qs.stringify(form)
}).then(res => {
callback(res.data);
});
}
function checkin(checkin_id, lat, lng, access_id, access_secret, sec_ts, user_id, callback) {
var url = CHECKIN_DOMAIN;
var headers = util.checkin_header_model();
var form = util.checkin_GPS_form_model();
if (lat == '0' || lng == '0') {
form = util.checkin_NO_GPS_form_model();
} else {
form.lat = lat;
form.lng = lng;
}
form.checkin_id = checkin_id;
headers.Host = 'checkin.mosoteach.cn:19528';
headers['x-mssvc-access-id'] = access_id;
headers['x-mssvc-sec-ts'] = sec_ts;
headers.date = util.current_date_string();
headers['x-mssvc-signature'] = util.pure_post_signature(url, headers.date, user_id, access_secret, []);
axios({
method: 'post',
url: url,
headers: headers,
data: qs.stringify(form)
}).then(res => {
callback(res.data);
});
}
module.exports.login = login;
module.exports.cc_list_joined = cc_list_joined;
module.exports.current_open_checkin = current_open_checkin;
module.exports.checkin = checkin;