Browse Source

1比赛信息

YY 2 years ago
parent
commit
6d09f91607

+ 110 - 100
commpents/hg-editor/hg-editor.js

@@ -1,111 +1,121 @@
 // components/hg-editor/hg-editor.js
 const app = getApp()
 Component({
-  /**
-   * 组件的属性列表
-   */
-  properties: {
-    /**是否显示工具栏 */
-    showTabBar: {
-      type: 'Boolean',
-      value: true
-    },
-    placeholder: {
-      type: 'String',
-      value: '请输入相关内容'
+    /**
+     * 组件的属性列表
+     */
+    properties: {
+        /**是否显示工具栏 */
+        showTabBar: {
+            type: 'Boolean',
+            value: true
+        },
+        placeholder: {
+            type: 'String',
+            value: '请输入相关内容'
+        },
+        name: {
+            type: 'String',
+            value: ''
+        },
     },
-    name: {
-      type: 'String',
-      value: ''
+    // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
+    attached: function () { }, // 此处attached的声明会被lifetimes字段中的声明覆盖
+    ready: function () { },
+    pageLifetimes: {
+        // 组件所在页面的生命周期函数
+        show: function () { },
+        hide: function () { },
+        resize: function () { },
     },
-  },
 
-  /**
-   * 组件的初始数据
-   */
-  data: {
+    /**
+     * 组件的初始数据
+     */
+    data: {
 
-  },
-
-  /**
-   * 组件的方法列表
-   */
-  methods: {
-    _onEditorReady: async function () {
-      const that = this;
-      that.createSelectorQuery().select('#editor').context(function (res) {
-        that.editorCtx = res.context
-        let html = that.data.name;
-        if (html) {
-          that.editorCtx.setContents({
-            html: html,
-            success: (res) => { },
-            fail: (res) => { console.log(res) }
-          })
-        }
-      }).exec()
     },
-    //插入图片
-    _addImage: function (event) {
-      let _this = this;
-      wx.chooseImage({
-        count: 1,
-        sizeType: ['compressed'],
-        sourceType: ['album'],
-        success: function (res) {
-          _this._uploadImage(res.tempFilePaths[0]);
-        }
-      });
-    },
-    _uploadImage: function (tempFilePath) {
-      let _this = this;
-      wx.uploadFile({
-        url: `${app.globalData.fileUrl}/files/court/elimg/upload`,
-        filePath: tempFilePath,
-        name: 'file',
-        formData: {},
-        success: (res) => {
-          let arr = JSON.parse(res.data);
-          if (arr.errcode == '0') {
-            _this.editorCtx.insertImage({ src: app.globalData.fileUrl + arr.uri });
-          } else {
-            wx.showToast({ title: `${arr.errmsg}`, icon: 'fail', duration: 2000 })
-          }
+
+    /**
+     * 组件的方法列表
+     */
+    methods: {
+        _onEditorReady: async function () {
+            const that = this;
+            that.createSelectorQuery().select('#editor').context(function (res) {
+                that.editorCtx = res.context
+                let html = that;
+                if (html) {
+                    that.editorCtx.setContents({
+                        html: html,
+                        success: (res) => {
+                        },
+                        fail: (res) => { console.log(res) }
+                    })
+                }
+            }).exec()
         },
-      })
-    },
-    //设置斜体
-    _addItalic: function () {
-      this.editorCtx.format("italic")
-    },
-    //添加粗体样式
-    _addBold: function () {
-      this.editorCtx.format("bold")
-    },
-    //设置标题
-    _addHeader: function (e) {
-      let headerType = e.currentTarget.dataset.header;
-      this.editorCtx.format("header", headerType)
-    },
-    //设置文字的排列方式
-    _addAlign: function (e) {
-      let alignType = e.currentTarget.dataset.align;
-      this.editorCtx.format("align", alignType);
-    },
-    //设置列表
-    _addList: function (e) {
-      let listType = e.currentTarget.dataset.list;
-      this.editorCtx.format("list", listType);
-    },
-    //撤销
-    _undo: function () {
-      this.editorCtx.undo();
-    },
-    //监控输入
-    _onInputting: function (e) {
-      let html = e.detail.html;
-      let text = e.detail.text;
-      this.triggerEvent("input", { html: html, text: text }, {});
+        //插入图片
+        _addImage: function (event) {
+            let _this = this;
+            wx.chooseImage({
+                count: 1,
+                sizeType: ['compressed'],
+                sourceType: ['album'],
+                success: function (res) {
+                    _this._uploadImage(res.tempFilePaths[0]);
+                }
+            });
+        },
+        _uploadImage: function (tempFilePath) {
+            let _this = this;
+            wx.uploadFile({
+                url: `${app.globalData.fileUrl}/files/court/elimg/upload`,
+                filePath: tempFilePath,
+                name: 'file',
+                formData: {},
+                success: (res) => {
+                    let arr = JSON.parse(res.data);
+                    if (arr.errcode == '0') {
+                        _this.editorCtx.insertImage({ src: app.globalData.fileUrl + arr.uri });
+                    } else {
+                        wx.showToast({ title: `${arr.errmsg}`, icon: 'fail', duration: 2000 })
+                    }
+                },
+            })
+        },
+        //设置斜体
+        _addItalic: function () {
+            this.editorCtx.format("italic")
+        },
+        //添加粗体样式
+        _addBold: function () {
+            this.editorCtx.format("bold")
+        },
+        //设置标题
+        _addHeader: function (e) {
+            let headerType = e.currentTarget.dataset.header;
+            this.editorCtx.format("header", headerType)
+        },
+        //设置文字的排列方式
+        _addAlign: function (e) {
+            let alignType = e.currentTarget.dataset.align;
+            this.editorCtx.format("align", alignType);
+        },
+        //设置列表
+        _addList: function (e) {
+            let listType = e.currentTarget.dataset.list;
+            this.editorCtx.format("list", listType);
+        },
+        //撤销
+        _undo: function () {
+            this.editorCtx.undo();
+        },
+        //监控输入
+        _onInputting: function (e) {
+            let html = e.detail.html;
+            let text = e.detail.text;
+            this.triggerEvent("input", { html: html, text: text }, {});
+        }
     }
-  }
 })

+ 35 - 15
pagesMatch/matchAdmin/match/add.js

@@ -8,14 +8,16 @@ Page({
         form: { logo: [] },
         // 状态列表
         statusList: [],
+        // 类别列表
+        typeList: []
     },
     initValidate() {
         const rules = {
-            logo: { required: true }, name: { required: true }, start_time: { required: true }, end_time: { required: true }, address: { required: true }, sign_time: { required: true }, contact: { required: true }, status: { required: true }
+            belong_id: { required: false }, logo: { required: true }, name: { required: true }, start_time: { required: true }, end_time: { required: true }, address: { required: true }, sign_time: { required: true }, contact: { required: true }, status: { required: true }
         }
         // 验证字段的提示信息,若不传则调用默认的信息
         const messages = {
-            logo: { required: 'logo' }, name: { required: '比赛名称' }, start_time: { required: '比赛开始时间' }, end_time: { required: '比赛结束时间' }, address: { required: '比赛地点' }, sign_time: { required: '报名截止时间' }, contact: { required: '联系方式' },  status: { required: '比赛状态' },
+            belong_id: { required: '属于id' }, logo: { required: 'logo' }, name: { required: '比赛名称' }, start_time: { required: '比赛开始时间' }, end_time: { required: '比赛结束时间' }, address: { required: '比赛地点' }, sign_time: { required: '报名截止时间' }, contact: { required: '联系方式' }, status: { required: '比赛状态' },
         };
         this.WxValidate = new WxValidate(rules, messages)
     },
@@ -38,7 +40,7 @@ Page({
     // 确认选择
     datetimeChange: function (e) {
         const that = this;
-        that.setData({ [`form.${e.detail.fieldValue}`]: e.detail.datetime });
+        that.setData({ [`form.${e.detail.name}`]: e.detail.datetime });
     },
     // 选择状态
     statusChange: function (e) {
@@ -46,7 +48,16 @@ Page({
         let data = that.data.statusList[e.detail.value];
         if (data) {
             that.setData({ 'form.status': data.value });
-            that.setData({ 'form.zhstatus': data.label });
+            that.setData({ 'form.zhStatus': data.label });
+        }
+    },
+    // 赛事类别
+    typeChange: function (e) {
+        const that = this;
+        let data = that.data.typeList[e.detail.value];
+        if (data) {
+            that.setData({ 'form.type': data.value });
+            that.setData({ 'form.zhtype': data.label });
         }
     },
     //赛事规程
@@ -58,11 +69,9 @@ Page({
     toSubmit: async function (e) {
         const that = this;
         const form = that.data.form;
-        const params = e.detail.value;
-        params.start_time = form.start_time;
-        params.end_time = form.end_time;
-        params.sign_time = form.sign_time;
-        params.logo = form.logo;
+        let params = e.detail.value;
+        const { start_time, end_time, sign_time, logo, regular } = form
+        params = { ...params, start_time, end_time, sign_time, logo, regular }
         if (!this.WxValidate.checkForm(params)) {
             const error = this.WxValidate.errorList[0];
             wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
@@ -78,13 +87,23 @@ Page({
     /**
      * 生命周期函数--监听页面加载
      */
-    onLoad: function (options) {
+    onLoad: async function (options) {
         const that = this;
         that.setData({ id: options.id || '' })
         //验证规则函数
         that.initValidate();
+        // 查询其他信息
+        await that.searchOther();
         // 监听用户是否登录
-        that.watchLogin();
+        await that.watchLogin();
+    },
+    searchOther: async function () {
+        const that = this;
+        let arr;
+        arr = await app.$get(`/dict`, { code: "match_status" });
+        if (arr.errcode == '0' && arr.total > 0) that.setData({ statusList: arr.data[0].list });
+        arr = await app.$get(`/dict`, { code: "match_type" });
+        if (arr.errcode == '0' && arr.total > 0) that.setData({ typeList: arr.data[0].list });
     },
     // 监听用户是否登录
     watchLogin: async function () {
@@ -92,14 +111,15 @@ Page({
         wx.getStorage({
             key: 'user',
             success: async res => {
-                const aee = await app.$get(`/dict`, { code: "match_status" });
-                if (aee.errcode == '0' && aee.total > 0) that.setData({ statusList: aee.data[0].list });
                 if (that.data.id) {
-                    const arr = await app.$get(`/match/${that.data.id}`, 'race');
+                    const arr = await app.$get(`/match/${that.data.id}`, {}, 'race');
                     if (arr.errcode == '0') {
                         // 比赛状态
-                        let status = statusList.find(i => i.value == arr.data.status)
+                        let status = that.data.statusList.find(i => i.value == arr.data.status)
                         if (status) arr.data.zhStatus = status.label;
+                        // 赛事类别
+                        let type = that.data.typeList.find(i => i.value == arr.data.type)
+                        if (type) arr.data.zhtype = type.label;
                         that.setData({ form: arr.data });
                     }
                 }

+ 12 - 4
pagesMatch/matchAdmin/match/add.wxml

@@ -2,6 +2,14 @@
     <view slot="info" class="container main">
         <view class="one">
             <form catchsubmit="toSubmit">
+                <view class="content">
+                    <view class="label">赛事类别:</view>
+                    <view class="value">
+                        <picker mode="selector" bindchange="typeChange" name="type" value="{{form.type}}" range="{{typeList}}" range-key="label">
+                            <view class="picker">{{form.zhtype||'请选择赛事类别'}}</view>
+                        </picker>
+                    </view>
+                </view>
                 <view class="content">
                     <view class="label">logo:</view>
                     <view class="value">
@@ -17,13 +25,13 @@
                 <view class="content">
                     <view class="label">比赛开始时间:</view>
                     <view class="value">
-                        <datatime-picker datetime="{{form.start_time}}" fieldValue="start_time" bind:datetimeChange="datetimeChange"></datatime-picker>
+                        <datatime-picker datetime="{{form.start_time}}" name="start_time" bind:datetimeChange="datetimeChange"></datatime-picker>
                     </view>
                 </view>
                 <view class="content">
                     <view class="label">比赛结束时间:</view>
                     <view class="value">
-                        <datatime-picker datetime="{{form.end_time}}" fieldValue="end_time" bind:datetimeChange="datetimeChange"></datatime-picker>
+                        <datatime-picker datetime="{{form.end_time}}" name="end_time" bind:datetimeChange="datetimeChange"></datatime-picker>
                     </view>
                 </view>
                 <view class="content">
@@ -35,7 +43,7 @@
                 <view class="content">
                     <view class="label">报名截止时间:</view>
                     <view class="value">
-                        <datatime-picker datetime="{{form.sign_time}}" fieldValue="sign_time" bind:datetimeChange="datetimeChange"></datatime-picker>
+                        <datatime-picker datetime="{{form.sign_time}}" name="sign_time" bind:datetimeChange="datetimeChange"></datatime-picker>
                     </view>
                 </view>
                 <view class="content">
@@ -71,7 +79,7 @@
                     <view class="label">比赛状态:</view>
                     <view class="value">
                         <picker mode="selector" bindchange="statusChange" name="status" value="{{form.status}}" range="{{statusList}}" range-key="label">
-                            <view class="picker">{{form.zhstatus||'请选择状态'}}</view>
+                            <view class="picker">{{form.zhStatus||'请选择状态'}}</view>
                         </picker>
                     </view>
                 </view>

+ 17 - 2
pagesMatch/matchAdmin/match/list.js

@@ -8,7 +8,10 @@ Page({
         page: 0,
         skip: 0,
         limit: 5,
+        // 状态列表
         statusList: [],
+        // 类别列表
+        typeList: []
     },
     // 返回
     back: function () { wx.navigateBack({ delta: 1 }) },
@@ -58,10 +61,20 @@ Page({
     /**
      * 生命周期函数--监听页面显示
      */
-    onShow: function () {
+    onShow: async function () {
         const that = this;
+        // 查询其他信息
+        await that.searchOther();
         // 监听用户是否登录
-        that.watchLogin();
+        await that.watchLogin();
+    },
+    searchOther: async function () {
+        const that = this;
+        let arr;
+        arr = await app.$get(`/dict`, { code: "match_status" });
+        if (arr.errcode == '0' && arr.total > 0) that.setData({ statusList: arr.data[0].list });
+        arr = await app.$get(`/dict`, { code: "match_type" });
+        if (arr.errcode == '0' && arr.total > 0) that.setData({ typeList: arr.data[0].list });
     },
     // 分页
     toPage: function () {
@@ -92,6 +105,8 @@ Page({
                     for (const val of arr.data) {
                         let status = that.data.statusList.find(i => i.value == val.status)
                         if (status) val.zhstatus = status.label;
+                        let type = that.data.typeList.find(i => i.value == val.type)
+                        if (type) val.zhtype = type.label;
                     }
                     that.setData({ list: [...that.data.list, ...arr.data] });
                     that.setData({ total: arr.total });

+ 4 - 0
pagesMatch/matchAdmin/match/list.wxml

@@ -14,6 +14,10 @@
                     <view class="list" wx:for="{{list}}" wx:key="item">
                         <view class="name">{{item.name||'暂无'}}</view>
                         <view class="other">
+                            <view class="other_1">
+                                <text>赛事类别:</text>
+                                <text>{{item.zhtype}}</text>
+                            </view>
                             <view class="other_1">
                                 <text>比赛时间:</text>
                                 <text>{{item.start_time}}至{{item.end_time}}</text>