diff --git a/src/api/captcha.js b/src/api/captcha.js new file mode 100644 index 0000000..d0d475c --- /dev/null +++ b/src/api/captcha.js @@ -0,0 +1,23 @@ +/** + * 此处可直接引用自己项目封装好的 axios 配合后端联调 + */ +import request from '@/utils/request' //组件内部封装的axios +// import request from "@/api/axios.js" //调用项目封装的axios + +//获取验证图片 以及token +export function reqGet(data) { + return request({ + url: '/captcha/get', + method: 'post', + data + }) +} + +//滑动或者点选验证 +export function reqCheck(data) { + return request({ + url: '/captcha/check', + method: 'post', + data + }) +} diff --git a/src/components/verifition/Verify.vue b/src/components/verifition/Verify.vue new file mode 100644 index 0000000..3893ab7 --- /dev/null +++ b/src/components/verifition/Verify.vue @@ -0,0 +1,474 @@ + + + diff --git a/src/components/verifition/Verify/VerifyPoints.vue b/src/components/verifition/Verify/VerifyPoints.vue new file mode 100644 index 0000000..c0c4d91 --- /dev/null +++ b/src/components/verifition/Verify/VerifyPoints.vue @@ -0,0 +1,262 @@ + + diff --git a/src/components/verifition/Verify/VerifySlide.vue b/src/components/verifition/Verify/VerifySlide.vue new file mode 100644 index 0000000..d773b52 --- /dev/null +++ b/src/components/verifition/Verify/VerifySlide.vue @@ -0,0 +1,369 @@ + + + diff --git a/src/utils/captchaUtil.js b/src/utils/captchaUtil.js new file mode 100644 index 0000000..8e263ea --- /dev/null +++ b/src/utils/captchaUtil.js @@ -0,0 +1,36 @@ +export function resetSize(vm) { + let img_width, img_height, bar_width, bar_height; //图片的宽度、高度,移动条的宽度、高度 + + const parentWidth = vm.$el.parentNode.offsetWidth || window.offsetWidth + const parentHeight = vm.$el.parentNode.offsetHeight || window.offsetHeight + + if (vm.imgSize.width.indexOf('%') !== -1) { + img_width = parseInt(this.imgSize.width) / 100 * parentWidth + 'px' + } else { + img_width = this.imgSize.width; + } + + if (vm.imgSize.height.indexOf('%') !== -1) { + img_height = parseInt(this.imgSize.height) / 100 * parentHeight + 'px' + } else { + img_height = this.imgSize.height + } + + if (vm.barSize.width.indexOf('%') !== -1) { + bar_width = parseInt(this.barSize.width) / 100 * parentWidth + 'px' + } else { + bar_width = this.barSize.width + } + + if (vm.barSize.height.indexOf('%') !== -1) { + bar_height = parseInt(this.barSize.height) / 100 * parentHeight + 'px' + } else { + bar_height = this.barSize.height + } + + return {imgWidth: img_width, imgHeight: img_height, barWidth: bar_width, barHeight: bar_height} +} + +export const _code_chars = [1, 2, 3, 4, 5, 6, 7, 8, 9, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] +export const _code_color1 = ['#fffff0', '#f0ffff', '#f0fff0', '#fff0f0'] +export const _code_color2 = ['#FF0033', '#006699', '#993366', '#FF9900', '#66CC66', '#FF33CC'] diff --git a/src/utils/password.js b/src/utils/password.js index 4010994..90e1e51 100644 --- a/src/utils/password.js +++ b/src/utils/password.js @@ -2,9 +2,9 @@ import * as CryptoJS from 'crypto-js' const securityKey = '==BallCat-Auth==' -export const encryption = (pass) => { +export const passEncrypt = (pass) => { // 密码加密 - const key = CryptoJS.enc.Latin1.parse(securityKey) + const key = CryptoJS.enc.Utf8.parse(securityKey) return CryptoJS.AES.encrypt( pass, key, { @@ -14,3 +14,13 @@ export const encryption = (pass) => { }).toString() } +/** + * @word 要加密的内容 + * @keyWord String 服务器随机返回的关键字 + * */ +export function captchaEncrypt (word, keyWord = 'XwKsGlMcdPMEhR1B') { + const key = CryptoJS.enc.Utf8.parse(keyWord) + const srcs = CryptoJS.enc.Utf8.parse(word) + const encrypted = CryptoJS.AES.encrypt(srcs, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }) + return encrypted.toString() +} diff --git a/src/views/sys/sysuser/PasswordModal.vue b/src/views/sys/sysuser/PasswordModal.vue index f310275..c4d0acd 100644 --- a/src/views/sys/sysuser/PasswordModal.vue +++ b/src/views/sys/sysuser/PasswordModal.vue @@ -30,7 +30,7 @@