buddhism/pages/test/monk-detail-test.vue

95 lines
2.2 KiB
Vue
Raw Normal View History

<template>
<view class="monk-detail-test-page">
<view class="test-section">
<text class="section-title">高僧详情API测试</text>
<input v-model="monkId" placeholder="请输入高僧ID" class="input-field" />
<button @click="testMonkDetail" class="test-btn">测试高僧详情API</button>
<button @click="testMonkList" class="test-btn">测试高僧列表API</button>
</view>
2025-08-14 11:22:53 +08:00
<view class="result-section">
<text class="section-title">测试结果</text>
<text class="result-text">{{ testResult }}</text>
</view>
</view>
</template>
<script>
2025-08-14 11:22:53 +08:00
import { getMonkDetail, getMonkList } from '@/api/monk/monkDetail.js'
2025-08-14 11:22:53 +08:00
export default {
data() {
return {
testResult: '',
monkId: '1', // 默认测试ID
}
},
2025-08-14 11:22:53 +08:00
methods: {
async testMonkDetail() {
try {
this.testResult = '正在测试高僧详情API...'
const result = await getMonkDetail(this.monkId)
this.testResult = `高僧详情API测试成功:\n${JSON.stringify(result, null, 2)}`
} catch (error) {
this.testResult = `高僧详情API测试失败: ${error.message}`
}
},
async testMonkList() {
try {
this.testResult = '正在测试高僧列表API...'
const result = await getMonkList({ name: '' })
this.testResult = `高僧列表API测试成功:\n${JSON.stringify(result, null, 2)}`
} catch (error) {
this.testResult = `高僧列表API测试失败: ${error.message}`
}
},
},
}
</script>
<style lang="scss">
2025-08-14 11:22:53 +08:00
.monk-detail-test-page {
padding: 40rpx;
}
2025-08-14 11:22:53 +08:00
.test-section {
margin-bottom: 40rpx;
}
2025-08-14 11:22:53 +08:00
.section-title {
font-size: 32rpx;
font-weight: bold;
margin-bottom: 20rpx;
display: block;
}
2025-08-14 11:22:53 +08:00
.input-field {
width: 100%;
height: 80rpx;
border: 1px solid #ccc;
border-radius: 10rpx;
padding: 0 20rpx;
margin-bottom: 20rpx;
}
2025-08-14 11:22:53 +08:00
.test-btn {
margin: 20rpx 0;
padding: 20rpx;
background-color: #007aff;
color: white;
border-radius: 10rpx;
}
2025-08-14 11:22:53 +08:00
.result-section {
margin-top: 40rpx;
}
2025-08-14 11:22:53 +08:00
.result-text {
font-size: 24rpx;
color: #666;
word-break: break-all;
white-space: pre-wrap;
}
</style>