- 超级个体:去掉首位特例;列表仅展示有头像且非微信默认昵称(vip.go) - 个人资料:居中头像、低调联系方式、点头像优先走存客宝 lead(ckbLeadToken) - 阅读页分享朋友圈复制与 toast 去重 - soul-api: miniprogram users 带 ckbLeadToken;其它 handler 与路由调整 - 脚本:content_upload、miniprogram 上传辅助等 Made-with: Cursor
90 lines
2.8 KiB
JavaScript
90 lines
2.8 KiB
JavaScript
/**
|
|
* Soul创业实验 - 订单页
|
|
*/
|
|
const app = getApp()
|
|
|
|
Page({
|
|
data: {
|
|
statusBarHeight: 44,
|
|
orders: [],
|
|
loading: true
|
|
},
|
|
|
|
onLoad() {
|
|
wx.showShareMenu({ withShareTimeline: true })
|
|
this.setData({ statusBarHeight: app.globalData.statusBarHeight })
|
|
this.loadOrders()
|
|
},
|
|
|
|
async loadOrders() {
|
|
this.setData({ loading: true })
|
|
try {
|
|
const userId = app.globalData.userInfo?.id
|
|
if (userId) {
|
|
const res = await app.request(`/api/miniprogram/orders?userId=${userId}`)
|
|
if (res && res.success && res.data) {
|
|
const raw = (res.data || []).map(item => ({
|
|
id: item.id || item.order_sn,
|
|
sectionId: item.product_id || item.section_id,
|
|
sectionMid: item.section_mid ?? item.mid ?? 0,
|
|
title: item.product_name || `章节 ${item.product_id || ''}`,
|
|
amount: item.amount || 0,
|
|
status: item.status || 'completed',
|
|
createTime: item.created_at ? new Date(item.created_at).toLocaleDateString() : '--',
|
|
_sortMs: new Date(item.created_at || item.pay_time || 0).getTime() || 0
|
|
}))
|
|
raw.sort((a, b) => b._sortMs - a._sortMs)
|
|
const orders = raw.map(({ _sortMs, ...rest }) => rest)
|
|
this.setData({ orders })
|
|
return
|
|
}
|
|
}
|
|
const purchasedSections = [...(app.globalData.purchasedSections || [])].reverse()
|
|
const orders = purchasedSections.map((id, index) => ({
|
|
id: `order_${index}`,
|
|
sectionId: id,
|
|
sectionMid: 0,
|
|
title: `章节 ${id}`,
|
|
amount: 1,
|
|
status: 'completed',
|
|
createTime: new Date(Date.now() - index * 86400000).toLocaleDateString()
|
|
}))
|
|
this.setData({ orders })
|
|
} catch (e) {
|
|
console.error('加载订单失败:', e)
|
|
const purchasedSections = [...(app.globalData.purchasedSections || [])].reverse()
|
|
this.setData({
|
|
orders: purchasedSections.map((id, i) => ({
|
|
id: `order_${i}`, sectionId: id, sectionMid: 0, title: `章节 ${id}`, amount: 1, status: 'completed',
|
|
createTime: new Date(Date.now() - i * 86400000).toLocaleDateString()
|
|
}))
|
|
})
|
|
} finally {
|
|
this.setData({ loading: false })
|
|
}
|
|
},
|
|
|
|
goToRead(e) {
|
|
const id = e.currentTarget.dataset.id
|
|
const mid = e.currentTarget.dataset.mid
|
|
if (!id) return
|
|
const q = mid ? `mid=${mid}` : `id=${id}`
|
|
wx.navigateTo({ url: `/pages/read/read?${q}` })
|
|
},
|
|
|
|
goBack() { getApp().goBackOrToHome() },
|
|
|
|
onShareAppMessage() {
|
|
const ref = app.getMyReferralCode()
|
|
return {
|
|
title: '卡若创业派对 - 购买记录',
|
|
path: ref ? `/pages/purchases/purchases?ref=${ref}` : '/pages/purchases/purchases'
|
|
}
|
|
},
|
|
|
|
onShareTimeline() {
|
|
const ref = app.getMyReferralCode()
|
|
return { title: '卡若创业派对 - 购买记录', query: ref ? `ref=${ref}` : '' }
|
|
}
|
|
})
|