zs il y a 2 ans
Parent
commit
7ac210724d
4 fichiers modifiés avec 81 ajouts et 8 suppressions
  1. 58 2
      pages/match/sign.js
  2. 6 0
      pages/match/sign.less
  3. 14 6
      pages/match/sign.wxml
  4. 3 0
      pages/match/sign.wxss

+ 58 - 2
pages/match/sign.js

@@ -1,5 +1,6 @@
 const app = getApp()
 import { examine_status } from '../../utils/dict';
+import WxValidate from '../../utils/wxValidate';
 Page({
 
     /**
@@ -12,7 +13,15 @@ Page({
         list: [],
         dialog: { title: '详细信息', show: false, type: '1' },
         info: {},
-        statusList: examine_status
+        statusList: examine_status,
+        projectList: [],
+        form: {}
+    },
+    initValidate() {
+        const rules = { grouping_id: { required: true }, project_id: { required: true } }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { grouping_id: { required: '请选择赛事分组' }, project_id: { required: '请选择组内项目' } };
+        this.WxValidate = new WxValidate(rules, messages)
     },
     // 跳转菜单
     back(e) {
@@ -44,10 +53,55 @@ Page({
         let { id } = e.currentTarget.dataset;
         const arr = await app.$get(`/newCourt/api/enroll/${id}`);
         if (arr.errcode == '0') {
-            that.setData({ info: arr.data })
+            const ass = await app.$get(`/newCourt/api/match/${arr.data.match_id}`);
+            if (ass.errcode == '0') {
+                that.setData({ info: ass.data })
+                let data = { openid: ass.data.openid, match_id: ass.data._id, match_name: ass.data.name }
+                that.setData({ form: data })
+            }
             that.setData({ dialog: { title: '信息审核', show: true, type: '2' } })
         }
     },
+    // 赛事分组
+    groupingChange: async function (e) {
+        const that = this;
+        let data = that.data.info.grouping[e.detail.value];
+        that.setData({ 'form.grouping_id': data._id });
+        that.setData({ 'form.grouping_name': data.name });
+        let project = [];
+        for (const val of data.project) {
+            const arr = await app.$get(`/newCourt/api/matchProject/${val}`);
+            if (arr.errcode == '0') {
+                project.push(arr.data)
+            }
+        }
+        that.setData({ projectList: project });
+    },
+    // 选择组内项目
+    projectChange: function (e) {
+        const that = this;
+        let data = that.data.projectList[e.detail.value];
+        that.setData({ 'form.project_id': data._id });
+        that.setData({ 'form.project_name': data.name });
+    },
+    onSubmit: async function (e) {
+        const that = this;
+        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 {
+            const arr = await app.$post(`/newCourt/api/enroll`, params);
+            if (arr.errcode == '0') {
+                wx.showToast({ title: `报名成功`, icon: 'success', duration: 2000 });
+                that.setData({ dialog: { title: '信息审核', show: false, type: '2' } })
+                that.watchLogin();
+            } else {
+                wx.showToast({ title: `${res.errMsg}`, icon: 'fail', duration: 2000 });
+            }
+        }
+    },
     // 关闭弹框
     toClose: function () {
         const that = this;
@@ -58,6 +112,8 @@ Page({
      */
     onLoad: function (options) {
         const that = this;
+        //验证规则函数
+        that.initValidate();
         that.watchLogin();
     },
     // 监听用户是否登录

+ 6 - 0
pages/match/sign.less

@@ -110,6 +110,12 @@
         margin: 0 0 10px 0;
         font-size: 14px;
         color: #000;
+
+        .value {
+            .input {
+                text-align: right;
+            }
+        }
     }
 
     .btn {

+ 14 - 6
pages/match/sign.wxml

@@ -46,21 +46,29 @@
         <view class="dialog_two" wx:elif="{{dialog.type=='2'}}">
             <form bindsubmit="onSubmit">
                 <view class="content">
-                    <view class="label textOver">赛事分组</view>
+                    <view class="label">赛事分组</view>
                     <view class="value">
-                        <picker mode="selector" bindchange="statusChange" name="status" value="{{info.status}}" range-key="label" range="{{statusList}}">
-                            <view class="input">{{info.pay_status=='0'?'待支付':info.status=='1'?'已支付':'支付失败'}}</view>
+                        <picker mode="selector" bindchange="groupingChange" value="{{form.grouping_id}}" name="grouping_id" range-key='name' range="{{info.grouping}}">
+                            <view class="input">{{form.grouping_name||'请选择赛事分组'}}</view>
                         </picker>
                     </view>
                 </view>
                 <view class="content">
-                    <view class="label textOver">组内项目</view>
+                    <view class="label">赛事分组名称</view>
+                    <view class="value"><input name="grouping_name" value="{{form.grouping_name}}" placeholder="请输入赛事分组名称" disabled /></view>
+                </view>
+                <view class="content">
+                    <view class="label">组内项目</view>
                     <view class="value">
-                        <picker mode="selector" bindchange="statusChange" name="status" value="{{info.status}}" range-key="label" range="{{statusList}}">
-                            <view class="input">{{info.pay_status=='0'?'待支付':info.status=='1'?'已支付':'支付失败'}}</view>
+                        <picker mode="selector" bindchange="projectChange" value="{{form.project_id}}" name="project_id" range-key='name' range="{{projectList}}">
+                            <view class="input">{{form.project_name||'请选择组内项目'}}</view>
                         </picker>
                     </view>
                 </view>
+                <view class="content">
+                    <view class="label">组内项目名称</view>
+                    <view class="value"><input name="project_name" value="{{form.project_name}}" placeholder="请输入组内项目名称" disabled /></view>
+                </view>
                 <view class="btn">
                     <button type="primary" size="mini" formType="submit">提交审核</button>
                 </view>

+ 3 - 0
pages/match/sign.wxss

@@ -94,6 +94,9 @@
   font-size: 14px;
   color: #000;
 }
+.dialog_two .content .value .input {
+  text-align: right;
+}
 .dialog_two .btn {
   text-align: center;
 }