刷卡检测转码

<el-input
ref=“inputDom”
v-model=“card_id”
@input=“changeEnrollId”
@clear=“clear”
clearable
style=“width: 250px; height: 36px”
>

let time
let timeDown // 停止输入
let length = ref(0)
const lock = ref(true) // 避免在转码这个过程中再次触发card_id.value.length > length.value
const changeEnrollId = () => {
if (card_id.value.length == 0) {
// 手动删除完毕时重置状态,此处判断为==1也可,为一表示在输入框为空时刷卡
length.value = 0
lock.value = true
}
clearTimeout(time)
time = setTimeout(() => {
length.value++
}, 100)
clearTimeout(timeDown)
timeDown = setTimeout(() => {
if (!lock.value) return
if (card_id.value.length > length.value) {
let aa = eval(Number(card_id.value) + ‘n’).toString(16)
let cardHex = aa.toUpperCase()
while (cardHex.length < 8) {
cardHex = ‘0’ + cardHex
}
let card_NO =
cardHex.substring(6, 8) +
cardHex.substring(4, 6) +
cardHex.substring(2, 4) +
cardHex.substring(0, 2)
length.value = 0
lock.value = false
card_id.value = card_NO
queryFund()
}
}, 180)
}

// 清空
const clear = () => {
console.log(‘触发clear’)
lock.value = true
length.value = 0
enroll_id.value = ‘’
cardData.user_name = ‘’
cardData.class_name = ‘’
cardData.money = ‘’
console.log(card_id.value, ‘clear’)
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值