2025/9/26/1:02
This commit is contained in:
@@ -1,50 +1,17 @@
|
||||
Component({
|
||||
data: {
|
||||
rawCardData: [
|
||||
{
|
||||
"article_id": 123123148,
|
||||
"article_title": "多选测试",
|
||||
"vote_type": "multiple",
|
||||
"total_voters": 3,
|
||||
"end_time": "2025-10-22 00:59:59",
|
||||
"is_ended": false,
|
||||
"publisher_id": "xlsisanasifknfdg",
|
||||
"create_time": "2025-09-24 23:10:22",
|
||||
"options": [
|
||||
{ "id": 69, "name": "Go", "votes": 1, "is_voted": false },
|
||||
{ "id": 70, "name": "Python", "votes": 1, "is_voted": false },
|
||||
{ "id": 71, "name": "Rust", "votes": 1, "is_voted": false }
|
||||
],
|
||||
"user_has_voted": false,
|
||||
"user_voted_option_ids": null
|
||||
},
|
||||
{
|
||||
"article_id": 123123149,
|
||||
"article_title": "单选测试",
|
||||
"vote_type": "single",
|
||||
"total_voters": 5,
|
||||
"end_time": "2025-10-25 12:00:00",
|
||||
"is_ended": false,
|
||||
"publisher_id": "another_user_id",
|
||||
"create_time": "2025-09-25 10:00:00",
|
||||
"options": [
|
||||
{ "id": 72, "name": "JavaScript", "votes": 3, "is_voted": false },
|
||||
{ "id": 73, "name": "TypeScript", "votes": 2, "is_voted": false },
|
||||
{ "id": 74, "name": "Java", "votes": 0, "is_voted": false }
|
||||
],
|
||||
"user_has_voted": false,
|
||||
"user_voted_option_ids": null
|
||||
}
|
||||
],
|
||||
processedCardsData: [] as any[]
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
const processedData = this.processVoteData(this.data.rawCardData);
|
||||
this.setData({
|
||||
processedCardsData: processedData
|
||||
});
|
||||
}
|
||||
attached() {
|
||||
// 从全局获取处理后的卡片数据
|
||||
const app = getApp();
|
||||
app.fetchRawCardData().then(cards => {
|
||||
this.setData({ processedCardsData: cards });
|
||||
}).catch(err => {
|
||||
wx.showToast({ title: '加载失败', icon: 'none' });
|
||||
});
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
processVoteData(cards: any[]): any[] {
|
||||
@@ -152,6 +119,13 @@ Component({
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
},
|
||||
goToDetail(e: { currentTarget: { dataset: { id: any; }; }; }) {
|
||||
const id = e.currentTarget.dataset.id;
|
||||
console.log(id)
|
||||
wx.navigateTo({
|
||||
url: `/pages/articledetail/articledetail?id=${id}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user