guhongwei hace 3 años
padre
commit
6153d2acc6
Se han modificado 5 ficheros con 233 adiciones y 3 borrados
  1. 153 0
      pages/lays/detail.js
  2. 6 0
      pages/lays/detail.json
  3. 23 0
      pages/lays/detail.wxml
  4. 44 0
      pages/lays/detail.wxss
  5. 7 3
      pages/lays/index.js

+ 153 - 0
pages/lays/detail.js

@@ -0,0 +1,153 @@
+// pages/login/login.js
+import WxValidate from '../../utils/wxValidate'
+const app = getApp()
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        frameStyle: { useTop: true, name: '编排信息管理', leftArrow: true, useBar: false },
+        // 主体高度
+        infoHeight: '',
+        // 比赛id
+        id: '',
+        // 比赛信息
+        matchInfo: {},
+    },
+    //验证必填项
+    initValidate() {
+        const rules = { match_name: { required: true }, }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { match_name: { required: '请输入比赛名称' }, };
+        this.WxValidate = new WxValidate(rules, messages)
+    },
+    back: function () {
+        wx.navigateBack({ url: '/pages/lays/index' })
+    },
+    // 保存信息
+    onSubmit: function (e) {
+        const that = this;
+        let parmas = e.detail.value;
+        if (!this.WxValidate.checkForm(parmas)) {
+            const error = this.WxValidate.errorList[0];
+            wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
+            return false
+        } else {
+            console.log(parmas);
+        }
+    },
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+        const that = this;
+        that.setData({ id: '6254da6515156e74edf8bbfc' })
+        //验证规则函数
+        this.initValidate();
+        // 计算高度
+        this.searchHeight();
+        // 监听用户是否登录
+        this.watchLogin();
+
+    },
+    // 验证用户登录
+    watchLogin: async function () {
+        const that = this;
+        let id = that.data.id;
+        wx.getStorage({
+            key: 'token',
+            success: async res => {
+                // 查询比赛信息
+                const arr = await app.$post(`/courtAdmin/api/match/${id}`);
+                if (arr.errcode === 0) {
+                    that.setData({ matchInfo: arr.data });
+                    // 赋值form比赛信息
+                    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 })
+                //     }
+                // })
+            },
+            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 () {
+
+    }
+})

+ 6 - 0
pages/lays/detail.json

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

+ 23 - 0
pages/lays/detail.wxml

@@ -0,0 +1,23 @@
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
+  <view slot="info" class="main" style="height:{{infoHeight}}px;">
+    <view class="one">
+      <form catchsubmit="onSubmit">
+        <view class="content" style="display: none;">
+          <view class="label">比赛id</view>
+          <view class="value">
+            <input name="match_id" value="{{form.match_id}}" disabled />
+          </view>
+        </view>
+        <view class="content">
+          <view class="label">比赛名称</view>
+          <view class="value">
+            <input name="match_name" value="{{form.match_name}}" disabled />
+          </view>
+        </view>
+        <view class="btn">
+          <button size="mini" type="primary" formType="submit">保存</button>
+        </view>
+      </form>
+    </view>
+  </view>
+</mobile-main>

+ 44 - 0
pages/lays/detail.wxss

@@ -0,0 +1,44 @@
+.main {
+    position: relative;
+    width: 100%;
+
+}
+
+.main .one {
+    float: left;
+    width: 100%;
+}
+
+.main .one .content {
+    float: left;
+    width: 95%;
+    padding: 10px;
+    background-color: #ffffff;
+    border-bottom: 1px solid #ccc;
+
+}
+
+.main .one .content .label {
+    float: left;
+    width: 30%;
+    font-size: 14px;
+}
+
+.main .one .content .value {
+    float: left;
+    width: 70%;
+    text-align: right;
+    font-size: 12px;
+    color: #666;
+}
+
+.main .one .btn {
+    float: left;
+    width: 100%;
+    text-align: center;
+    margin: 10px 0 0 0;
+}
+
+.main .one .btn button {
+    width: 50%;
+}

+ 7 - 3
pages/lays/index.js

@@ -16,20 +16,24 @@ Page({
         wx.navigateBack({ url: '/pages/meMatch/index' })
         wx.navigateBack({ url: '/pages/meMatch/index' })
     },
     },
     //新增赛程编排
     //新增赛程编排
+    // addTo: function (e) {
+    //     let id = this.data.id;
+    //     wx.navigateTo({ url: `/pages/layNew/index?id=${id}`, })
+    // },
     addTo: function (e) {
     addTo: function (e) {
         let id = this.data.id;
         let id = this.data.id;
-        wx.navigateTo({ url: `/pages/layNew/index?id=${id}`, })
+        wx.navigateTo({ url: `/pages/lays/detail?id=${id}`, })
     },
     },
     //维护赛程编排
     //维护赛程编排
     modify: function (e) {
     modify: function (e) {
         let id = e.currentTarget.dataset.id;
         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) {
     onLoad: function (options) {
-        this.setData({ id: options.id })
+        this.setData({ id: options.id || '6254da6515156e74edf8bbfc' })
         // 计算高度
         // 计算高度
         this.searchHeight();
         this.searchHeight();
         // 监听用户是否登录
         // 监听用户是否登录