zs 2 gadi atpakaļ
vecāks
revīzija
d3bc8fcb80

+ 2 - 0
app.json

@@ -15,6 +15,8 @@
         "pages/match/index",
         "pages/match/mess",
         "pages/match/matchadd",
+        "pages/match/project",
+        "pages/match/projectadd",
         "pages/test/index"
     ],
     "usingComponents": {

+ 133 - 0
pages/match/project.js

@@ -0,0 +1,133 @@
+const app = getApp()
+import WxValidate from '../../utils/wxValidate'
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        frameStyle: { useTop: true, name: '比赛管理', leftArrow: true, useBar: false },
+        //查询条件
+        searchName: '',
+        list: [{
+            name: '测试',
+            explain: '比赛说明',
+            num: 1
+        }]
+    },
+    // 跳转菜单
+    back(e) {
+        wx.navigateBack({ delta: 1 })
+    },
+    //添加
+    toAdd: function () {
+        wx.navigateTo({ url: `/pages/match/projectadd` })
+    },
+    // 修改
+    toEdit: function (e) {
+        const that = this;
+        let { id } = e.currentTarget.dataset;
+        wx.navigateTo({ url: `/pages/match/projectadd?id=${id}` })
+    },
+    // 删除
+    toDel: async function (e) {
+        const that = this;
+        const { id } = e.currentTarget.dataset;
+        wx.showModal({
+            title: '提示',
+            content: '是否确认删除该条数据?',
+            async success(res) {
+                if (res.confirm) {
+                    const arr = await app.$delete(`/newCourt/api/matchProject/${id}`);
+                    if (arr.errcode == '0') {
+                        wx.showToast({ title: `删除信息成功`, icon: 'success', duration: 2000 })
+                        that.watchLogin()
+                    } else {
+                        wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
+                    }
+                }
+            }
+        })
+    },
+    // 查询信息
+    onSearch: function (e) {
+        const that = this;
+        that.setData({ searchName: e.detail });
+        that.watchLogin();
+    },
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+        const that = this;
+        // 监听用户是否登录
+        that.watchLogin();
+
+    },
+    // 监听用户是否登录
+    watchLogin: async function () {
+        const that = this;
+        wx.getStorage({
+            key: 'user',
+            success: async res => {
+                let info = {};
+                if (that.data.searchName) info.name = that.data.searchName;
+                const arr = await app.$get(`/newCourt/api/matchProject/`, { ...info });
+                if (arr.errcode == '0') {
+                    that.setData({ list: arr.data });
+                }
+            },
+            fail: res => {
+                wx.redirectTo({ url: '/pages/index/index', })
+            }
+        })
+    },
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
+        this.watchLogin();
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom: function () {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
+
+    }
+})

+ 6 - 0
pages/match/project.json

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

+ 114 - 0
pages/match/project.less

@@ -0,0 +1,114 @@
+.main {
+    height: 88.8vh;
+
+    .zero {
+        width: 96vw;
+        margin: 0 0 2vw 0;
+    }
+
+    .zero:nth-child(2) {
+        margin: 0 0 0 0;
+    }
+
+    .one {
+        display: flex;
+        flex-direction: row;
+        justify-content: space-between;
+        padding: 2vw;
+        width: 92vw;
+        background-color: #fff;
+
+        .one_1 {
+            width: 76vw;
+            background-color: #f1f1f1;
+            padding: 0 0 0 2vw;
+
+            input {
+                padding: 1vw 2px;
+                font-size: 14px;
+            }
+        }
+
+        .one_2 {
+            text-align: center;
+
+            button {
+                font-size: 14px;
+            }
+        }
+    }
+
+    .two {
+        flex-grow: 1;
+        width: 100%;
+        position: relative;
+
+        .scroll-view {
+            position: absolute;
+            top: 0;
+            left: 0;
+            right: 0;
+            bottom: 0;
+
+            .list-scroll-view {
+                display: flex;
+                flex-direction: column;
+
+                .list {
+                    background-color: #ffffff;
+                    border-bottom: 1px solid #cccccc;
+                    padding: 2vw 0;
+                    display: flex;
+                    flex-direction: column;
+
+                    .info {
+                        display: flex;
+                        flex-direction: row;
+                        margin: 0 0 2vw 0;
+
+                        .list_2 {
+                            width: 80vw;
+                            padding: 0 0 0 2vw;
+
+                            .name {
+                                font-size: 16px;
+                                font-weight: bold;
+                                margin: 0 0 1vw 0;
+                                overflow: hidden;
+                                text-overflow: ellipsis;
+                                -webkit-line-clamp: 2;
+                                word-break: break-all;
+                                display: -webkit-box;
+                                -webkit-box-orient: vertical;
+                            }
+
+                            .other {
+                                .other_1 {
+                                    margin: 0 0 1vw 0;
+                                    color: #000000a6;
+                                    font-size: 12px;
+                                    overflow: hidden;
+                                    text-overflow: ellipsis;
+                                    -webkit-line-clamp: 4;
+                                    word-break: break-all;
+                                    display: -webkit-box;
+                                    -webkit-box-orient: vertical;
+                                }
+                            }
+                        }
+                    }
+
+                    .btn {
+                        text-align: center;
+
+                        button {
+                            margin: 0 2vw;
+                            font-size: 14px;
+                        }
+                    }
+
+                }
+            }
+        }
+    }
+}

+ 41 - 0
pages/match/project.wxml

@@ -0,0 +1,41 @@
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back" bind:tabPath="tabPath">
+    <view slot="info" class="container main">
+        <view class="zero one">
+            <view class="one_1">
+                <input type="text" value="{{searchInfo.name}}" placeholder="请输入比赛名称" />
+            </view>
+            <view class="one_2">
+                <button type="primary" size="mini" bindtap="toAdd">添加</button>
+            </view>
+        </view>
+        <view class="zero two">
+            <scroll-view scroll-y="true" class="scroll-view">
+                <view class="list-scroll-view">
+                    <view class="list" wx:for="{{list}}" wx:key="item">
+                        <view class="info">
+                            <view class="list_2">
+                                <view class="name">
+                                    <text>{{item.name||'暂无'}}</text>
+                                </view>
+                                <view class="other">
+                                    <view class="other_1">
+                                        <text>比赛项目说明:</text>
+                                        <text>{{item.explain||'暂无'}}</text>
+                                    </view>
+                                    <view class="other_1">
+                                        <text>比赛人数:</text>
+                                        <text>{{item.num||'0'}}人</text>
+                                    </view>
+                                </view>
+                            </view>
+                        </view>
+                        <view class="btn">
+                            <button type="primary" bindtap="toEdit" data-id="{{item._id}}" size="mini">维护</button>
+                            <button size="mini" type="warn" bindtap="toDel" data-id="{{item._id}}">删除</button>
+                        </view>
+                    </view>
+                </view>
+            </scroll-view>
+        </view>
+    </view>
+</mobile-main>

+ 94 - 0
pages/match/project.wxss

@@ -0,0 +1,94 @@
+.main {
+  height: 88.8vh;
+}
+.main .zero {
+  width: 96vw;
+  margin: 0 0 2vw 0;
+}
+.main .zero:nth-child(2) {
+  margin: 0 0 0 0;
+}
+.main .one {
+  display: flex;
+  flex-direction: row;
+  justify-content: space-between;
+  padding: 2vw;
+  width: 92vw;
+  background-color: #fff;
+}
+.main .one .one_1 {
+  width: 76vw;
+  background-color: #f1f1f1;
+  padding: 0 0 0 2vw;
+}
+.main .one .one_1 input {
+  padding: 1vw 2px;
+  font-size: 14px;
+}
+.main .one .one_2 {
+  text-align: center;
+}
+.main .one .one_2 button {
+  font-size: 14px;
+}
+.main .two {
+  flex-grow: 1;
+  width: 100%;
+  position: relative;
+}
+.main .two .scroll-view {
+  position: absolute;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+}
+.main .two .scroll-view .list-scroll-view {
+  display: flex;
+  flex-direction: column;
+}
+.main .two .scroll-view .list-scroll-view .list {
+  background-color: #ffffff;
+  border-bottom: 1px solid #cccccc;
+  padding: 2vw 0;
+  display: flex;
+  flex-direction: column;
+}
+.main .two .scroll-view .list-scroll-view .list .info {
+  display: flex;
+  flex-direction: row;
+  margin: 0 0 2vw 0;
+}
+.main .two .scroll-view .list-scroll-view .list .info .list_2 {
+  width: 80vw;
+  padding: 0 0 0 2vw;
+}
+.main .two .scroll-view .list-scroll-view .list .info .list_2 .name {
+  font-size: 16px;
+  font-weight: bold;
+  margin: 0 0 1vw 0;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  -webkit-line-clamp: 2;
+  word-break: break-all;
+  display: -webkit-box;
+  -webkit-box-orient: vertical;
+}
+.main .two .scroll-view .list-scroll-view .list .info .list_2 .other .other_1 {
+  margin: 0 0 1vw 0;
+  color: #000000a6;
+  font-size: 12px;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  -webkit-line-clamp: 4;
+  word-break: break-all;
+  display: -webkit-box;
+  -webkit-box-orient: vertical;
+}
+.main .two .scroll-view .list-scroll-view .list .btn {
+  text-align: center;
+}
+.main .two .scroll-view .list-scroll-view .list .btn button {
+  margin: 0 2vw;
+  font-size: 14px;
+}

+ 132 - 0
pages/match/projectadd.js

@@ -0,0 +1,132 @@
+const app = getApp()
+import WxValidate from '../../utils/wxValidate'
+import { match_project } from '../../utils/dict';
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        frameStyle: { useTop: true, name: '添加比赛', leftArrow: true, useBar: false },
+        form: {},
+        //比赛类型
+        typeList: match_project,
+        // 用户id
+        id: ''
+    },
+    initValidate() {
+        const rules = { name: { required: true }, type: { required: true }, explain: { required: true }, num: { required: true } }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { name: { required: '请输入比赛项目名称', }, type: { required: '请选择类型', }, explain: { required: '请输入比赛项目说明', }, num: { required: '请输入比赛人数' } };
+        this.WxValidate = new WxValidate(rules, messages)
+    },
+    // 返回
+    back: function () {
+        wx.navigateBack({ delta: 1 })
+    },
+    // 选择类型
+    typeChange: function (e) {
+        const that = this;
+        let index = e.detail.value;
+        let value = that.data.typeList[index];
+        that.setData({ 'form.type': value.value });
+    },
+    // 提交登录
+    onSubmit: async function (e) {
+        const that = this;
+        const params = e.detail.value;
+        params.num = parseFloat(params.num);
+        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 {
+            let arr;
+            if (data._id) {
+                arr = await app.$post(`/newCourt/api/matchProject/${data._id}`, params);
+                if (arr.errcode == '0') { wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 }); that.back(); }
+                else wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
+            } else {
+                arr = await app.$post(`/newCourt/api/matchProject`, 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({ id: options.id })
+        //验证规则函数
+        that.initValidate();
+        // 监听用户是否登录
+        that.watchLogin();
+    },
+    // 监听用户是否登录
+    watchLogin: async function () {
+        const that = this;
+        wx.getStorage({
+            key: 'user',
+            success: async res => {
+                const arr = await app.$get(`/newCourt/api/matchProject/${that.data.id}`);
+                if (arr.errcode == '0') {
+                    that.setData({ form: arr.data });
+                }
+            },
+            fail: res => {
+                wx.redirectTo({ url: '/pages/index/index', })
+            }
+        })
+    },
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom: function () {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
+
+    }
+})

+ 7 - 0
pages/match/projectadd.json

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

+ 37 - 0
pages/match/projectadd.less

@@ -0,0 +1,37 @@
+.main {
+    height: 88vh;
+    background: #ffffff;
+
+    .one {
+        width: 96vw;
+
+        .content {
+            display: flex;
+            flex-direction: row;
+            justify-content: space-between;
+            align-items: center;
+            margin: 0 10px;
+            padding: 10px 5px;
+            border-bottom: 1px solid #cccccc;
+
+            .label {
+                font-size: 14px;
+            }
+
+            .value {
+                color: #666;
+                font-size: 12px;
+
+                input {
+                    text-align: right;
+                }
+            }
+        }
+
+        .btn {
+            width: 96vw;
+            margin: 50px 0;
+            text-align: center;
+        }
+    }
+}

+ 31 - 0
pages/match/projectadd.wxml

@@ -0,0 +1,31 @@
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
+    <view slot="info" class="container main">
+        <view class="one">
+            <form catchsubmit="onSubmit">
+                <view class="content">
+                    <view class="label">比赛类型</view>
+                    <view class="value">
+                        <picker name="type" bindchange="typeChange" value="{{form.type}}" range-key='value' range="{{typeList}}">
+                            <view class="input">{{form.type||'选择比赛类型'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">比赛项目名称:</view>
+                    <view class="value"><input name="name" value="{{form.name}}" placeholder="请输入比赛项目名称" /></view>
+                </view>
+                <view class="content">
+                    <view class="label">比赛项目说明:</view>
+                    <view class="value"><input name="explain" value="{{form.explain}}" placeholder="请输入比赛项目说明" /></view>
+                </view>
+                <view class="content">
+                    <view class="label">比赛人数:</view>
+                    <view class="value"><input type="number" name="num" value="{{form.num}}" placeholder="请输入比赛人数" /></view>
+                </view>
+                <view class="btn">
+                    <button type="primary" size="mini" formType="submit">提交保存</button>
+                </view>
+            </form>
+        </view>
+    </view>
+</mobile-main>

+ 31 - 0
pages/match/projectadd.wxss

@@ -0,0 +1,31 @@
+.main {
+  height: 88vh;
+  background: #ffffff;
+}
+.main .one {
+  width: 96vw;
+}
+.main .one .content {
+  display: flex;
+  flex-direction: row;
+  justify-content: space-between;
+  align-items: center;
+  margin: 0 10px;
+  padding: 10px 5px;
+  border-bottom: 1px solid #cccccc;
+}
+.main .one .content .label {
+  font-size: 14px;
+}
+.main .one .content .value {
+  color: #666;
+  font-size: 12px;
+}
+.main .one .content .value input {
+  text-align: right;
+}
+.main .one .btn {
+  width: 96vw;
+  margin: 50px 0;
+  text-align: center;
+}

+ 1 - 1
pages/setting/basic.js

@@ -16,7 +16,7 @@ Page({
         genderList: gender,
     },
     initValidate() {
-        const rules = { name: { required: true }, phone: { required: true, tel: true }, gender: { required: false }, email: { required: true } }
+        const rules = { name: { required: true }, phone: { required: true, tel: true }, gender: { required: true }, email: { required: true } }
         // 验证字段的提示信息,若不传则调用默认的信息
         const messages = { name: { required: '请输入用户名', }, phone: { required: '请输入手机号', }, gender: { required: '请选择性别', }, email: { required: '请输入邮箱' } };
         this.WxValidate = new WxValidate(rules, messages)

+ 0 - 4
pages/setting/basic.less

@@ -32,10 +32,6 @@
             width: 96vw;
             margin: 50px 0;
             text-align: center;
-
-            button {
-                background-color: #216EC7;
-            }
         }
     }
 }

+ 0 - 3
pages/setting/basic.wxss

@@ -29,6 +29,3 @@
   margin: 50px 0;
   text-align: center;
 }
-.main .one .btn button {
-  background-color: #216EC7;
-}

+ 4 - 0
utils/dict.js

@@ -31,3 +31,7 @@ export const gender = [
     { label: '未知', value: '未知' },
 
 ]
+export const match_project = [
+    { label: '单打', value: '单打' },
+    { label: '双打', value: '双打' },
+]