213 lines
3.9 KiB
Vue
213 lines
3.9 KiB
Vue
|
|
<template>
|
|||
|
|
<view v-if="visible" class="modal-overlay" @click="handleOverlayClick">
|
|||
|
|
<view class="modal-content" @click.stop>
|
|||
|
|
<!-- 关闭按钮 -->
|
|||
|
|
<view class="close-btn" @click="handleClose">
|
|||
|
|
<text class="close-icon">×</text>
|
|||
|
|
</view>
|
|||
|
|
|
|||
|
|
<!-- 二维码卡片 -->
|
|||
|
|
<view class="qrcode-card">
|
|||
|
|
<!-- 标题 -->
|
|||
|
|
<view class="card-title">
|
|||
|
|
<text class="title-text">{{ title }}</text>
|
|||
|
|
</view>
|
|||
|
|
|
|||
|
|
<!-- 二维码 -->
|
|||
|
|
<view class="qrcode-container">
|
|||
|
|
<uv-qrcode
|
|||
|
|
ref="qrcode"
|
|||
|
|
:value="value"
|
|||
|
|
:options="qrcodeOptions"
|
|||
|
|
canvas-id="modal-qrcode"
|
|||
|
|
size="400rpx"
|
|||
|
|
></uv-qrcode>
|
|||
|
|
</view>
|
|||
|
|
|
|||
|
|
<!-- 票号信息 -->
|
|||
|
|
<view class="ticket-info">
|
|||
|
|
<text class="ticket-label">票号:</text>
|
|||
|
|
<text class="ticket-number">{{ ticketNumber }}</text>
|
|||
|
|
</view>
|
|||
|
|
|
|||
|
|
<!-- 提示文字 -->
|
|||
|
|
<view class="tip-text">
|
|||
|
|
<text>此二维码可直接检票</text>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</view>
|
|||
|
|
</template>
|
|||
|
|
|
|||
|
|
<script>
|
|||
|
|
import UvQrcode from "../uni_modules/uv-qrcode/components/uv-qrcode/uv-qrcode.vue";
|
|||
|
|
|
|||
|
|
export default {
|
|||
|
|
name: "QRCodeModal",
|
|||
|
|
components: { UvQrcode },
|
|||
|
|
props: {
|
|||
|
|
// 是否显示弹窗
|
|||
|
|
visible: {
|
|||
|
|
type: Boolean,
|
|||
|
|
default: false
|
|||
|
|
},
|
|||
|
|
// 二维码内容
|
|||
|
|
value: {
|
|||
|
|
type: String,
|
|||
|
|
default: ""
|
|||
|
|
},
|
|||
|
|
// 标题
|
|||
|
|
title: {
|
|||
|
|
type: String,
|
|||
|
|
default: "预约详情"
|
|||
|
|
},
|
|||
|
|
// 票号
|
|||
|
|
ticketNumber: {
|
|||
|
|
type: String,
|
|||
|
|
default: ""
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
qrcodeOptions: {
|
|||
|
|
errorCorrectLevel: "Q",
|
|||
|
|
margin: 10,
|
|||
|
|
areaColor: "#fff"
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
},
|
|||
|
|
watch: {
|
|||
|
|
visible(newVal) {
|
|||
|
|
if (newVal) {
|
|||
|
|
this.$nextTick(() => {
|
|||
|
|
this.generateQRCode();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
// 生成二维码
|
|||
|
|
generateQRCode() {
|
|||
|
|
if (this.$refs.qrcode) {
|
|||
|
|
this.$refs.qrcode.remake({
|
|||
|
|
success: () => {
|
|||
|
|
console.log("二维码生成成功");
|
|||
|
|
},
|
|||
|
|
fail: (err) => {
|
|||
|
|
console.error("二维码生成失败:", err);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
// 关闭弹窗
|
|||
|
|
handleClose() {
|
|||
|
|
this.$emit("close");
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
// 点击遮罩层
|
|||
|
|
handleOverlayClick() {
|
|||
|
|
this.handleClose();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
</script>
|
|||
|
|
|
|||
|
|
<style lang="scss" scoped>
|
|||
|
|
.modal-overlay {
|
|||
|
|
position: fixed;
|
|||
|
|
top: 0;
|
|||
|
|
left: 0;
|
|||
|
|
right: 0;
|
|||
|
|
bottom: 0;
|
|||
|
|
background-color: rgba(0, 0, 0, 0.5);
|
|||
|
|
display: flex;
|
|||
|
|
align-items: center;
|
|||
|
|
justify-content: center;
|
|||
|
|
z-index: 9999;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.modal-content {
|
|||
|
|
position: relative;
|
|||
|
|
width: 100%;
|
|||
|
|
height: 100%;
|
|||
|
|
display: flex;
|
|||
|
|
align-items: center;
|
|||
|
|
justify-content: center;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.close-btn {
|
|||
|
|
position: absolute;
|
|||
|
|
bottom: 100rpx;
|
|||
|
|
left: 50%;
|
|||
|
|
transform: translateX(-50%);
|
|||
|
|
width: 80rpx;
|
|||
|
|
height: 80rpx;
|
|||
|
|
background-color: rgba(255, 255, 255, 0.9);
|
|||
|
|
border-radius: 50%;
|
|||
|
|
display: flex;
|
|||
|
|
align-items: center;
|
|||
|
|
justify-content: center;
|
|||
|
|
z-index: 10000;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.close-icon {
|
|||
|
|
font-size: 40rpx;
|
|||
|
|
color: #666;
|
|||
|
|
font-weight: bold;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.qrcode-card {
|
|||
|
|
background-color: white;
|
|||
|
|
border-radius: 20rpx;
|
|||
|
|
padding: 60rpx 40rpx;
|
|||
|
|
box-shadow: 0 8rpx 40rpx rgba(0, 0, 0, 0.15);
|
|||
|
|
max-width: 600rpx;
|
|||
|
|
width: 90%;
|
|||
|
|
text-align: center;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.card-title {
|
|||
|
|
margin-bottom: 40rpx;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.title-text {
|
|||
|
|
font-size: 36rpx;
|
|||
|
|
font-weight: bold;
|
|||
|
|
color: #333;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.qrcode-container {
|
|||
|
|
margin-bottom: 40rpx;
|
|||
|
|
display: flex;
|
|||
|
|
justify-content: center;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.ticket-info {
|
|||
|
|
margin-bottom: 20rpx;
|
|||
|
|
display: flex;
|
|||
|
|
justify-content: center;
|
|||
|
|
align-items: center;
|
|||
|
|
gap: 10rpx;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.ticket-label {
|
|||
|
|
font-size: 28rpx;
|
|||
|
|
color: #666;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.ticket-number {
|
|||
|
|
font-size: 28rpx;
|
|||
|
|
color: #333;
|
|||
|
|
font-weight: 500;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.tip-text {
|
|||
|
|
text-align: center;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.tip-text text {
|
|||
|
|
font-size: 24rpx;
|
|||
|
|
color: #999;
|
|||
|
|
}
|
|||
|
|
</style>
|