UNPKG

run-away-from-sdu

Version:

山大? 快润! 山东大学一键申请出校脚本

55 lines (54 loc) 2.91 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.batchSubmitGooutApplication = void 0; const authScenterLogin_1 = __importDefault(require("./lib/authScenterLogin")); const gooutServices_1 = require("./lib/gooutServices"); /** * 提交单次出校申请 * @param userId 山大统一身份认证账号 * @param password 山大统一身份认证密码 * @param dateTimeStp 申请出校日期13位时间戳 */ function submitGooutApplication(userId, password, dateTimeStp) { return __awaiter(this, void 0, void 0, function* () { const Cookie = yield (0, authScenterLogin_1.default)(userId, password); yield (0, gooutServices_1.applyGoOut)(yield (0, gooutServices_1.getFormTplStr)(Cookie), dateTimeStp, Cookie); }); } exports.default = submitGooutApplication; /** * 批量提交指定日期范围内的出校申请 * @param userId 山大统一身份认证账号 * @param password 山大统一身份认证密码 * @param startTimeStp 申请出校的开始日期13位时间戳 * @param endTimeStp 申请出校的结束日期13位时间戳(包含该日期) * @param onTick 每提交一天的申请后的回调函数,如果是Async异步函数则会等待该函数执行完毕再提交下一天的申请 */ function batchSubmitGooutApplication(userId, password, startTimeStp, endTimeStp, onTick) { return __awaiter(this, void 0, void 0, function* () { const Cookie = yield (0, authScenterLogin_1.default)(userId, password); const formTplStr = yield (0, gooutServices_1.getFormTplStr)(Cookie); for (let i = startTimeStp; i <= endTimeStp; i += 86400000) { try { yield (0, gooutServices_1.applyGoOut)(formTplStr, i, Cookie); yield (onTick === null || onTick === void 0 ? void 0 : onTick(i, true)); } catch (error) { yield (onTick === null || onTick === void 0 ? void 0 : onTick(i, false, error)); } } }); } exports.batchSubmitGooutApplication = batchSubmitGooutApplication;