guhongwei 2 years ago
parent
commit
aac45b55a6

+ 1 - 0
app.json

@@ -99,6 +99,7 @@
             "pages": [
                 "system/index",
                 "matchAdmin/referee/list",
+                "matchAdmin/referee/add",
                 "matchAdmin/profit/list",
                 "matchAdmin/match/list",
                 "matchAdmin/group/list",

+ 1 - 1
pages/index/index.js

@@ -17,7 +17,7 @@ Page({
         wx.getStorage({
             key: 'user',
             success: async res => {
-                if (res.data) wx.redirectTo({ url: '/pages/school/index' })
+                if (res.data) wx.redirectTo({ url: '/pages/test/index' })
             },
             fail: async res => {
                 wx.login({

+ 78 - 2
pages/test/index.js

@@ -1,5 +1,8 @@
 // pages/test/index.js
 const app = getApp()
+import dateTimePicker from '../../utils/dateTimePicker';
+const moment = require("../../utils/moment.min");
+
 Page({
 
     /**
@@ -13,6 +16,20 @@ Page({
         img_url: [],
         // dialog弹框
         dialog: { title: '弹框标题', show: false, type: '1' },
+        // 日期时间选择
+        dateTimeArray: [
+            ['2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010'],
+            ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'],
+            ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'],
+            ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'],
+            ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59'],
+            ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59'],
+        ],
+        // 日期时间选择
+        datatime: '',
+        // 计算日期
+        year: '',
+        moneh: ''
     },
     // 跳转菜单
     tabPath(e) {
@@ -47,11 +64,70 @@ Page({
         const that = this;
         that.setData({ dialog: { title: '弹框标题', show: false, type: '1' } })
     },
-
+    // 确认选择
+    change: function (e) {
+        const that = this;
+        let dateTime = that.data.dateTimeArray;
+        let value = e.detail.value;
+        let datetimes = dateTime[0][value[0]] + '-' + dateTime[1][value[1]] + '-' + dateTime[2][value[2]] + ' ' + dateTime[3][value[3]] + ':' + dateTime[4][value[4]] + ':' + dateTime[5][value[5]];
+        that.setData({ datatime: datetimes });
+    },
+    // 选择月份
+    columnChange: function (e) {
+        const that = this;
+        const { column, value } = e.detail;
+        let dateTimeArray = that.data.dateTimeArray;
+        let year = that.data.year;
+        let month = that.data.month;
+
+        // let year = monthDay.year || dateTimeArray[0][0];
+        // let month = monthDay.month || dateTimeArray[1][0];
+        // if (column == '0') year = dateTimeArray[0][value];
+        // else if (column == '1') month = dateTimeArray[1][value];
+        // console.log(year);
+        // console.log(month);
+        // that.setData({ monthDay: { year: year, moneh: month } });
+        // console.log(that.data.monthDay);
+        // 计算当前选择年月所要显示的日期
+        let ym = year + '-' + month;
+        // let monthDay = moment(ym).daysInMonth();
+        // console.log(monthDay);
+        // if (column == '0') {
+        //     console.log(column, value);
+        // } else if (column == '1') {
+        //     monthDay = dateTimeArray
+        // }
+        // that.setData({ monthDay })
+        // console.log(that.data.monthDay);
+        // console.log(data);
+        // if (column == '0') {
+        //     console.log('0');
+        // } else if (column == '1') {
+        //     console.log('1');
+        // }
+        // console.log(column);
+        // console.log(value);
+    },
     /**
      * 生命周期函数--监听页面加载
      */
-    onLoad: function (options) { },
+    onLoad: async function (options) {
+        // 获取完整的年月日 时分秒,以及默认显示的数组
+        var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
+        var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
+        // this.setData({ dateTimeArray: obj.dateTimeArray });
+        // let start = moment('02').startOf('month').format('YYYY-MM-DD');
+        // let end = moment('02').endOf('month').format('YYYY-MM-DD');
+        // 01,03,05,07,08,10
+        // 02
+        // let days = moment('2001-02').daysInMonth();
+        // console.log(start);
+        // console.log(end);
+        // console.log(days);
+        const arr = await app.$get('/user', {}, 'race');
+        console.log(arr);
+
+    },
 
     /**
      * 生命周期函数--监听页面初次渲染完成

+ 8 - 0
pages/test/index.wxml

@@ -12,6 +12,14 @@
                 <button type="primary" size="mini" bindtap="toDialog">打开弹框</button>
             </view>
         </view>
+        <view class="zero">
+            <view>日期时间选择</view>
+            <view>
+                <picker mode="multiSelector" value="{{dateTime1}}" bindchange="change" bindcolumnchange="columnChange" range="{{dateTimeArray}}">
+                    <view class="text">{{datatime||'选择日期时间'}}</view>
+                </picker>
+            </view>
+        </view>
     </view>
 </mobile-main>
 <dialog dialog="{{dialog}}" bind:toClose="toClose">

+ 95 - 0
pagesMatch/matchAdmin/referee/add.js

@@ -0,0 +1,95 @@
+const app = getApp();
+import WxValidate from '../../../utils/wxValidate';
+import dateTimePicker from '../../../utils/dateTimePicker';
+Page({
+    data: {
+        frameStyle: { useTop: true, name: '信息维护', leftArrow: true, useBar: false },
+        id: '',
+        form: {},
+        dateTimeArray1: null,
+        dateTime1: null,
+        startYear: null,
+        endYear: null,
+    },
+    initValidate() {
+        const rules = { name: { required: true }, phone: { required: true } }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { name: { required: '用户姓名', }, phone: { required: '联系电话', } };
+        this.WxValidate = new WxValidate(rules, messages)
+    },
+    // 返回
+    back: function () { wx.navigateBack({ delta: 1 }) },
+
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+        const that = this;
+        that.setData({ id: options.id || '' });
+        //验证规则函数
+        that.initValidate();
+        // 监听用户是否登录
+        that.watchLogin();
+        that.searchOther()
+    },
+    watchLogin: async function () {
+        const that = this;
+        wx.getStorage({
+            key: 'user',
+            success: async res => {
+                if (that.data.id) {
+                    console.log('信息维护');
+                } else {
+                    console.log('信息添加');
+                }
+            },
+            fail: async res => {
+                wx.redirectTo({ url: '/pages/index/index' })
+            }
+        })
+    },
+    // 其他信息
+    searchOther: function () {
+        // 获取完整的年月日 时分秒,以及默认显示的数组
+        var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
+        this.setData({ dateTimeArray1: obj.dateTimeArray });
+    },
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () { },
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () { },
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
+
+    }
+})

+ 6 - 0
pagesMatch/matchAdmin/referee/add.json

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

+ 30 - 0
pagesMatch/matchAdmin/referee/add.less

@@ -0,0 +1,30 @@
+@import (css) "/app.wxss";
+
+.main {
+    background-color: var(--mainColor);
+
+    .one {
+        .content {
+            display: flex;
+            flex-direction: row;
+            border-bottom: 1px dashed var(--f1Color);
+            padding: 2vw 0;
+            margin: 0 2vw 2vw 2vw;
+
+            .value {
+                flex-grow: 1;
+                color: var(--blackColor);
+
+            }
+        }
+
+        .btn {
+            text-align: center;
+            margin: 3vw 0;
+
+            button {
+                margin: 0 2vw;
+            }
+        }
+    }
+}

+ 35 - 0
pagesMatch/matchAdmin/referee/add.wxml

@@ -0,0 +1,35 @@
+<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">
+                        <input name="name" value="{{form.name}}" placeholder="请输入用户名" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">联系电话:</view>
+                    <view class="value">
+                        <input name="phone" value="{{form.phone}}" placeholder="请输入联系电话" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">
+                        日期时间:
+                    </view>
+                    <view class="value">
+                        <picker mode="multiSelector" value="{{dateTime1}}" bindchange="changeDateTime1" bindcolumnchange="changeDateTimeColumn1" range="{{dateTimeArray1}}">
+                            <view class="text">
+                                {{dateTimeArray1[0][dateTime1[0]]}}-{{dateTimeArray1[1][dateTime1[1]]}}-{{dateTimeArray1[2][dateTime1[2]]}} {{dateTimeArray1[3][dateTime1[3]]}}:{{dateTimeArray1[4][dateTime1[4]]}}:{{dateTimeArray1[5][dateTime1[5]]}}
+                            </view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="btn">
+                    <button type="primary" size="mini" formType="submit">提交保存</button>
+                </view>
+            </form>
+        </view>
+    </view>
+</mobile-main>

+ 22 - 0
pagesMatch/matchAdmin/referee/add.wxss

@@ -0,0 +1,22 @@
+@import "/app.wxss";
+.main {
+  background-color: var(--mainColor);
+}
+.main .one .content {
+  display: flex;
+  flex-direction: row;
+  border-bottom: 1px dashed var(--f1Color);
+  padding: 2vw 0;
+  margin: 0 2vw 2vw 2vw;
+}
+.main .one .content .value {
+  flex-grow: 1;
+  color: var(--blackColor);
+}
+.main .one .btn {
+  text-align: center;
+  margin: 3vw 0;
+}
+.main .one .btn button {
+  margin: 0 2vw;
+}

+ 66 - 2
pagesMatch/matchAdmin/referee/list.js

@@ -2,10 +2,65 @@ const app = getApp();
 Page({
     data: {
         frameStyle: { useTop: true, name: '裁判信息', leftArrow: true, useBar: false },
+        list: [
+            { _id: '123456', name: '裁判信息', phone: '12345678901' },
+        ],
+        total: 0,
+        page: 0,
+        skip: 0,
+        limit: 5,
     },
     // 返回
     back: function () { wx.navigateBack({ delta: 1 }) },
-
+    // 功能跳转
+    toCommon: function (e) {
+        const that = this;
+        const { route, item } = e.currentTarget.dataset;
+        that.setData({ skip: 0, page: 0, list: [] })
+        wx.navigateTo({ url: `/pagesMatch/${route}?id=${item && item._id ? item._id : ''}` });
+    },
+    // 账号绑定
+    toBind: function (e) {
+        const that = this;
+        const { item } = e.currentTarget.dataset;
+        console.log(item);
+    },
+    // 信息删除
+    toDel: async function (e) {
+        const that = this;
+        const { item } = e.currentTarget.dataset;
+        wx.showModal({
+            title: '提示',
+            content: '是否确认删除该条数据?',
+            async success(res) {
+                if (res.confirm) {
+                    // const arr = await app.$delete(`/user/${item._id}`);
+                    // if (arr.errcode == '0') {
+                    //     wx.showToast({ title: `删除信息成功`, icon: 'success', duration: 2000 })
+                    //     that.setData({ skip: 0, page: 0, list: [] })
+                    //     that.watchLogin()
+                    // } else {
+                    //     wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
+                    // }
+                }
+            }
+        })
+    },
+    // 分页
+    toPage: function () {
+        const that = this;
+        let list = that.data.list;
+        let limit = that.data.limit;
+        if (that.data.total > list.length) {
+            wx.showLoading({ title: '加载中', mask: true })
+            let page = that.data.page + 1;
+            that.setData({ page: page })
+            let skip = page * limit;
+            that.setData({ skip: skip })
+            that.watchLogin();
+            wx.hideLoading()
+        } else { wx.showToast({ title: '没有更多数据了', icon: 'none', duration: 2000 }) }
+    },
     /**
      * 生命周期函数--监听页面加载
      */
@@ -27,7 +82,16 @@ Page({
         const that = this;
         wx.getStorage({
             key: 'user',
-            success: async res => { },
+            success: async res => {
+                // referee
+                // let info = { skip: that.data.skip, limit: that.data.limit };
+                // const arr = await app.$get(`/user`, { ...info });
+                // if (arr.errcode == '0') {
+                //     that.setData({ list: [...that.data.list, ...arr.data] });
+                //     that.setData({ total: arr.total })
+                // }
+                // else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }); }
+            },
             fail: async res => {
                 wx.redirectTo({ url: '/pages/index/index' })
             }

+ 67 - 1
pagesMatch/matchAdmin/referee/list.less

@@ -5,7 +5,73 @@
     background-color: var(--mainColor);
 
     .one {
-        width: 100vw;
+        display: flex;
+        flex-direction: row;
+        padding: 2vw;
+        border-bottom: 1px solid var(--f1Color);
+
+        .one_1 {
+            flex-grow: 1;
+
+            input {
+                padding: 1vw 0 2vw 2vw;
+                background-color: var(--f1Color);
+                border-radius: 5px;
+            }
+        }
+
+        .one_2 {
+            width: 20vw;
+
+            button {
+                width: 100%;
+                padding: 2vw;
+                font-size: var(--font14Size);
+            }
+        }
+    }
+
+    .two {
+        position: relative;
+        flex-grow: 1;
+        background-color: var(--whiteColor);
+        padding: 0 2vw;
+
+        .list {
+            background-color: var(--f9Color);
+            margin: 0 0 2vw 0;
+            padding: 2vw;
+            margin: 0 2vw 2vw 2vw;
+            border-radius: 5px;
+
+            .name {
+                font-size: var(--font16Szie);
+                font-weight: bold;
+                margin: 0 0 1vw 0;
+            }
+
+            .other {
+                margin: 0 0 1vw 0;
+
+                .other_1 {
+                    margin: 0 0 1vw 0;
+                    font-size: var(--font16Size);
+
+                    text:first-child {
+                        color: var(--f85Color);
+                    }
+                }
+            }
+
+            .btn {
+                text-align: center;
+
+                button {
+                    margin: 0 2vw;
+                    font-size: var(--font14Size);
+                }
+            }
+        }
     }
 }
 

+ 28 - 1
pagesMatch/matchAdmin/referee/list.wxml

@@ -1,7 +1,34 @@
 <mobile-main frameStyle="{{frameStyle}}" bind:back="back">
     <view slot="info" class="container main">
         <view class="one">
-            裁判信息
+            <view class="one_1">
+                <input type="text" placeholder="请输入关键词" />
+            </view>
+            <view class="one_2">
+                <button type="primary" bindtap="toCommon" data-route="matchAdmin/referee/add">添加</button>
+            </view>
+        </view>
+        <view class="two">
+            <scroll-view scroll-y="true" class="scroll-view" bindscrolltolower="toPage">
+                <view class="list-scroll-view">
+                    <view class="list" wx:for="{{list}}" wx:key="index">
+                        <view class="name">{{item.name}}</view>
+                        <view class="other">
+                            <view class="other_1">
+                                <text>联系电话:</text>
+                                <text>{{item.phone}}</text>
+                            </view>
+                        </view>
+                        <view class="btn">
+                            <button type="primary" size="mini" bindtap="toCommon" data-item="{{item}}" data-route="matchAdmin/referee/add">信息维护</button>
+                            <button type="primary" size="mini" bindtap="toBind" data-item="{{item}}">账号绑定</button>
+                            <button type="warn" size="mini" bindtap="toDel" data-item="{{item}}">信息删除</button>
+
+
+                        </view>
+                    </view>
+                </view>
+            </scroll-view>
         </view>
     </view>
 </mobile-main>

+ 55 - 1
pagesMatch/matchAdmin/referee/list.wxss

@@ -4,7 +4,61 @@
   background-color: var(--mainColor);
 }
 .main .one {
-  width: 100vw;
+  display: flex;
+  flex-direction: row;
+  padding: 2vw;
+  border-bottom: 1px solid var(--f1Color);
+}
+.main .one .one_1 {
+  flex-grow: 1;
+}
+.main .one .one_1 input {
+  padding: 1vw 0 2vw 2vw;
+  background-color: var(--f1Color);
+  border-radius: 5px;
+}
+.main .one .one_2 {
+  width: 20vw;
+}
+.main .one .one_2 button {
+  width: 100%;
+  padding: 2vw;
+  font-size: var(--font14Size);
+}
+.main .two {
+  position: relative;
+  flex-grow: 1;
+  background-color: var(--whiteColor);
+  padding: 0 2vw;
+}
+.main .two .list {
+  background-color: var(--f9Color);
+  margin: 0 0 2vw 0;
+  padding: 2vw;
+  margin: 0 2vw 2vw 2vw;
+  border-radius: 5px;
+}
+.main .two .list .name {
+  font-size: var(--font16Szie);
+  font-weight: bold;
+  margin: 0 0 1vw 0;
+}
+.main .two .list .other {
+  margin: 0 0 1vw 0;
+}
+.main .two .list .other .other_1 {
+  margin: 0 0 1vw 0;
+  font-size: var(--font16Size);
+}
+.main .two .list .other .other_1 text:first-child {
+  color: var(--f85Color);
+}
+.main .two .list .btn {
+  text-align: center;
+}
+.main .two .list .btn button {
+  margin: 0 2vw;
+  font-size: var(--font14Size);
 }
 .scroll-view {
   position: absolute;

+ 80 - 0
utils/dateTimePicker.js

@@ -0,0 +1,80 @@
+function withData(param) {
+    return param < 10 ? '0' + param : '' + param;
+}
+function getLoopArray(start, end) {
+    var start = start || 0;
+    var end = end || 1;
+    var array = [];
+    for (var i = start; i <= end; i++) {
+        array.push(withData(i));
+    }
+    return array;
+}
+function getMonthDay(year, month) {
+    var flag = year % 400 == 0 || (year % 4 == 0 && year % 100 != 0), array = null;
+
+    switch (month) {
+        case '01':
+        case '03':
+        case '05':
+        case '07':
+        case '08':
+        case '10':
+        case '12':
+            array = getLoopArray(1, 31)
+            break;
+        case '04':
+        case '06':
+        case '09':
+        case '11':
+            array = getLoopArray(1, 30)
+            break;
+        case '02':
+            array = flag ? getLoopArray(1, 29) : getLoopArray(1, 28)
+            break;
+        default:
+            array = '月份格式不正确,请重新输入!'
+    }
+    return array;
+}
+function getNewDateArry() {
+    // 当前时间的处理
+    var newDate = new Date();
+    var year = withData(newDate.getFullYear()),
+        mont = withData(newDate.getMonth() + 1),
+        date = withData(newDate.getDate()),
+        hour = withData(newDate.getHours()),
+        minu = withData(newDate.getMinutes()),
+        seco = withData(newDate.getSeconds());
+
+    return [year, mont, date, hour, minu, seco];
+}
+function dateTimePicker(startYear, endYear, date) {
+    // 返回默认显示的数组和联动数组的声明
+    var dateTime = [], dateTimeArray = [[], [], [], [], [], []];
+    var start = startYear || 1978;
+    var end = endYear || 2100;
+    // 默认开始显示数据
+    var defaultDate = date ? [...date.split(' ')[0].split('-'), ...date.split(' ')[1].split(':')] : getNewDateArry();
+    // 处理联动列表数据
+    /*年月日 时分秒*/
+    dateTimeArray[0] = getLoopArray(start, end);
+    dateTimeArray[1] = getLoopArray(1, 12);
+    dateTimeArray[2] = getMonthDay(defaultDate[0], defaultDate[1]);
+    dateTimeArray[3] = getLoopArray(0, 23);
+    dateTimeArray[4] = getLoopArray(0, 59);
+    dateTimeArray[5] = getLoopArray(0, 59);
+
+    dateTimeArray.forEach((current, index) => {
+        dateTime.push(current.indexOf(defaultDate[index]));
+    });
+
+    return {
+        dateTimeArray: dateTimeArray,
+        dateTime: dateTime
+    }
+}
+module.exports = {
+    dateTimePicker: dateTimePicker,
+    getMonthDay: getMonthDay
+}