新增e2e测试脚本,修复部分问题
This commit was merged in pull request #51.
This commit is contained in:
@@ -65,9 +65,9 @@
|
||||
<view class="info-item">
|
||||
<text class="info-label">人数</text>
|
||||
<text class="info-value">
|
||||
{{ course.currentMembers }} / {{ course.maxMembers }}
|
||||
<text v-if="course.maxMembers - course.currentMembers > 0" class="remain-text">
|
||||
(剩{{ course.maxMembers - course.currentMembers }}位)
|
||||
{{ realMemberCount }} / {{ course.maxMembers }}
|
||||
<text v-if="course.maxMembers - realMemberCount > 0" class="remain-text">
|
||||
(剩{{ course.maxMembers - realMemberCount }}位)
|
||||
</text>
|
||||
</text>
|
||||
</view>
|
||||
@@ -165,7 +165,8 @@
|
||||
statusClass: '',
|
||||
coverImage: '',
|
||||
coverError: false
|
||||
}
|
||||
},
|
||||
realMemberCount: 0
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
@@ -187,7 +188,11 @@
|
||||
async loadCourseDetail(id) {
|
||||
this.loading = true
|
||||
try {
|
||||
const detail = await courseApi.getCourseDetail(id)
|
||||
// 并行加载课程详情和实时预约列表
|
||||
const [detail, bookings] = await Promise.all([
|
||||
courseApi.getCourseDetail(id),
|
||||
bookingApi.getCourseBookings(id).catch(() => [])
|
||||
])
|
||||
if (detail) {
|
||||
// 基础难度:优先 calculatedDifficulty,其次 baseDifficulty
|
||||
const bd = detail.calculatedDifficulty || detail.baseDifficulty || 0
|
||||
@@ -222,11 +227,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
// 实时预约人数:booking表中 status='0'(已预约) + status='2'(已出席) 的记录数
|
||||
const bookingsArr = Array.isArray(bookings) ? bookings : []
|
||||
this.realMemberCount = bookingsArr.filter(b => b.status === '0' || b.status === '2').length
|
||||
const maxMems = detail.maxMembers != null ? detail.maxMembers : 0
|
||||
const isFull = maxMems > 0 && this.realMemberCount >= maxMems
|
||||
|
||||
// 状态:数据库 status 字段 (0正常 1已取消 2已结束 3进行中 4超时)
|
||||
const statusStr = detail.status != null ? Number(detail.status) : 0
|
||||
const curMembers = detail.currentMembers != null ? detail.currentMembers : 0
|
||||
const maxMems = detail.maxMembers != null ? detail.maxMembers : 0
|
||||
const isFull = maxMems > 0 && curMembers >= maxMems
|
||||
|
||||
let statusText = ''
|
||||
let statusClass = ''
|
||||
@@ -288,7 +296,7 @@
|
||||
endShortTime: (ehh && emm) ? ehh + ':' + emm : '--',
|
||||
duration: durationStr,
|
||||
maxMembers: maxMems,
|
||||
currentMembers: curMembers,
|
||||
currentMembers: this.realMemberCount,
|
||||
isFull: isFull,
|
||||
canBook: canBook,
|
||||
btnText: btnText,
|
||||
|
||||
Reference in New Issue
Block a user