我试图开发一个演唱会座位预订系统,我想用超文本标记语言,CSS和JavaScript绘制座位。
例如,如果音乐厅只有10排,每排20个座位,我可以用
const rows = [
{ name: 'A', seats: [1, 2, 3, 4] },
{ name: 'B', seats: [1, 2, 3, 4, 5, 6, 7, 8] },
{ name: 'C', seats: [1, 2, 3, 4] },
{ name: 'D', seats: [1, 2, 3, 4] },
];但是如果音乐厅有多个部分呢?它是否仍然只是一个具有多个对象Section的对象ConcertHall,每个对象都有多个对象Row,它也有多个Seat
所以音乐厅看起来像这样
{
name: "Concert Hall Name",
sections: [
{
name: "Balcon",
rows: [
{
name: "A",
seats: [1, 2, 3, 4, 5]
}
]
}
]
}但是我想让用户预订一个特定座位的门票,所以我猜这些座位应该是一个单独的对象。也许是像这样的
{
name: "Concert Hall Name",
sections: [
{
name: "Balcon",
rows: [
{
name: "A",
seats: [
{ id: 'some seat id', name: '1' },
{ id: 'some different seat id', name: '2' },
]
}
]
}
]
}然后创建票证
{
date: 'some date',
seatId: 'some seat id'
}这样行得通吗?
它是否可以扩展到音乐厅,例如,http://www.lcsd.gov.hk/en/hkcc/common/images/facilities/concerthall/concert_hall_seating_plan_s.gif的音乐厅
发布于 2017-03-16 02:27:23
我会这样做:
const concertHall = {
"name": "Example Hall",
"seats": [
{
"id": 1,
"section": "1",
"row": "A",
"number": 42
},
{
"id": 2,
"section": "VIP Box 1",
"row": null,
"number": 1
},
{
"id": 3,
"section": "VIP Box 2",
"row": null,
"number": 1
},
{
"id": 4,
"section": "Wheelchair Box",
"row": null,
"number": 1
}
]
}让它非常简单,每个座位都有你需要的所有信息。
然后,对于一张票,它可能看起来像这样:
{
"purchased": "2017-03-15T18:30:31.980Z",
"seatId": 1,
"holder": {
"firstName": "John",
"lastName": "Doe",
"email": "jdoe@example.com"
},
"eventId": 52,
"price": 102.42,
"currency": "USD"
}https://stackoverflow.com/questions/42817703
复制相似问题