guhongwei 2 years ago
parent
commit
e44880e996

+ 3 - 1
app.json

@@ -1,5 +1,7 @@
 {
     "pages": [
+
+        "pages/race/index",
         "pages/index/index",
         "pages/register/index",
         "pages/home/index",
@@ -39,7 +41,7 @@
         "pages/raceteam/index",
         "pages/raceteam/add",
         "pages/raceteam/auto",
-        "pages/race/index",
+
         "pages/race/add",
         "pages/race/auto",
         "pages/eliminate/index",

+ 1 - 0
pages/eliminate/add.js

@@ -19,6 +19,7 @@ Page({
      */
     onLoad: function (options) {
         const that = this;
+        console.log(options);
 
     },
     /**

+ 84 - 1
pages/eliminate/index.js

@@ -6,6 +6,14 @@ Page({
      */
     data: {
         frameStyle: { useTop: true, name: '淘汰赛管理', leftArrow: true, useBar: false },
+        dialog: { title: '赛程信息', show: false, type: '1' },
+        form: {},
+        // 赛事信息
+        matchList: [],
+        // 组别
+        groupingList: [],
+        //组内项目
+        projectList: [],
     },
     // 跳转菜单
     back(e) {
@@ -15,7 +23,64 @@ Page({
     },
     // 添加
     toAdd: function () {
-        wx.navigateTo({ url: '/pages/eliminate/add' })
+        const that = this;
+        that.setData({ dialog: { title: '赛程信息', show: true, type: '1' } })
+    },
+    // 关闭弹框
+    toClose: function () {
+        const that = this;
+        that.setData({ form: {} })
+        that.setData({ dialog: { title: '赛程信息', show: true, type: '1' } })
+
+    },
+    // 选择赛事
+    matchChange: function (e) {
+        const that = this;
+        let data = that.data.matchList[e.detail.value];
+        if (data) {
+            that.setData({ 'form.match_id': data._id });
+            that.setData({ 'form.match_name': data.name });
+            if (data.grouping && data.grouping.length > 0) {
+                that.setData({ groupingList: data.grouping })
+            }
+        }
+    },
+    // 选择赛事组别
+    grpupChange: async function (e) {
+        const that = this;
+        let data = that.data.groupingList[e.detail.value];
+        if (data) {
+            that.setData({ 'form.grouping_id': data._id });
+            that.setData({ 'form.grouping_name': data.name });
+            if (data.project && data.project.length > 0) {
+                let projectList = [];
+                for (const val of data.project) {
+                    const arr = await app.$get(`/newCourt/api/matchProject/${val}`)
+                    if (arr.errcode == '0') projectList.push(arr.data);
+                    that.setData({ projectList: projectList })
+                }
+            }
+        }
+    },
+    // 选择组内项目
+    projectChange: function (e) {
+        const that = this;
+        let data = that.data.projectList[e.detail.value];
+        if (data) {
+            that.setData({ 'form.project_id': data._id });
+            that.setData({ 'form.project_name': data.name });
+        }
+    },
+    // 赛程信息
+    onSubmit: function (e) {
+        const that = this;
+        const params = e.detail.value;
+        if (params.match_id && params.grouping_id && params.project_id) {
+            wx.navigateTo({ url: `/pages/eliminate/add?match_id=${params.match_id}&grouping_id=${params.grouping_id}&project_id=${params.project_id}` })
+        } else {
+            wx.showToast({ title: `缺少必要信息`, icon: 'error', duration: 2000 })
+        }
+
     },
     /**
      * 生命周期函数--监听页面加载
@@ -35,7 +100,25 @@ Page({
      * 生命周期函数--监听页面显示
      */
     onShow: function () {
+        const that = this;
+        that.watchLogin();
+    },
+    // 监听用户是否登录
+    watchLogin: async function () {
+        const that = this;
+        wx.getStorage({
+            key: 'user',
+            success: async res => {
+                let arr;
+                // 比赛信息
+                arr = await app.$get(`/newCourt/api/match`, { status: '0' });//2
+                if (arr.errcode == '0') { that.setData({ matchList: arr.data }) }
 
+            },
+            fail: res => {
+                wx.redirectTo({ url: '/pages/index/index', })
+            }
+        })
     },
 
     /**

+ 3 - 2
pages/eliminate/index.json

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

+ 35 - 0
pages/eliminate/index.less

@@ -32,4 +32,39 @@
         position: relative;
         background-color: #ff0000;
     }
+}
+
+.dialog_one {
+    width: 80vw;
+
+    .content {
+        background-color: #ffffff;
+        border-bottom: 1px solid #cccccc;
+        display: flex;
+        flex-direction: row;
+        justify-content: space-between;
+        padding: 2vw;
+        width: 76vw;
+
+        .label {
+            width: 25vw;
+            text-align: left;
+            font-size: 16px;
+        }
+
+        .value {
+            width: 65vw;
+            text-align: right;
+            font-size: 16px;
+
+            textarea {
+                width: 65vw;
+            }
+        }
+    }
+
+    .btn {
+        margin: 2vw 0 0 0;
+        text-align: center;
+    }
 }

+ 36 - 1
pages/eliminate/index.wxml

@@ -9,4 +9,39 @@
             列表
         </view>
     </view>
-</mobile-main>
+</mobile-main>
+<e-dialog dialog="{{dialog}}" bind:toClose="toClose">
+    <view slot="info">
+        <view class="dialog_one" wx:if="{{dialog.type=='1'}}">
+            <form catchsubmit="onSubmit">
+                <view class="content">
+                    <view class="label">比赛名称</view>
+                    <view class="value">
+                        <picker bindchange="matchChange" name="match_id" value="{{form.match_id}}" range-key='name' range="{{matchList}}">
+                            <view class="input">{{form.match_name||'请选择赛事'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">赛事组别</view>
+                    <view class="value">
+                        <picker bindchange="grpupChange" name="grouping_id" value="{{form.grouping_id}}" range-key='name' range="{{groupingList}}">
+                            <view class="input">{{form.grouping_name||'请选择赛事组别'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">组内项目</view>
+                    <view class="value">
+                        <picker bindchange="projectChange" name="project_id" value="{{form.project_id}}" range-key='name' range="{{projectList}}">
+                            <view class="input">{{form.project_name||'请选择组内项目'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="btn">
+                    <button type="primary" size="mini" form-type="submit">赛程编辑</button>
+                </view>
+            </form>
+        </view>
+    </view>
+</e-dialog>

+ 29 - 0
pages/eliminate/index.wxss

@@ -28,3 +28,32 @@
   position: relative;
   background-color: #ff0000;
 }
+.dialog_one {
+  width: 80vw;
+}
+.dialog_one .content {
+  background-color: #ffffff;
+  border-bottom: 1px solid #cccccc;
+  display: flex;
+  flex-direction: row;
+  justify-content: space-between;
+  padding: 2vw;
+  width: 76vw;
+}
+.dialog_one .content .label {
+  width: 25vw;
+  text-align: left;
+  font-size: 16px;
+}
+.dialog_one .content .value {
+  width: 65vw;
+  text-align: right;
+  font-size: 16px;
+}
+.dialog_one .content .value textarea {
+  width: 65vw;
+}
+.dialog_one .btn {
+  margin: 2vw 0 0 0;
+  text-align: center;
+}

+ 30 - 1
pages/race/index.js

@@ -1,4 +1,5 @@
 const app = getApp()
+import { race_status } from '../../utils/dict';
 Page({
 
     /**
@@ -8,6 +9,9 @@ Page({
         frameStyle: { useTop: true, name: '小组赛管理', leftArrow: true, useBar: false },
         searchInfo: {},
         list: [],
+        dialog: { title: '赛事管理', show: false, type: '1' },
+        form: {},
+        statusList: race_status,
     },
     back(e) {
         wx.navigateBack({ delta: 1 })
@@ -24,6 +28,31 @@ Page({
         const { route } = e.currentTarget.dataset;
         wx.navigateTo({ url: `/pages/${route}` })
     },
+    // 赛事管理
+    toScore: async function (e) {
+        const that = this;
+        const { item } = e.currentTarget.dataset;
+        const arr = await app.$get(`/newCourt/api/race/${item._id}`);
+        if (arr.errcode == '0') { that.setData({ form: arr.data }) }
+        that.setData({ dialog: { title: '赛事管理', show: true, type: '1' } });
+    },
+    // 选择比赛状态
+    statusChange: function (e) {
+        const that = this;
+        let data = that.data.statusList[e.detail.value];
+        if (data) { that.setData({ 'form.status': data.value }) }
+    },
+    // 提交保存
+    onSubmit: function (e) {
+        console.log(e);
+    },
+    // 关闭弹框
+    toClose: function () {
+        const that = this;
+        that.setData({ form: {} })
+        that.setData({ dialog: { title: '赛事管理', show: false, type: '1' } })
+        that.watchLogin();
+    },
     // 信息维护
     toEdit: function (e) {
         const { item } = e.currentTarget.dataset;
@@ -77,7 +106,7 @@ Page({
             key: 'user',
             success: async (res) => {
                 let arr;
-                let info = { skip: 0, limit: 1000 };
+                let info = { skip: 0, limit: 5 };
                 // if (searchInfo && searchInfo.name) info.name = searchInfo.name;
                 arr = await app.$get(`/newCourt/api/race`, { ...info });
                 if (arr.errcode == '0') { that.setData({ raceList: arr.data }) }

+ 3 - 2
pages/race/index.json

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

+ 35 - 0
pages/race/index.less

@@ -106,4 +106,39 @@
             }
         }
     }
+}
+
+.dialog_one {
+    width: 80vw;
+
+    .content {
+        background-color: #ffffff;
+        border-bottom: 1px solid #cccccc;
+        display: flex;
+        flex-direction: row;
+        justify-content: space-between;
+        padding: 2vw;
+        width: 76vw;
+
+        .label {
+            width: 25vw;
+            text-align: left;
+            font-size: 14px;
+        }
+
+        .value {
+            width: 65vw;
+            text-align: right;
+            font-size: 14px;
+
+            textarea {
+                width: 65vw;
+            }
+        }
+    }
+
+    .btn {
+        margin: 2vw 0 0 0;
+        text-align: center;
+    }
 }

+ 39 - 1
pages/race/index.wxml

@@ -26,6 +26,7 @@
                         </view>
                         <view class="btn">
                             <button type="primary" size="mini" bindtap="toEdit" data-item="{{item}}">信息维护</button>
+                            <button type="primary" size="mini" bindtap="toScore" data-item="{{item}}">赛事管理</button>
                             <button type="warn" size="mini" bindtap="toDel" data-item="{{item}}">信息删除</button>
                         </view>
                     </view>
@@ -33,4 +34,41 @@
             </scroll-view>
         </view>
     </view>
-</mobile-main>
+</mobile-main>
+<e-dialog dialog="{{dialog}}" bind:toClose="toClose">
+    <view slot="info">
+        <view class="dialog_one" wx:if="{{dialog.type=='1'}}">
+            <form catchsubmit="onSubmit">
+                <view class="content">
+                    <view class="label">比赛状态</view>
+                    <view class="value">
+                        <picker bindchange="statusChange" name="status" value="{{form.status}}" range-key='label' range="{{statusList}}">
+                            <view class="input">{{form.status=='0'?'已安排':item.status=='1'?'待开赛':item.status=='2'?'已开赛':item.status=='3'?'已结束':'请选择比赛状态'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">选手一比分</view>
+                    <view class="value">
+                        <input type="number" name="score_one" value="{{form.score_one}}" placeholder="请输入选手一比分" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">选手二比分</view>
+                    <view class="value">
+                        <input type="number" name="score_two" value="{{form.score_two}}" placeholder="请输入选手二比分" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">胜者</view>
+                    <view class="value">
+                        <input type="text" name="winner" value="{{form.winner}}" placeholder="请输入胜者" />
+                    </view>
+                </view>
+                <view class="btn">
+                    <button type="primary" size="mini" form-type="submit">提交保存</button>
+                </view>
+            </form>
+        </view>
+    </view>
+</e-dialog>

+ 29 - 0
pages/race/index.wxss

@@ -86,3 +86,32 @@
 .main .two .scroll-view .list-scroll-view .list:last-child {
   border-bottom: none;
 }
+.dialog_one {
+  width: 80vw;
+}
+.dialog_one .content {
+  background-color: #ffffff;
+  border-bottom: 1px solid #cccccc;
+  display: flex;
+  flex-direction: row;
+  justify-content: space-between;
+  padding: 2vw;
+  width: 76vw;
+}
+.dialog_one .content .label {
+  width: 25vw;
+  text-align: left;
+  font-size: 14px;
+}
+.dialog_one .content .value {
+  width: 65vw;
+  text-align: right;
+  font-size: 14px;
+}
+.dialog_one .content .value textarea {
+  width: 65vw;
+}
+.dialog_one .btn {
+  margin: 2vw 0 0 0;
+  text-align: center;
+}