Files
soul/miniprogram/pages/purchases/purchases.js

46 lines
1.0 KiB
JavaScript
Raw Normal View History

/**
* Soul创业实验 - 订单页
*/
const app = getApp()
Page({
data: {
statusBarHeight: 44,
orders: [],
loading: true
},
onLoad() {
this.setData({ statusBarHeight: app.globalData.statusBarHeight })
this.loadOrders()
},
async loadOrders() {
this.setData({ loading: true })
try {
// 模拟订单数据
const purchasedSections = app.globalData.purchasedSections || []
const orders = purchasedSections.map((id, index) => ({
id: `order_${index}`,
sectionId: id,
title: `章节 ${id}`,
amount: 1,
status: 'completed',
createTime: new Date(Date.now() - index * 86400000).toLocaleDateString()
}))
this.setData({ orders })
} catch (e) {
console.error('加载订单失败:', e)
} finally {
this.setData({ loading: false })
}
},
goToRead(e) {
const id = e.currentTarget.dataset.id
wx.navigateTo({ url: `/pages/read/read?id=${id}` })
},
goBack() { wx.navigateBack() }
})