Browse Source

修改上传比分

zs 2 years ago
parent
commit
eb697a2091
3 changed files with 128 additions and 24 deletions
  1. 42 23
      pages/me/index.js
  2. 49 1
      pages/me/index.wxml
  3. 37 0
      pages/me/index.wxss

+ 42 - 23
pages/me/index.js

@@ -1,5 +1,6 @@
 const app = getApp();
 import { btn } from '../../utils/dict';
+import WxValidate from '../../utils/wxValidate'
 Page({
 
     /**
@@ -14,34 +15,21 @@ Page({
         // 用户信息
         userInfo: {},
         // 正在比赛
-        ismatchList: [
-            {
-                id: '1',
-                _id: '1',
-                status: '0',
-                match_time: '2020-11-11 10:11',
-                red_logo: [{
-                    name: "20220331104915.jpg",
-                    uri: "/files/court/elimg/20220331104915.jpg",
-                    url: "http://broadcast.waityou24.cn/files/court/elimg/20220331104915.jpg",
-                }],
-                red_name: '红方名称',
-                red_branch: '11',
-                blue_branch: '11',
-                blue_name: '蓝方名称',
-                blue_logo: [{
-                    name: "20220331104915.jpg",
-                    uri: "/files/court/elimg/20220331104915.jpg",
-                    url: "http://broadcast.waityou24.cn/files/court/elimg/20220331104915.jpg",
-                }],
-            },
-        ],
+        ismatchList: [],
         // 我的团队
         teamList: [],
         // 我的服务
         btnList: [],
         // 弹框
-        dialog: { title: '上传比分', show: false, type: '1' }
+        dialog: { title: '上传比分', show: false, type: '1' },
+        form: {},
+
+    },
+    initValidate() {
+        const rules = { red_branch: { required: true }, blue_branch: { required: true }, red_integral: { required: true }, blue_integral: { required: true } }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { red_branch: { required: '请输入红方比分', }, blue_branch: { required: '请输入蓝方比分', }, red_integral: { required: '请输入红方积分', }, blue_integral: { required: '请输入蓝方积分', } };
+        this.WxValidate = new WxValidate(rules, messages)
     },
     tabPath: function (e) {
         let { route } = e.detail.detail;
@@ -52,6 +40,35 @@ Page({
         const that = this;
         that.setData({ dialog: { title: '上传比分', show: true, type: '1' } })
     },
+    // 选择比赛
+    ismatchChange: function (e) {
+        const that = this;
+        const list = that.data.ismatchList;
+        const { value } = e.detail;
+        const data = list[value];
+        if (data) {
+            that.setData({ 'form._id': data._id })
+            that.setData({ 'form.red_name': data.red_name })
+            that.setData({ 'form.blue_name': data.blue_name })
+        }
+    },
+    // 提交上传比分
+    async onSubmit(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.$get(`/courtAdmin/api/schedule/${params._id}`, params)
+            if (arr.errcode == '0') {
+                wx.showToast({ title: `上传比分成功`, icon: 'success', duration: 2000 });
+                that.toClose();
+                that.watchLogin();
+            } else wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
+        }
+    },
     // 比赛信息
     matchView: function (e) {
         const { id } = e.currentTarget.dataset;
@@ -87,6 +104,8 @@ Page({
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
+        //验证规则函数
+        this.initValidate();
         // 计算高度
         this.searchHeight();
         // // 监听用户是否登录

+ 49 - 1
pages/me/index.wxml

@@ -93,7 +93,55 @@
 <e-dialog dialog="{{dialog}}" bind:toClose="toClose">
     <view slot="info">
         <view class="dialog_one" wx:if="{{dialog.type=='1'}}">
-            上传比分
+            <form bindsubmit="onSubmit">
+                <view class="content">
+                    <view class="label textOver">比赛</view>
+                    <view class="value">
+                        <picker mode="selector" bindchange="ismatchChange" name="_id" value="{{form._id}}" range-key="{{'red_name'}}" range="{{ismatchList}}">
+                            <view class="input">{{form.red_name||'暂无'+'-'+form.blue_name||'暂无'}}</view>
+                        </picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">红方团队</view>
+                    <view class="value">
+                        <input type="text" name="red_name" value="{{form.red_name}}" placeholder="请输入红方团队" disabled />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">蓝方团队</view>
+                    <view class="value">
+                        <input type="text" name="blue_name" value="{{form.blue_name}}" placeholder="请输入蓝方团队" disabled />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">红方比分</view>
+                    <view class="value">
+                        <input type="text" name="red_branch" value="{{form.red_branch}}" placeholder="请输入红方比分" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">蓝方比分</view>
+                    <view class="value">
+                        <input type="text" name="blue_branch" value="{{form.blue_branch}}" placeholder="请输入蓝方比分" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">红方积分</view>
+                    <view class="value">
+                        <input type="text" name="red_integral" value="{{form.red_integral}}" placeholder="请输入红方积分" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label textOver">蓝方积分</view>
+                    <view class="value">
+                        <input type="text" name="blue_integral" value="{{form.blue_integral}}" placeholder="请输入蓝方积分" />
+                    </view>
+                </view>
+                <view class="btn">
+                    <button type="primary" size="mini" formType="submit">提交保存</button>
+                </view>
+            </form>
         </view>
     </view>
 </e-dialog>

+ 37 - 0
pages/me/index.wxss

@@ -381,3 +381,40 @@
     font-size: 12px;
     color: #666;
 }
+
+
+
+.dialog_one {
+    float: left;
+    width: 100%;
+}
+
+.dialog_one .content {
+    float: left;
+    width: 100%;
+    border-bottom: 1px solid #ccc;
+    padding: 10px 0;
+    margin: 0 0 10px 0;
+    font-size: 14px;
+}
+
+.dialog_one .content .label {
+    float: left;
+    width: 20%;
+}
+
+.dialog_one .content .value {
+    float: left;
+    width: 80%;
+    text-align: right;
+}
+
+.dialog_one .btn {
+    float: left;
+    width: 100%;
+    text-align: center;
+}
+
+.dialog_one .btn button {
+    font-size: 14px;
+}