UNPKG

go-captcha-uni-beta

Version:

验证码,UniApp 验证码,GoCaptcha 验证码,行为验证码,点选验证码,滑动验证码,旋转验证码,拼图滑块验证码,拼图拖放验证码,图像旋转验证码,点击验证码

39 lines (36 loc) 1.14 kB
/** * @Author Awen * @Date 2025/02/15 * @Email wengaolng@gmail.com **/ export const getDomPosition = (id, cabs) => { try{ const query = uni.createSelectorQuery().in(this); query.select(id).boundingClientRect(data => { cabs && cabs(data) }).exec(); } catch (e) { console.warn(`gocaptcha boundingClientRect err`, e) } } export const getXY = (e) => { let xy = {x: 0, y: 0} try { if (e.touches && Array.isArray(e.touches) && e.touches.length > 0) { xy.x = e.touches[0].clientX || e.touches[0].pageX || 0; xy.y = e.touches[0].clientY || e.touches[0].pageY || 0; } else if (e.target && typeof e.target.x !== 'undefined') { xy.x = e.target.x || 0; xy.y = e.target.y || 0; } else if (e.detail && (typeof e.detail.clientX !== 'undefined' || typeof e.detail.pageX !== 'undefined')){ xy.x = e.detail.clientX || e.detail.pageX || 0; xy.y = e.detail.clientY || e.detail.pageY || 0; } else { xy.x = e.clientX || e.pageX || 0; xy.y = e.clientY || e.pageY || 0; } return xy } catch (e) { console.warn('>>>>>>>> go captcha err: ', e) } }