123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- // 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() {
- }
- })
|