瀏覽代碼

订单及退款

lrf 2 年之前
父節點
當前提交
2043fe7b7b
共有 7 個文件被更改,包括 243 次插入12 次删除
  1. 2 11
      app.json
  2. 136 0
      pages/usermyorder/index.js
  3. 6 0
      pages/usermyorder/index.json
  4. 68 0
      pages/usermyorder/index.less
  5. 29 0
      pages/usermyorder/index.wxml
  6. 1 0
      pages/usermyorder/index.wxss
  7. 1 1
      utils/httpUtil.js

+ 2 - 11
app.json

@@ -1,24 +1,17 @@
 {
     "pages": [
-    
- 
-
         "pages/index/index",
         "pages/register/index",
         "pages/home/index",
         "pages/news/index",
         "pages/topic/index",
-
         "pages/my/index",
         "pages/my/userInfo",
-
         "pages/user/index",
         "pages/usermymatch/index",
-
         "pages/setting/index",
         "pages/setting/basic",
         "pages/setting/contact",
-
         "pages/match/index",
         "pages/match/mess",
         "pages/match/matchadd",
@@ -27,12 +20,10 @@
         "pages/match/matchgroup",
         "pages/match/shteam",
         "pages/match/sign",
-
         "pages/matchInfo/index",
         "pages/matchInfo/sign",
-      
-
-        "pages/test/index"
+        "pages/test/index",
+        "pages/usermyorder/index"
     ],
     "usingComponents": {
         "van-sidebar": "@vant/weapp/sidebar/index",

+ 136 - 0
pages/usermyorder/index.js

@@ -0,0 +1,136 @@
+// 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() {
+
+    }
+})

+ 6 - 0
pages/usermyorder/index.json

@@ -0,0 +1,6 @@
+{
+    "usingComponents": {
+        "mobile-main": "/commpents/mobile-frame/index",
+        "e-dialog": "/commpents/dialog/index"
+    }
+}

+ 68 - 0
pages/usermyorder/index.less

@@ -0,0 +1,68 @@
+.main {
+    height: 88vh;
+
+    .one {
+        width: 96vw;
+        margin: 0 0 2vw 0;
+        background-color: #fff;
+    }
+
+    .two {
+        flex-grow: 1;
+        position: relative;
+        width: 96vw;
+
+        .scroll-view {
+            position: absolute;
+            top: 0;
+            left: 0;
+            right: 0;
+            bottom: 0;
+
+            .list-scroll-view {
+                display: flex;
+                flex-wrap: wrap;
+                align-content: flex-start;
+                justify-content: space-between;
+
+                .list {
+                    display: flex;
+                    flex-direction: column;
+                    width: 96vw;
+                    padding: 2vw;
+                    background-color: #ffffff;
+                    margin: 0 0 2vw 0;
+
+                    .name {
+                        font-size: 14px;
+                        font-weight: bold;
+                        margin: 0 0 1vw 0;
+                    }
+
+                    .other {
+                        font-size: 12px;
+                        margin: 0 0 1vw 0;
+
+                        .other_1 {
+                            padding: 0 0 1vw 0;
+                        }
+
+                        .other_1 text:nth-child(1) {
+                            color: #666;
+                        }
+                    }
+
+                    .btn {
+                        text-align: center;
+
+                        button {
+                            color: #ffffff;
+                            font-size: 14px;
+                            margin: 0 2vw;
+                        }
+                    }
+                }
+            }
+        }
+    }
+}

+ 29 - 0
pages/usermyorder/index.wxml

@@ -0,0 +1,29 @@
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
+    <view slot="info" class="container main">
+        <view class="one">
+            <van-search value="{{ searchName }}" bind:search="onSearch" placeholder="请输入用户姓名" />
+        </view>
+        <view class="two">
+            <scroll-view scroll-y="true" class="scroll-view">
+                <view class="list-scroll-view">
+                    <view class="list" wx:for="{{list}}" wx:key="item">
+                        <view class="other">
+                            <view class="other_1 textOver"><text>订单号:</text><text>{{item.order_no}}</text></view>
+                            <view class="other_1"><text>支付理由:</text><text>{{item.type}}</text></view>
+                            <view class="other_1"><text>支付金额:</text><text>{{item.money}}</text></view>
+                            <view class="other_1"><text>支付状态:</text><text>{{item.statusZh}}</text></view>
+                        </view>
+                        <view class="btn">
+                            <view wx:if="{{item.status==='0'}}">
+                                <button size="mini" type="primary" bindtap="toPay" data-id="{{item._id}}">支付</button>
+                            </view>
+                            <view wx:if="{{item.status==='1'}}">
+                                <button size="mini" type="primary" bindtap="toRefund" data-id="{{item._id}}">退款</button>
+                            </view>
+                        </view>
+                    </view>
+                </view>
+            </scroll-view>
+        </view>
+    </view>
+</mobile-main>

+ 1 - 0
pages/usermyorder/index.wxss

@@ -0,0 +1 @@
+/* pages/usermyorder/index.wxss */

+ 1 - 1
utils/httpUtil.js

@@ -1,4 +1,4 @@
-let serverUrl = "https://broadcast.waityou24.cn";//http://127.0.0.1:15000
+let serverUrl = "http://127.0.0.1:15000";//http://127.0.0.1:15000
 let wechatUrl = 'https://broadcast.waityou24.cn';
 
 const getDomain = (uri) => {