ykt-team-wxapp/pages/archive/verify-name-popup.vue

141 lines
3.4 KiB
Vue
Raw Permalink Normal View History

2026-05-08 16:57:16 +08:00
<template>
<uni-popup ref="popup" type="center" :mask-click="false">
<view class="bg-white rounded overflow-hidden" style="width: 690rpx;">
<view class="flex items-center justify-between px-15 py-12 border-b">
<view class="text-lg font-semibold text-dark">校验姓名</view>
<uni-icons type="closeempty" :size="24" color="#999" @click="close"></uni-icons>
</view>
<view class="px-15 pt-15 text-base text-dark">
请输入所选档案的姓名进行验证
</view>
2026-05-15 15:38:48 +08:00
<view class="px-15 py-12 flex items-center justify-center">
<view class="text-xl font-semibold text-dark">{{ nameSet.pre }}</view>
<view v-if="nameSet.middle" class="text-xl font-semibold text-dark">{{ nameSet.middle }}</view>
2026-05-29 12:06:00 +08:00
<!-- <view class="input-name border rounded-sm text-xl font-semibold text-dark text-center">
{{ firstInputName }} -->
<input v-model="inputName" :focus="focus" class="input-name text-xl font-semibold text-dark"
placeholder-class="text-lg font-semibold placeholder-class" />
<!-- </view> -->
2026-05-08 16:57:16 +08:00
</view>
<view class="pb-15">
<button-footer hideden-shadow confirmText="确定" @cancel="close" @confirm="confirm()" />
</view>
</view>
</uni-popup>
</template>
<script setup>
2026-05-15 15:38:48 +08:00
import { computed, ref, watch, nextTick } from 'vue';
2026-05-08 16:57:16 +08:00
import { toast } from '@/utils/widget';
import ButtonFooter from '@/components/button-footer.vue';
const emits = defineEmits(['close', 'confirm'])
const props = defineProps({
visible: {
type: Boolean,
default: false
},
customer: {
type: Object,
default: () => ({})
}
})
const popup = ref()
const inputName = ref('')
2026-05-15 15:38:48 +08:00
const focus = ref(false)
2026-05-29 12:06:00 +08:00
const firstInputName = computed(() => inputName.value.trim()[0] || '')
2026-05-15 15:38:48 +08:00
const placeholder = computed(() => '请输入姓名' + (props.customer.maskName ? `(${props.customer.maskName})` : ''));
const nameSet = computed(() => {
const name = props.customer && typeof props.customer.name === 'string' ? props.customer.name.trim() : ''
const pre = name.slice(0, -1);
const middle = pre.slice(4);
const last = name.slice(-1);
return { pre, middle: middle ? '*' : '', last: last ? '*' : '', last }
})
2026-05-08 16:57:16 +08:00
function close() {
emits('close')
}
function confirm() {
const trimmedName = inputName.value.trim()
if (!trimmedName) {
2026-05-15 15:38:48 +08:00
toast('请输入姓名最后一个字')
2026-05-08 16:57:16 +08:00
return
}
2026-05-15 15:38:48 +08:00
if (trimmedName && trimmedName === nameSet.value.last) {
2026-05-08 16:57:16 +08:00
emits('confirm')
close()
} else {
toast('姓名不一致,请重新输入')
}
}
watch(() => props.visible, n => {
if (n) {
inputName.value = ''
2026-05-15 15:38:48 +08:00
popup.value && popup.value.open();
nextTick(() => {
focus.value = true
})
2026-05-08 16:57:16 +08:00
} else {
popup.value && popup.value.close()
2026-05-15 15:38:48 +08:00
focus.value = false
2026-05-08 16:57:16 +08:00
}
})
</script>
<style lang="scss" scoped>
.input-name {
2026-05-29 12:06:00 +08:00
position: relative;
2026-05-15 15:38:48 +08:00
border: 1px solid #eee;
2026-05-08 16:57:16 +08:00
border-radius: 8rpx;
2026-05-15 15:38:48 +08:00
margin-left: 8rpx;
width: 64rpx;
height: 64rpx;
line-height: 60rpx;
text-align: center;
2026-05-08 16:57:16 +08:00
}
2026-05-29 12:06:00 +08:00
.input-name-enter {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
}
2026-05-08 16:57:16 +08:00
.placeholder-class {
color: #999;
}
.btn {
flex: 1;
height: 80rpx;
line-height: 80rpx;
text-align: center;
border-radius: 8rpx;
2026-05-26 11:27:23 +08:00
font-size: 30rpx;
2026-05-08 16:57:16 +08:00
}
.btn-cancel {
margin-right: 20rpx;
color: #666;
background-color: #f5f5f5;
}
.btn-confirm {
color: #fff;
background-color: #1890ff;
}
2026-05-15 15:38:48 +08:00
.leading-1 {
line-height: 1em;
}
2026-05-08 16:57:16 +08:00
</style>