测试文件清理
This commit is contained in:
parent
5bac70ac96
commit
a463bdde89
|
|
@ -1,213 +0,0 @@
|
|||
<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>
|
||||
16
pages.json
16
pages.json
|
|
@ -210,18 +210,10 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/personalCenter/myAppointment",
|
||||
"style" :
|
||||
{
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/basePage/test",
|
||||
"style" :
|
||||
{
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
"path": "pages/personalCenter/myAppointment",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}
|
||||
],
|
||||
"subPackages": [
|
||||
|
|
|
|||
|
|
@ -1,109 +0,0 @@
|
|||
<template>
|
||||
<view class="page">
|
||||
<view class="qrcode-container">
|
||||
<uv-qrcode
|
||||
ref="qrcode"
|
||||
:value="value"
|
||||
:options="options"
|
||||
canvas-id="qrcode"
|
||||
size="300rpx"
|
||||
></uv-qrcode>
|
||||
</view>
|
||||
|
||||
<!-- 测试按钮 -->
|
||||
<view class="button-container">
|
||||
<button @click="showQRModal" class="test-btn">显示二维码弹窗</button>
|
||||
</view>
|
||||
|
||||
<!-- 二维码弹窗组件 -->
|
||||
<QRCodeModal
|
||||
:visible="modalVisible"
|
||||
:value="modalValue"
|
||||
:title="modalTitle"
|
||||
:ticket-number="modalTicketNumber"
|
||||
@close="handleModalClose"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import UvQrcode from "../../uni_modules/uv-qrcode/components/uv-qrcode/uv-qrcode.vue";
|
||||
import QRCodeModal from "../../components/QRCodeModal.vue";
|
||||
|
||||
export default {
|
||||
components: { UvQrcode, QRCodeModal },
|
||||
data() {
|
||||
return {
|
||||
value: "测试二维码内容",
|
||||
options: {
|
||||
errorCorrectLevel: "Q",
|
||||
margin: 10,
|
||||
areaColor: "#fff"
|
||||
},
|
||||
// 弹窗相关数据
|
||||
modalVisible: false,
|
||||
modalValue: "VERIFY:31454786135789613287",
|
||||
modalTitle: "观音诞祈福法会",
|
||||
modalTicketNumber: "31454786135789613287"
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.qrcode.remake({
|
||||
success: () => {
|
||||
console.log("二维码生成成功");
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error("二维码生成失败:", err);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
// 显示二维码弹窗
|
||||
showQRModal() {
|
||||
this.modalVisible = true;
|
||||
},
|
||||
|
||||
// 关闭弹窗
|
||||
handleModalClose() {
|
||||
this.modalVisible = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page {
|
||||
background: #f5f0e7;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40rpx;
|
||||
}
|
||||
|
||||
.qrcode-container {
|
||||
padding: 40rpx;
|
||||
background: white;
|
||||
border-radius: 20rpx;
|
||||
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
|
||||
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;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
<template>
|
||||
<view class="test-page">
|
||||
<view class="test-section">
|
||||
<text class="section-title">API测试</text>
|
||||
<button @click="testGetHomeConfig" class="test-btn">测试获取首页配置</button>
|
||||
<button @click="testWxLogin" class="test-btn">测试微信登录</button>
|
||||
<button @click="testEnvironment" class="test-btn">测试环境配置</button>
|
||||
</view>
|
||||
|
||||
<view class="result-section">
|
||||
<text class="section-title">测试结果</text>
|
||||
<text class="result-text">{{ testResult }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getHomeConfig } from '@/api/index/index.js'
|
||||
import { wxLogin } from '@/api/auth/auth.js'
|
||||
import { getRequestConfig } from '@/utils/request.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
testResult: '',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async testGetHomeConfig() {
|
||||
try {
|
||||
this.testResult = '正在测试获取首页配置...'
|
||||
const result = await getHomeConfig()
|
||||
this.testResult = `获取首页配置成功: ${JSON.stringify(result, null, 2)}`
|
||||
} catch (error) {
|
||||
this.testResult = `获取首页配置失败: ${error.message}`
|
||||
}
|
||||
},
|
||||
|
||||
async testWxLogin() {
|
||||
try {
|
||||
this.testResult = '正在测试微信登录...'
|
||||
const mockData = {
|
||||
loginCode: 'test_code_123',
|
||||
appId: 1,
|
||||
}
|
||||
const result = await wxLogin(mockData)
|
||||
this.testResult = `微信登录测试成功: ${JSON.stringify(result, null, 2)}`
|
||||
} catch (error) {
|
||||
this.testResult = `微信登录测试失败: ${error.message}`
|
||||
}
|
||||
},
|
||||
|
||||
testEnvironment() {
|
||||
try {
|
||||
const config = getRequestConfig()
|
||||
this.testResult = `环境配置: ${JSON.stringify(config, null, 2)}`
|
||||
} catch (error) {
|
||||
this.testResult = `获取环境配置失败: ${error.message}`
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.test-page {
|
||||
padding: 40rpx;
|
||||
}
|
||||
|
||||
.test-section {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20rpx;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.test-btn {
|
||||
margin: 20rpx 0;
|
||||
padding: 20rpx;
|
||||
background-color: #007aff;
|
||||
color: white;
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
|
||||
.result-section {
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
|
||||
.result-text {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
word-break: break-all;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
import QRCode from 'qrcode'
|
||||
|
||||
/**
|
||||
* 生成二维码
|
||||
* @param {string} text - 要生成二维码的文本内容
|
||||
* @param {Object} options - 二维码配置选项
|
||||
* @returns {Promise<string>} 返回base64格式的二维码图片
|
||||
*/
|
||||
export function generateQRCode(text, options = {}) {
|
||||
const defaultOptions = {
|
||||
width: 200,
|
||||
margin: 2,
|
||||
color: {
|
||||
dark: '#000000',
|
||||
light: '#FFFFFF'
|
||||
},
|
||||
errorCorrectionLevel: 'M'
|
||||
}
|
||||
|
||||
const qrOptions = { ...defaultOptions, ...options }
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
QRCode.toDataURL(text, qrOptions, (err, url) => {
|
||||
if (err) {
|
||||
console.error('生成二维码失败:', err)
|
||||
reject(err)
|
||||
} else {
|
||||
resolve(url)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成核销验证码二维码
|
||||
* @param {string} value - 核销码值或预约ID
|
||||
* @param {Object} options - 二维码配置选项
|
||||
* @returns {Promise<string>} 返回base64格式的二维码图片
|
||||
*/
|
||||
export function generateVerificationQRCode(value, options = {}) {
|
||||
// 如果值已经包含VERIFY:前缀,直接使用;否则添加前缀
|
||||
const verificationText = value.startsWith('VERIFY:') ? value : `VERIFY:${value}`
|
||||
|
||||
return generateQRCode(verificationText, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成二维码并保存到本地
|
||||
* @param {string} text - 要生成二维码的文本内容
|
||||
* @param {string} filePath - 保存路径
|
||||
* @param {Object} options - 二维码配置选项
|
||||
* @returns {Promise<string>} 返回保存的文件路径
|
||||
*/
|
||||
export function generateQRCodeToFile(text, filePath, options = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
QRCode.toFile(filePath, text, options, (err) => {
|
||||
if (err) {
|
||||
console.error('生成二维码文件失败:', err)
|
||||
reject(err)
|
||||
} else {
|
||||
resolve(filePath)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成二维码的Canvas元素
|
||||
* @param {string} text - 要生成二维码的文本内容
|
||||
* @param {Object} options - 二维码配置选项
|
||||
* @returns {Promise<HTMLCanvasElement>} 返回Canvas元素
|
||||
*/
|
||||
export function generateQRCodeCanvas(text, options = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
QRCode.toCanvas(text, options, (err, canvas) => {
|
||||
if (err) {
|
||||
console.error('生成二维码Canvas失败:', err)
|
||||
reject(err)
|
||||
} else {
|
||||
resolve(canvas)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user