|
|
|
@ -57,7 +57,7 @@
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<script type="text/babel">
|
|
|
|
<script type="text/babel" setup>
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* VerifyPoints
|
|
|
|
* VerifyPoints
|
|
|
|
* @description 点选
|
|
|
|
* @description 点选
|
|
|
|
@ -67,9 +67,8 @@ import { aesEncrypt } from './../utils/ase'
|
|
|
|
import { getCodeApi, reqCheckApi } from '@/api/login'
|
|
|
|
import { getCodeApi, reqCheckApi } from '@/api/login'
|
|
|
|
import { onMounted, reactive, ref, nextTick, toRefs, getCurrentInstance } from 'vue'
|
|
|
|
import { onMounted, reactive, ref, nextTick, toRefs, getCurrentInstance } from 'vue'
|
|
|
|
import { useI18n } from '@/hooks/web/useI18n'
|
|
|
|
import { useI18n } from '@/hooks/web/useI18n'
|
|
|
|
export default {
|
|
|
|
|
|
|
|
name: 'VerifyPoints',
|
|
|
|
const props = defineProps({
|
|
|
|
props: {
|
|
|
|
|
|
|
|
//弹出式pop,固定fixed
|
|
|
|
//弹出式pop,固定fixed
|
|
|
|
mode: {
|
|
|
|
mode: {
|
|
|
|
type: String,
|
|
|
|
type: String,
|
|
|
|
@ -101,12 +100,12 @@ export default {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
})
|
|
|
|
setup(props) {
|
|
|
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
const { t } = useI18n()
|
|
|
|
const { mode, captchaType } = toRefs(props)
|
|
|
|
const { mode, captchaType } = toRefs(props)
|
|
|
|
const { proxy } = getCurrentInstance()
|
|
|
|
const { proxy } = getCurrentInstance()
|
|
|
|
let secretKey = ref(''), //后端返回的ase加密秘钥
|
|
|
|
let secretKey = ref(''), //后端返回的ase加密秘钥
|
|
|
|
checkNum = ref(3), //默认需要点击的字数
|
|
|
|
checkNum = ref(3), //默认需要点击的字数
|
|
|
|
fontPos = reactive([]), //选中的坐标信息
|
|
|
|
fontPos = reactive([]), //选中的坐标信息
|
|
|
|
checkPosArr = reactive([]), //用户点击的坐标
|
|
|
|
checkPosArr = reactive([]), //用户点击的坐标
|
|
|
|
@ -127,7 +126,7 @@ export default {
|
|
|
|
showRefresh = ref(true),
|
|
|
|
showRefresh = ref(true),
|
|
|
|
bindingClick = ref(true)
|
|
|
|
bindingClick = ref(true)
|
|
|
|
|
|
|
|
|
|
|
|
const init = () => {
|
|
|
|
const init = () => {
|
|
|
|
//加载页面
|
|
|
|
//加载页面
|
|
|
|
fontPos.splice(0, fontPos.length)
|
|
|
|
fontPos.splice(0, fontPos.length)
|
|
|
|
checkPosArr.splice(0, checkPosArr.length)
|
|
|
|
checkPosArr.splice(0, checkPosArr.length)
|
|
|
|
@ -141,16 +140,16 @@ export default {
|
|
|
|
setSize.barWidth = barWidth
|
|
|
|
setSize.barWidth = barWidth
|
|
|
|
proxy.$parent.$emit('ready', proxy)
|
|
|
|
proxy.$parent.$emit('ready', proxy)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onMounted(() => {
|
|
|
|
onMounted(() => {
|
|
|
|
// 禁止拖拽
|
|
|
|
// 禁止拖拽
|
|
|
|
init()
|
|
|
|
init()
|
|
|
|
proxy.$el.onselectstart = function () {
|
|
|
|
proxy.$el.onselectstart = function () {
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
const canvas = ref(null)
|
|
|
|
const canvas = ref(null)
|
|
|
|
const canvasClick = (e) => {
|
|
|
|
const canvasClick = (e) => {
|
|
|
|
checkPosArr.push(getMousePos(canvas, e))
|
|
|
|
checkPosArr.push(getMousePos(canvas, e))
|
|
|
|
if (num.value == checkNum.value) {
|
|
|
|
if (num.value == checkNum.value) {
|
|
|
|
num.value = createPoint(getMousePos(canvas, e))
|
|
|
|
num.value = createPoint(getMousePos(canvas, e))
|
|
|
|
@ -200,19 +199,19 @@ export default {
|
|
|
|
if (num.value < checkNum.value) {
|
|
|
|
if (num.value < checkNum.value) {
|
|
|
|
num.value = createPoint(getMousePos(canvas, e))
|
|
|
|
num.value = createPoint(getMousePos(canvas, e))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//获取坐标
|
|
|
|
//获取坐标
|
|
|
|
const getMousePos = function (obj, e) {
|
|
|
|
const getMousePos = function (obj, e) {
|
|
|
|
var x = e.offsetX
|
|
|
|
var x = e.offsetX
|
|
|
|
var y = e.offsetY
|
|
|
|
var y = e.offsetY
|
|
|
|
return { x, y }
|
|
|
|
return { x, y }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//创建坐标点
|
|
|
|
//创建坐标点
|
|
|
|
const createPoint = function (pos) {
|
|
|
|
const createPoint = function (pos) {
|
|
|
|
tempPoints.push(Object.assign({}, pos))
|
|
|
|
tempPoints.push(Object.assign({}, pos))
|
|
|
|
return num.value + 1
|
|
|
|
return num.value + 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const refresh = function () {
|
|
|
|
const refresh = async function () {
|
|
|
|
tempPoints.splice(0, tempPoints.length)
|
|
|
|
tempPoints.splice(0, tempPoints.length)
|
|
|
|
barAreaColor.value = '#000'
|
|
|
|
barAreaColor.value = '#000'
|
|
|
|
barAreaBorderColor.value = '#ddd'
|
|
|
|
barAreaBorderColor.value = '#ddd'
|
|
|
|
@ -220,17 +219,16 @@ export default {
|
|
|
|
fontPos.splice(0, fontPos.length)
|
|
|
|
fontPos.splice(0, fontPos.length)
|
|
|
|
checkPosArr.splice(0, checkPosArr.length)
|
|
|
|
checkPosArr.splice(0, checkPosArr.length)
|
|
|
|
num.value = 1
|
|
|
|
num.value = 1
|
|
|
|
getPictrue()
|
|
|
|
await getPictrue()
|
|
|
|
text.value = t('captcha.fail')
|
|
|
|
|
|
|
|
showRefresh.value = true
|
|
|
|
showRefresh.value = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 请求背景图片和验证图片
|
|
|
|
// 请求背景图片和验证图片
|
|
|
|
function getPictrue() {
|
|
|
|
const getPictrue = async () => {
|
|
|
|
let data = {
|
|
|
|
let data = {
|
|
|
|
captchaType: captchaType.value
|
|
|
|
captchaType: captchaType.value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getCodeApi(data).then((res) => {
|
|
|
|
const res = await getCodeApi(data)
|
|
|
|
if (res.repCode == '0000') {
|
|
|
|
if (res.repCode == '0000') {
|
|
|
|
pointBackImgBase.value = res.repData.originalImageBase64
|
|
|
|
pointBackImgBase.value = res.repData.originalImageBase64
|
|
|
|
backToken.value = res.repData.token
|
|
|
|
backToken.value = res.repData.token
|
|
|
|
@ -240,42 +238,14 @@ export default {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
text.value = res.repMsg
|
|
|
|
text.value = res.repMsg
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//坐标转换函数
|
|
|
|
//坐标转换函数
|
|
|
|
const pointTransfrom = function (pointArr, imgSize) {
|
|
|
|
const pointTransfrom = function (pointArr, imgSize) {
|
|
|
|
|
|
|
|
var newPointArr = pointArr.map((p) => {
|
|
|
|
var newPointArr = pointArr.map((p) => {
|
|
|
|
let x = Math.round((310 * p.x) / parseInt(imgSize.imgWidth))
|
|
|
|
let x = Math.round((310 * p.x) / parseInt(imgSize.imgWidth))
|
|
|
|
let y = Math.round((155 * p.y) / parseInt(imgSize.imgHeight))
|
|
|
|
let y = Math.round((155 * p.y) / parseInt(imgSize.imgHeight))
|
|
|
|
return { x, y }
|
|
|
|
return { x, y }
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return newPointArr
|
|
|
|
return newPointArr
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
secretKey,
|
|
|
|
|
|
|
|
checkNum,
|
|
|
|
|
|
|
|
fontPos,
|
|
|
|
|
|
|
|
checkPosArr,
|
|
|
|
|
|
|
|
num,
|
|
|
|
|
|
|
|
pointBackImgBase,
|
|
|
|
|
|
|
|
poinTextList,
|
|
|
|
|
|
|
|
backToken,
|
|
|
|
|
|
|
|
setSize,
|
|
|
|
|
|
|
|
tempPoints,
|
|
|
|
|
|
|
|
text,
|
|
|
|
|
|
|
|
barAreaColor,
|
|
|
|
|
|
|
|
barAreaBorderColor,
|
|
|
|
|
|
|
|
showRefresh,
|
|
|
|
|
|
|
|
bindingClick,
|
|
|
|
|
|
|
|
init,
|
|
|
|
|
|
|
|
canvas,
|
|
|
|
|
|
|
|
canvasClick,
|
|
|
|
|
|
|
|
getMousePos,
|
|
|
|
|
|
|
|
createPoint,
|
|
|
|
|
|
|
|
refresh,
|
|
|
|
|
|
|
|
getPictrue,
|
|
|
|
|
|
|
|
pointTransfrom
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|