220 lines
4.6 KiB
Vue
220 lines
4.6 KiB
Vue
<template>
|
||
<view class="content">
|
||
<image src="https://aliyunoss.hn12301.net/learnlaw/gift_zt_bj.jpg" mode="widthFix" style="width:750rpx;position:absolute;top:0;left:0;z-index:-1;"></image>
|
||
<view class="page-body">
|
||
<view class="loading-box" v-if="!loaded && !loadError">
|
||
<u-loading mode="circle" size="40"></u-loading>
|
||
<text class="loading-text">加载中...</text>
|
||
</view>
|
||
<view class="loading-box" v-if="loadError">
|
||
<text class="error-text">{{ loadError }}</text>
|
||
<button class="retry-btn" @tap="fetchRecords">重新加载</button>
|
||
</view>
|
||
<view class="empty-box" v-if="loaded && records.length === 0 && !loadError">
|
||
<text class="empty-icon">📝</text>
|
||
<text class="empty-text">暂无答题记录</text>
|
||
</view>
|
||
<template v-if="records.length > 0">
|
||
<view class="record-item" v-for="(item, i) in records" :key="item.id" @click="goDetail(item)">
|
||
<view class="record-index">
|
||
<text class="record-index-text">{{ i + 1 }}</text>
|
||
</view>
|
||
<view class="record-body">
|
||
<view class="record-row">
|
||
<text class="record-label">答题时间:</text>
|
||
<text class="record-value">{{ item.create_time }}</text>
|
||
</view>
|
||
<view class="record-row">
|
||
<text class="record-label">答对题数:</text>
|
||
<text class="record-value">{{ item.correct_question_num }} / {{ item.total_question_num }} 题</text>
|
||
</view>
|
||
<view class="record-row">
|
||
<text class="record-label">答题用时:</text>
|
||
<text class="record-value">{{ formatTime(item.use_time) }}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
export default {
|
||
data() {
|
||
return {
|
||
records: [],
|
||
loaded: false,
|
||
loadError: ''
|
||
}
|
||
},
|
||
onLoad() {
|
||
this.fetchRecords()
|
||
},
|
||
methods: {
|
||
fetchRecords() {
|
||
this.loadError = ''
|
||
const userId = uni.getStorageSync('userIdGift')
|
||
if (!userId) {
|
||
this.loadError = '暂未登录'
|
||
return
|
||
}
|
||
this.$u.api.getUserHisResultList({
|
||
wenjuanId: 1003,
|
||
userId: userId
|
||
}).then(res => {
|
||
if (res.code === 0) {
|
||
this.records = res.Data?.result_list || []
|
||
this.loaded = true
|
||
} else {
|
||
this.loadError = res.msg || '数据异常'
|
||
}
|
||
}).catch(err => {
|
||
console.error('获取答题记录失败', err)
|
||
this.loadError = '网络请求失败'
|
||
})
|
||
},
|
||
formatTime(sec) {
|
||
const m = Math.floor(sec / 60)
|
||
const s = sec % 60
|
||
return (m < 10 ? '0' : '') + m + ':' + (s < 10 ? '0' : '') + s
|
||
},
|
||
goDetail(item) {
|
||
uni.navigateTo({
|
||
url: '/pages/record-detail/record-detail?resultId=' + item.id
|
||
})
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
page {
|
||
background-color: #7CC6EB;
|
||
}
|
||
|
||
.content {
|
||
position: relative;
|
||
min-height: 100vh;
|
||
min-height: 100dvh;
|
||
}
|
||
|
||
.page-body {
|
||
position: relative;
|
||
z-index: 1;
|
||
min-height: 100vh;
|
||
min-height: 100dvh;
|
||
padding: 40rpx 30rpx;
|
||
box-sizing: border-box;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.record-item {
|
||
background: rgba(255,255,255,0.95);
|
||
border-radius: 20rpx;
|
||
padding: 28rpx;
|
||
margin-bottom: 20rpx;
|
||
display: flex;
|
||
box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.04);
|
||
}
|
||
|
||
.record-index {
|
||
width: 44rpx;
|
||
height: 44rpx;
|
||
border-radius: 50%;
|
||
background: linear-gradient(135deg, #FD5401, #FF7A3D);
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
flex-shrink: 0;
|
||
margin-right: 16rpx;
|
||
margin-top: 2rpx;
|
||
box-shadow: 0 2rpx 8rpx rgba(253,84,1,0.3);
|
||
}
|
||
|
||
.record-index-text {
|
||
font-size: 20rpx;
|
||
font-weight: 700;
|
||
color: #fff;
|
||
}
|
||
|
||
.record-body {
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
|
||
.record-row {
|
||
display: flex;
|
||
align-items: baseline;
|
||
margin-top: 6rpx;
|
||
}
|
||
|
||
.record-row:first-child {
|
||
margin-top: 0;
|
||
}
|
||
|
||
.record-label {
|
||
font-size: 24rpx;
|
||
color: #999;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.record-value {
|
||
font-size: 26rpx;
|
||
color: #333;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.loading-box {
|
||
flex: 1;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.loading-text {
|
||
font-size: 28rpx;
|
||
color: #fff;
|
||
margin-top: 20rpx;
|
||
}
|
||
|
||
.error-text {
|
||
font-size: 28rpx;
|
||
color: #fff;
|
||
text-align: center;
|
||
display: block;
|
||
}
|
||
|
||
.retry-btn {
|
||
margin-top: 30rpx;
|
||
width: 240rpx;
|
||
height: 72rpx;
|
||
line-height: 72rpx;
|
||
background: rgba(255, 255, 255, 0.9);
|
||
color: #FD5401;
|
||
border: none;
|
||
border-radius: 36rpx;
|
||
font-size: 28rpx;
|
||
}
|
||
|
||
.empty-box {
|
||
flex: 1;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.empty-icon {
|
||
font-size: 80rpx;
|
||
margin-bottom: 16rpx;
|
||
}
|
||
|
||
.empty-text {
|
||
font-size: 26rpx;
|
||
color: rgba(255,255,255,0.7);
|
||
}
|
||
</style>
|