guhongwei 2 vuotta sitten
vanhempi
commit
f2a476914d

+ 2 - 0
app.wxss

@@ -38,6 +38,8 @@ page {
     --labelColor: #858585;
     /* 按钮字体大小 */
     --btnSize: 14px;
+    /* 输入框查询背景颜色 */
+    --f1Color: #f1f1f1;
 }
 
 /* @import "/icon/icon.wxss"; */

+ 69 - 28
pages/address/add.js

@@ -1,43 +1,84 @@
-const app = getApp()
+const app = getApp();
+import WxValidate from '../../utils/wxValidate';
+import { isuse } from '../../utils/dict'
 Page({
     data: {
-        frameStyle: { useTop: true, name: '系统', leftArrow: false, useBar: false },
+        frameStyle: { useTop: true, name: '信息管理', leftArrow: true, useBar: false },
+        form: {},
+        // 裁判信息
+        refereeList: [],
+        // 是否启用
+        isuseList: isuse
     },
-    toCommon: function (e) {
-        const { route } = e.currentTarget.dataset;
-        if (route) wx.navigateTo({ url: `/pages/${route}` });
+    initValidate() {
+        const rules = { name: { required: true }, is_use: { required: true } }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { name: { required: '请输入场地名称' }, is_use: { required: '请选择是否启用' } };
+        this.WxValidate = new WxValidate(rules, messages)
+    },
+    back: function () {
+        wx.navigateBack({
+            delta: 1,
+        })
+    },
+    // 选择裁判
+    referee_idChange: function (e) {
+        const that = this;
+        let index = e.detail.value;
+        let value = that.data.refereeList[index];
+        that.setData({ 'form.referee_id': value.openid });
+        that.setData({ 'form.referee_name': value.name });
+    },
+    // 是否使用
+    is_useChange: function (e) {
+        const that = this;
+        let index = e.detail.value;
+        let value = that.data.isuseList[index];
+        that.setData({ 'form.is_use': value.value });
+    },
+    toSubmit: async function (e) {
+        const that = this;
+        const form = that.data.form;
+        const params = e.detail.value;
+        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 (form.id) arr = await app.$post(`/newCourt/api/ground/${form.id}`, params);
+            else arr = await app.$post(`/newCourt/api/ground`, params);
+            if (arr.errcode == '0') { wx.showToast({ title: `维护信息成功`, icon: 'success', duration: 2000 }); that.back() }
+            else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
+        }
     },
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
-
+        const that = this;
+        console.log(options);
+        //验证规则函数
+        that.initValidate();
     },
     // 监听用户是否登录
     watchLogin: async function () {
+        const that = this;
         // 监听用户是否登录,
-        wx.getStorage({
-            key: 'user',
-            success: async res => {
-                // if (res.data) wx.redirectTo({ url: '/pages/home/index' })
-            },
-            fail: async res => {
-                // wx.redirectTo({ url: '/pages/login/index' })
-                // wx.login({
-                //     success: async arr => {
-                //         const { code: js_code } = arr;
-                //         const aee = await app.$get('/api/hc/wx/openid', { js_code: js_code });
-                //         if (aee.errcode === 0 && aee.openid) {
-                //             app.globalData.wxInfo = { openid: aee.openid };
-                //             // wx.redirectTo({ url: '/pages/login/index' })
-                //         } else {
-                //             wx.showToast({ title: `${res.errMsg}`, icon: 'fail', duration: 2000 })
-                //             x.redirectTo({ url: '/pages/login/index' })
-                //         }
-                //     }
-                // })
-            }
-        })
+        // wx.getStorage({
+        //     key: 'user',
+        //     success: async res => {
+        //         // if (res.data) wx.redirectTo({ url: '/pages/home/index' })
+        //     },
+        //     fail: async res => {
+        //         // wx.redirectTo({ url: '/pages/index/index' })
+        //     }
+        // })
+        // 查询裁判信息
+        let arr;
+        arr = await app.$get(`/newCourt/api/user`, { type: '-1' });
+        if (arr.errcode == '0') { that.setData({ refereeList: arr.data }) }
+        else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
     },
     /**
      * 生命周期函数--监听页面初次渲染完成

+ 26 - 13
pages/address/add.less

@@ -3,20 +3,33 @@
     background-color: var(--bgColor);
 
     .one {
-        text-align: center;
-        margin: 0 0 10vw 0;
-    }
-}
+        .content {
+            display: flex;
+            flex-direction: row;
+            border-bottom: 1px dashed var(--f1Color);
+            padding: 2vw 0;
+            margin: 0 2vw 2vw 2vw;
+
+            .label {
+                color: var(--labelColor);
+            }
+
+            .value {
+                flex-grow: 1;
+                color: var(--txtColor);
+
+            }
+        }
 
-.scroll-view {
-    position: absolute;
-    top: 0;
-    left: 0;
-    right: 0;
-    bottom: 0;
+        .btn {
+            text-align: center;
+            margin: 5vw 0 0 0;
 
-    .list-scroll-view {
-        display: flex;
-        flex-direction: column;
+            button {
+                width: 40vw;
+                margin: 0 2vw;
+                padding: 1vw 0;
+            }
+        }
     }
 }

+ 34 - 8
pages/address/add.wxml

@@ -1,13 +1,39 @@
-<mobile-main frameStyle="{{frameStyle}}">
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
     <view slot="info" class="container main">
         <view class="one">
-            <view>系统首页</view>
-            <view>
-                <button type="primary" size="mini" bindtap="toCommon" data-route="login/index">去登录</button>
-                <button type="primary" size="mini" bindtap="toCommon" data-route="register/index">去注册</button>
-                <button type="primary" size="mini" bindtap="toCommon" data-route="home/index">系统首页</button>
-                <button type="primary" size="mini" bindtap="toCommon" data-route="test/index">组件页面</button>
-            </view>
+            <form catchsubmit="toSubmit">
+                <view class="content">
+                    <view class="label">场地名称:</view>
+                    <view class="value">
+                        <input type="text" name="name" value="{{form.name}}" placeholder="请输入场地名称" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">裁判:</view>
+                    <view class="value">
+                        <picker name="referee_id" bindchange="referee_idChange" value="{{form.referee_id}}" range-key='name' range="{{refereeList}}">
+                            <view class="input">{{form.referee_name||'请选择裁判'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">备注:</view>
+                    <view class="value">
+                        <input type="text" name="remark" value="{{form.remark}}" placeholder="请输入备注" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">是否启用:</view>
+                    <view class="value">
+                        <picker name="is_use" bindchange="is_useChange" value="{{form.is_use}}" range-key='label' range="{{isuseList}}">
+                            <view class="input">{{form.is_use=='0'?'启用':form.is_use=='1'?'禁用':'选择是否使用'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="btn">
+                    <button type="primary" size="mini" formType="submit">提交保存</button>
+                </view>
+            </form>
         </view>
     </view>
 </mobile-main>

+ 20 - 12
pages/address/add.wxss

@@ -2,18 +2,26 @@
   height: 91vh;
   background-color: var(--bgColor);
 }
-.main .one {
-  text-align: center;
-  margin: 0 0 10vw 0;
+.main .one .content {
+  display: flex;
+  flex-direction: row;
+  border-bottom: 1px dashed var(--f1Color);
+  padding: 2vw 0;
+  margin: 0 2vw 2vw 2vw;
 }
-.scroll-view {
-  position: absolute;
-  top: 0;
-  left: 0;
-  right: 0;
-  bottom: 0;
+.main .one .content .label {
+  color: var(--labelColor);
 }
-.scroll-view .list-scroll-view {
-  display: flex;
-  flex-direction: column;
+.main .one .content .value {
+  flex-grow: 1;
+  color: var(--txtColor);
+}
+.main .one .btn {
+  text-align: center;
+  margin: 5vw 0 0 0;
+}
+.main .one .btn button {
+  width: 40vw;
+  margin: 0 2vw;
+  padding: 1vw 0;
 }

+ 4 - 0
pages/address/list.js

@@ -3,6 +3,10 @@ Page({
     data: {
         frameStyle: { useTop: true, name: '比赛场地', leftArrow: false, useBar: false },
     },
+    toCommon: function (e) {
+        const { route } = e.currentTarget.dataset;
+        if (route) wx.navigateTo({ url: `/pages/${route}` });
+    },
     /**
      * 生命周期函数--监听页面加载
      */

+ 35 - 0
pages/address/list.less

@@ -1,6 +1,41 @@
 .main {
     height: 91vh;
     background-color: var(--bgColor);
+
+    .one {
+        display: flex;
+        flex-direction: row;
+        width: 96vw;
+        padding: 2vw;
+
+        .one_1 {
+            flex-grow: 1;
+
+            input {
+                padding: 1vw 2vw 1.6vw 2vw;
+                border-radius: 2px;
+                font-size: var(--txtSize);
+                background-color: var(--f1Color);
+            }
+        }
+
+        .one_2 {
+            width: 15vw;
+
+            button {
+                width: 100%;
+                font-size: var(--btnSize);
+                padding: 2vw;
+            }
+        }
+    }
+
+    .two {
+        flex-grow: 1;
+        position: relative;
+        width: 100vw;
+        background-color: #0000ff;
+    }
 }
 
 .scroll-view {

+ 9 - 1
pages/address/list.wxml

@@ -1,7 +1,15 @@
 <mobile-main frameStyle="{{frameStyle}}">
     <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="address/add">添加</button>
+            </view>
+        </view>
+        <view class="two">
+            列表
         </view>
     </view>
 </mobile-main>

+ 29 - 0
pages/address/list.wxss

@@ -2,6 +2,35 @@
   height: 91vh;
   background-color: var(--bgColor);
 }
+.main .one {
+  display: flex;
+  flex-direction: row;
+  width: 96vw;
+  padding: 2vw;
+}
+.main .one .one_1 {
+  flex-grow: 1;
+}
+.main .one .one_1 input {
+  padding: 1vw 2vw 1.6vw 2vw;
+  border-radius: 2px;
+  font-size: var(--txtSize);
+  background-color: var(--f1Color);
+}
+.main .one .one_2 {
+  width: 15vw;
+}
+.main .one .one_2 button {
+  width: 100%;
+  font-size: var(--btnSize);
+  padding: 2vw;
+}
+.main .two {
+  flex-grow: 1;
+  position: relative;
+  width: 100vw;
+  background-color: #0000ff;
+}
 .scroll-view {
   position: absolute;
   top: 0;

+ 5 - 0
utils/dict.js

@@ -11,6 +11,11 @@ export const gender = [
     { label: '女', value: '1' },
     { label: '未知', value: '2' },
 ];
+// 是否启用
+export const isuse = [
+    { label: '启用', value: '0' },
+    { label: '禁用', value: '1' },
+]
 // 我的页面,功能按钮
 // -1:管理员,0:普通用户,1:裁判用户
 export const myBtn = [

+ 2 - 2
utils/httpUtil.js

@@ -1,5 +1,5 @@
-let serverUrl = "https://broadcast.waityou24.cn";//http://127.0.0.1:15000
-let wechatUrl = 'https://broadcast.waityou24.cn';
+let serverUrl = "http://120.48.146.1";//http://120.48.146.1    https://broadcast.waityou24.cn
+let wechatUrl = 'http://120.48.146.1';
 
 const getDomain = (uri) => {
     if (uri.startsWith('/wechat/api')) return wechatUrl;