Commit cf860148 by 张立顺

feat:验证码组件开发

1 parent 5e662259
......@@ -27,7 +27,7 @@
"js-md5": "^0.7.3",
"lodash": "^4.17.11",
"lowdb": "^1.0.0",
"moment": "^2.29.1",
"moment": "^2.29.3",
"nprogress": "^0.2.0",
"qs": "^6.8.0",
"screenfull": "^4.2.0",
......
......@@ -37,6 +37,7 @@ export function getServicerefApi(data) {
return request(data)
}
/** 服务商查询 */
export function getServiceListApi(data) {
data.method = `${path2}goodsOrderProfitAllocation.page.bySubOrder`
return request(data)
......
<template>
<div class="row-center captcha_input_wrapper">
<input v-for="(item,index) in captchas"
:key="index"
v-model="item.num"
:id="'captcha'+index"
@input="inputFinash(index)"
@focus="adjust(index)"
@keydown="inputDirection(index)"
class="captcha_input_box row-center"
:style="customStyle"
type="tel"
maxlength="1" />
</div>
</template>
<script>
export default {
props: {
customStyle: {
type: String,
required: false,
default: ''
},
Number: {
type: Number,
required: false,
default: 4
},
captchaList: {
type: Object,
required: true
}
},
data() {
return {
// 当前输入框
activeInput: 0,
item: { num: '' },
captchas: [
{ num: '' },
{ num: '' },
{ num: '' },
{ num: '' },
{ num: '' },
{ num: '' }
]
}
},
watch: {
'captchas': {
handler: function (value) {
console.log(value)
this.$emit('update:captchaList', value)
},
deep: true
}
},
computed: {
test() {
return new Array(this.Number)
// return list.map((item) => {
// item = this.item
// return item
// })
}
},
methods: {
// 自动校准输入顺序
adjust(index) {
const dom = document.getElementById('captcha' + this.activeInput)
if (index !== this.activeInput && dom) {
dom.focus()
}
},
// 控制前后方向
inputDirection(index) {
const val = this.captchas[index].num
// debugger
console.log(event.keyCode)
// 回退键处理
if (event.keyCode == 8 && val == '') {
console.log(index)
// 重新校准
const dom = document.getElementById('captcha' + (index - 1))
this.activeInput = index == 0 ? 0 : index - 1
if (dom) dom.focus()
}
if (event.keyCode != 8 && val != '') {
const dom = document.getElementById('captcha' + (index + 1))
this.activeInput = index + 1
if (dom) dom.focus()
}
},
// 输入框相互联动
inputFinash(index) {
const val = this.captchas[index].num
this.activeInput = val ? index + 1 : index - 1
const dom = document.getElementById('captcha' + this.activeInput)
if (dom) dom.focus()
if (index == this.captchas.length - 1) {
const code = this.captchas.map((x) => x.num).join('')
if (code.length == 6) {
this.$emit('finish', code)
}
}
}
}
}
</script>
<style lang='scss'>
.row-center {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.captcha_input_wrapper {
width: 100%;
}
.captcha_input_box {
width: 48px;
height: 60px;
margin-right: 12px;
background: rgba(255, 255, 255, 1);
border-radius: 6px;
border: 1px solid #dddddd;
font-size: 40px;
text-align: center;
color: #1e243a;
}
</style>
......@@ -406,6 +406,13 @@
<download-account-dialog :accountVisible="accountVisible"
v-if="accountVisible"
@accountClose="accountClose"></download-account-dialog>
<!-- <el-drawer
title="我是标题"
:visible.sync="drawer"
:direction="direction"
:before-close="handleClose">
<span>我来啦!</span>
</el-drawer> -->
</div>
</template>
......
<!-- 服务商 = 财务列表 -->
<template>
<div class="service_finance_list">
<captchaInput captchaList.sync="captchaList"></captchaInput>
<div v-show="!isSingle"
class="header"
slot="header"
......@@ -261,6 +262,7 @@
<script>
import moment from 'moment'
import serviceDetailDialog from './serviceDetailDialog'
import captchaInput from './components/captchaInput'
import { getServiceListApi, exportFile, getListTotal, getServicerefApi, getServiceSummaryApi } from '@api/finance'
import { getPartnerYqListApi } from '@/api/account'
import { getServiceStore } from '@api/editCustomer'
......@@ -271,6 +273,7 @@ export default {
name: 'serviceFinanceList',
data() {
return {
captchaList: [{ num: '' }, { num: '' }, { num: '' }, { num: '' }],
userInfo: this.$store.state.d2admin.user.info,
// 单店或多店
isSingle: true,
......@@ -429,7 +432,8 @@ export default {
},
components: {
serviceDetailDialog
serviceDetailDialog,
captchaInput
},
mounted() {
......
......@@ -6657,10 +6657,10 @@ mkdirp@0.5.1, mkdirp@0.5.x, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@~0.5.1:
dependencies:
minimist "0.0.8"
moment@^2.29.1:
version "2.29.1"
resolved "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz"
integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==
moment@^2.29.3:
version "2.29.3"
resolved "https://registry.npmmirror.com/moment/-/moment-2.29.3.tgz#edd47411c322413999f7a5940d526de183c031f3"
integrity sha512-c6YRvhEo//6T2Jz/vVtYzqBzwvPT95JBQ+smCytzf7c50oMZRsR/a4w88aD34I+/QVSfnoAnSBFPJHItlOMJVw==
move-concurrently@^1.0.1:
version "1.0.1"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!