ソースを参照

修改 赛程编排

zs 3 年 前
コミット
6463ad9a81

+ 0 - 1
app.json

@@ -34,7 +34,6 @@
     "pages/maintain/index",
     "pages/maintain/index",
     "pages/lays/detail",
     "pages/lays/detail",
     "pages/lays/index",
     "pages/lays/index",
-    "pages/layNew/index",
     "pages/modify/index",
     "pages/modify/index",
     "pages/match/detail",
     "pages/match/detail",
     "pages/logs/logs"
     "pages/logs/logs"

+ 0 - 198
pages/layNew/index.js

@@ -1,198 +0,0 @@
-// pages/login/login.js
-import WxValidate from '../../utils/wxValidate'
-const app = getApp()
-Page({
-    /**
-     * 页面的初始数据
-     */
-    data: {
-        // 主体高度
-        infoHeight: '',
-        frameStyle: { useTop: true, name: '新增赛程编排', leftArrow: true, useBar: false },
-        form: {
-        },
-        // 上传图片
-        fileList: [],
-        //比赛id
-        id: '',
-        //团队
-        cateArray: [],
-        cateIndex: 0,
-        objectArray: [],
-        cateIndex1: 0,
-        objectArray1: [],
-        index: 0,
-        date: '2022-05-01',
-        time: '08:00',
-        red: {},
-        blue: {},
-    },
-    //验证必填项
-    initValidate() {
-        const rules = { match_name: { required: true }, }
-        // 验证字段的提示信息,若不传则调用默认的信息
-        const messages = { match_name: { required: '请输入比赛名称' }, };
-        this.WxValidate = new WxValidate(rules, messages)
-    },
-    back: function () {
-        wx.navigateBack({ url: '/pages/me/index' })
-    },
-    //蓝方
-    bindCatePickerChangeblue: function (e) {
-        this.setData({ cateIndex: e.detail.value, blue: e.currentTarget.dataset.item, })
-    },
-    //红方
-    bindCatePickerChangered: function (e) {
-        this.setData({ cateIndex1: e.detail.value, red: e.currentTarget.dataset.item, })
-    },
-    //选择时间
-    bindDateChange: function (e) {
-        this.setData({date: e.detail.value})
-    },
-    bindTimeChange: function (e) {
-        this.setData({time: e.detail.value})
-    },
-    //提交
-    formSubmit: function (e) {
-        const value = e.detail.value;
-        value.match_id = this.data.id;
-        value.red_id = this.data.red.team_id;
-        value.red_name = this.data.red.team_name;
-        value.red_logo = this.data.red.logo;
-        value.red_members = this.data.red.members;
-        value.blue_id = this.data.blue.team_id;
-        value.blue_name = this.data.blue.team_name;
-        value.blue_logo = this.data.blue.logo;
-        value.blue_members = this.data.blue.members;
-        value.match_time = this.data.date + '  ' + this.data.time;
-        if (!this.WxValidate.checkForm(value)) {
-            const error = this.WxValidate.errorList[0];
-            wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
-            return false
-        } else {
-            wx.request({
-                url: `${app.globalData.publicUrl}/courtAdmin/api/schedule`, 
-                method: "post",
-                data: value,
-                header: {},
-                success: res => {
-                    if (res.data.errcode == 0) {
-                        wx.showToast({
-                            title: '保存成功',
-                            icon: 'success',
-                            duration: 2000
-                        })
-                    } else {
-                        wx.showToast({
-                            title: '保存失败',
-                            icon: 'success',
-                            duration: 2000
-                        })
-                    }
-                },
-            })
-        }
-    },
-    /**
-     * 生命周期函数--监听页面加载
-     */
-    onLoad: function (options) {
-        this.setData({ id: options.id })
-        //验证规则函数
-        this.initValidate();
-        // 计算高度
-        this.searchHeight();
-        // 监听用户是否登录
-        this.watchLogin();
-    },
-    // 监听用户是否登录
-    watchLogin: function () {
-        const that = this;
-        let id = that.data.id;
-        wx.getStorage({
-            key: 'token',
-            success: res => {
-                wx.request({
-                    url: `${app.globalData.publicUrl}/courtAdmin/api/match/${id}`,
-                    method: 'get',
-                    data: {},
-                    success(res) {
-                        that.setData({ form: res.data.data })
-                    }
-                })
-                wx.request({
-                    url: `${app.globalData.publicUrl}/courtAdmin/api/matchteam`,
-                    method: 'get',
-                    data: { match_id: id, status: 1 },
-                    success(res) {
-                        that.setData({ cateArray: res.data.data })
-                    }
-                })
-            },
-            fail: res => {
-                return wx.redirectTo({ url: '/pages/login/index', })
-            }
-        })
-    },
-
-    // 计算高度
-    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 () {
-
-    }
-})

+ 0 - 7
pages/layNew/index.json

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

+ 0 - 37
pages/layNew/index.wxml

@@ -1,37 +0,0 @@
-<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
-    <view slot="info" class="main" style="height:{{infoHeight}}px;">
-        <form catchsubmit="formSubmit" catchreset="formReset">
-            <view class="form" style="height:{{infoHeight-140}}px;">
-                <view class="one">
-                    <view class="text">比赛名称</view>
-                    <input class="input" name="match_name" disabled="true" value="{{form.name}}" placeholder="" />
-                </view>
-                <view class="one">
-                    <view class="text">蓝方</view>
-                    <picker mode="selector" bindchange="bindCatePickerChangeblue" value="{{cateIndex}}"   data-item="{{cateArray[cateIndex]}}" range-key="team_name" range="{{cateArray}}">
-                        <view class="input" >{{cateArray[cateIndex].team_name}}</view>
-                    </picker>
-                </view>
-                <view class="one">
-                    <view class="text">红方</view>
-                    <picker mode="selector" bindchange="bindCatePickerChangered" value="{{cateIndex1}}" data-item="{{cateArray[cateIndex1]}}" range-key="team_name" range="{{cateArray}}">
-                        <view class="input"  >{{cateArray[cateIndex1].team_name}}</view>
-                    </picker>
-                </view>
-                <view class="one">
-                    <view class="text">比赛时间</view>
-                    <picker mode="date" value="{{date}}" start="2015-09-01" end="3017-09-01" bindchange="bindDateChange">
-                        <view class="input1">{{date}}</view>
-                    </picker>
-                    <picker mode="time" value="{{time}}" start="00:00" end="23:59" bindchange="bindTimeChange">
-                        <view class="input2">{{time}}</view>
-                    </picker>
-                </view>
-            </view>
-
-            <view class="btn-area">
-                <button class="button" formType="submit">保存</button>
-            </view>
-        </form>
-    </view>
-</mobile-main>

+ 0 - 112
pages/layNew/index.wxss

@@ -1,112 +0,0 @@
-.main {
-  position: relative;
-  width: 100%;
-  background-color: #ffffff;
-  padding: 20px 0 0 0;
-}
-
-
-.one {
-  border-bottom: 1px solid #dddddd;
-  margin: 0 20px;
-  height: 40px;
-}
-
-.text {
-  position: relative;
-  top: 10px;
-  width: 40%;
-}
-
-.input {
-  position: relative;
-  text-align: right;
-  left: 130px;
-  top: -10px;
-  width: 60%;
-  font-size: 14px;
-}
-
-.input1 {
-  position: relative;
-  text-align: right;
-  left: 120px;
-  top: -8px;
-  width: 50%;
-  font-size: 14px;
-}
-
-.input2 {
-  width: 50px;
-  position: relative;
-  text-align: right;
-  left: 280px;
-  top: -27px;
-  font-size: 14px;
-}
-
-.button {
-  position: relative;
-  top: 50px;
-  width: 300px !important;
-  background-image: linear-gradient(to right, #fd3c1e, #c74df0);
-  border-radius: 30px;
-  color: #ffffff;
-  text-align: center;
-  font-size: small;
-}
-
-.top-text {
-  float: left;
-}
-
-/* 下拉框 */
-
-.top-selected {
-  width: 50%;
-  display: flex;
-  float: right;
-  align-items: center;
-  justify-content: space-between;
-  padding: 0 10rpx;
-  z-index: 999;
-  font-size: 30rpx;
-}
-
-/* 下拉内容 */
-
-.select_box {
-  background-color: #fff;
-  padding: 0 20rpx;
-  width: 50%;
-  float: right;
-  position: relative;
-  right: 0;
-  z-index: 1;
-  overflow: hidden;
-  text-align: left;
-  animation: myfirst 0.5s;
-  font-size: 30rpx;
-}
-
-.select_one {
-  padding-left: 20rpx;
-  width: 100%;
-  height: 60rpx;
-  position: relative;
-  z-index: 1;
-  line-height: 60rpx;
-  border-bottom: 1px solid #ccc;
-}
-
-/* 下拉过度效果 */
-
-@keyframes myfirst {
-  from {
-    height: 0rpx;
-  }
-
-  to {
-    height: 210rpx;
-  }
-}

+ 61 - 23
pages/lays/detail.js

@@ -10,31 +10,85 @@ Page({
         frameStyle: { useTop: true, name: '编排信息管理', leftArrow: true, useBar: false },
         frameStyle: { useTop: true, name: '编排信息管理', leftArrow: true, useBar: false },
         // 主体高度
         // 主体高度
         infoHeight: '',
         infoHeight: '',
+        form: {},
         // 比赛id
         // 比赛id
         id: '',
         id: '',
         // 比赛信息
         // 比赛信息
         matchInfo: {},
         matchInfo: {},
+        // 参赛团队
+        matchteamList: [],
+        // 红方数据
+        redInfo: {},
+        // 蓝方数据
+        blueInfo: {},
     },
     },
     //验证必填项
     //验证必填项
     initValidate() {
     initValidate() {
-        const rules = { match_name: { required: true }, }
+        const rules = { red_id: { required: true }, blue_id: { required: true }, date: { required: true }, time: { required: true }, }
         // 验证字段的提示信息,若不传则调用默认的信息
         // 验证字段的提示信息,若不传则调用默认的信息
-        const messages = { match_name: { required: '请输入比赛名称' }, };
+        const messages = { red_id: { required: '选择红方' }, blue_id: { required: '选择蓝方' }, date: { required: '选择日期' }, time: { required: '选择时间' } };
         this.WxValidate = new WxValidate(rules, messages)
         this.WxValidate = new WxValidate(rules, messages)
     },
     },
     back: function () {
     back: function () {
         wx.navigateBack({ url: '/pages/lays/index' })
         wx.navigateBack({ url: '/pages/lays/index' })
     },
     },
+    // 选择红方
+    redChange: function (e) {
+        const that = this;
+        let index = e.detail.value;
+        let data = that.data.matchteamList[index];
+        if (data) {
+            that.setData({ 'form.red_id': data._id, 'form.red_name': data.team_name })
+            that.setData({ redInfo: data })
+        }
+    },
+    // 选择蓝方
+    blueChange: function (e) {
+        const that = this;
+        let index = e.detail.value;
+        let data = that.data.matchteamList[index];
+        if (data) {
+            that.setData({ 'form.blue_id': data._id, 'form.blue_name': data.team_name })
+            that.setData({ blueInfo: data })
+        }
+    },
+    // 日期选择
+    dateChange: function (e) {
+        const that = this;
+        that.setData({ 'form.date': e.detail.value });
+        that.setData({ 'form.match_time': that.data.form.date + ' ' + that.data.form.time })
+    },
+    // 时间选择
+    timeChange: function (e) {
+        const that = this;
+        that.setData({ 'form.time': e.detail.value });
+        that.setData({ 'form.match_time': that.data.form.date + ' ' + that.data.form.time })
+    },
     // 保存信息
     // 保存信息
-    onSubmit: function (e) {
+    onSubmit: async function (e) {
         const that = this;
         const that = this;
+        let red = that.data.redInfo;
+        let blue = that.data.blueInfo;
         let parmas = e.detail.value;
         let parmas = e.detail.value;
+        parmas.red_name = red.team_name;
+        parmas.red_logo = red.logo;
+        parmas.red_members = red.members;
+        parmas.blue_name = blue.team_name;
+        parmas.blue_logo = blue.logo;
+        parmas.blue_members = blue.members;
         if (!this.WxValidate.checkForm(parmas)) {
         if (!this.WxValidate.checkForm(parmas)) {
             const error = this.WxValidate.errorList[0];
             const error = this.WxValidate.errorList[0];
             wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
             wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
             return false
             return false
         } else {
         } else {
-            console.log(parmas);
+            const arr = await app.$post(`/courtAdmin/api/schedule`, parmas);
+            if (arr.errcode === 0) {
+                wx.showToast({ title: '保存成功', icon: 'success', duration: 2000 })
+                that.back();
+            } else {
+                wx.showToast({ title: arr.errmsg, icon: 'error', duration: 2000 })
+
+            }
         }
         }
     },
     },
     /**
     /**
@@ -42,7 +96,7 @@ Page({
      */
      */
     onLoad: function (options) {
     onLoad: function (options) {
         const that = this;
         const that = this;
-        that.setData({ id: '6254da6515156e74edf8bbfc' })
+        that.setData({ id: options.id})
         //验证规则函数
         //验证规则函数
         this.initValidate();
         this.initValidate();
         // 计算高度
         // 计算高度
@@ -66,24 +120,8 @@ Page({
                     that.setData({ 'form.match_id': arr.data._id, 'form.match_name': arr.data.name })
                     that.setData({ 'form.match_id': arr.data._id, 'form.match_name': arr.data.name })
                 }
                 }
                 // 参赛团队
                 // 参赛团队
-                const aee = await app.$get(`/courtAdmin/api/match`, { match_id: id, status: 1 });
-                console.log(aee);
-                // wx.request({
-                //     url: `${app.globalData.publicUrl}/courtAdmin/api/match/${id}`,
-                //     method: 'get',
-                //     data: {},
-                //     success(res) {
-                //         that.setData({ form: res.data.data })
-                //     }
-                // })
-                // wx.request({
-                //     url: `${app.globalData.publicUrl}/courtAdmin/api/matchteam`,
-                //     method: 'get',
-                //     data: { match_id: id, status: 1 },
-                //     success(res) {
-                //         that.setData({ cateArray: res.data.data })
-                //     }
-                // })
+                const aee = await app.$get(`/courtAdmin/api/matchteam`, { match_id: id, status: 1 });
+                if (aee.errcode === 0) that.setData({ matchteamList: aee.data })
             },
             },
             fail: res => {
             fail: res => {
                 return wx.redirectTo({ url: '/pages/login/index', })
                 return wx.redirectTo({ url: '/pages/login/index', })

+ 39 - 1
pages/lays/detail.wxml

@@ -14,8 +14,46 @@
             <input name="match_name" value="{{form.match_name}}" disabled />
             <input name="match_name" value="{{form.match_name}}" disabled />
           </view>
           </view>
         </view>
         </view>
+        <view class="content">
+          <view class="label">红方</view>
+          <view class="value">
+            <picker mode="selector" bindchange="redChange" name="red_id" value="{{form.red_id}}" range-key="team_name" range="{{matchteamList}}">
+              <view class="input">{{form.red_name||'选择红方'}}</view>
+            </picker>
+          </view>
+        </view>
+        <view class="content">
+          <view class="label">蓝方</view>
+          <view class="value">
+            <picker mode="selector" bindchange="blueChange" name="blue_id" value="{{form.blue_id}}" range-key="team_name" range="{{matchteamList}}">
+              <view class="input">{{form.blue_name||'选择蓝方'}}</view>
+            </picker>
+          </view>
+        </view>
+        <view class="content">
+          <view class="label">比赛日期</view>
+          <view class="value">
+            <picker mode="date" name="date" value="{{form.date}}" bindchange="dateChange">
+              <view>{{form.date||'选择日期'}}</view>
+            </picker>
+          </view>
+        </view>
+        <view class="content">
+          <view class="label">比赛时间</view>
+          <view class="value">
+            <picker mode="time" name="time" value="{{form.time}}" bindchange="timeChange">
+              <view>{{form.time||'选择时间'}}</view>
+            </picker>
+          </view>
+        </view>
+        <view class="content">
+          <view class="label">比赛完整日期</view>
+          <view class="value">
+            <input name="match_time" value="{{form.match_time}}" disabled />
+          </view>
+        </view>
         <view class="btn">
         <view class="btn">
-          <button size="mini" type="primary" formType="submit">保存</button>
+          <button class="button" size="mini" type="primary" formType="submit">保存</button>
         </view>
         </view>
       </form>
       </form>
     </view>
     </view>

+ 6 - 2
pages/lays/detail.wxss

@@ -39,6 +39,10 @@
     margin: 10px 0 0 0;
     margin: 10px 0 0 0;
 }
 }
 
 
-.main .one .btn button {
-    width: 50%;
+.main .one .btn .button {
+    width: 300px !important;
+    border-radius: 30px;
+    color: #ffffff;
+    text-align: center;
+    background-image: linear-gradient(to right, #fd3c1e, #c74df0);
 }
 }

+ 1 - 1
pages/lays/index.js

@@ -33,7 +33,7 @@ Page({
      * 生命周期函数--监听页面加载
      * 生命周期函数--监听页面加载
      */
      */
     onLoad: function (options) {
     onLoad: function (options) {
-        this.setData({ id: options.id || '6254da6515156e74edf8bbfc' })
+        this.setData({ id: options.id})
         // 计算高度
         // 计算高度
         this.searchHeight();
         this.searchHeight();
         // 监听用户是否登录
         // 监听用户是否登录