首次完整推送,
V:1.20240808.006
This commit is contained in:
49
uni_modules/uni-captcha/changelog.md
Normal file
49
uni_modules/uni-captcha/changelog.md
Normal file
@ -0,0 +1,49 @@
|
||||
## 0.7.5(2023-12-18)
|
||||
- 修复 在uni-app x项目,部分情况下,执行uni-captcha组件的setFocus无效的问题
|
||||
## 0.7.4(2023-12-18)
|
||||
- 更新 `package.json` -> `dependencies` 增加 `uni-popup`
|
||||
## 0.7.3(2023-11-15)
|
||||
- 更新 uni-popup-captcha.uvue依赖的popup组件,直接使用uni_modules下的uni-popup组件
|
||||
## 0.7.2(2023-11-07)
|
||||
- 新增 前端组件:uni-captcha.uvue、uni-popup-captcha
|
||||
## 0.7.1(2023-11-07)
|
||||
- 新增 前端组件:uni-captcha.uvue、uni-popup-captcha
|
||||
## 0.7.0(2023-10-10)
|
||||
- 新增 支持在`uni-config-center`中配置mode,可选值为svg和bmp,配置成bmp后可以在uniappx的uvue页面正常显示验证码(uvue不支持显示svg验证码)
|
||||
## 0.6.4(2023-01-16)
|
||||
- 修复 部分情况下APP端无法获取验证码的问题
|
||||
## 0.6.3(2023-01-11)
|
||||
- 修复 抖音小程序无法显示的Bug
|
||||
- 修复 刷新时兼容 device_uuid
|
||||
## 0.6.1(2022-06-23)
|
||||
- 修复:部分返回值,不符合响应体规范的问题
|
||||
## 0.6.0(2022-05-27)
|
||||
- 新增:支持在`uni-config-center`中根据场景值配置
|
||||
- 修复:弹窗式验证码,输入内容后点击取消,重新打开验证码的值仍然存在的问题
|
||||
## 0.5.2(2022-05-19)
|
||||
- 修复在Vue3的兼容问题
|
||||
## 0.5.1(2022-05-18)
|
||||
- 修复在某些情况下微信小程序端验证码显示错误的问题
|
||||
## 0.5.0(2022-05-17)
|
||||
- 新增支持在`uni-captcha-co`->`config`配置验证码
|
||||
## 0.4.1(2022-05-16)
|
||||
- 新增示例项目
|
||||
## 0.4.0(2022-05-16)
|
||||
- 集成创建、刷新、显示验证码的云端一体验证码组件
|
||||
- 云对象`uni-captcha-co`集成获取验证码的api,`getImageCaptcha`
|
||||
## 0.3.1(2022-05-13)
|
||||
- 新增 返回值符合响应体规范
|
||||
## 0.3.0(2022-05-13)
|
||||
- 新增 支持 uni-config-center 配置
|
||||
## 0.2.2(2022-04-25)
|
||||
- 修复 0.2.1 版本引起的使用 image 组件验证码不显示的Bug
|
||||
## 0.2.1(2022-04-18)
|
||||
- 更新 优化字体
|
||||
## 0.2.0(2022-04-14)
|
||||
- 新增 使用 svg 表现形式更好
|
||||
- 新增 使用字体,可以任意替换默认字体
|
||||
- 新增 支持设置字体大小
|
||||
- 新增 支持忽略某些字符
|
||||
- 注意 更新之后请重新上传公共模块
|
||||
## 0.1.0(2021-03-01)
|
||||
- 调整为uni_modules目录规范
|
180
uni_modules/uni-captcha/components/uni-captcha/uni-captcha.uvue
Normal file
180
uni_modules/uni-captcha/components/uni-captcha/uni-captcha.uvue
Normal file
@ -0,0 +1,180 @@
|
||||
<template>
|
||||
<view class="captcha-box">
|
||||
<view class="captcha-img-box">
|
||||
<image class="loding" src="/uni_modules/uni-captcha/static/run.gif" v-if="loging" mode="widthFix" />
|
||||
<image class="captcha-img" :class="{opacity:loging}" @click="getImageCaptcha(true)" :src="captchaBase64" mode="widthFix" />
|
||||
</view>
|
||||
<input @blur="focusCaptchaInput = false" @focus="focusCaptchaInput = true" :focus="focusCaptchaInput" type="digit" class="captcha" :inputBorder="false"
|
||||
maxlength="4" v-model="val" placeholder="请输入验证码" :cursor-spacing="cursorSpacing" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
emits: ["modelValue"],
|
||||
props: {
|
||||
cursorSpacing: {
|
||||
type: Number,
|
||||
default: 100
|
||||
},
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
value: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
scene: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
focus: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
focusCaptchaInput: false,
|
||||
captchaBase64: "" as string,
|
||||
loging: false,
|
||||
val: ""
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
value: {
|
||||
handler(value : string) {
|
||||
// console.log('setvue', value);
|
||||
this.val = value
|
||||
},
|
||||
immediate: true
|
||||
},
|
||||
modelValue: {
|
||||
handler(modelValue : string) {
|
||||
// console.log('setvue', modelValue);
|
||||
this.val = modelValue
|
||||
},
|
||||
immediate: true
|
||||
},
|
||||
scene: {
|
||||
handler(scene : string) {
|
||||
if (scene.length != 0) {
|
||||
this.getImageCaptcha(this.focus)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: 'scene不能为空',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
immediate: true
|
||||
},
|
||||
val(value : string) {
|
||||
// console.log('setvue', value);
|
||||
// TODO 兼容 vue2
|
||||
// #ifdef VUE2
|
||||
this.$emit('input', value);
|
||||
// #endif
|
||||
// TODO 兼容 vue3
|
||||
// #ifdef VUE3
|
||||
this.$emit('update:modelValue', value)
|
||||
// #endif
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setFocus(state:boolean){
|
||||
this.focusCaptchaInput = state
|
||||
},
|
||||
getImageCaptcha(focus : boolean) {
|
||||
this.loging = true
|
||||
if (focus) {
|
||||
this.val = ''
|
||||
this.focusCaptchaInput = true
|
||||
}
|
||||
const uniIdCo = uniCloud.importObject("uni-captcha-co", {
|
||||
customUI: true
|
||||
})
|
||||
uniIdCo.getImageCaptcha({
|
||||
scene: this.scene,
|
||||
isUniAppX:true
|
||||
}).then((result : UTSJSONObject) => {
|
||||
this.captchaBase64 = (result.getString('captchaBase64') as string)
|
||||
})
|
||||
.catch<void>((err : any | null) : void => {
|
||||
const error = err as UniCloudError
|
||||
console.error(error)
|
||||
console.error(error.code)
|
||||
uni.showToast({
|
||||
title: error.message,
|
||||
icon: 'none'
|
||||
});
|
||||
})
|
||||
.finally(()=> {
|
||||
this.loging = false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.captcha-box {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: flex;
|
||||
/* #endif */
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.captcha-img-box,
|
||||
.captcha {
|
||||
height: 44px;
|
||||
}
|
||||
|
||||
.captcha {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.captcha-img-box {
|
||||
position: relative;
|
||||
background-color: #FEFAE7;
|
||||
}
|
||||
|
||||
.captcha {
|
||||
background-color: #F8F8F8;
|
||||
font-size: 14px;
|
||||
flex: 1;
|
||||
padding: 0 20rpx;
|
||||
margin-left: 20rpx;
|
||||
/* #ifndef APP-NVUE */
|
||||
box-sizing: border-box;
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
.captcha-img-box,
|
||||
.captcha-img,
|
||||
.loding {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.captcha-img {
|
||||
/* #ifdef WEB */
|
||||
cursor: pointer;
|
||||
/* #endif */
|
||||
height: 44px;
|
||||
}
|
||||
|
||||
.loding {
|
||||
z-index: 9;
|
||||
position: absolute;
|
||||
width: 30px;
|
||||
margin:7px 35px;
|
||||
}
|
||||
|
||||
.opacity {
|
||||
opacity: 0.5;
|
||||
}
|
||||
</style>
|
167
uni_modules/uni-captcha/components/uni-captcha/uni-captcha.vue
Normal file
167
uni_modules/uni-captcha/components/uni-captcha/uni-captcha.vue
Normal file
@ -0,0 +1,167 @@
|
||||
<template>
|
||||
<view class="captcha-box">
|
||||
<view class="captcha-img-box">
|
||||
<uni-icons class="loding" size="20px" color="#BBB" v-if="loging" type="spinner-cycle"></uni-icons>
|
||||
<image class="captcha-img" :class="{opacity:loging}" @click="getImageCaptcha" :src="captchaBase64"
|
||||
mode="widthFix"></image>
|
||||
</view>
|
||||
<input @blur="focusCaptchaInput = false" :focus="focusCaptchaInput" type="text" class="captcha"
|
||||
:inputBorder="false" maxlength="4" v-model="val" placeholder="请输入验证码">
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
modelValue:String,
|
||||
value:String,
|
||||
scene: {
|
||||
type: String,
|
||||
default () {
|
||||
return ""
|
||||
}
|
||||
},
|
||||
focus: {
|
||||
type: Boolean,
|
||||
default () {
|
||||
return false
|
||||
}
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
val:{
|
||||
get(){
|
||||
return this.value||this.modelValue
|
||||
},
|
||||
set(value){
|
||||
// console.log(value);
|
||||
// TODO 兼容 vue2
|
||||
// #ifdef VUE2
|
||||
this.$emit('input', value);
|
||||
// #endif
|
||||
|
||||
// TODO 兼容 vue3
|
||||
// #ifdef VUE3
|
||||
this.$emit('update:modelValue', value)
|
||||
// #endif
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
focusCaptchaInput: false,
|
||||
captchaBase64: "",
|
||||
loging: false
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
scene: {
|
||||
handler(scene) {
|
||||
if (scene) {
|
||||
this.getImageCaptcha(this.focus)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: 'scene不能为空',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
immediate:true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getImageCaptcha(focus = true) {
|
||||
this.loging = true
|
||||
if (focus) {
|
||||
this.val = ''
|
||||
this.focusCaptchaInput = true
|
||||
}
|
||||
const uniIdCo = uniCloud.importObject("uni-captcha-co", {
|
||||
customUI: true
|
||||
})
|
||||
uniIdCo.getImageCaptcha({
|
||||
scene: this.scene
|
||||
}).then(result => {
|
||||
// console.log(result);
|
||||
this.captchaBase64 = result.captchaBase64
|
||||
})
|
||||
.catch(e => {
|
||||
uni.showToast({
|
||||
title: e.message,
|
||||
icon: 'none'
|
||||
});
|
||||
}).finally(e => {
|
||||
this.loging = false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.captcha-box {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: flex;
|
||||
/* #endif */
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.captcha-img-box,
|
||||
.captcha {
|
||||
height: 44px;
|
||||
line-height: 44px;
|
||||
}
|
||||
|
||||
.captcha-img-box {
|
||||
position: relative;
|
||||
background-color: #FEFAE7;
|
||||
}
|
||||
|
||||
.captcha {
|
||||
background-color: #F8F8F8;
|
||||
font-size: 14px;
|
||||
flex: 1;
|
||||
padding: 0 20rpx;
|
||||
margin-left: 20rpx;
|
||||
/* #ifndef APP-NVUE */
|
||||
box-sizing: border-box;
|
||||
/* #endif */
|
||||
}
|
||||
|
||||
.captcha-img-box,
|
||||
.captcha-img,
|
||||
.loding {
|
||||
height: 44px !important;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.captcha-img{
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.loding {
|
||||
z-index: 9;
|
||||
color: #bbb;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
line-height: 45px;
|
||||
animation: rotate 1s linear infinite;
|
||||
}
|
||||
|
||||
.opacity {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
@keyframes rotate {
|
||||
from {
|
||||
transform: rotate(0deg)
|
||||
}
|
||||
|
||||
to {
|
||||
transform: rotate(360deg)
|
||||
}
|
||||
}
|
||||
</style>
|
@ -0,0 +1,130 @@
|
||||
<template>
|
||||
<uni-popup ref="popup" @clickMask="cancel">
|
||||
<view class="popup-captcha">
|
||||
<view class="content">
|
||||
<text class="title">{{title}}</text>
|
||||
<uni-captcha ref="captcha" :focus="focus" :scene="scene" v-model="val" :cursorSpacing="150"></uni-captcha>
|
||||
</view>
|
||||
<view class="button-box">
|
||||
<text @click="cancel" class="btn cancel">取消</text>
|
||||
<text @click="confirm" class="btn confirm">确认</text>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
let confirmCallBack = ():void=>console.log('未传入回调函数')
|
||||
export default {
|
||||
emits:["modelValue","confirm","cancel"],
|
||||
data() {
|
||||
return {
|
||||
focus: false,
|
||||
val:""
|
||||
}
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
value: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
scene: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: "默认标题"
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
val(val:string) {
|
||||
// console.log(val);
|
||||
// TODO 兼容 vue2
|
||||
// #ifdef VUE2
|
||||
this.$emit('input', val);
|
||||
// #endif
|
||||
|
||||
// TODO 兼容 vue3
|
||||
// #ifdef VUE3
|
||||
this.$emit('update:modelValue', val)
|
||||
// #endif
|
||||
|
||||
if(val.length == 4){
|
||||
this.confirm()
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {},
|
||||
methods: {
|
||||
open(callback: () => void) {
|
||||
// console.log('callback',callback);
|
||||
confirmCallBack = callback;
|
||||
this.focus = true
|
||||
this.val = "";
|
||||
(this.$refs['popup'] as ComponentPublicInstance).$callMethod("open");
|
||||
this.$nextTick(()=>{
|
||||
(this.$refs['captcha'] as ComponentPublicInstance).$callMethod("getImageCaptcha",true);
|
||||
})
|
||||
},
|
||||
close() {
|
||||
this.focus = false;
|
||||
(this.$refs['popup'] as ComponentPublicInstance).$callMethod("close");
|
||||
},
|
||||
cancel(){
|
||||
this.close()
|
||||
this.$emit("cancel")
|
||||
},
|
||||
confirm() {
|
||||
if (this.val.length != 4) {
|
||||
return uni.showToast({
|
||||
title: '请填写验证码',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
this.close()
|
||||
this.$emit('confirm')
|
||||
confirmCallBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.popup-captcha {
|
||||
background-color: #fff;
|
||||
flex-direction: column;
|
||||
width: 600rpx;
|
||||
padding:10px 15px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.popup-captcha .title {
|
||||
text-align: center;
|
||||
font-weight: 700;
|
||||
margin: 5px 0;
|
||||
}
|
||||
.popup-captcha .button-box {
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
margin-top: 5px;
|
||||
}
|
||||
.popup-captcha .button-box .btn {
|
||||
flex: 1;
|
||||
height: 35px;
|
||||
line-height: 35px;
|
||||
text-align: center;
|
||||
}
|
||||
.popup-captcha .button-box .cancel {
|
||||
border: 1px solid #eee;
|
||||
color: #666;
|
||||
}
|
||||
.confirm {
|
||||
background-color: #0070ff;
|
||||
color: #fff;
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,140 @@
|
||||
<template>
|
||||
<uni-popup ref="popup" type="center">
|
||||
<view class="popup-captcha">
|
||||
<view class="content">
|
||||
<text class="title">{{title}}</text>
|
||||
<uni-captcha :focus="focus" :scene="scene" v-model="val"></uni-captcha>
|
||||
</view>
|
||||
<view class="button-box">
|
||||
<view @click="close" class="btn">取消</view>
|
||||
<view @click="confirm" class="btn confirm">确认</view>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
focus: false
|
||||
}
|
||||
},
|
||||
props: {
|
||||
modelValue:String,
|
||||
value:String,
|
||||
scene: {
|
||||
type: String,
|
||||
default () {
|
||||
return ""
|
||||
}
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default () {
|
||||
return ""
|
||||
}
|
||||
},
|
||||
},
|
||||
computed:{
|
||||
val:{
|
||||
get(){
|
||||
return this.value||this.modelValue
|
||||
},
|
||||
set(value){
|
||||
// console.log(value);
|
||||
// TODO 兼容 vue2
|
||||
// #ifdef VUE2
|
||||
this.$emit('input', value);
|
||||
// #endif
|
||||
|
||||
// TODO 兼容 vue3
|
||||
// #ifdef VUE3
|
||||
this.$emit('update:modelValue', value)
|
||||
// #endif
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open() {
|
||||
this.focus = true
|
||||
this.val = ""
|
||||
this.$refs.popup.open()
|
||||
},
|
||||
close() {
|
||||
this.focus = false
|
||||
this.$refs.popup.close()
|
||||
},
|
||||
confirm() {
|
||||
if(!this.val){
|
||||
return uni.showToast({
|
||||
title: '请填写验证码',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
this.close()
|
||||
this.$emit('confirm')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/* #ifndef APP-NVUE */
|
||||
view {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* #endif */
|
||||
.popup-captcha {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: flex;
|
||||
max-width: 600px;
|
||||
/* #endif */
|
||||
width: 600rpx;
|
||||
padding-bottom: 0;
|
||||
background-color: #FFF;
|
||||
border-radius: 10px;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.popup-captcha .content {
|
||||
padding: 1.3em 0.8em;
|
||||
}
|
||||
|
||||
.popup-captcha .title {
|
||||
text-align: center;
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
white-space: pre-wrap;
|
||||
font-weight: 400;
|
||||
font-size: 18px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #111;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.button-box {
|
||||
height: 44px;
|
||||
border-top: solid 1px #eee;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-around;
|
||||
}
|
||||
.button-box ,.btn{
|
||||
height: 44px;
|
||||
line-height: 44px;
|
||||
}
|
||||
.button-box .btn{
|
||||
flex: 1;
|
||||
margin: 1px;
|
||||
text-align: center;
|
||||
}
|
||||
.button-box .confirm{
|
||||
color: #007aff;
|
||||
border-left: solid 1px #eee;
|
||||
}
|
||||
</style>
|
83
uni_modules/uni-captcha/package.json
Normal file
83
uni_modules/uni-captcha/package.json
Normal file
@ -0,0 +1,83 @@
|
||||
{
|
||||
"id": "uni-captcha",
|
||||
"displayName": "uni-captcha",
|
||||
"version": "0.7.5",
|
||||
"description": "云端一体图形验证码组件",
|
||||
"keywords": [
|
||||
"captcha",
|
||||
"图形验证码",
|
||||
"人机验证",
|
||||
"防刷",
|
||||
"防脚本"
|
||||
],
|
||||
"repository": "https://gitee.com/dcloud/uni-captcha",
|
||||
"engines": {
|
||||
"HBuilderX": "^3.1.0"
|
||||
},
|
||||
"dcloudext": {
|
||||
"sale": {
|
||||
"regular": {
|
||||
"price": "0.00"
|
||||
},
|
||||
"sourcecode": {
|
||||
"price": "0.00"
|
||||
}
|
||||
},
|
||||
"contact": {
|
||||
"qq": ""
|
||||
},
|
||||
"declaration": {
|
||||
"ads": "无",
|
||||
"data": "无",
|
||||
"permissions": "无"
|
||||
},
|
||||
"npmurl": "",
|
||||
"type": "unicloud-template-function"
|
||||
},
|
||||
"uni_modules": {
|
||||
"dependencies": [
|
||||
"uni-popup"
|
||||
],
|
||||
"encrypt": [],
|
||||
"platforms": {
|
||||
"cloud": {
|
||||
"tcb": "y",
|
||||
"aliyun": "y"
|
||||
},
|
||||
"client": {
|
||||
"App": {
|
||||
"app-vue": "u",
|
||||
"app-nvue": "u"
|
||||
},
|
||||
"H5-mobile": {
|
||||
"Safari": "u",
|
||||
"Android Browser": "u",
|
||||
"微信浏览器(Android)": "u",
|
||||
"QQ浏览器(Android)": "u"
|
||||
},
|
||||
"H5-pc": {
|
||||
"Chrome": "u",
|
||||
"IE": "u",
|
||||
"Edge": "u",
|
||||
"Firefox": "u",
|
||||
"Safari": "u"
|
||||
},
|
||||
"小程序": {
|
||||
"微信": "u",
|
||||
"阿里": "u",
|
||||
"百度": "u",
|
||||
"字节跳动": "u",
|
||||
"QQ": "u"
|
||||
},
|
||||
"快应用": {
|
||||
"华为": "u",
|
||||
"联盟": "u"
|
||||
},
|
||||
"Vue": {
|
||||
"vue2": "y",
|
||||
"vue3": "u"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
3
uni_modules/uni-captcha/readme.md
Normal file
3
uni_modules/uni-captcha/readme.md
Normal file
@ -0,0 +1,3 @@
|
||||
<h2>
|
||||
文档已移至 <a href="https://uniapp.dcloud.io/uniCloud/uni-captcha.html" target="_blank">uni-captcha文档</a>
|
||||
</h2>
|
BIN
uni_modules/uni-captcha/static/run.gif
Normal file
BIN
uni_modules/uni-captcha/static/run.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
Binary file not shown.
File diff suppressed because one or more lines are too long
@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "uni-captcha",
|
||||
"version": "0.7.0",
|
||||
"description": "uni-captcha",
|
||||
"main": "index.js",
|
||||
"homepage": "https://ext.dcloud.net.cn/plugin?id=4048",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://gitee.com/dcloud/uni-captcha"
|
||||
},
|
||||
"author": "DCloud",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"uni-config-center": "file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
"image-captcha":{
|
||||
"width": 150, //图片宽度
|
||||
"height": 44, //图片高度
|
||||
"background": "#FFFAE8", //验证码背景色,设置空字符`''`不使用背景颜色
|
||||
// "size": 4, //验证码长度,最多 6 个字符
|
||||
// "noise": 4, //验证码干扰线条数
|
||||
// "color": false, //字体是否使用随机颜色,当设置`background`后恒为`true`
|
||||
// "fontSize": 40, //字体大小
|
||||
// "ignoreChars": '', //忽略那些字符
|
||||
// "mathExpr": false, //是否使用数学表达式
|
||||
// "mathMin": 1, //表达式所使用的最小数字
|
||||
// "mathMax": 9, //表达式所使用的最大数字
|
||||
// "mathOperator": '' //表达式所使用的运算符,支持 `+`、`-`。不传随机使用
|
||||
// "expiresDate":180 //验证码过期时间(s)
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
// 开发文档: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj
|
||||
//导入验证码公共模块
|
||||
const uniCaptcha = require('uni-captcha')
|
||||
//获取数据库对象
|
||||
const db = uniCloud.database();
|
||||
//获取数据表opendb-verify-codes对象
|
||||
const verifyCodes = db.collection('opendb-verify-codes')
|
||||
module.exports = {
|
||||
async getImageCaptcha({
|
||||
scene,isUniAppX
|
||||
}) {
|
||||
//获取设备id
|
||||
let {
|
||||
deviceId,
|
||||
platform
|
||||
} = this.getClientInfo();
|
||||
//根据:设备id、场景值、状态,查找记录是否存在
|
||||
let res = await verifyCodes.where({
|
||||
scene,
|
||||
deviceId,
|
||||
state: 0
|
||||
}).limit(1).get()
|
||||
//如果已存在则调用刷新接口,反之调用插件接口
|
||||
let action = res.data.length ? 'refresh' : 'create'
|
||||
//执行并返回结果
|
||||
let option = {
|
||||
scene, //来源客户端传递,表示:使用场景值,用于防止不同功能的验证码混用
|
||||
uniPlatform: platform
|
||||
}
|
||||
if(isUniAppX){
|
||||
option.mode = "bmp"
|
||||
}
|
||||
return await uniCaptcha[action](option)
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "uni-captcha-co",
|
||||
"dependencies": {
|
||||
"uni-captcha": "file:../common/uni-captcha",
|
||||
"uni-config-center": "file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
|
||||
},
|
||||
"extensions": {
|
||||
"uni-cloud-jql": {}
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
{
|
||||
"bsonType": "object",
|
||||
"properties": {
|
||||
"_id": {
|
||||
"description": "ID,系统自动生成"
|
||||
},
|
||||
"code": {
|
||||
"bsonType": "string",
|
||||
"description": "验证码"
|
||||
},
|
||||
"create_date": {
|
||||
"bsonType": "timestamp",
|
||||
"description": "创建时间"
|
||||
},
|
||||
"device_uuid": {
|
||||
"bsonType": "string",
|
||||
"description": "设备UUID,常用于图片验证码"
|
||||
},
|
||||
"email": {
|
||||
"bsonType": "string",
|
||||
"description": "邮箱"
|
||||
},
|
||||
"expired_date": {
|
||||
"bsonType": "timestamp",
|
||||
"description": "过期时间"
|
||||
},
|
||||
"ip": {
|
||||
"bsonType": "string",
|
||||
"description": "请求时客户端IP地址"
|
||||
},
|
||||
"mobile": {
|
||||
"bsonType": "string",
|
||||
"description": "手机号码"
|
||||
},
|
||||
"scene": {
|
||||
"bsonType": "string",
|
||||
"description": "使用验证码的场景,如:login, bind, unbind, pay"
|
||||
},
|
||||
"state": {
|
||||
"bsonType": "int",
|
||||
"description": "验证状态:0 未验证、1 已验证、2 已作废"
|
||||
}
|
||||
},
|
||||
"required": []
|
||||
}
|
Reference in New Issue
Block a user