- 新增商家/信息详情页电话拨打接口,支持每日额度限制与拨打日志记录 - 新增平台免责声明内容及协议接口,完善用户服务协议相关配置 - 新增农产品分类图标与上市角标展示,优化分类管理界面样式 - 新增全国行政区划工具类与城市选择组件,重构地区数据结构 - 新增SSH自检与部署脚本,完善项目部署流程
229 行
5.0 KiB
Vue
229 行
5.0 KiB
Vue
<template>
|
||
<view v-if="show" class="payswd" @touchmove.stop.prevent>
|
||
<view class="payswd__mask" @click="cancel" @touchmove.stop.prevent />
|
||
<view class="payswd__panel">
|
||
<view class="payswd__head">
|
||
<text class="payswd__title">{{ title }}</text>
|
||
<view v-if="closable" class="payswd__close" @click="cancel">
|
||
<text class="payswd__close-x">×</text>
|
||
</view>
|
||
</view>
|
||
<text v-if="tip" class="payswd__tip">{{ tip }}</text>
|
||
<view class="payswd__dots" @click="focusInput">
|
||
<view v-for="i in 6" :key="i" class="payswd__dot-cell">
|
||
<view v-if="pwd.length >= i" class="payswd__dot" />
|
||
<view v-else-if="pwd.length === i - 1" class="payswd__cursor" />
|
||
</view>
|
||
<!-- 透明输入框覆盖在密码格上,直接调起数字键盘 -->
|
||
<input class="payswd__input" type="number" :value="pwd" :focus="focused"
|
||
:maxlength="6" :adjust-position="false" @input="onInput" @blur="focused = false" />
|
||
</view>
|
||
<view class="payswd__actions">
|
||
<view class="payswd__btn payswd__btn--ghost" @click="cancel">
|
||
<text>取消</text>
|
||
</view>
|
||
<view class="payswd__btn payswd__btn--primary" :class="{ 'payswd__btn--disabled': pwd.length !== 6 }"
|
||
@click="confirm">
|
||
<text>{{ confirmText }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
/**
|
||
* 支付密码弹窗(6 位数字)
|
||
* 用法:
|
||
* <fc-pay-password :show="show" title="请输入支付密码" @close="show=false" @confirm="onPwd" />
|
||
* 事件:confirm(password);close(取消/关闭)
|
||
*/
|
||
export default {
|
||
name: 'FcPayPassword',
|
||
props: {
|
||
show: { type: Boolean, default: false },
|
||
title: { type: String, default: '请输入支付密码' },
|
||
tip: { type: String, default: '' },
|
||
confirmText: { type: String, default: '确认' },
|
||
/** 是否显示右上角关闭按钮(涉及资金安全时建议仅保留「取消」) */
|
||
closable: { type: Boolean, default: false },
|
||
},
|
||
data() {
|
||
return {
|
||
pwd: '',
|
||
focused: false,
|
||
}
|
||
},
|
||
watch: {
|
||
show(v) {
|
||
if (v) {
|
||
this.pwd = ''
|
||
this.focused = false
|
||
// 延迟聚焦:等弹窗渲染完成,避免部分机型不弹键盘
|
||
this.$nextTick(() => {
|
||
setTimeout(() => {
|
||
this.focused = true
|
||
}, 150)
|
||
})
|
||
}
|
||
},
|
||
},
|
||
methods: {
|
||
focusInput() {
|
||
this.focused = false
|
||
this.$nextTick(() => {
|
||
this.focused = true
|
||
})
|
||
},
|
||
onInput(e) {
|
||
// 仅保留数字,最多 6 位
|
||
const val = String(e.detail.value || '').replace(/\D/g, '').slice(0, 6)
|
||
if (val !== e.detail.value) {
|
||
// 强制回写,防止非数字字符残留
|
||
this.$nextTick(() => {
|
||
this.pwd = val
|
||
})
|
||
return
|
||
}
|
||
this.pwd = val
|
||
// 输满 6 位自动确认,减少一步操作
|
||
if (val.length === 6) {
|
||
this.confirm()
|
||
}
|
||
},
|
||
confirm() {
|
||
if (this.pwd.length !== 6) return
|
||
this.focused = false
|
||
this.$emit('confirm', this.pwd)
|
||
},
|
||
cancel() {
|
||
this.focused = false
|
||
this.$emit('close')
|
||
},
|
||
},
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.payswd {
|
||
position: fixed;
|
||
inset: 0;
|
||
z-index: 9999;
|
||
}
|
||
.payswd__mask {
|
||
position: absolute;
|
||
inset: 0;
|
||
background: rgba(15, 23, 42, 0.5);
|
||
}
|
||
.payswd__panel {
|
||
position: absolute;
|
||
left: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
background: #ffffff;
|
||
border-radius: 32rpx 32rpx 0 0;
|
||
padding: 40rpx 40rpx calc(40rpx + env(safe-area-inset-bottom));
|
||
}
|
||
.payswd__head {
|
||
position: relative;
|
||
display: flex;
|
||
justify-content: center;
|
||
}
|
||
.payswd__title {
|
||
font-size: 32rpx;
|
||
font-weight: 700;
|
||
color: #1e293b;
|
||
}
|
||
.payswd__close {
|
||
position: absolute;
|
||
right: 0;
|
||
top: -8rpx;
|
||
width: 48rpx;
|
||
height: 48rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
.payswd__close-x {
|
||
font-size: 40rpx;
|
||
color: #94a3b8;
|
||
line-height: 1;
|
||
}
|
||
.payswd__tip {
|
||
display: block;
|
||
margin-top: 12rpx;
|
||
text-align: center;
|
||
font-size: 24rpx;
|
||
color: #64748b;
|
||
}
|
||
.payswd__dots {
|
||
position: relative;
|
||
margin-top: 40rpx;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
}
|
||
.payswd__dot-cell {
|
||
position: relative;
|
||
width: 96rpx;
|
||
height: 104rpx;
|
||
border: 2rpx solid #e2e8f0;
|
||
border-radius: 16rpx;
|
||
background: #f8fafc;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
.payswd__dot {
|
||
width: 24rpx;
|
||
height: 24rpx;
|
||
border-radius: 50%;
|
||
background: #1e293b;
|
||
}
|
||
.payswd__cursor {
|
||
width: 4rpx;
|
||
height: 44rpx;
|
||
border-radius: 2rpx;
|
||
background: #00a854;
|
||
animation: payswd-blink 1s step-end infinite;
|
||
}
|
||
@keyframes payswd-blink {
|
||
0%, 100% { opacity: 1; }
|
||
50% { opacity: 0; }
|
||
}
|
||
.payswd__input {
|
||
position: absolute;
|
||
inset: 0;
|
||
width: 100%;
|
||
height: 100%;
|
||
opacity: 0;
|
||
z-index: 2;
|
||
}
|
||
.payswd__actions {
|
||
margin-top: 48rpx;
|
||
display: flex;
|
||
gap: 24rpx;
|
||
}
|
||
.payswd__btn {
|
||
flex: 1;
|
||
height: 88rpx;
|
||
border-radius: 44rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
font-size: 30rpx;
|
||
font-weight: 600;
|
||
}
|
||
.payswd__btn--ghost {
|
||
background: #f2fef7;
|
||
color: #334155;
|
||
}
|
||
.payswd__btn--primary {
|
||
background: linear-gradient(135deg, #00d26a, #00e070);
|
||
color: #06301e;
|
||
box-shadow: 0 10rpx 28rpx rgba(0, 210, 106, 0.25);
|
||
}
|
||
.payswd__btn--disabled {
|
||
opacity: 0.5;
|
||
}
|
||
</style>
|