// pages/usermyorder/index.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { frameStyle: { useTop: true, name: '订单管理', leftArrow: true, useBar: false }, list: [], userInfo: {} }, async search() { const openid = this.data.userInfo?.openid; if (!openid) { wx.showToast({ title: '用户未登录', icon: 'error' }) return; } const res = await app.$get(`/newCourt/api/payOrder`, { openid }) if (app.$checkRes(res)) { let list = res.data; list = list.map(i => ({ ...i, statusZh: this.getStatusZh(i.status) })) this.setData({ list }) } }, // 付款 async toPay(e) { }, // 退款 async toRefund(e) { const id = e.target.dataset?.id; const res = await app.$post('/newCourt/api/payOrder/toRefund', { id }) if (app.$checkRes(res)) { wx.showToast({ title: '退款成功', }) this.search(); } }, getStatusZh(status) { let word = "未知" switch (status) { case '0': word = "未支付" break; case '1': word = "支付成功" break; case '-1': word = "支付失败" break; case '-2': word = "申请退款" break; case '-3': word = "已退款" break; default: break; } return word; }, back() { wx.navigateBack({ delta: 1 }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.watchLogin(); this.search(); }, // 监听用户是否登录 watchLogin: async function () { const userInfo = wx.getStorageSync('user') if (!userInfo) wx.redirectTo({ url: '/pages/index/index', }) this.setData({ userInfo }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })