Browse Source

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

zs 3 years ago
parent
commit
a07f483a4e
5 changed files with 61 additions and 121 deletions
  1. 11 22
      pages/layNew/index.js
  2. 8 13
      pages/lays/index.js
  3. 0 6
      pages/lays/index.wxml
  4. 39 76
      pages/maintain/index.js
  5. 3 4
      pages/modify/index.js

+ 11 - 22
pages/layNew/index.js

@@ -1,7 +1,6 @@
 // pages/login/login.js
 import WxValidate from '../../utils/wxValidate'
 const app = getApp()
-var type = "";//用来保存picker组件选中的类别id
 Page({
     /**
      * 页面的初始数据
@@ -16,6 +15,7 @@ Page({
         fileList: [],
         //比赛id
         id: '',
+        //团队
         cateArray: [],
         cateIndex: 0,
         objectArray: [],
@@ -39,32 +39,21 @@ Page({
     },
     //蓝方
     bindCatePickerChangeblue: function (e) {
-        this.setData({
-            cateIndex: e.detail.value,
-            blue: e.currentTarget.dataset.item,
-        })
+        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,
-        })
+        this.setData({ cateIndex1: e.detail.value, red: e.currentTarget.dataset.item, })
     },
     //选择时间
     bindDateChange: function (e) {
-        this.setData({
-            date: e.detail.value
-        })
+        this.setData({date: e.detail.value})
     },
     bindTimeChange: function (e) {
-        this.setData({
-            time: e.detail.value
-        })
+        this.setData({time: e.detail.value})
     },
     //提交
     formSubmit: function (e) {
-        var match_time = this.data.date + '  ' + this.data.time;
         const value = e.detail.value;
         value.match_id = this.data.id;
         value.red_id = this.data.red.team_id;
@@ -75,14 +64,14 @@ Page({
         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 = match_time;
+        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`, //接口地址
+                url: `${app.globalData.publicUrl}/courtAdmin/api/schedule`, 
                 method: "post",
                 data: value,
                 header: {},
@@ -91,7 +80,7 @@ Page({
                         wx.showToast({
                             title: '保存成功',
                             icon: 'success',
-                            duration: 2000//延迟两秒
+                            duration: 2000
                         })
                     } else {
                         wx.showToast({
@@ -124,7 +113,7 @@ Page({
             key: 'token',
             success: res => {
                 wx.request({
-                    url: `${app.globalData.publicUrl}/courtAdmin/api/match/${id}`, //接口地址
+                    url: `${app.globalData.publicUrl}/courtAdmin/api/match/${id}`,
                     method: 'get',
                     data: {},
                     success(res) {
@@ -132,9 +121,9 @@ Page({
                     }
                 })
                 wx.request({
-                    url: `${app.globalData.publicUrl}/courtAdmin/api/matchteam`, //接口地址
+                    url: `${app.globalData.publicUrl}/courtAdmin/api/matchteam`,
                     method: 'get',
-                    data: { match_id: id },
+                    data: { match_id: id, status: 1 },
                     success(res) {
                         that.setData({ cateArray: res.data.data })
                     }

+ 8 - 13
pages/lays/index.js

@@ -16,25 +16,20 @@ Page({
         wx.navigateBack({ url: '/pages/meMatch/index' })
     },
     //新增赛程编排
-    addTo: function () {
+    addTo: function (e) {
         let id = this.data.id;
-        wx.navigateTo({
-            url: `/pages/layNew/index?id=${id}`,
-        })
+        wx.navigateTo({ url: `/pages/layNew/index?id=${id}`, })
     },
-     //新增赛程编排
-     modify: function (e) {
+    //维护赛程编排
+    modify: function (e) {
         let id = e.currentTarget.dataset.id;
-        wx.navigateTo({
-            url: `/pages/modify/index?id=${id}`,
-        })
+        wx.navigateTo({url: `/pages/modify/index?id=${id}`,})
     },
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
         this.setData({ id: options.id })
-        // let id = options.id
         // 计算高度
         this.searchHeight();
         // 监听用户是否登录
@@ -47,7 +42,7 @@ Page({
             key: 'token',
             success: res => {
                 wx.request({
-                    url: `${app.globalData.publicUrl}/courtAdmin/api/schedule`, //接口地址
+                    url: `${app.globalData.publicUrl}/courtAdmin/api/schedule`,
                     method: 'get',
                     data: { match_id: that.data.id },
                     success(res) {
@@ -60,8 +55,8 @@ Page({
             }
         })
     },
-     // 计算高度
-     searchHeight: function () {
+    // 计算高度
+    searchHeight: function () {
         let frameStyle = this.data.frameStyle;
         let client = app.globalData.client;
         let infoHeight = client.windowHeight;

+ 0 - 6
pages/lays/index.wxml

@@ -9,9 +9,6 @@
                     <view class="left">
                         <view class="fourright4">
                             <view class="fourright1_2">
-                                <!-- <view class="fourright1_2o">
-                                    <image class="fourhead1" src="{{item.blue_logo[0].url}}"></image>
-                                </view> -->
                                 <view class="fourright1_2t"><text>{{item.blue_name}}</text></view>
                                 <view class="fourright1_2i">
                                     <text class="fourtext6-1">{{item.blue_branch||0}}</text>
@@ -19,9 +16,6 @@
                                     <text class="fourtext7-1">{{item.red_branch||0}}</text>
                                 </view>
                                 <view class="fourright1_2t"><text>{{item.red_name}}</text></view>
-                                <!-- <view class="fourright1_2oi">
-                                    <image class="fourhead2" src="{{item.red_logo[0].url}}"></image>
-                                </view> -->
                             </view>
                         </view>
                     </view>

+ 39 - 76
pages/maintain/index.js

@@ -33,6 +33,13 @@ Page({
     // 赛制储存信息
     szList: [],
   },
+  //验证是否输入
+  initValidate() {
+    const rules = { name: { required: true }, match_time: { required: true, }, single_time: { required: true }, address: { required: true, }, format: { required: true } }
+    // 验证字段的提示信息,若不传则调用默认的信息
+    const messages = { name: { required: '请输入比赛名称', }, match_time: { required: '请输入时间', }, single_time: { required: '请输入单场时间', }, address: { required: '请输入地点', }, format: { required: '请选择赛制', } };
+    this.WxValidate = new WxValidate(rules, messages)
+  },
   //当用户点击确定时,执行的事件
   bindCatePickerChange: function (e) {
     var cid = this.data.cateArray[e.detail.value].id;
@@ -100,25 +107,12 @@ Page({
   //提交
   formSubmit: function (e) {
     const value = e.detail.value;
-    var cateIndex =this.data.cateIndex
-    var id = this.ids;
-    var name = value.name;
-    var match_time = this.data.starttime + ' - ' + this.data.endtime;
-    var single_time = this.data.timedate + ' ' + this.data.time;
-    var address = value.address;
-    var format = this.data.szList;
-    // var match_team = this.form.match_team;
-    const params = {
-      "id": id,
-      "name": name,
-      "match_time": match_time,
-      "single_time": single_time,
-      "address": address,
-      "format": format,
-      "match_team": [],
-      "status": cateIndex
-    };
-    if (!this.WxValidate.checkForm(params)) {
+    value.match_time = this.data.starttime + ' - ' + this.data.endtime;
+    value.single_time = this.data.timedate + ' ' + this.data.time;
+    value.format = this.data.szList;
+    value.status = this.data.cateIndex;
+    var id = this.data.ids;
+    if (!this.WxValidate.checkForm(value)) {
       const error = this.WxValidate.errorList[0];
       wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
       return false
@@ -127,20 +121,12 @@ Page({
         key: 'token',
         success: function (res) {
           wx.request({
-            url: `${app.globalData.publicUrl}/courtAdmin/api/match/${id}`, //接口地址
+            url: `${app.globalData.publicUrl}/courtAdmin/api/match/${id}`,
             method: 'post',
-            data: params,
+            data: value,
             success(res) {
-              if (res.data.errcode == 0) {
-                wx.showToast({ title: `修改比赛成功`, icon: 'success', duration: 2000 }) //创建成功提示
-                // wx.navigateTo({ url: '/pages/administration/index' })// 跳转页面
-              } else {
-                wx.showToast({
-                  title: res.data.errmsg,
-                  icon: 'none',
-                  duration: 2000
-                })
-              }
+              console.log(res.data.data);
+              wx.showToast({ title: `修改比赛成功`, icon: 'success', duration: 2000 })
             }
           })
         }
@@ -154,65 +140,42 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    this.ids = options.id;
+    const that = this;
+    that.setData({ ids: options.id })
     //选择器
-    var cindex = this.data.cateIndex
-    type = this.data.cateArray[cindex].id
+    var cindex = that.data.cateIndex
+    type = that.data.cateArray[cindex].id
     // 监听用户是否登录
-    this.watchLogin();
+    that.watchLogin();
     //验证规则函数
-    this.initValidate()
+    that.initValidate()
     // 计算高度
-    this.searchHeight()
-    const that = this;
+    that.searchHeight()
     // 初始化数据
     that.search();
   },
-  //验证是否输入
-  initValidate() {
-    const rules = { name: { required: true }, match_time: { required: true, }, single_time: { required: true }, address: { required: true, }, format: { required: true } }
-    // 验证字段的提示信息,若不传则调用默认的信息
-    const messages = { name: { required: '请输入比赛名称', }, match_time: { required: '请输入时间', }, single_time: { required: '请输入单场时间', }, address: { required: '请输入地点', }, format: { required: '请选择赛制', } };
-    this.WxValidate = new WxValidate(rules, messages)
-  },
+
   // 监听用户是否登录
   watchLogin: function () {
+    var that = this;
+    var id = that.data.ids;
     wx.getStorage({
       key: 'token',
       success: res => {
-        var that = this;
-        var id = that.ids;
         wx.request({
-          url: `${app.globalData.publicUrl}/courtAdmin/api/match/${id}`, //接口地址
+          url: `${app.globalData.publicUrl}/courtAdmin/api/match/${id}`,
           method: 'get',
-          // data: {},
+          data: {},
           success(res) {
-            if (res.data.errcode == 0) {
-              let datas = res.data.data
-              let timer = res.data.data.single_time
-              let date = res.data.data.match_time
-              let status = res.data.data.status
-              let szList = res.data.data.format
-              let timedate = timer.substring(0, 10)
-              let time = timer.substring(11, 16)
-              let starttime = date.substring(0, 10)
-              let endtime = date.substring(16, 28)
-              that.setData({
-                form: datas,
-                timedate: timedate,
-                time: time,
-                starttime: starttime,
-                endtime: endtime,
-                cateIndex: status,
-                szList: szList
-              });  
-            } else {
-              wx.showToast({
-                title: res.data.errmsg,
-                icon: 'none',
-                duration: 2000
-              })
-            }
+            that.setData({
+              form: res.data.data,
+              timedate: res.data.data.single_time.substring(0, 10),
+              time: res.data.data.single_time.substring(11, 16),
+              starttime: res.data.data.match_time.substring(0, 10),
+              endtime: res.data.data.match_time.substring(13, 28),
+              cateIndex: res.data.data.status,
+              szList: res.data.data.format
+            });
           }
         })
       },
@@ -237,7 +200,7 @@ Page({
     // 是否减去底部菜单
     if (frameStyle.useBar) infoHeight = infoHeight - 50;
     if (infoHeight) this.setData({ infoHeight: infoHeight })
-},
+  },
 
   /**
    * 生命周期函数--监听页面初次渲染完成

+ 3 - 4
pages/modify/index.js

@@ -21,7 +21,6 @@ Page({
   bindCatePickerChange: function (e) {
     var cid = this.data.cateArray[e.detail.value].id;
     type = cid
-    //下面重新赋值必须有,页面显示的信息才会改为刚刚选中的值
     this.setData({
       cateIndex: e.detail.value,
     })
@@ -35,7 +34,7 @@ Page({
     let id = that.data.id;
     let status = that.data.cateIndex
     wx.request({
-      url: `${app.globalData.publicUrl}/courtAdmin/api/schedule/${id}`, //接口地址
+      url: `${app.globalData.publicUrl}/courtAdmin/api/schedule/${id}`,
       method: "post",
       data: { status: status },
       header: {},
@@ -44,7 +43,7 @@ Page({
           wx.showToast({
             title: '修改成功',
             icon: 'success',
-            duration: 2000//延迟两秒
+            duration: 2000
           })
         } else {
           wx.showToast({
@@ -77,7 +76,7 @@ Page({
       key: 'token',
       success: res => {
         wx.request({
-          url: `${app.globalData.publicUrl}/courtAdmin/api/schedule/${id}`, //接口地址
+          url: `${app.globalData.publicUrl}/courtAdmin/api/schedule/${id}`,
           method: 'get',
           data: {},
           success(res) {