buddhism/pages/basePage/test.vue

110 lines
2.2 KiB
Vue
Raw Normal View History

2025-08-15 17:35:58 +08:00
<template>
<view class="page">
2025-08-15 17:45:56 +08:00
<view class="qrcode-container">
2025-08-15 17:35:58 +08:00
<uv-qrcode
ref="qrcode"
:value="value"
2025-08-15 17:45:56 +08:00
:options="options"
2025-08-15 17:35:58 +08:00
canvas-id="qrcode"
size="300rpx"
></uv-qrcode>
</view>
2025-08-15 17:51:15 +08:00
<!-- 测试按钮 -->
<view class="button-container">
<button @click="showQRModal" class="test-btn">显示二维码弹窗</button>
</view>
<!-- 二维码弹窗组件 -->
<QRCodeModal
:visible="modalVisible"
:value="modalValue"
:title="modalTitle"
:ticket-number="modalTicketNumber"
@close="handleModalClose"
/>
2025-08-15 17:35:58 +08:00
</view>
</template>
<script>
import UvQrcode from "../../uni_modules/uv-qrcode/components/uv-qrcode/uv-qrcode.vue";
2025-08-15 17:51:15 +08:00
import QRCodeModal from "../../components/QRCodeModal.vue";
2025-08-15 17:35:58 +08:00
export default {
2025-08-15 17:51:15 +08:00
components: { UvQrcode, QRCodeModal },
2025-08-15 17:35:58 +08:00
data() {
return {
2025-08-15 17:45:56 +08:00
value: "测试二维码内容",
2025-08-15 17:35:58 +08:00
options: {
errorCorrectLevel: "Q",
margin: 10,
2025-08-15 17:45:56 +08:00
areaColor: "#fff"
2025-08-15 17:51:15 +08:00
},
// 弹窗相关数据
modalVisible: false,
modalValue: "VERIFY:31454786135789613287",
modalTitle: "观音诞祈福法会",
modalTicketNumber: "31454786135789613287"
2025-08-15 17:35:58 +08:00
};
},
onLoad() {
this.$nextTick(() => {
this.$refs.qrcode.remake({
success: () => {
2025-08-15 17:45:56 +08:00
console.log("二维码生成成功");
2025-08-15 17:35:58 +08:00
},
fail: (err) => {
2025-08-15 17:45:56 +08:00
console.error("二维码生成失败:", err);
}
2025-08-15 17:35:58 +08:00
});
});
2025-08-15 17:51:15 +08:00
},
methods: {
// 显示二维码弹窗
showQRModal() {
this.modalVisible = true;
},
// 关闭弹窗
handleModalClose() {
this.modalVisible = false;
}
2025-08-15 17:45:56 +08:00
}
2025-08-15 17:35:58 +08:00
};
</script>
<style lang="scss" scoped>
.page {
background: #f5f0e7;
2025-08-15 17:45:56 +08:00
min-height: 100vh;
display: flex;
2025-08-15 17:51:15 +08:00
flex-direction: column;
2025-08-15 17:45:56 +08:00
align-items: center;
justify-content: center;
2025-08-15 17:51:15 +08:00
padding: 40rpx;
2025-08-15 17:35:58 +08:00
}
2025-08-15 17:45:56 +08:00
.qrcode-container {
padding: 40rpx;
background: white;
border-radius: 20rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
2025-08-15 17:51:15 +08:00
margin-bottom: 60rpx;
}
.button-container {
width: 100%;
display: flex;
justify-content: center;
}
.test-btn {
background: #48893B;
color: white;
border: none;
border-radius: 10rpx;
padding: 20rpx 40rpx;
font-size: 28rpx;
2025-08-15 17:35:58 +08:00
}
</style>