From dd641c4e101b3dc60c7ceef2777ea197efc84903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E6=87=8B=E5=BB=BA?= <982267890@qq.com> Date: Thu, 17 Dec 2020 14:34:39 +0800 Subject: [PATCH 1/3] update src/disk/longbow.slidercaptcha.js. --- src/disk/longbow.slidercaptcha.js | 36 ++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/disk/longbow.slidercaptcha.js b/src/disk/longbow.slidercaptcha.js index a1dcf1a..62a0e63 100644 --- a/src/disk/longbow.slidercaptcha.js +++ b/src/disk/longbow.slidercaptcha.js @@ -1,4 +1,4 @@ -(function () { +(function () { 'use strict'; var extend = function () { @@ -55,17 +55,33 @@ }, verify: function (arr, url) { var ret = false; - fetch(url, { - method: 'post', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' + $.ajax({ + url:url, + data:{ + "datas":JSON.stringify(arr), }, - body: JSON.stringify(arr) - }).then(function (result) { - ret = result; + dataType:"json", + type:"post", + async:false, + success:function(result){ + ret=JSON.stringify(result); + console.log("返回结果:"+ret) + } }); + console.log("结束:"+ret) + return ret; + // fetch(url, { + // method: 'post', + // headers: { + // 'Accept': 'application/json', + // 'Content-Type': 'application/json' + // }, + // body: JSON.stringify(arr) + // }).then(function (result) { + // console.log("返回结果"+JSON.stringify(result)) + // ret = result; + // }); }, remoteUrl: null }; @@ -341,4 +357,4 @@ this.text.textContent = this.options.loadingText; this.img.setSrc(); }; -})(); \ No newline at end of file +})(); -- Gitee From 4601278d41d81a4ebe6ce360166a0765aab5b367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E6=87=8B=E5=BB=BA?= <982267890@qq.com> Date: Thu, 17 Dec 2020 14:35:11 +0800 Subject: [PATCH 2/3] update src/disk/longbow.slidercaptcha.js. --- src/disk/longbow.slidercaptcha.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/disk/longbow.slidercaptcha.js b/src/disk/longbow.slidercaptcha.js index 62a0e63..8659a89 100644 --- a/src/disk/longbow.slidercaptcha.js +++ b/src/disk/longbow.slidercaptcha.js @@ -68,20 +68,7 @@ console.log("返回结果:"+ret) } }); - console.log("结束:"+ret) - return ret; - // fetch(url, { - // method: 'post', - // headers: { - // 'Accept': 'application/json', - // 'Content-Type': 'application/json' - // }, - // body: JSON.stringify(arr) - // }).then(function (result) { - // console.log("返回结果"+JSON.stringify(result)) - // ret = result; - // }); }, remoteUrl: null }; -- Gitee From 496e81e1a7a639f35692bccaa2fec3c4bd39204d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E6=87=8B=E5=BB=BA?= <982267890@qq.com> Date: Thu, 17 Dec 2020 14:43:51 +0800 Subject: [PATCH 3/3] =?UTF-8?q?boot=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SliderCaptchaController.java | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 SliderCaptchaController.java diff --git a/SliderCaptchaController.java b/SliderCaptchaController.java new file mode 100644 index 0000000..7a8c10f --- /dev/null +++ b/SliderCaptchaController.java @@ -0,0 +1,37 @@ +package com.fmj43.fanyoutong.config; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; +import java.util.List; + +@Slf4j +@RestController +@RequestMapping("/sliderCaptcha") +public class SliderCaptchaController { + + + @PostMapping("/isVerify") + public boolean isVerify(@RequestParam(value = "datas") String datazz) { + List datas=new ArrayList<>(); + for (int i = 0; i < datazz.length(); i++) { + char c = datazz.charAt(i); + if (c >= '0' && c <= '9') { + datas.add(Integer.valueOf(String.valueOf(c))); + } + } + int sum = 0; + for (Integer data : datas) { + sum += data; + } + double avg = sum * 1.0 / datas.size(); + double sum2 = 0.0; + for (Integer data : datas) { + sum2 += Math.pow(data - avg, 2); + } + double stddev = sum2 / datas.size(); + System.out.println("验证码判断"+(stddev != 0)); + return stddev != 0; + } + +} -- Gitee