huangye-parking/miniapp/components/QrcodePopup.vue
2026-02-28 17:35:49 +08:00

92 lines
1.7 KiB
Vue

<template>
<view class="popup-mask" v-if="visible" @click.self="close">
<view class="popup-content">
<view class="popup-title">优惠券二维码</view>
<view class="qrcode-area">
<!-- 使用 canvas 绘制二维码,实际项目中可引入 uQRCode 等库 -->
<canvas canvas-id="qrcode" class="qrcode-canvas"></canvas>
<text class="coupon-code">{{ code }}</text>
</view>
<view class="popup-tip">请将二维码出示给商户扫码核销</view>
<button class="btn-close" @click="close">关闭</button>
</view>
</view>
</template>
<script>
export default {
name: 'QrcodePopup',
props: {
visible: {
type: Boolean,
default: false
},
code: {
type: String,
default: ''
}
},
emits: ['close', 'verified', 'verifyFailed'],
methods: {
close() {
this.$emit('close')
}
}
}
</script>
<style scoped>
.popup-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 999;
}
.popup-content {
background: #fff;
border-radius: 24rpx;
padding: 40rpx;
width: 560rpx;
text-align: center;
}
.popup-title {
font-size: 34rpx;
font-weight: bold;
color: #333;
margin-bottom: 30rpx;
}
.qrcode-area {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 20rpx;
}
.qrcode-canvas {
width: 400rpx;
height: 400rpx;
}
.coupon-code {
font-size: 28rpx;
color: #666;
margin-top: 16rpx;
letter-spacing: 4rpx;
}
.popup-tip {
font-size: 24rpx;
color: #999;
margin-bottom: 30rpx;
}
.btn-close {
background: #f5f5f5;
color: #666;
border-radius: 8rpx;
font-size: 28rpx;
}
</style>