guhongwei 2 年 前
コミット
54e247156c

+ 4 - 3
app.json

@@ -1,8 +1,9 @@
 {
     "pages": [
-        "pages/index/index",
         "pages/me/index",
         "pages/matchadmin/index",
+        "pages/matchadmin/layout",
+        "pages/index/index",
         "pages/login/index",
         "pages/register/index",
         "pages/home/index",
@@ -11,7 +12,6 @@
         "pages/teamrank/index",
         "pages/addmatch/index",
         "pages/matchadmin/edit",
-        "pages/matchadmin/layout",
         "pages/teamexam/index",
         "pages/team/index",
         "pages/teamInfo/index",
@@ -29,7 +29,8 @@
         "pages/user/index",
         "pages/user/detail",
         "pages/test/index",
-        "pages/logs/logs"
+        "pages/logs/logs",
+        "pages/matchadmin/layoutInfo"
     ],
     "usingComponents": {
         "van-button": "/miniprogram_npm/@vant/weapp/button/index",

+ 1 - 0
pages/matchadmin/index.wxml

@@ -11,6 +11,7 @@
                 <view class="btn" wx:if="{{item.status=='0'||item.status=='1'||item.status=='2'}}">
                     <button type="default" size="mini" bindtap="toEdit" data-id="{{item._id}}" data-route="addmatch">修改</button>
                     <button type="warn" size="mini" bindtap="toCommon" data-id="{{item._id}}" data-route="layout">编排</button>
+                    <button type="primary" size="mini" bindtap="toCommon" data-id="{{item._id}}" data-route="layoutInfo">编排信息</button>
                 </view>
             </view>
         </view>

+ 106 - 1
pages/matchadmin/layout.js

@@ -10,16 +10,121 @@ Page({
         frameStyle: { useTop: true, name: '编排比赛赛制', leftArrow: true, useBar: false },
         // 主体高度
         infoHeight: '',
+        // 用户信息
+        user: {},
+        // 比赛信息
+        match_id: '629eb5de78fa03648c0535d9',
+        matchInfo: {},
+        // 团队列表
+        teamList: [],
+        // 团队总数
+        teamTotal: 0,
+        // 表单
+        form: { red_logo: [], red_members: [], blue_logo: [], blue_members: [] },
+        // 是否轮空
+        byeList: ['true', 'false',]
+    },
+    initValidate() {
+        const rules = { date: { required: true }, time: { required: true }, position: { required: true }, red_position: { required: true }, red_id: { required: true }, blue_position: { required: false }, blue_id: { required: false } }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { date: { required: '比斯日期', }, time: { required: '比赛时间', }, position: { required: '比赛场次轮数', }, red_position: { required: '红方场次编号', }, red_id: { required: '红方团队', }, blue_id: { required: '蓝方团队', }, blue_position: { required: '蓝方场次编号', } };
+        this.WxValidate = new WxValidate(rules, messages)
     },
     back: function () {
         wx.navigateBack({ url: '/pages/matchadmin/index' })
     },
+    // 选择比赛时间
+    dateChange: function (e) {
+        const that = this;
+        const { type } = e.currentTarget.dataset;
+        const { value } = e.detail;
+        if (type == 'date') that.setData({ 'form.date': value })
+        else if (type == 'time') that.setData({ 'form.time': value });
+        let match_time = that.data.form.date + '-' + that.data.form.time;
+        that.setData({ 'form.match_time': match_time })
+    },
+    // 比赛场次轮数
+    positionBlur: function (e) {
+        const that = this;
+        const { value } = e.detail;
+        that.setData({ 'form.position': value });
+        that.setData({ 'form.red_position': value + '-' });
+        that.setData({ 'form.blue_position': value + '-' });
+    },
+    // 选择比赛双方
+    teamChange: function (e) {
+        const that = this;
+        const { type } = e.currentTarget.dataset;
+        const { value } = e.detail;
+        let teamInfo = that.data.teamList[value];
+        that.setData({ ['form.' + `${type}_id`]: teamInfo.team_id })
+        that.setData({ ['form.' + `${type}_name`]: teamInfo.team_name })
+        that.setData({ ['form.' + `${type}_logo`]: teamInfo.logo })
+        that.setData({ ['form.' + `${type}_members`]: teamInfo.members })
+    },
+    // 选择是否轮空
+    byeChange: function (e) {
+        const that = this;
+        const { value } = e.detail;
+        let data = that.data.byeList[value];
+        that.setData({ 'form.is_bye': data })
+    },
+    // 提交保存
+    async onSubmit(e) {
+        const that = this;
+        const params = e.detail.value;
+        const data = that.data.form;
+        if (!this.WxValidate.checkForm(params)) {
+            const error = this.WxValidate.errorList[0];
+            wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
+            return false
+        } else {
+            params.format = data.format;
+            params.red_logo = data.red_logo;
+            params.red_members = data.red_members;
+            params.blue_logo = data.blue_logo;
+            params.blue_members = data.blue_members;
+            const arr = await app.$post(`/courtAdmin/api/schedule`, params)
+            if (arr.errcode == '0') { wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 }); that.back(); }
+            else wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
+        }
+    },
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
+        const that = this;
+        if (options && options.id) that.setData({ match_id: options.id })
+        //验证规则函数
+        this.initValidate();
         // 计算高度
-        this.searchHeight()
+        this.searchHeight();
+        // 监听用户是否登录
+        this.watchLogin();
+    },
+    // 监听用户是否登录
+    watchLogin: function () {
+        const that = this;
+        wx.getStorage({
+            key: 'token',
+            success: async res => {
+                that.setData({ user: res.data });
+                let arr;
+                // 查询比赛信息
+                arr = await app.$get(`/courtAdmin/api/match/${that.data.match_id}`);
+                if (arr.errcode == '0') that.setData({ matchInfo: arr.data });
+                // 查询报名团队
+                arr = await app.$get(`/courtAdmin/api/matchteam`, { match_id: that.data.match_id })
+                if (arr.errcode == '0') that.setData({ teamList: arr.data });
+                that.setData({ teamTotal: arr.total });
+                // 组织表单数据
+                let data = { match_id: that.data.matchInfo._id, match_name: that.data.matchInfo.name, format: that.data.matchInfo.format };
+                that.setData({ form: data })
+            },
+            fail: res => {
+                return wx.redirectTo({ url: '/pages/login/index', })
+            }
+        })
     },
     // 计算高度
     searchHeight: function () {

+ 128 - 3
pages/matchadmin/layout.wxml

@@ -1,5 +1,130 @@
 <mobile-main frameStyle="{{frameStyle}}" bind:back="back">
-  <view slot="info" class="main" style="height:{{infoHeight}}px;">
-    模板
-  </view>
+    <view slot="info" class="main" style="height:{{infoHeight}}px;">
+        <view class="one">
+            <form bindsubmit="onSubmit">
+                <view class="content" style="display: none;">
+                    <view class="label textOver">比赛id</view>
+                    <view class="value">
+                        <input type="text" name="match_id" value="{{form.match_id}}" placeholder="请输入比赛id" disabled />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">比赛名称</view>
+                    <view class="value">
+                        <input type="text" name="match_name" value="{{form.match_name}}" placeholder="请输入比赛名称" disabled />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">比赛赛制</view>
+                    <view class="value">
+                        <text class="format" wx:for="{{form.format}}" wx:key="item">{{item.value}}</text>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">比赛日期</view>
+                    <view class="value">
+                        <picker mode="date" value="{{form.date}}" name="date" bindchange="dateChange" data-type="date">
+                            <view class="picker">{{form.date||'选择比赛日期'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">比赛时间</view>
+                    <view class="value">
+                        <picker mode="time" value="{{form.time}}" name="time" bindchange="dateChange" data-type="time">
+                            <view class="picker">{{form.time||'选择比赛时间'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">比赛完整时间</view>
+                    <view class="value">
+                        <input type="text" name="match_time" value="{{form.match_time}}" placeholder="请输入比赛完整时间" disabled />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">比赛场次轮数</view>
+                    <view class="value">
+                        <!-- bindblur----bindinput -->
+                        <input type="number" name="position" value="{{form.position}}" bindinput="positionBlur" placeholder="请输入比赛场次轮数" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">红方场次编号</view>
+                    <view class="value">
+                        <input type="number" name="red_position" value="{{form.red_position}}" placeholder="请输入红方场次编号" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">红方团队</view>
+                    <view class="value">
+                        <picker mode="selector" bindchange="teamChange" name="red_id" value="{{form.red_id}}" range-key="team_name" range="{{teamList}}" data-type="red">
+                            <view class="input">{{form.red_name||'选择红方团队'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">红方团队名称</view>
+                    <view class="value">
+                        <input type="text" name="red_name" value="{{form.red_name}}" placeholder="请输入红方团队名称" disabled />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">红方LOGO</view>
+                    <view class="value">
+                        <image class="image" src="{{form.red_logo[0].url}}"></image>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">红方成员</view>
+                    <view class="value">
+                        <text class="format" wx:for="{{form.red_members}}" wx:key="item">{{item.nickname}}</text>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">是否轮空</view>
+                    <view class="value">
+                        <picker name="is_bye" bindchange="byeChange" name="is_bye" value="{{form.is_bye}}" range="{{byeList}}">
+                            <view class="input">{{form.is_bye||'团队是否轮空'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">蓝方场次编号</view>
+                    <view class="value">
+                        <input type="number" name="blue_position" value="{{form.blue_position}}" placeholder="请输入蓝方场次编号" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">蓝方团队</view>
+                    <view class="value">
+                        <picker mode="selector" bindchange="teamChange" name="blue_id" value="{{form.blue_id}}" range-key="team_name" range="{{teamList}}" data-type="blue">
+                            <view class="input">{{form.blue_name||'选择蓝方团队'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">蓝方团队名称</view>
+                    <view class="value">
+                        <input type="text" name="blue_name" value="{{form.blue_name}}" placeholder="请输入蓝方团队名称" disabled />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">蓝方LOGO</view>
+                    <view class="value">
+                        <image class="image" src="{{form.blue_logo[0].url}}"></image>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">蓝方成员</view>
+                    <view class="value">
+                        <text class="format" wx:for="{{form.blue_members}}" wx:key="item">{{item.nickname}}</text>
+                    </view>
+                </view>
+                <view class="btn">
+                    <button type="primary" size="mini" formType="submit">提交保存</button>
+                </view>
+            </form>
+        </view>
+    </view>
 </mobile-main>

+ 60 - 0
pages/matchadmin/layout.wxss

@@ -1,4 +1,64 @@
 .main {
     position: relative;
     width: 100%;
+    background-color: #ffffff;
+    overflow-y: auto;
+}
+
+.main .one {
+    float: left;
+    width: 95%;
+    padding: 0 10px;
+}
+
+.main .one .content {
+    float: left;
+    width: 100%;
+    border-bottom: 1px solid #ccc;
+    padding: 10px 0;
+}
+
+.main .one .content .label {
+    float: left;
+    width: 30%;
+}
+
+.main .one .content .value {
+    float: left;
+    width: 70%;
+    text-align: right;
+}
+
+.main .one .content .value .image {
+    width: 50px;
+    height: 50px;
+    border-radius: 90px;
+
+}
+
+.main .one .content .value .input {
+    color: #868686;
+}
+
+.main .one .content .value .format {
+    float: right;
+    padding: 5px 10px;
+    background-color: #409eff;
+    color: #ffffff;
+    margin: 0 0 10px 10px;
+    border-radius: 5px;
+    font-size: 14px;
+}
+
+
+.main .one .btn {
+    float: left;
+    width: 100%;
+    text-align: center;
+    margin: 10px 0;
+}
+
+.main .one .btn button {
+    width: 50%;
+    font-size: 14px;
 }

+ 84 - 0
pages/matchadmin/layoutInfo.js

@@ -0,0 +1,84 @@
+// pages/login/login.js
+import WxValidate from '../../utils/wxValidate'
+const app = getApp()
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        frameStyle: { useTop: true, name: '赛制编排信息', leftArrow: true, useBar: false },
+        // 主体高度
+        infoHeight: '',
+    },
+    back: function () {
+        wx.navigateBack({ url: '/pages/matchadmin/index' })
+    },
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+        // 计算高度
+        this.searchHeight()
+    },
+    // 计算高度
+    searchHeight: function () {
+        let frameStyle = this.data.frameStyle;
+        let client = app.globalData.client;
+        let infoHeight = client.windowHeight;
+        // 是否去掉状态栏
+        if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
+        // 是否减去底部菜单
+        if (frameStyle.useBar) infoHeight = infoHeight - 50;
+        if (infoHeight) this.setData({ infoHeight: infoHeight })
+    },
+
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom: function () {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
+
+    }
+})

+ 6 - 0
pages/matchadmin/layoutInfo.json

@@ -0,0 +1,6 @@
+{
+    "component": true,
+    "usingComponents": {
+      "mobile-main": "/commpents/mobile-frame/mobile-main"
+    }
+  }

+ 5 - 0
pages/matchadmin/layoutInfo.wxml

@@ -0,0 +1,5 @@
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
+  <view slot="info" class="main" style="height:{{infoHeight}}px;">
+    模板
+  </view>
+</mobile-main>

+ 4 - 0
pages/matchadmin/layoutInfo.wxss

@@ -0,0 +1,4 @@
+.main {
+    position: relative;
+    width: 100%;
+}