guhongwei 2 anni fa
parent
commit
7d055fd924

+ 3 - 3
app.json

@@ -1,6 +1,6 @@
 {
     "pages": [
-  
+    
 
         "pages/index/index",
         "pages/register/index",
@@ -28,8 +28,8 @@
         "pages/matchInfo/sign",
       
         "pages/order/index",
-        "pages/test/index",
-        "pages/usermyorder/index"
+        "pages/usermyorder/index",
+        "pages/test/index"
     ],
     "usingComponents": {
         "van-sidebar": "@vant/weapp/sidebar/index",

+ 6 - 2
pages/match/sign.js

@@ -110,10 +110,14 @@ Page({
         }
     },
     // 退款
-    toRefund: function (e) {
+    toRefund: async function (e) {
         const that = this;
         const { item } = e.currentTarget.dataset;
-        console.log(item);
+        const res = await app.$post('/newCourt/api/payOrder/toRefund', { id: item._id })
+        if (app.$checkRes(res)) {
+            wx.showToast({ title: '退款成功' })
+            this.search();
+        }
     },
     // 关闭弹框
     toClose: function () {

+ 40 - 47
pages/usermyorder/index.js

@@ -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 })
-    },
-
     /**
      * 生命周期函数--监听页面初次渲染完成
      */

+ 31 - 14
pages/usermyorder/index.less

@@ -1,10 +1,23 @@
 .main {
-    height: 88vh;
+    height: 88.8vh;
 
-    .one {
+    .zero {
         width: 96vw;
         margin: 0 0 2vw 0;
-        background-color: #fff;
+    }
+
+    .zero:nth-child(2) {
+        margin: 0;
+    }
+
+    .one {
+        width: 92vw;
+        padding: 2vw;
+        background-color: #f1f1f1;
+
+        input {
+            font-size: 14px;
+        }
     }
 
     .two {
@@ -26,29 +39,30 @@
                 justify-content: space-between;
 
                 .list {
+                    background-color: #ffffff;
+                    margin: 0 0 2vw 0;
+                    padding: 2vw;
                     display: flex;
                     flex-direction: column;
                     width: 96vw;
-                    padding: 2vw;
-                    background-color: #ffffff;
-                    margin: 0 0 2vw 0;
 
                     .name {
-                        font-size: 14px;
+                        font-size: 16px;
                         font-weight: bold;
                         margin: 0 0 1vw 0;
                     }
 
                     .other {
-                        font-size: 12px;
                         margin: 0 0 1vw 0;
 
                         .other_1 {
-                            padding: 0 0 1vw 0;
-                        }
+                            color: #858585;
+                            font-size: 12px;
+                            margin: 0 0 1vw 0;
 
-                        .other_1 text:nth-child(1) {
-                            color: #666;
+                            text:nth-child(1) {
+                                color: #000000;
+                            }
                         }
                     }
 
@@ -56,12 +70,15 @@
                         text-align: center;
 
                         button {
-                            color: #ffffff;
-                            font-size: 14px;
                             margin: 0 2vw;
+                            font-size: 14px;
                         }
                     }
                 }
+
+                .list:last-child {
+                    margin: 0;
+                }
             }
         }
     }

+ 20 - 13
pages/usermyorder/index.wxml

@@ -1,25 +1,32 @@
 <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 class="zero one">
+            <input type="text" value="{{searchInfo.order_no}}" placeholder="请输入订单号" />
         </view>
-        <view class="two">
+        <view class="zero 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 class="name">
+                            {{item.order_no}}
                         </view>
-                        <view class="btn">
-                            <view wx:if="{{item.status==='0'}}">
-                                <button size="mini" type="primary" bindtap="toPay" data-id="{{item._id}}">支付</button>
+                        <view class="other">
+                            <view class="other_1">
+                                <text>支付金额:</text>
+                                <text>{{item.money}}</text>
                             </view>
-                            <view wx:if="{{item.status==='1'}}">
-                                <button size="mini" type="primary" bindtap="toRefund" data-id="{{item._id}}">退款</button>
+                            <view class="other_1">
+                                <text>支付类型:</text>
+                                <text>{{item.type}}</text>
                             </view>
+                            <view class="other_1">
+                                <text>支付状态:</text>
+                                <text>{{item.statusZh}}</text>
+                            </view>
+                        </view>
+                        <view class="btn">
+                            <button size="mini" type="primary" bindtap="toPay" data-item="{{item}}" wx:if="{{item.status==='0'}}">支付</button>
+                            <button size="mini" type="primary" bindtap="toRefund" data-item="{{item}}" wx:if="{{item.status==='1'}}">退款</button>
                         </view>
                     </view>
                 </view>

+ 70 - 1
pages/usermyorder/index.wxss

@@ -1 +1,70 @@
-/* pages/usermyorder/index.wxss */
+.main {
+  height: 88.8vh;
+}
+.main .zero {
+  width: 96vw;
+  margin: 0 0 2vw 0;
+}
+.main .zero:nth-child(2) {
+  margin: 0;
+}
+.main .one {
+  width: 92vw;
+  padding: 2vw;
+  background-color: #f1f1f1;
+}
+.main .one input {
+  font-size: 14px;
+}
+.main .two {
+  flex-grow: 1;
+  position: relative;
+  width: 96vw;
+}
+.main .two .scroll-view {
+  position: absolute;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+}
+.main .two .scroll-view .list-scroll-view {
+  display: flex;
+  flex-wrap: wrap;
+  align-content: flex-start;
+  justify-content: space-between;
+}
+.main .two .scroll-view .list-scroll-view .list {
+  background-color: #ffffff;
+  margin: 0 0 2vw 0;
+  padding: 2vw;
+  display: flex;
+  flex-direction: column;
+  width: 96vw;
+}
+.main .two .scroll-view .list-scroll-view .list .name {
+  font-size: 16px;
+  font-weight: bold;
+  margin: 0 0 1vw 0;
+}
+.main .two .scroll-view .list-scroll-view .list .other {
+  margin: 0 0 1vw 0;
+}
+.main .two .scroll-view .list-scroll-view .list .other .other_1 {
+  color: #858585;
+  font-size: 12px;
+  margin: 0 0 1vw 0;
+}
+.main .two .scroll-view .list-scroll-view .list .other .other_1 text:nth-child(1) {
+  color: #000000;
+}
+.main .two .scroll-view .list-scroll-view .list .btn {
+  text-align: center;
+}
+.main .two .scroll-view .list-scroll-view .list .btn button {
+  margin: 0 2vw;
+  font-size: 14px;
+}
+.main .two .scroll-view .list-scroll-view .list:last-child {
+  margin: 0;
+}

+ 1 - 1
utils/httpUtil.js

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