瀏覽代碼

Merge branch 'master' of http://git.cc-lotus.info/ball-court/ball-applet

guhongwei 2 年之前
父節點
當前提交
37c4e470be
共有 2 個文件被更改,包括 49 次插入23 次删除
  1. 40 15
      pages/match/index.js
  2. 9 8
      pages/match/index.wxml

+ 40 - 15
pages/match/index.js

@@ -3,18 +3,9 @@ Page({
     data: {
         frameStyle: { useTop: true, name: '比赛管理', leftArrow: false, useBar: true },
         user: {},
-        typeList: [
-            { label: '其他', value: '0' },
-            { label: '羽毛球', value: '1' },
-            { label: '篮球', value: '2' },
-            { label: '足球', value: '3' },
-        ],
-        statusList: [
-            { label: '计划中', value: '0' },
-            { label: '报名中', value: '1' },
-            { label: '进行中', value: '2' },
-            { label: '已结束', value: '3' },
-        ],
+        searchInfo: {},
+        statusList: [],
+        typeList: [],
         list: [],
         total: 0,
         page: 0,
@@ -37,12 +28,16 @@ Page({
         const that = this;
         let data = that.data.typeList[e.detail.value];
         if (data) that.setData({ 'searchInfo.type': data.value })
+        that.setData({ skip: 0, page: 0, list: [] })
+        that.watchLogin();
     },
     // 状态选择
     statusChange: function (e) {
         const that = this;
         let data = that.data.statusList[e.detail.value];
         that.setData({ 'searchInfo.status': data.value });
+        that.setData({ skip: 0, page: 0, list: [] })
+        that.watchLogin();
     },
     // 分页
     toPage: function () {
@@ -70,18 +65,47 @@ Page({
     /**
      * 生命周期函数--监听页面显示
      */
-    onShow: function () {
+    onShow: async function () {
         const that = this;
+        // 查询其他信息
+        await that.searchOther();
         // 监听用户是否登录
-        that.watchLogin();
+        await that.watchLogin();
+    },
+    searchOther: async function () {
+        const that = this;
+        let arr;
+        // 状态
+        arr = await app.$get(`/dict`, { code: "match_status" });
+        if (arr.errcode == '0' && arr.total > 0) that.setData({ statusList: arr.data[0].list });
+        // 赛事类别
+        arr = await app.$get(`/dict`, { code: "match_type" });
+        if (arr.errcode == '0' && arr.total > 0) that.setData({ typeList: arr.data[0].list });
     },
     // 监听用户是否登录
     watchLogin: async function () {
         const that = this;
+        const searchInfo = that.data.searchInfo;
+        const statusList = that.data.statusList;
+        const typeList = that.data.typeList;
         wx.getStorage({
             key: 'user',
             success: async res => {
                 that.setData({ user: res.data })
+                let info = { skip: that.data.skip, limit: that.data.limit };
+                if (searchInfo.status) info.status = searchInfo.status;
+                if (searchInfo.type) info.type = searchInfo.type;
+                const arr = await app.$get(`/match`, { ...info }, 'race');
+                if (arr.errcode == '0') {
+                    for (const val of arr.data) {
+                        let status = statusList.find(i => i.value == val.status)
+                        if (status) val.zhStatus = status.label;
+                        let type = typeList.find(i => i.value == val.type)
+                        if (type) val.zhType = type.label;
+                    }
+                    that.setData({ list: [...that.data.list, ...arr.data] });
+                    that.setData({ total: arr.total });
+                }
             },
             fail: async res => {
                 wx.redirectTo({ url: '/pages/index/index' })
@@ -95,7 +119,8 @@ Page({
      * 生命周期函数--监听页面隐藏
      */
     onHide: function () {
-
+        const that = this;
+        that.setData({ skip: 0, page: 0, list: [] })
     },
 
     /**

+ 9 - 8
pages/match/index.wxml

@@ -12,7 +12,7 @@
             <view class="one_2">
                 <view class="one_2_1">
                     <picker mode="selector" bindchange="typeChange" value="{{searchInfo.type}}" name="type" range-key='label' range="{{typeList}}">
-                        <view class="input">{{typeList[searchInfo.type].label||'请选择运动类型'}}</view>
+                        <view class="input">{{typeList[searchInfo.type].label||'请选择赛事类别'}}</view>
                     </picker>
                 </view>
                 <view class="one_2_2">
@@ -23,22 +23,23 @@
             </view>
         </view>
         <view class="two">
-            <scroll-view scroll-y="true" class="scroll-view">
+            <scroll-view scroll-y="true" class="scroll-view" bindscrolltolower="toPage">
                 <view class="list-scroll-view">
                     <view class="list" wx:for="{{list}}" wx:key="index">
                         <view class="list_1">
                             <image class="image" src="{{item.logo&&item.logo.length>0?item.logo[0].url:''}}"></image>
                         </view>
                         <view class="list_2">
-                            <view class="title">{{item.title}}</view>
+                            <view class="title">{{item.name||'暂无'}}</view>
                             <view class="other">
-                                <view class="other_1 textOver">时间:{{item.time}}</view>
-                                <view class="other_1 textOver">等级:{{item.grade}}</view>
-                                <view class="other_1 textOver">类型:{{item.type=='0'?'其他':item.type=='1'?'羽毛球':item.type=='2'?'篮球':'足球'}}</view>
-                                <view class="other_1 textOver">地点:{{item.address}}</view>
+                                <view class="other_1 textOver">赛事类别:{{item.zhType||'暂无'}}</view>
+                                <view class="other_1 textOver">时间:{{item.start_time||'暂无'}}-{{item.end_time||'暂无'}}</view>
+                                <view class="other_1 textOver">联系电话:{{item.contact||'暂无'}}</view>
+                                <view class="other_1 textOver">报名截止时间:{{item.sign_time||'暂无'}}</view>
+                                <view class="other_1 textOver">地点:{{item.address||'暂无'}}</view>
                             </view>
                             <view class="status">
-                                <text>{{item.status=='0'?'计划中':item.status=='1'?'报名中':item.status=='2'?'进行中':'已结束'}}</text>
+                                <text>{{item.zhStatus||'暂无'}}</text>
                             </view>
                         </view>
                     </view>