|
@@ -8,39 +8,53 @@ Page({
|
|
|
data: {
|
|
|
frameStyle: { useTop: true, name: '订单管理', leftArrow: true, useBar: false },
|
|
|
list: [],
|
|
|
- userInfo: {}
|
|
|
},
|
|
|
+ back() {
|
|
|
+ wx.navigateBack({ delta: 1 })
|
|
|
+ },
|
|
|
+ // 支付
|
|
|
+ toPay: function (e) {
|
|
|
|
|
|
- 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();
|
|
|
+ toRefund: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ const { item } = e.currentTarget.dataset;
|
|
|
+ const arr = await app.$post('/newCourt/api/payOrder/toRefund', { id: item._id })
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ wx.showToast({ title: `退款成功`, icon: 'success', duration: 2000 });
|
|
|
+ that.watchLogin();
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 });
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
+ */
|
|
|
+ onLoad(options) {
|
|
|
+ this.watchLogin();
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ // 监听用户是否登录
|
|
|
+ watchLogin: async function () {
|
|
|
+ const that = this;
|
|
|
+ wx.getStorage({
|
|
|
+ key: 'user',
|
|
|
+ success: async res => {
|
|
|
+ const arr = await app.$get(`/newCourt/api/payOrder`, { openid: res.data.openid })
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ let list = arr.data;
|
|
|
+ list = list.map(i => ({ ...i, statusZh: this.getStatusZh(i.status) }))
|
|
|
+ this.setData({ list })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: res => {
|
|
|
+ wx.redirectTo({ url: '/pages/index/index', })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
getStatusZh(status) {
|
|
|
let word = "未知"
|
|
|
switch (status) {
|
|
@@ -64,27 +78,6 @@ Page({
|
|
|
}
|
|
|
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 })
|
|
|
- },
|
|
|
-
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|