Files
soul-yongping/miniprogram/pages/gift-pay/list.js
Alex-larget 601044ec60 实施美团式的支付流程,并增强相关功能
- 将支付流程统一至礼品支付页面,禁止从阅读页面进行支付,以优化用户体验。
- 更新了礼物支付详情页面,为发起人和朋友展示了不同的用户界面元素,包括为发起人提供的分享按钮和为朋友提供的支付按钮。
- 增强了后端逻辑,以确保在支付处理过程中正确将收益归因于发起人。
- 增加了每日章节更新,并改进了章节页面的加载状态,以提升用户交互体验。
- 更新了文档,以反映新的支付流程和相关变更。
2026-03-17 12:15:08 +08:00

98 lines
2.6 KiB
JavaScript

/**
* Soul创业派对 - 我的代付
* Tab: 我发起的 / 我帮付的
*/
const app = getApp()
Page({
data: {
statusBarHeight: 44,
tab: 'requests',
requests: [],
payments: [],
loading: false
},
onLoad() {
this.setData({ statusBarHeight: app.globalData.statusBarHeight || 44 })
this.loadData()
},
onShow() {
if (this.data.requests.length > 0 || this.data.payments.length > 0) {
this.loadData()
}
},
switchTab(e) {
const tab = e.currentTarget.dataset.tab || 'requests'
this.setData({ tab })
this.loadData()
},
async loadData() {
const userId = app.globalData.userInfo?.id || ''
if (!userId) {
wx.showToast({ title: '请先登录', icon: 'none' })
return
}
this.setData({ loading: true })
try {
if (this.data.tab === 'requests') {
const res = await app.request(`/api/miniprogram/gift-pay/my-requests?userId=${encodeURIComponent(userId)}`)
this.setData({ requests: (res && res.list) || [], loading: false })
} else {
const res = await app.request(`/api/miniprogram/gift-pay/my-payments?userId=${encodeURIComponent(userId)}`)
this.setData({ payments: (res && res.list) || [], loading: false })
}
} catch (e) {
this.setData({ loading: false })
}
},
goToDetail(e) {
const requestSn = e.currentTarget.dataset.sn
if (requestSn) {
wx.navigateTo({ url: `/pages/gift-pay/detail?requestSn=${encodeURIComponent(requestSn)}` })
}
},
shareRequest(e) {
e.stopPropagation()
wx.showToast({ title: '请点击右上角「...」分享给好友', icon: 'none', duration: 2500 })
},
async cancelRequest(e) {
e.stopPropagation()
const requestSn = e.currentTarget.dataset.sn
if (!requestSn) return
const ok = await new Promise(r => {
wx.showModal({ title: '取消代付', content: '确定取消该代付请求?', success: res => r(res.confirm) })
})
if (!ok) return
try {
const res = await app.request({
url: '/api/miniprogram/gift-pay/cancel',
method: 'POST',
data: { requestSn, userId: app.globalData.userInfo?.id }
})
if (res && res.success) {
wx.showToast({ title: '已取消', icon: 'success' })
this.loadData()
} else {
wx.showToast({ title: res?.error || '取消失败', icon: 'none' })
}
} catch (e) {
wx.showToast({ title: '取消失败', icon: 'none' })
}
},
goBack() {
app.goBackOrToHome()
},
onShareAppMessage() {
return { title: '我的代付 - Soul创业派对', path: '/pages/gift-pay/list' }
}
})