浏览代码

创建团队

YY 3 年之前
父节点
当前提交
8dc1157e68
共有 3 个文件被更改,包括 61 次插入62 次删除
  1. 54 56
      pages/createTeam/index.js
  2. 4 4
      pages/createTeam/index.wxml
  3. 3 2
      pages/createTeam/index.wxss

+ 54 - 56
pages/createTeam/index.js

@@ -17,29 +17,31 @@ Page({
             objectType: [{ id: 0, name: '乒乓球' }, { id: 1, name: '足球' }, { id: 2, name: '篮球' },],
             create_time: '2016-09-01',
         },
+        members: [],
         lists: [],
         index: 0,
+        //选择成员列表
         item: [],
-        menbers: [],
+        check: [],
         // 上传图片
         fileList: [],
     },
-    apply: function (e) {
+    determine: function (e) {
         this.setData({ showModal: false })
-        console.log(this.data.menbers);
+        console.log(this.data.members);
     },
     //选择队员
     checkboxChange: function (e) {
         const that = this;
         let data = e.detail.value;
         let item = that.data.item;
-        let menbers = [];
+        let members = [];
         for (const val of data) {
             let arr = item.find((i) => i._id == val);
             console.log(arr);
-            if (arr) menbers.push({ id: arr._id, nickname: arr.nickname, icon: arr.icon })
+            if (arr) members.push({ id: arr._id, nickname: arr.nickname, icon: arr.icon })
         }
-        that.setData({ menbers: menbers })
+        that.setData({ members: members })
     },
     //显示对话框
     clickme: function () {
@@ -71,60 +73,57 @@ Page({
     back: function () {
         wx.navigateBack({ url: '/pages/me/index' })
     },
-
     //点击减号删除
     delList: function () {
-        var lists = this.data.lists;
-        lists.pop();      //实质是删除lists数组内容,使for循环少一次
+        var members = this.data.members;
+        members.pop();//实质是删除lists数组内容,使for循环少一次
         this.setData({
-            lists: lists,
+            members: members,
         })
     },
-    // //提交
-    // formSubmit: function (e) {
-    //     const value = e.detail.value;
-    //     if (!this.WxValidate.checkForm(value)) {
-    //         const error = this.WxValidate.errorList[0];
-    //         wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
-    //         return false
-    //     } else {
-    //         value.icon = this.data.fileList;
-    //         wx.getStorage({
-    //             key: 'token',
-    //             success: function (res) {
-    //                 wx.request({
-    //                     url: `${app.globalData.publicUrl}/courtAdmin/api/team`, //接口地址
-    //                     method: "post",//请求方法
-    //                     //请求参数
-    //                     data: value,
-    //                     header: {},
-    //                     success: res => {
-    //                         console.log(res);
-    //                         if (res.data.errcode == 0) {
-    //                             wx.showToast({
-    //                                 title: '创建团队成功',
-    //                                 icon: 'success',
-    //                                 duration: 2000//延迟两秒
-    //                             })
-    //                         } else {
-    //                             wx.showToast({
-    //                                 title: '创建团队失败',
-    //                                 icon: 'error',
-    //                                 duration: 2000
-    //                             })
-    //                         }
-    //                     },
-    //                     error: err => {
-    //                         console.log(err);
-    //                     }
-    //                 })
-    //             }
-    //         })
-    //     }
-    // },
-    //上传图片
-    formSubmit(e) {
-        console.log('form发生了submit事件,携带数据为:', e.detail.value)
+    //提交
+    formSubmit: function (e) {
+        const value = e.detail.value;
+        if (!this.WxValidate.checkForm(value)) {
+            const error = this.WxValidate.errorList[0];
+            wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
+            return false
+        } else {
+            value.logo = this.data.fileList;
+            value.members = this.data.members;
+            wx.getStorage({
+                key: 'token',
+                success: function (res) {
+                    wx.request({
+                        url: `${app.globalData.publicUrl}/courtAdmin/api/team`, //接口地址
+                        method: "post",//请求方法
+                        //请求参数
+                        data: value,
+                        header: {},
+                        success: res => {
+                            console.log(res);
+                            if (res.data.errcode == 0) {
+                                wx.showToast({
+                                    title: '创建团队成功',
+                                    icon: 'success',
+                                    duration: 2000//延迟两秒
+                                })
+                            } else {
+                                wx.showToast({
+                                    title: '创建团队失败',
+                                    icon: 'error',
+                                    duration: 2000
+                                })
+                            }
+                        },
+                        error: err => {
+                            console.log(err);
+                        }
+                    })
+                }
+            })
+        }
+        console.log(e.detail.value);
     },
     afterRead: function (event) {
         const that = this;
@@ -149,7 +148,6 @@ Page({
             },
         });
     },
-
     //验证必填项
     initValidate() {
         const rules = { name: { required: true }, type: { required: true }, create_user: { required: true }, }

+ 4 - 4
pages/createTeam/index.wxml

@@ -36,13 +36,13 @@
                     <view class="two">
                         <view class="two_title"> 团队队员</view>
                         <view class="two_main">
-                            <view class="two_1" wx:key="item1" wx:for="{{menbers}}">
+                            <view class="two_1" wx:key="item" wx:for="{{members}}">
                                 <view class="team_1">
-                                    <image class="two_logo1" src="{{item1.icon[0].url}}"></image>
+                                    <image class="two_logo1" src="{{item.icon[0].url}}"></image>
                                     <image bindtap='delList' class="two_jian" src="/image/jian.png"></image>
                                 </view>
                                 <view class="team_text">
-                                    <input class="input1" name="nickname" value="{{item1.nickname}}" placeholder="队员名称" />
+                                    <input class="input1" value="{{item.nickname}}" placeholder="队员名称" />
                                 </view>
                             </view>
                             <view class="two_1">
@@ -65,7 +65,7 @@
                             <checkbox class="box" value="{{item._id}}" checked="{{item.checked}}" />
                         </label>
                     </checkbox-group>
-                    <button bindtap="apply" class="modal_button">确定</button>
+                    <button bindtap="determine" class="modal_button">确定</button>
                     <text bindtap="go" class="modal_text4">取消</text>
                 </view>
             </view>

+ 3 - 2
pages/createTeam/index.wxss

@@ -116,9 +116,10 @@
 }
 
 .two_logo1 {
-  margin: 4px 2px;
+  border-radius: 50%;
+  margin: 6px 2px;
   width: 45px;
-  height: 50px;
+  height: 45px;
 }
 
 .two_jian {