<template>
|
<view>
|
<view v-if="modelValue" class="popup-mask" @tap="close" />
|
<view v-if="modelValue" class="popup-container" :class="{ show: modelValue }">
|
<view class="popup-header">
|
<text class="popup-title">实名信息确认</text>
|
<view class="close-btn" @tap="close">
|
<u-icon name="close" color="#999" size="20" />
|
</view>
|
</view>
|
|
<view class="popup-body">
|
<view class="signature-box">
|
<Signature ref="signatureRef" v-model="localSignature" />
|
</view>
|
<button class="sign-btn" @tap="generateSignature" type="primary" plain size="mini">
|
生成签名
|
</button>
|
</view>
|
|
<view class="popup-footer">
|
<button class="cancel-btn" @tap="close" :disabled="loading">取消</button>
|
<button class="submit-btn" type="primary" :loading="loading" :disabled="!localSignature" @tap="submit">
|
提交
|
</button>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import Signature from '@/components/sin-signature/index.vue'
|
|
export default {
|
name: 'SignPopup',
|
components: { Signature },
|
props: {
|
modelValue: {
|
type: Boolean,
|
default: false
|
},
|
signature: {
|
type: String,
|
default: ''
|
},
|
loading: {
|
type: Boolean,
|
default: false
|
}
|
},
|
data() {
|
return {
|
localSignature: ''
|
}
|
},
|
watch: {
|
modelValue(val) {
|
if (val) this.localSignature = this.signature
|
}
|
},
|
methods: {
|
close() {
|
if (this.loading) return
|
this.$emit('update:modelValue', false)
|
},
|
async generateSignature() {
|
try {
|
const data = await this.$refs.signatureRef.getSyncSignature()
|
this.localSignature = data
|
this.$emit('update:signature', data)
|
uni.showToast({ title: '签名已生成', icon: 'success' })
|
} catch (err) {
|
uni.showToast({ title: '签名生成失败', icon: 'none' })
|
}
|
},
|
submit() {
|
if (!this.localSignature) {
|
return uni.showToast({ title: '请先生成签名', icon: 'none' })
|
}
|
this.$emit('update:signature', this.localSignature)
|
this.$emit('submit')
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.popup-mask {
|
position: fixed;
|
top: 0;
|
left: 0;
|
right: 0;
|
bottom: 0;
|
background-color: rgba(0, 0, 0, 0.5);
|
z-index: 998;
|
}
|
|
.popup-container {
|
position: fixed;
|
left: 0;
|
right: 0;
|
bottom: 0;
|
background-color: #ffffff;
|
border-top-left-radius: 20rpx;
|
border-top-right-radius: 20rpx;
|
z-index: 999;
|
padding: 30rpx;
|
box-sizing: border-box;
|
transform: translateY(100%);
|
transition: transform 0.3s ease-out;
|
max-height: 90vh;
|
display: flex;
|
flex-direction: column;
|
}
|
|
.popup-container.show {
|
transform: translateY(0);
|
}
|
|
.popup-header {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
margin-bottom: 30rpx;
|
padding-bottom: 20rpx;
|
border-bottom: 1rpx solid #f0f0f0;
|
}
|
|
.popup-title {
|
flex: 1;
|
font-size: 34rpx;
|
color: #333;
|
font-weight: 600;
|
text-align: center;
|
}
|
|
.close-btn {
|
width: 60rpx;
|
height: 60rpx;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
}
|
|
.popup-body {
|
flex: 1;
|
overflow-y: auto;
|
padding: 10rpx 0;
|
}
|
|
.signature-box {
|
width: 100%;
|
height: 400rpx;
|
border: 2rpx dashed #555;
|
border-radius: 8rpx;
|
overflow: hidden;
|
}
|
|
.sign-btn {
|
margin-top: 20rpx;
|
width: 200rpx;
|
}
|
|
.popup-footer {
|
display: flex;
|
gap: 20rpx;
|
margin-top: 30rpx;
|
padding-top: 20rpx;
|
border-top: 1rpx solid #f0f0f0;
|
}
|
|
.popup-footer .cancel-btn,
|
.popup-footer .submit-btn {
|
flex: 1;
|
height: 90rpx;
|
line-height: 90rpx;
|
font-size: 32rpx;
|
border-radius: 8rpx;
|
border: none;
|
}
|
|
.popup-footer .cancel-btn {
|
color: #666;
|
background-color: #f5f5f5;
|
}
|
|
.popup-footer .submit-btn {
|
color: #fff;
|
background-color: #1677ff;
|
}
|
|
.popup-footer .submit-btn[disabled] {
|
background-color: #c9d8e9;
|
opacity: 0.7;
|
}
|
</style>
|