{"version":3,"file":"/pc/common/js/captcha.js.map","sources":["/pc/common/js/captcha.js"],"sourcesContent":["/**\n * Created by caixiaohua on 2021/6/22.\n * 滑动验证码组件\n * 使用方式:\n * 在html中 \n * \n \t\n \t\n * 两个参数 closeCallback 关闭回调,succCallback 滑动验证成功回调\n */\ndefine([\"ko\", \"jquery\", \"galert\"], function (ko, $, galert){\n var dragHandler;//滑块\n var dragContainer;//滑块容器\n var dragBg;//滑块滑动背景\n var maxHandlerOffset = 0;\n var puzzleReset;//刷新图片\n var puzzleTip;//滑动错误提示\n var closePuzzle;//关闭\n var puzzleVerify;//图形验证方式容器\n var slideVerify;//滑块验证方式容器\n var dragHandlerOriginX = 0;//滑块左边距离\n var isDanger = false;\n var dragDuration = 0;\n var shadeImg;//底图\n var cutImg;//切图\n var dragVerifyconfig = {\n getImgAPI: '',\n checkAPI: '',\n verifyType: 'drag'\n }\n var pageModel = function(params){\n var self = this;\n this.closeCallback = params.closeCallback;\n this.succCallback = params.succCallback;\n this.bizType = params.bizType;\n this.checkUrl = '';\n this.sessionKey = '';\n this.getCaptereAPI = function () {\n var params = {\n bizType: self.bizType || 6\n };\n $.ajax(\"/gmminf/config/getSlideCaptcha\", {\n data: params,\n noNeedBlock: true,\n success: function (res) {\n if (res.data.checkUrl) {\n self.checkUrl = res.data.checkUrl.slice(res.data.checkUrl.indexOf('/api'))\n self.sessionKey = res.data.sessionKey\n dragVerifyconfig.verifyType = 'drag';\n self.initVerifyDOM(dragVerifyconfig.verifyType == 'slide' ? slideVerify : puzzleVerify);\n self.getCaptereImg();\n }\n }\n })\n }\n //获取验证图\n this.getCaptereImg = function(){\n isDanger = false;\n var params = {};\n $.ajax(self.checkUrl, {\n data: params,\n noNeedBlock: true,\n success: function (res) {\n var code = res.code;\n var data = res.data;\n if (code == -3) {\n isDanger = true\n if (puzzleVerify.style.display != \"none\") {\n shadeImg.src = \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAACXCAIAAAAgZfEgAAAAA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72zsactVHhHu67jbqmVBtce7buGqrcw8/atxqGQ9+Oqovqe/X6LT4nf0HxR+u5thETmOp7dMWNYyrs9BXNVtTEwzPVzZ/s28Mhhpqaq1Sc5NS1fYxD2a2Q81pNQbqQq14JpTw4Lp4ccIUUdvbcbXywenonBVzS53Ofbb/+qcCtmf1trpfemOP/YlXeB1tSAjDR5S6c7phiR9XxluD3WZ7v0iNT6OKQqJHFGu4y55k4p9PxvcZHm/iselfl4ftQKNRbNtVGtVOX1vDgaDlUNtW+lzk4nHMvaZUiyldJ/Ext0nGpobTfeN+l9eD6MVzsxhFZnfdW+1WHfmFWREMt4qsV2omfdZRGdY6fcPDvV+1DKVloXEDKZeIXX1EaNhP+flgUA64IQAs74eULAGSEEnBFCwBkhBJwRQsAZIQScEULAGSEEnBFCwBkhBJwRQsAZIQScEULAGSEEnBFCwBkhBJwRQsAZIQScEULAGSEEnBFCwBkhBJwRQsAZIQScEULAGSEEnBFCwBkhBJwRQsAZIQScEULAGSEEnBFCwBkhBJwRQsAZIQScEULAGSEEnBFCwBkhBJwRQsAZIQScEULAGSEEnBFCwBkhBJwRQsAZIQScEULAGSEEnBFCwBkhBJwRQsAZIQScEULAGSEEnBFCwBkhBJwRQsAZIQScEULAGSEEnBFCwBkhBJwRQsAZIQScEULAGSEEXH3zzX8A0WpE7azGsHUAAAAASUVORK5CYII=\"\n cutImg.src = \"\"\n puzzleReset.style.display = \"none\"\n }\n return;\n }\n if (!res || !data || !data.shadeImage) {\n galert(res.msg || \"网络错误,请重试\");\n self.hidePuzzle();\n self.closeCallback();\n return;\n }\n\n dragVerifyconfig.verifyType == 'drag' && self.initPuzzleImage({ shadeImage: data.shadeImage, cutoutImage: data.cutoutImage, cutPosY: data.y });\n dragVerifyconfig.verifyType == 'slide' && self.initSlideImage({ shadeImage: data.shadeImage })\n\n maxHandlerOffset = dragContainer.clientWidth - dragHandler.clientWidth;\n dragHandlerOriginX = document.getElementById(\"dragHandler\").getBoundingClientRect().left;\n\n dragVerifyconfig.verifyType == 'drag' && (dragText.textContent = \"向右拖动滑块填充拼图\");\n dragHandler.addEventListener(\"mousedown\", self.onDragHandlerMouseDown);\n }\n })\n }\n this.initVerifyDOM = function(container) {\n if (container.innerHTML) return\n if (dragVerifyconfig.verifyType == 'drag') container.innerHTML += puzzleElement;\n container.innerHTML += dragElement;\n dragContainer = document.getElementById(\"dragContainer\");\n dragBg = document.getElementById(\"dragBg\");\n dragText = document.getElementById(\"dragText\");\n dragHandler = document.getElementById(\"dragHandler\");\n maxHandlerOffset = dragContainer.clientWidth - dragHandler.clientWidth;\n dragHandlerOriginX = document.getElementById(\"dragHandler\").getBoundingClientRect().left;\n },\n this.initPuzzleImage = function(image) {\n shadeImg = document.getElementById(\"shadeImg\");\n cutImg = document.getElementById(\"cutImg\");\n puzzleReset = document.getElementById(\"puzzleReset\");\n puzzleVerify = document.getElementById(\"puzzleVerify\")\n closePuzzle = document.getElementById(\"closePuzzle\");\n puzzleTip = document.getElementById(\"puzzleTip\");\n puzzleVerify.style.opacity = 1;\n puzzleVerify.style.zIndex = 9010;\n puzzleVerify.style.display = \"block\";\n puzzleReset.style.display = \"block\";\n if (self.bizType == 9){ //点券更换刷新图片\n puzzleReset.src = \"https://www.gmmsj.com/r/vpage/upage_pic/bcaptpcudq_s_180/tmp_img_1675232837229.png\";\n }\n cutImg.style.left = 30 + 'px';\n cutImg.style.top = image.cutPosY + 60 + 'px';\n shadeImg.src = \"data:image/png;base64,\" + image.shadeImage;\n cutImg.src = \"data:image/png;base64,\" + image.cutoutImage;\n puzzleReset.addEventListener(\"click\", self.onDragResetClick);\n closePuzzle.addEventListener(\"click\", self.onCloseDragClick);\n },\n this.initSlideImage = function(image) {\n dragContainer.style.backgroundImage = 'url(' + \"data:image/png;base64,\" + image.shadeImage + ')';\n slideVerify.style.opacity = 1;\n slideVerify.style.zIndex = 900;\n slideVerify.style.display = \"block\";\n },\n this.hidePuzzle = function(){\n puzzleVerify.style.opacity = 0;\n puzzleVerify.style.zIndex = -1;\n puzzleVerify.style.display = \"none\";\n puzzleTip.style.color = 'unset';\n },\n this.onDragHandlerMouseDown = function() {\n if (isDanger) return;\n dragDuration = new Date();\n document.addEventListener(\"mousemove\", self.onDragHandlerMouseMove);\n document.addEventListener(\"mouseup\", self.onDragHandlerMouseUp);\n },\n this.onDragHandlerMouseMove = function(event){\n var left = event.clientX - dragHandlerOriginX - dragHandler.clientWidth / 2;\n if (left < 0) {\n left = 0;\n } else if (left > maxHandlerOffset) {\n left = maxHandlerOffset;\n }\n dragHandler.style.left = left + \"px\";\n dragText.textContent = \"\";\n dragBg.style.width = left + 55 + \"px\";\n if (left >= 235 || dragVerifyconfig.verifyType != 'drag') return;\n cutImg.style.left = left + 30 + \"px\";\n },\n this.onDragHandlerMouseUp = function(){\n self.removeEvent();\n dragDuration = new Date().getTime() - dragDuration.getTime();\n var x = parseInt(dragHandler.style.left.match(/(.+)px/)[1]) + 10;\n var params = {\n sessionKey: self.sessionKey,\n point: x,\n phone: 'null',\n bizType: self.bizType || 6,\n src_code: 7,\n dragDuration: dragDuration\n };\n $.ajax('/api/captcha/checkSlideCaptcha',{\n data: params,\n success: function (res){\n if (!res || res.code != 0) self.verifyFail();\n else self.verifySucc();\n },\n error:function() {\n self.verifyFail();\n }\n });\n },\n this.onDragResetClick = function() {\n self.getCaptereImg();\n },\n this.onCloseDragClick = function() {\n self.hidePuzzle();\n self.closeCallback();\n },\n this.removeEvent = function() {\n document.removeEventListener(\"mousemove\", self.onDragHandlerMouseMove);\n document.removeEventListener(\"mouseup\", self.onDragHandlerMouseUp);\n },\n this.verifySucc = function() {\n dragText.style.colr = \"#fff\";\n dragBg.style.backgroundColor = \"#d2f4ef\";\n dragHandler.style.backgroundColor = \"#52ccba\";\n setTimeout(function () {\n self.resetPosition();\n // self.removeEvent();\n dragHandler.removeEventListener(\"mousedown\", self.onDragHandlerMouseDown);\n self.succCallback(self.sessionKey);\n }, 500)\n },\n this.verifyFail = function() {\n dragText.style.colr = \"#fff\";\n dragBg.style.backgroundColor = \"rgba(255, 0, 0, 0.4)\";\n dragHandler.style.backgroundColor = \"rgba(255, 0, 0, 0.5)\";\n puzzleTip.style.color = '#f00';\n setTimeout(function () {\n self.resetPosition();\n self.getCaptereAPI();\n }, 500);\n },\n this.resetPosition = function() {\n dragHandler.style.left = 0;\n dragBg.style.width = 0;\n dragVerifyconfig.verifyType == 'drag' && (cutImg.style.left = 30 + \"px\");\n dragText.style.colr = \"#000\";\n dragBg.style.backgroundColor = \"rgba(25, 145, 250, 0.4)\";\n dragHandler.style.backgroundColor = \"#fff\";\n }\n dragHandler = document.getElementById(\"dragHandler\");\n dragContainer = document.getElementById(\"dragContainer\");\n dragBg = document.getElementById(\"dragBg\");\n shadeImg = document.getElementById(\"shadeImg\");\n cutImg = document.getElementById(\"cutImg\");\n puzzleReset = document.getElementById(\"puzzleReset\");\n puzzleTip = document.getElementById(\"puzzleTip\");\n closePuzzle = document.getElementById(\"closePuzzle\");\n puzzleVerify = document.getElementById(\"puzzleVerify\");\n slideVerify = document.getElementById(\"slideVerify\");\n maxHandlerOffset = dragContainer.clientWidth - dragHandler.clientWidth;\n self.getCaptereAPI();\n };\n\n ko.components.register('captcha', {\n viewModel:pageModel,\n template: \"\\n