fix bugs
This commit is contained in:
@@ -26,48 +26,56 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import competitionAPI from '@/api/competition.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
eventId: '',
|
||||
type: '',
|
||||
projectList: [
|
||||
{
|
||||
id: 1,
|
||||
name: '男子组剑术',
|
||||
price: 199,
|
||||
selected: true
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '女子组太极拳',
|
||||
price: 99,
|
||||
selected: false
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '女子组单鞭',
|
||||
price: 1299,
|
||||
selected: false
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '男子组太极拳',
|
||||
price: 299,
|
||||
selected: true
|
||||
}
|
||||
]
|
||||
projectList: []
|
||||
};
|
||||
},
|
||||
onLoad(options) {
|
||||
if (options.eventId) {
|
||||
this.eventId = options.eventId;
|
||||
this.loadProjectList(options.eventId)
|
||||
}
|
||||
if (options.type) {
|
||||
this.type = options.type;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 加载报名项目列表
|
||||
*/
|
||||
async loadProjectList(eventId) {
|
||||
try {
|
||||
const res = await competitionAPI.getProjectList({ competitionId: eventId })
|
||||
|
||||
let list = []
|
||||
if (res.records) {
|
||||
list = res.records
|
||||
} else if (Array.isArray(res)) {
|
||||
list = res
|
||||
}
|
||||
|
||||
// 数据映射
|
||||
this.projectList = list.map(item => ({
|
||||
id: item.id,
|
||||
name: item.name || item.projectName,
|
||||
price: item.price || item.registrationFee || 0,
|
||||
selected: false
|
||||
}))
|
||||
} catch (err) {
|
||||
console.error('加载项目列表失败:', err)
|
||||
uni.showToast({
|
||||
title: '加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
toggleProject(item) {
|
||||
item.selected = !item.selected;
|
||||
this.$forceUpdate();
|
||||
@@ -83,7 +91,7 @@ export default {
|
||||
}
|
||||
|
||||
uni.navigateTo({
|
||||
url: `/pages/event-register/event-register?eventId=${this.eventId}&projects=${JSON.stringify(selectedProjects)}`
|
||||
url: `/pages/event-register/event-register?eventId=${this.eventId}&projects=${encodeURIComponent(JSON.stringify(selectedProjects))}`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user