提交 2b44ab22 编写于 作者: C CodFrm

修复验证码打码

上级 b4f6a600
......@@ -7,19 +7,22 @@ module.exports = function () {
this.monitorVcode = function () {
//验证码监控加载
//作业处验证码
window.getVarCode = function () {
let notic = until.signleLine('cxmooc自动打码中...', 'dama', $('#sub').parents('td'));
let img = document.getElementById('imgVerCode');
getVcode('/img/code?' + new Date().getTime(), img, function (code, msg) {
if (code === undefined) {
$(notic).html(msg);
return;
}
$(notic).html('cxmooc打码成功,准备提交');
$('input#code').val(code);
setTimeout(function () {
$('a#sub').click();
}, 2000);
if (document.getElementById('imgVerCode')) {
$('#imgVerCode').on('load', function () {
console.log('准备打码...');
let notic = until.signleLine('cxmooc自动打码中...', 'dama', $('#sub').parents('td'));
let img = document.getElementById('imgVerCode');
getVcode('/img/code?' + new Date().getTime(), img, function (code, msg) {
if (code === undefined) {
$(notic).html(msg);
return;
}
$(notic).html('cxmooc打码成功,准备提交');
$('input#code').val(code);
setTimeout(function () {
$('a#sub').click();
}, 2000);
}, true);
});
}
//异常验证码
......@@ -41,7 +44,7 @@ module.exports = function () {
//保障账号安全验证码
window.showChapterVerificationCodeTip = window.showChapterVerificationCode || 0;
window.chapterVerifyCode = function () {
let notic = until.signleLine('cxmooc自动打码中...', 'dama', $('.DySearch'));
let notic = until.signleLine('cxmooc自动打码中...', 'dama1', $('.DySearch'));
$(notic).css('float', 'left');
let img = $('.fl[name=chapterNumVerCode]');
if (img.length <= 0) {
......@@ -62,13 +65,15 @@ module.exports = function () {
}
}
function getVcode(url, img, callback) {
let vcodeimg = document.createElement('img');
vcodeimg.onload = function () {
function getVcode(url, img, callback, show) {
let vcodeimg = show ? img : document.createElement('img');
let dmStart = function () {
let base64 = common.getImageBase64(vcodeimg, 'jpeg');
img.src = base64;
if (!show) {
img.src = base64;
}
common.gm_post(serverConfig.url + 'vcode', 'img=' + encodeURIComponent(base64.substr('data:image/jpeg;base64,'.length)), false, function (ret) {
let json = JSON.parse(ret)
let json = JSON.parse(ret);
if (json.code == -2) {
alert('cxmooc打码已超限制,请手动输入');
callback(undefined, json.msg);
......@@ -83,7 +88,12 @@ module.exports = function () {
callback(undefined, '网络请求失败');
});
}
vcodeimg.src = url;
if (show) {
dmStart();
} else {
vcodeimg.onload = dmStart;
vcodeimg.src = url;
}
}
self.monitorVcode();
......
......@@ -64,11 +64,11 @@ app.use(function (req, res, next) {
res.header("Access-Control-Allow-Headers", "Content-Type,Content-Length,Authorization,Accept,X-Requested-With");
res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
if (req.method == "OPTIONS") {
res.send(200);
return res.send(200,'success');
} else {
next();
return next();
}
})
});
app.all('/player/*', function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
......@@ -81,11 +81,10 @@ app.post('/answer', function (req, res) {
var ip = getClientIp(req);
var ret = [];
if (req.body.length <= 0) {
res.send({
return res.send({
code: 0,
msg: 'success'
});
return;
}
for (let i in req.body) {
let topic = req.body[i];
......@@ -156,7 +155,7 @@ app.get('/update', function (req, res) {
redis.onlineNum(function (err, data) {
//分发各个版本热更新
let hotversion = config.getHotVersion(req.query.ver || config.version);
res.send({
return res.send({
version: config.version,
url: config.update,
enforce: config.enforce,
......@@ -171,7 +170,7 @@ function getClientIp(req) {
return req.headers['x-forwarded-for'] ||
req.connection.remoteAddress ||
req.socket.remoteAddress ||
req.connection.socket.remoteAddress;
req.connection.socket.remoteAddress || 'error-ip';
}
app.post('/v2/answer', function (req, res) {
var topic = req.body.topic || [];
......@@ -210,11 +209,10 @@ app.get('/answer', function (req, res) {
function selectAnswer(topic, res, where) {
var ret = [];
if (topic.length <= 0) {
res.send({
return res.send({
code: 0,
msg: 'success'
});
return;
}
for (let i = 0; i < topic.length; i++) {
mooc.find('answer', where(i), {
......@@ -236,7 +234,7 @@ function selectAnswer(topic, res, where) {
}
ret.push(pushData);
if (ret.length == topic.length) {
res.send(ret);
return res.send(ret);
}
});
}
......
......@@ -9,7 +9,6 @@ window.onload = function () {
var ev = ev || event;
var _this = ev.srcElement || ev.target;
if (_this.id == 'iframe') {
cx.vcode.monitorVcode();
cx.studentstudy();
}
}, true);
......
......@@ -23,7 +23,7 @@ if (branch == tag) {
push();
}
function push() {
let range=commit_range;
let range = commit_range;
if (branch == tag) {
range = tag + '...' + lastTag;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册