@pubinfo/module-captcha 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/api/modules/auth/index.d.ts +1 -0
- package/dist/api/modules/auth/renzhengfuwu.d.ts +78 -0
- package/dist/api/request.d.ts +1 -0
- package/dist/components/VerifyInput/PubinfoVerifyInput.vue.d.ts +17 -0
- package/dist/components/VerifyInput/authService.d.ts +9 -0
- package/dist/components/VerifyInput/captchaUtils.d.ts +6 -0
- package/dist/components/VerifyPoints/PubinfoFixedPoint.vue.d.ts +11 -0
- package/dist/components/VerifyPoints/PubinfoPopPoint.vue.d.ts +17 -0
- package/dist/components/VerifyPoints/PubinfoTouchPoint.vue.d.ts +30 -0
- package/dist/components/VerifyPoints/common/checkEvent.d.ts +5 -0
- package/dist/components/VerifyPoints/common/initFuns.d.ts +2 -0
- package/dist/components/VerifyPoints/common/touchService.d.ts +10 -0
- package/dist/components/VerifyPoints/common/variable.d.ts +39 -0
- package/dist/components/VerifyPoints/pubinfoPopPoint.d.ts +1 -0
- package/dist/components/VerifySlide/PubinfoFixedSlide.vue.d.ts +14 -0
- package/dist/components/VerifySlide/PubinfoPopSlide.vue.d.ts +17 -0
- package/dist/components/VerifySlide/PubinfoTouchSlide.vue.d.ts +35 -0
- package/dist/components/VerifySlide/common/init.d.ts +2 -0
- package/dist/components/VerifySlide/common/mouse.d.ts +9 -0
- package/dist/components/VerifySlide/common/touchService.d.ts +10 -0
- package/dist/components/VerifySlide/common/variable.d.ts +59 -0
- package/dist/components/VerifySlide/pubinfoPopSlide.d.ts +1 -0
- package/dist/components/aes.d.ts +1 -0
- package/dist/context.d.ts +2 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +6165 -0
- package/dist/interface.d.ts +15 -0
- package/package.json +44 -0
- package/src/api/modules/auth/index.ts +1 -0
- package/src/api/modules/auth/renzhengfuwu.ts +223 -0
- package/src/api/modules/auth/typings.d.ts +140 -0
- package/src/api/request.ts +4 -0
- package/src/components/VerifyInput/PubinfoVerifyInput.vue +91 -0
- package/src/components/VerifyInput/authService.ts +22 -0
- package/src/components/VerifyInput/captchaUtils.ts +15 -0
- package/src/components/VerifyPoints/PubinfoFixedPoint.vue +224 -0
- package/src/components/VerifyPoints/PubinfoPopPoint.vue +55 -0
- package/src/components/VerifyPoints/PubinfoTouchPoint.vue +73 -0
- package/src/components/VerifyPoints/common/checkEvent.ts +72 -0
- package/src/components/VerifyPoints/common/initFuns.ts +44 -0
- package/src/components/VerifyPoints/common/touchService.ts +53 -0
- package/src/components/VerifyPoints/common/variable.ts +76 -0
- package/src/components/VerifyPoints/pubinfoPopPoint.ts +34 -0
- package/src/components/VerifySlide/PubinfoFixedSlide.vue +285 -0
- package/src/components/VerifySlide/PubinfoPopSlide.vue +53 -0
- package/src/components/VerifySlide/PubinfoTouchSlide.vue +51 -0
- package/src/components/VerifySlide/common/init.ts +41 -0
- package/src/components/VerifySlide/common/mouse.ts +124 -0
- package/src/components/VerifySlide/common/touchService.ts +52 -0
- package/src/components/VerifySlide/common/variable.ts +90 -0
- package/src/components/VerifySlide/pubinfoPopSlide.ts +34 -0
- package/src/components/aes.ts +13 -0
- package/src/context.ts +4 -0
- package/src/images/click.png +0 -0
- package/src/index.ts +37 -0
- package/src/interface.ts +19 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { CheckOutlined, CloseOutlined, RightOutlined } from '@ant-design/icons-vue';
|
|
3
|
+
import { useElementSize } from '@vueuse/core';
|
|
4
|
+
import { computed, defineEmits, getCurrentInstance, onMounted, ref } from 'vue';
|
|
5
|
+
import { getPictrue, refresh } from './common/init.ts';
|
|
6
|
+
import useMounseOpertae from './common/mouse.ts';
|
|
7
|
+
import { variable } from './common/variable.ts';
|
|
8
|
+
|
|
9
|
+
const emit = defineEmits(['success', 'menter', 'mleave']);
|
|
10
|
+
|
|
11
|
+
const slideRef = ref();
|
|
12
|
+
|
|
13
|
+
const { width: slideWidth } = useElementSize(slideRef);
|
|
14
|
+
|
|
15
|
+
const VA = variable();
|
|
16
|
+
const { start, move, end } = useMounseOpertae(VA);
|
|
17
|
+
const { proxy } = getCurrentInstance()!;
|
|
18
|
+
|
|
19
|
+
// 滑动小方块
|
|
20
|
+
const barArea = computed(() => {
|
|
21
|
+
return proxy?.$el.querySelector('.verify-bar-area');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
onMounted(() => {
|
|
25
|
+
getPictrue(VA);
|
|
26
|
+
VA.setSize.value.imgHeight = `${slideWidth.value / 2}px`;
|
|
27
|
+
VA.realImgSize.value = {
|
|
28
|
+
width: slideWidth.value,
|
|
29
|
+
height: slideWidth.value / 2,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
window.removeEventListener('touchmove', (e) => {
|
|
33
|
+
move(e, { barArea: barArea.value });
|
|
34
|
+
});
|
|
35
|
+
window.removeEventListener('mousemove', (e) => {
|
|
36
|
+
move(e, { barArea: barArea.value });
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// 鼠标松开
|
|
40
|
+
window.removeEventListener('touchend', () => {
|
|
41
|
+
end(emit);
|
|
42
|
+
});
|
|
43
|
+
window.removeEventListener('mouseup', () => {
|
|
44
|
+
end(emit);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
window.addEventListener('touchmove', (e) => {
|
|
48
|
+
move(e, { barArea: barArea.value });
|
|
49
|
+
});
|
|
50
|
+
window.addEventListener('mousemove', (e) => {
|
|
51
|
+
move(e, { barArea: barArea.value });
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// 鼠标松开
|
|
55
|
+
window.addEventListener('touchend', () => {
|
|
56
|
+
end(emit);
|
|
57
|
+
});
|
|
58
|
+
window.addEventListener('mouseup', () => {
|
|
59
|
+
end(emit);
|
|
60
|
+
});
|
|
61
|
+
// 禁止拖拽
|
|
62
|
+
proxy!.$el.onselectstart = function () {
|
|
63
|
+
// console.log('onselectstart');
|
|
64
|
+
return false;
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
function pushMouseEnter() {
|
|
69
|
+
emit('menter');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function pushMouseLeave() {
|
|
73
|
+
emit('mleave');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
defineExpose({
|
|
77
|
+
refresh: () => {
|
|
78
|
+
refresh(VA);
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<template>
|
|
84
|
+
<div ref="slideRef" style="position: relative;">
|
|
85
|
+
<div
|
|
86
|
+
class="verify-img-out"
|
|
87
|
+
:style="{ height: `${parseInt(VA.setSize.value.imgHeight) + 10}px` }"
|
|
88
|
+
>
|
|
89
|
+
<div
|
|
90
|
+
class="verify-img-panel" :style="{ width: VA.setSize.value.width,
|
|
91
|
+
height: VA.setSize.value.imgHeight }"
|
|
92
|
+
>
|
|
93
|
+
<img v-if="VA.backImgBase.value" :src="`data:image/png;base64,${VA.backImgBase.value}`" alt="" style="display: block;width: 100%;height: 100%;">
|
|
94
|
+
<div v-show="VA.showRefresh.value" class="verify-refresh" @click="refresh(VA)">
|
|
95
|
+
<RedoOutlined :style="{ fontSize: '20px', color: 'white', transform: 'rotate(-90deg)' }" />
|
|
96
|
+
</div>
|
|
97
|
+
<transition name="tips">
|
|
98
|
+
<span v-if="VA.tipWords.value" class="verify-tips" :class="VA.passFlag.value ? 'suc-bg' : 'err-bg'">{{ VA.tipWords.value }}</span>
|
|
99
|
+
</transition>
|
|
100
|
+
</div>
|
|
101
|
+
<div
|
|
102
|
+
class="verify-sub-block"
|
|
103
|
+
:style="{ 'width': `${Math.floor(VA.realImgSize.value.width * 47 / 310)}px`,
|
|
104
|
+
'height': VA.setSize.value.imgHeight,
|
|
105
|
+
'background-size': `${VA.setSize.value.width} ${VA.setSize.value.imgHeight}`,
|
|
106
|
+
'left': VA.moveBlockLeft.value,
|
|
107
|
+
'transition': VA.transitionLeft.value,
|
|
108
|
+
}"
|
|
109
|
+
>
|
|
110
|
+
<img v-if="VA.blockBackImgBase.value" :src="`data:image/png;base64,${VA.blockBackImgBase.value}`" alt="" style="display: block;width: 100%;height: 100%;-webkit-user-drag: none;">
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
<div
|
|
114
|
+
class="verify-bar-area"
|
|
115
|
+
:style="{
|
|
116
|
+
'width': '100%',
|
|
117
|
+
'height': VA.setSize.value.barHeight,
|
|
118
|
+
'line-height': VA.setSize.value.barHeight,
|
|
119
|
+
}"
|
|
120
|
+
@mouseenter="pushMouseEnter"
|
|
121
|
+
@mouseleave="pushMouseLeave"
|
|
122
|
+
>
|
|
123
|
+
<span class="verify-msg" v-text="VA.text.value" />
|
|
124
|
+
<div
|
|
125
|
+
class="verify-left-bar"
|
|
126
|
+
:style="{ 'width': (VA.leftBarWidth.value !== undefined) ? VA.leftBarWidth.value : VA.setSize.value.barHeight, 'height': VA.setSize.value.barHeight, 'border-color': VA.leftBarBorderColor.value, 'background': VA.verifyLeftBarBackgroundColor.value }"
|
|
127
|
+
>
|
|
128
|
+
<div
|
|
129
|
+
class="verify-move-block"
|
|
130
|
+
:style="{ 'width': VA.setSize.value.barHeight, 'height': VA.setSize.value.barHeight, 'background-color': VA.moveBlockBackgroundColor.value, 'left': VA.moveBlockLeft.value, 'transition': VA.transitionLeft.value }"
|
|
131
|
+
@touchstart="start"
|
|
132
|
+
@mousedown="start"
|
|
133
|
+
@mouseenter="() => VA.iconColor.value = 'white'"
|
|
134
|
+
@mouseleave="() => VA.iconColor.value = 'rgba(0,0,0,0.88)'"
|
|
135
|
+
>
|
|
136
|
+
<RightOutlined v-if="VA.iconName.value === 'normal'" :style="{ fontSize: '18px', color: VA.iconColor.value }" />
|
|
137
|
+
<CheckOutlined v-if="VA.iconName.value === 'right'" :style="{ fontSize: '18px', color: 'white' }" />
|
|
138
|
+
<CloseOutlined v-if="VA.iconName.value === 'wrong'" :style="{ fontSize: '18px', color: 'white' }" />
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
</template>
|
|
144
|
+
|
|
145
|
+
<style scoped>
|
|
146
|
+
.verify-tips {
|
|
147
|
+
position: absolute;
|
|
148
|
+
bottom:0;
|
|
149
|
+
left:0;
|
|
150
|
+
right:0;
|
|
151
|
+
z-index:7;
|
|
152
|
+
height: 30px;
|
|
153
|
+
line-height:30px;
|
|
154
|
+
color: #fff;
|
|
155
|
+
padding-left:8px;
|
|
156
|
+
opacity: 1;
|
|
157
|
+
}
|
|
158
|
+
.suc-bg {
|
|
159
|
+
background-color: rgba(92, 184, 92, 0.5);
|
|
160
|
+
filter: progid:DXImageTransform.Microsoft.gradient(startcolorstr=#7f5CB85C, endcolorstr=#7f5CB85C);
|
|
161
|
+
}
|
|
162
|
+
.err-bg {
|
|
163
|
+
background-color: rgba(217, 83, 79, 0.5);
|
|
164
|
+
filter: progid:DXImageTransform.Microsoft.gradient(startcolorstr=#7fD9534F, endcolorstr=#7fD9534F);
|
|
165
|
+
}
|
|
166
|
+
/* .tips-enter,
|
|
167
|
+
.tips-leave-to {
|
|
168
|
+
opacity: 0;
|
|
169
|
+
}
|
|
170
|
+
.tips-enter-active,
|
|
171
|
+
.tips-leave-active {
|
|
172
|
+
transition: opacity 0.5s;
|
|
173
|
+
} */
|
|
174
|
+
/* ---------------------------- */
|
|
175
|
+
|
|
176
|
+
/*滑动验证码*/
|
|
177
|
+
.verify-bar-area {
|
|
178
|
+
position: relative;
|
|
179
|
+
box-sizing: border-box;
|
|
180
|
+
text-align: center;
|
|
181
|
+
border: 1px solid #e4e7eb;
|
|
182
|
+
background-color: #f7f9fa;
|
|
183
|
+
border-radius: 2px;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.verify-bar-area .verify-move-block {
|
|
187
|
+
position: absolute;
|
|
188
|
+
top: -1px;
|
|
189
|
+
left: 0px;
|
|
190
|
+
box-sizing: border-box;
|
|
191
|
+
cursor: pointer;
|
|
192
|
+
background-color: #fff;
|
|
193
|
+
border-radius: 2px;
|
|
194
|
+
box-shadow: 0 0 3px rgba(0,0,0,.3);
|
|
195
|
+
transition: background .2s linear;
|
|
196
|
+
display: flex;
|
|
197
|
+
align-items: center;
|
|
198
|
+
justify-content: center;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.verify-bar-area .verify-move-block:hover {
|
|
202
|
+
background-color: #1991fa;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.verify-bar-area .verify-move-block:hover .verify-icon {
|
|
206
|
+
color: #fff;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.verify-bar-area .verify-left-bar {
|
|
210
|
+
position: absolute;
|
|
211
|
+
top: -1px;
|
|
212
|
+
left: 0px;
|
|
213
|
+
-webkit-box-sizing: border-box;
|
|
214
|
+
-moz-box-sizing: border-box;
|
|
215
|
+
box-sizing: border-box;
|
|
216
|
+
cursor: pointer;
|
|
217
|
+
background-color: #7bbaf1;
|
|
218
|
+
border: 1px solid #1991fa;
|
|
219
|
+
border-right-width: 0px;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.verify-img-panel {
|
|
223
|
+
position: relative;
|
|
224
|
+
-webkit-box-sizing: border-box;
|
|
225
|
+
-moz-box-sizing: border-box;
|
|
226
|
+
box-sizing: border-box;
|
|
227
|
+
margin: 0;
|
|
228
|
+
border-top: 1px solid #ddd;
|
|
229
|
+
border-bottom: 1px solid #ddd;
|
|
230
|
+
border-radius: 3px;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.verify-img-panel .verify-refresh {
|
|
234
|
+
position: absolute;
|
|
235
|
+
top: 0;
|
|
236
|
+
right: 0;
|
|
237
|
+
z-index: 2;
|
|
238
|
+
width: 30px;
|
|
239
|
+
height: 30px;
|
|
240
|
+
text-align: center;
|
|
241
|
+
cursor: pointer;
|
|
242
|
+
background-color: rgba(0,0,0,0.12);
|
|
243
|
+
line-height: 30px;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.verify-img-panel .icon-refresh {
|
|
247
|
+
font-size: 20px;
|
|
248
|
+
color: #fff;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.verify-img-out{
|
|
252
|
+
position: relative;
|
|
253
|
+
}
|
|
254
|
+
.verify-sub-block {
|
|
255
|
+
position: absolute;
|
|
256
|
+
z-index: 3;
|
|
257
|
+
text-align: center;
|
|
258
|
+
left:0px;
|
|
259
|
+
top: 0px;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.verify-bar-area .verify-move-block .verify-icon {
|
|
263
|
+
font-size: 18px;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.verify-bar-area .verify-msg {
|
|
267
|
+
z-index: 3;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.pubinfo-m-normal .verify-img-out {
|
|
271
|
+
position: absolute;
|
|
272
|
+
bottom: 20px;
|
|
273
|
+
opacity: 0;
|
|
274
|
+
transition: opacity 0.5s, bottom 0.5s, visibility 0.5s;
|
|
275
|
+
visibility: hidden;
|
|
276
|
+
z-index:999;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.pubinfo-m-touch .verify-img-out {
|
|
280
|
+
bottom: 40px;
|
|
281
|
+
opacity: 1;
|
|
282
|
+
transition: opacity 0.5s, bottom 0.5s, visibility 0.5s;
|
|
283
|
+
visibility:visible;
|
|
284
|
+
}
|
|
285
|
+
</style>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { RESULT } from './common/mouse.ts';
|
|
3
|
+
import { useToggle } from '@vueuse/core';
|
|
4
|
+
import { useAttrs } from 'vue';
|
|
5
|
+
import Fixed from './PubinfoFixedSlide.vue';
|
|
6
|
+
|
|
7
|
+
export interface PubinfoPopSlideProps {
|
|
8
|
+
onSuccess?: (data: RESULT) => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
defineOptions({
|
|
12
|
+
name: 'PubinfoPopSlide',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const props = withDefaults(defineProps<PubinfoPopSlideProps>(), {});
|
|
16
|
+
|
|
17
|
+
const attrs = useAttrs();
|
|
18
|
+
|
|
19
|
+
// 双向绑定
|
|
20
|
+
const open = defineModel<boolean>('open');
|
|
21
|
+
|
|
22
|
+
const setOpen = useToggle(open);
|
|
23
|
+
|
|
24
|
+
function onOpen() {
|
|
25
|
+
setOpen(true);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function onSuccess(data: RESULT) {
|
|
29
|
+
props.onSuccess?.(data);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
defineExpose({
|
|
33
|
+
open: onOpen,
|
|
34
|
+
});
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<template>
|
|
38
|
+
<div>
|
|
39
|
+
<a-modal
|
|
40
|
+
v-bind="attrs"
|
|
41
|
+
v-model:open="open"
|
|
42
|
+
title="请完成安全验证"
|
|
43
|
+
:width="370"
|
|
44
|
+
:z-index="1101"
|
|
45
|
+
:destroy-on-close="true"
|
|
46
|
+
:footer="false"
|
|
47
|
+
centered
|
|
48
|
+
:mask-closable="false"
|
|
49
|
+
>
|
|
50
|
+
<Fixed @success="onSuccess" />
|
|
51
|
+
</a-modal>
|
|
52
|
+
</div>
|
|
53
|
+
</template>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { onMounted, ref } from 'vue';
|
|
3
|
+
import { useTouchService } from './common/touchService.ts';
|
|
4
|
+
import Fixed from './PubinfoFixedSlide.vue';
|
|
5
|
+
|
|
6
|
+
const emit = defineEmits(['success']);
|
|
7
|
+
const { onAreaMouseLeave, onMouseEnter, onMouseLeave, handleSubmit, showButton, isSuccess, inArea } = useTouchService();
|
|
8
|
+
|
|
9
|
+
const pubinfoMMFixedSlideRef = ref<any>(null);
|
|
10
|
+
onMounted(() => {
|
|
11
|
+
showButton.value = true;
|
|
12
|
+
isSuccess.value = false;
|
|
13
|
+
inArea.value = false;
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
function onSubmit(data: any) {
|
|
17
|
+
handleSubmit(data, emit);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
defineExpose({
|
|
21
|
+
refresh: () => {
|
|
22
|
+
showButton.value = true;
|
|
23
|
+
isSuccess.value = false;
|
|
24
|
+
inArea.value = false;
|
|
25
|
+
pubinfoMMFixedSlideRef.value.refresh();
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<template>
|
|
31
|
+
<div relative h-40px class="w-100%">
|
|
32
|
+
<div absolute bottom-0 left-0 right-0 class="pubinfo-m-normal" :class="{ 'pubinfo-m-touch': !showButton }" @mouseleave="onMouseLeave">
|
|
33
|
+
<div absolute bottom-0 w-full>
|
|
34
|
+
<Fixed ref="pubinfoMMFixedSlideRef" @success="onSubmit" @menter="onMouseEnter" @mleave="onAreaMouseLeave" />
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<style scoped>
|
|
41
|
+
.button_touch {
|
|
42
|
+
width: 320px;
|
|
43
|
+
height: 40px;
|
|
44
|
+
border-radius: 2px;
|
|
45
|
+
background: linear-gradient(180deg, #fff 0, #ebedf0 87%);
|
|
46
|
+
border: 1px solid #e4e7eb;
|
|
47
|
+
cursor: pointer;
|
|
48
|
+
font-size: 14px;
|
|
49
|
+
color: #45494c;
|
|
50
|
+
}
|
|
51
|
+
</style>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { postAuthCaptchaGet } from '@/api/modules/auth/renzhengfuwu';
|
|
2
|
+
|
|
3
|
+
export function refresh(VA: any) {
|
|
4
|
+
VA.showRefresh.value = true;
|
|
5
|
+
VA.transitionLeft.value = 'left .3s';
|
|
6
|
+
VA.moveBlockLeft.value = '';
|
|
7
|
+
VA.leftBarWidth.value = undefined;
|
|
8
|
+
VA.verifyLeftBarBackgroundColor.value = '#d1e9fe';
|
|
9
|
+
VA.moveBlockBackgroundColor.value = '';
|
|
10
|
+
VA.leftBarBorderColor.value = '#ddd';
|
|
11
|
+
VA.iconColor.value = 'rgba(0,0,0,0.88)';
|
|
12
|
+
VA.iconName.value = 'normal';
|
|
13
|
+
VA.isEnd.value = false;
|
|
14
|
+
getPictrue(VA);
|
|
15
|
+
VA.tipWords.value = '';
|
|
16
|
+
setTimeout(() => {
|
|
17
|
+
VA.transitionLeft.value = '';
|
|
18
|
+
VA.text.value = '向右滑动完成验证';
|
|
19
|
+
}, 300);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// 请求背景图片和验证图片
|
|
23
|
+
export function getPictrue(VA: any) {
|
|
24
|
+
const data = {
|
|
25
|
+
captchaType: 'blockPuzzle',
|
|
26
|
+
size: '320*160',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
postAuthCaptchaGet(data).then((res: any) => {
|
|
30
|
+
if (res.success) {
|
|
31
|
+
const captchaMessage = JSON.parse(res.data.plaintext);
|
|
32
|
+
VA.backImgBase.value = captchaMessage.originalImageBase64;
|
|
33
|
+
VA.blockBackImgBase.value = captchaMessage.jigsawImageBase64;
|
|
34
|
+
VA.backToken.value = captchaMessage.token;
|
|
35
|
+
VA.secretKey.value = captchaMessage.secretKey;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
VA.tipWords.value = res.msg;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { postAuthCaptchaCheck } from '@/api/modules/auth/renzhengfuwu';
|
|
2
|
+
import { aesEncrypt } from '../../aes.ts';
|
|
3
|
+
import { refresh } from './init.ts';
|
|
4
|
+
|
|
5
|
+
export interface RESULT {
|
|
6
|
+
captchaVerification: string
|
|
7
|
+
captchaType: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default function useMounseOpertae(VA: any) {
|
|
11
|
+
// 鼠标按下
|
|
12
|
+
function start(e: any) {
|
|
13
|
+
e = e || window.event;
|
|
14
|
+
|
|
15
|
+
VA.verifyLeftBarBackgroundColor.value = '#d1e9fe';
|
|
16
|
+
|
|
17
|
+
VA.moveBlockBackgroundColor.value = '#1991fa';
|
|
18
|
+
|
|
19
|
+
VA.leftBarBorderColor.value = '#1991fa';
|
|
20
|
+
|
|
21
|
+
VA.iconColor.value = '#fff';
|
|
22
|
+
|
|
23
|
+
VA.startMoveTime.value = +new Date(); // 开始滑动的时间
|
|
24
|
+
|
|
25
|
+
if (VA.isEnd.value === false) {
|
|
26
|
+
VA.text.value = '';
|
|
27
|
+
e.stopPropagation();
|
|
28
|
+
VA.status.value = true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 鼠标移动
|
|
33
|
+
function move(e: any, options?: any) {
|
|
34
|
+
e = e || window.event;
|
|
35
|
+
if (VA.status.value && VA.isEnd.value === false) {
|
|
36
|
+
const x = e.clientX;
|
|
37
|
+
const bar_area_left = options.barArea.getBoundingClientRect().left;
|
|
38
|
+
let move_block_left = x - bar_area_left; // 小方块相对于父元素的left值
|
|
39
|
+
if (move_block_left >= options.barArea.offsetWidth - Number.parseInt((Number.parseInt((VA.blockSize.value.width) as any) / 2) as any) - 2) {
|
|
40
|
+
move_block_left = options.barArea.offsetWidth - Number.parseInt((Number.parseInt((VA.blockSize.value.width) as any) / 2) as any) - 2;
|
|
41
|
+
}
|
|
42
|
+
if (move_block_left <= 0) {
|
|
43
|
+
move_block_left = Number.parseInt((Number.parseInt((VA.blockSize.value.width) as any) / 2) as any);
|
|
44
|
+
}
|
|
45
|
+
// 拖动后小方块的left值
|
|
46
|
+
VA.moveBlockLeft.value = `${(move_block_left - VA.startLeft.value) < 0 ? '0px' : (move_block_left - VA.startLeft.value)}px`;
|
|
47
|
+
|
|
48
|
+
VA.leftBarWidth.value = `${move_block_left - VA.startLeft.value}px`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function end(emit: any) {
|
|
53
|
+
VA.endMovetime.value = +new Date();
|
|
54
|
+
// 判断是否重合
|
|
55
|
+
if (VA.status.value && VA.isEnd.value === false) {
|
|
56
|
+
let moveLeftDistance = Number.parseInt((VA.moveBlockLeft.value || '').replace('px', ''));
|
|
57
|
+
moveLeftDistance = moveLeftDistance * 310 / Number.parseInt(VA.realImgSize.value.width as any);
|
|
58
|
+
const data = {
|
|
59
|
+
captchaType: 'blockPuzzle',
|
|
60
|
+
pointJson: VA.secretKey.value ? aesEncrypt(JSON.stringify({ x: moveLeftDistance, y: 5.0 }), VA.secretKey.value) : JSON.stringify({ x: moveLeftDistance, y: 5.0 }),
|
|
61
|
+
token: VA.backToken.value,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
postAuthCaptchaCheck(data).then((res: any) => {
|
|
65
|
+
if (res.success) {
|
|
66
|
+
VA.verifyLeftBarBackgroundColor.value = '#d2f4ef';
|
|
67
|
+
|
|
68
|
+
VA.moveBlockBackgroundColor.value = '#52ccba';
|
|
69
|
+
|
|
70
|
+
VA.leftBarBorderColor.value = '#52ccba';
|
|
71
|
+
|
|
72
|
+
VA.iconColor.value = '#fff';
|
|
73
|
+
|
|
74
|
+
VA.iconName.value = 'right';
|
|
75
|
+
|
|
76
|
+
VA.showRefresh.value = false;
|
|
77
|
+
|
|
78
|
+
VA.isEnd.value = true;
|
|
79
|
+
|
|
80
|
+
VA.passFlag.value = true;
|
|
81
|
+
|
|
82
|
+
VA.tipWords.value = `${((VA.endMovetime.value - VA.startMoveTime.value) / 1000).toFixed(2)}s验证成功`;
|
|
83
|
+
|
|
84
|
+
const captchaVerification = VA.secretKey.value ? aesEncrypt(`${VA.backToken.value}---${JSON.stringify({ x: moveLeftDistance, y: 5.0 })}`, VA.secretKey.value) : `${VA.backToken.value}---${JSON.stringify({ x: moveLeftDistance, y: 5.0 })}`;
|
|
85
|
+
const params: RESULT = {
|
|
86
|
+
captchaVerification,
|
|
87
|
+
captchaType: 'blockPuzzle',
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
emit('success', params);
|
|
92
|
+
}, 200);
|
|
93
|
+
}
|
|
94
|
+
}).catch(() => {
|
|
95
|
+
VA.verifyLeftBarBackgroundColor.value = '#fce1e1';
|
|
96
|
+
|
|
97
|
+
VA.moveBlockBackgroundColor.value = '#f57a7a';
|
|
98
|
+
|
|
99
|
+
VA.leftBarBorderColor.value = '#f57a7a';
|
|
100
|
+
|
|
101
|
+
VA.iconColor.value = '#fff';
|
|
102
|
+
|
|
103
|
+
VA.iconName.value = 'wrong';
|
|
104
|
+
|
|
105
|
+
VA.passFlag.value = false;
|
|
106
|
+
|
|
107
|
+
VA.tipWords.value = '验证失败';
|
|
108
|
+
|
|
109
|
+
setTimeout(() => {
|
|
110
|
+
VA.tipWords.value = '';
|
|
111
|
+
refresh(VA);
|
|
112
|
+
}, 300);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
VA.status.value = false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
start,
|
|
121
|
+
move,
|
|
122
|
+
end,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
// 定义提交处理函数的类型
|
|
3
|
+
export type EmitFunction = (event: 'success', data: any) => void;
|
|
4
|
+
|
|
5
|
+
export function useTouchService() {
|
|
6
|
+
const showButton = ref<boolean>(true);
|
|
7
|
+
const isSuccess = ref<boolean>(false);
|
|
8
|
+
const inArea = ref<boolean>(false);
|
|
9
|
+
|
|
10
|
+
function handleSubmit(data: any, emit: EmitFunction) {
|
|
11
|
+
showButton.value = true;
|
|
12
|
+
isSuccess.value = true;
|
|
13
|
+
emit('success', data);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function onMouseEnter() {
|
|
17
|
+
inArea.value = true;
|
|
18
|
+
setTimeout(() => {
|
|
19
|
+
if (!isSuccess.value && inArea.value) {
|
|
20
|
+
showButton.value = false;
|
|
21
|
+
}
|
|
22
|
+
}, 300);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function onMouseLeave() {
|
|
26
|
+
// 当已经校验成功时,不做任何操作(也看不到验证码图片)
|
|
27
|
+
if (!isSuccess.value) {
|
|
28
|
+
showButton.value = true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function onAreaMouseLeave() {
|
|
33
|
+
inArea.value = false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
showButton,
|
|
38
|
+
isSuccess,
|
|
39
|
+
inArea,
|
|
40
|
+
handleSubmit,
|
|
41
|
+
onMouseEnter,
|
|
42
|
+
onMouseLeave,
|
|
43
|
+
onAreaMouseLeave,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// export function refreshTouchSlide() {
|
|
48
|
+
// showButton.value = true;
|
|
49
|
+
// isSuccess.value = false;
|
|
50
|
+
// inArea.value = false;
|
|
51
|
+
// refreshFixedSlide();
|
|
52
|
+
// }
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
|
|
3
|
+
export function variable() {
|
|
4
|
+
const blockSize = ref({
|
|
5
|
+
width: '50px',
|
|
6
|
+
height: '50px',
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// 是否通过的标识
|
|
10
|
+
const passFlag = ref<boolean>(false);
|
|
11
|
+
// 移动开始的时间
|
|
12
|
+
const startMoveTime = ref<number>(0);
|
|
13
|
+
// 移动结束的时间
|
|
14
|
+
const endMovetime = ref<number>(0);
|
|
15
|
+
// ??s验证成功/验证失败
|
|
16
|
+
const tipWords = ref('');
|
|
17
|
+
// 下方滑动区域的文字
|
|
18
|
+
const text = ref('向右滑动完成验证');
|
|
19
|
+
// 图片与滑动区域的宽高
|
|
20
|
+
const setSize = ref({
|
|
21
|
+
imgHeight: '160px',
|
|
22
|
+
width: '100%',
|
|
23
|
+
barHeight: '40px',
|
|
24
|
+
barWidth: '310px',
|
|
25
|
+
});
|
|
26
|
+
// 图片实际大小
|
|
27
|
+
const realImgSize = ref({
|
|
28
|
+
width: 0,
|
|
29
|
+
height: 0,
|
|
30
|
+
});
|
|
31
|
+
// 滑动块的左侧位置(距离左侧的宽度)
|
|
32
|
+
const moveBlockLeft = ref<string>('');
|
|
33
|
+
// 滑动区域的左侧宽度
|
|
34
|
+
const leftBarWidth = ref<any>();
|
|
35
|
+
// 滑动区域左侧的颜色
|
|
36
|
+
const verifyLeftBarBackgroundColor = ref<string>('#d1e9fe');
|
|
37
|
+
// 滑块背景色
|
|
38
|
+
const moveBlockBackgroundColor = ref<string>('');
|
|
39
|
+
// 滑动过程中左侧区域的边框颜色
|
|
40
|
+
const leftBarBorderColor = ref<string>('#ddd');
|
|
41
|
+
// 滑块图标颜色
|
|
42
|
+
const iconColor = ref<string>('rgba(0,0,0,0.88)');
|
|
43
|
+
// 滑块中的图标样式
|
|
44
|
+
const iconName = ref('normal');
|
|
45
|
+
// 鼠标状态
|
|
46
|
+
const status = ref(false);
|
|
47
|
+
// 是够验证完成
|
|
48
|
+
const isEnd = ref(false);
|
|
49
|
+
// 是否显示刷新按钮
|
|
50
|
+
const showRefresh = ref(true);
|
|
51
|
+
// left过渡
|
|
52
|
+
const transitionLeft = ref('');
|
|
53
|
+
// 用于滑动过程中左侧的计算
|
|
54
|
+
const startLeft = ref(25);
|
|
55
|
+
// 背景图
|
|
56
|
+
const backImgBase = ref<any>();
|
|
57
|
+
// 拼图背景图
|
|
58
|
+
const blockBackImgBase = ref<any>();
|
|
59
|
+
// token
|
|
60
|
+
const backToken = ref<any>();
|
|
61
|
+
// 加密key
|
|
62
|
+
const secretKey = ref<any>();
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
backImgBase,
|
|
66
|
+
backToken,
|
|
67
|
+
blockBackImgBase,
|
|
68
|
+
blockSize,
|
|
69
|
+
endMovetime,
|
|
70
|
+
iconColor,
|
|
71
|
+
iconName,
|
|
72
|
+
isEnd,
|
|
73
|
+
leftBarBorderColor,
|
|
74
|
+
leftBarWidth,
|
|
75
|
+
moveBlockBackgroundColor,
|
|
76
|
+
moveBlockLeft,
|
|
77
|
+
passFlag,
|
|
78
|
+
secretKey,
|
|
79
|
+
setSize,
|
|
80
|
+
realImgSize,
|
|
81
|
+
showRefresh,
|
|
82
|
+
startLeft,
|
|
83
|
+
startMoveTime,
|
|
84
|
+
status,
|
|
85
|
+
text,
|
|
86
|
+
tipWords,
|
|
87
|
+
transitionLeft,
|
|
88
|
+
verifyLeftBarBackgroundColor,
|
|
89
|
+
};
|
|
90
|
+
};
|