Jelajahi Sumber

Merge branch 'master' of http://git.cc-lotus.info/ball-court/court-mobile

zs 3 tahun lalu
induk
melakukan
8ab9cf4a1e

+ 62 - 83
pages/createTeam/index.js

@@ -8,24 +8,19 @@ Page({
      * 页面的初始数据
      */
     data: {
-        showModal: false,
         // 主体高度
         infoHeight: '',
         frameStyle: { useTop: true, name: '创建团队', leftArrow: true, useBar: false },
-        form: {
-            type: ['乒乓球', '足球', '篮球'],
-            objectType: [{ id: 0, name: '乒乓球' }, { id: 1, name: '足球' }, { id: 2, name: '篮球' },],
-            create_time: '2020-02-02',
-            create_id: '',
-            create_user: '',
-        },
+        form: {},
+        // 团队logo
+        logo: [],
+        // 团队类型
+        typeList: ['乒乓球', '足球', '篮球'],
         //成员
         members: [],
-        index: 0,
-        //选择成员列表
-        item: [],
-        // 上传图片
-        fileList: [],
+        show: false,
+        // 用户列表
+        userList: [],
     },
     //验证必填项
     initValidate() {
@@ -40,60 +35,60 @@ Page({
     //上传图片
     imgUpload: function (e) {
         const that = this;
-        let data = that.data.fileList;
+        let data = that.data.logo;
         data.push(e.detail)
-        that.setData({ fileList: data })
+        that.setData({ logo: data })
     },
     //删除图片
     imgDel: function (e) {
         const that = this;
-        let data = that.data.fileList;
+        let data = that.data.logo;
         let arr = data.filter((i, index) => index != e.detail.index)
-        that.setData({ fileList: arr })
+        that.setData({ logo: arr })
     },
-    //点击确定关闭弹窗
-    determine: function (e) {
-        this.setData({ showModal: false })
-    },
-    //显示对话框
-    clickme: function () {
-        this.setData({
-            showModal: true
-        })
+    // 选择团队类型
+    typeChange: function (e) {
+        const that = this;
+        let index = e.detail.value;
+        let data = that.data.typeList[index];
+        that.setData({ 'form.type': data })
     },
-    preventTouchMove: function () {
+    // 时间选择
+    dataChange: function (e) {
+        const that = this;
+        let value = e.detail.value;
+        that.setData({ 'form.create_time': value })
     },
-    //关闭弹窗
-    go: function () {
-        this.setData({
-            showModal: false
-        })
+    // 添加成员
+    createMem: function () {
+        const that = this;
+        that.setData({ show: true })
     },
-     //选择队
-     checkboxChange: function (e) {
+    // 选择成
+    memChange: function (e) {
         const that = this;
         let data = e.detail.value;
-        let item = that.data.item;
+        let user = that.data.userList;
         let members = [];
         for (const val of data) {
-            let arr = item.find((i) => i._id == val);
+            let arr = user.find((i) => i._id == val);
             if (arr) members.push({ id: arr._id, nickname: arr.nickname, icon: arr.icon })
         }
         that.setData({ members: members })
     },
-    //选择
-    bindPickerChange: function (e) {
-        this.setData({
-            index: e.detail.value
-        })
+    // 确认选择成员
+    memfirmSubmit: function () {
+        const that = this;
+        that.setData({ show: false });
     },
-    bindDateChange: function (e) {
-        this.setData({
-            ['form.create_time']: e.detail.value
-        })
+    // 取消选择成员
+    memClose: function () {
+        const that = this;
+        that.setData({ members: [] });
+        that.setData({ show: false });
     },
-    //点击减号删除
-    delList: function (e) {
+    //删除成员
+    memDel: function (e) {
         var id = e.currentTarget.dataset.id;
         var members = this.data.members;
         for (var i = 0; i < members.length; i++) {
@@ -105,39 +100,28 @@ Page({
     },
     //提交
     formSubmit: function (e) {
+        const that = this;
         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;
-            value.create_id = this.data.form.create_id;
+            value.logo = that.data.logo;
+            value.members = that.data.members;
             wx.request({
-                url: `${app.globalData.publicUrl}/courtAdmin/api/team`, //接口地址
-                method: "post",//请求方法
-                //请求参数
+                url: `${app.globalData.publicUrl}/courtAdmin/api/team`,
+                method: "post",
                 data: value,
-                header: {},
                 success: res => {
                     if (res.data.errcode == 0) {
-                        wx.showToast({
-                            title: '创建团队成功',
-                            icon: 'success',
-                            duration: 2000//延迟两秒
-                        })
-                        return wx.redirectTo({ url: '/pages/me/index' })// 跳转页面
+                        wx.showToast({ title: '创建团队成功', icon: 'success', duration: 2000 })
+                        wx.redirectTo({ url: '/pages/me/index' })// 跳转页面
                     } else {
-                        wx.showToast({
-                            title: '创建团队失败',
-                            icon: 'error',
-                            duration: 2000
-                        })
+                        wx.showToast({ title: res.data.errmsg, icon: 'error', duration: 2000 })
                     }
                 },
-                error: err => {
-                }
+                error: err => { }
             })
         }
     },
@@ -169,30 +153,25 @@ Page({
         wx.getStorage({
             key: 'token',
             success: res => {
-                //数据请求
+                //查询用户列表
                 wx.request({
                     url: `${app.globalData.publicUrl}/courtAdmin/api/user`, //接口地址
                     method: "get",
-                    data: {},
+                    data: { status: '1' },
                     header: {},
-                    success: res => {
-                        that.setData({ item: res.data.data })
+                    success: arr => {
+                        let aee = arr.data.data.filter((i) => i.type == '2')
+                        if (aee) {
+                            that.setData({ userList: aee });
+                            // 过滤当前用户
+                            let user = arr.data.data.find((i) => i._id == res.data._id);
+                            if (user) that.setData({ 'form.create_user': user.nickname, 'form.create_id': user._id })
+
+                        }
                     },
                     error: err => {
                     }
                 })
-                wx.request({
-                    url: `${app.globalData.publicUrl}/courtAdmin/api/user/${res.data.id}`, //接口地址
-                    method: "get",//请求方法
-                    data: {},//请求参数
-                    header: {},
-                    success: res => {
-                        that.setData({ ['form.create_user']: res.data.data.nickname, ['form.create_id']: res.data.data.id })
-                    },
-                    error: err => {
-                    }
-                })
-
             },
             fail: res => {
                 wx.redirectTo({ url: '/pages/login/index', })

+ 35 - 25
pages/createTeam/index.wxml

@@ -5,41 +5,45 @@
                 <view class="top">
                     <view class="zero">
                         <view class="text">团队LOGO</view>
-                        <upload class="tou" list="{{fileList}}" count="{{1}}"  bind:imgUpload="imgUpload" bind:imgDel="imgDel"></upload>
+                        <upload class="tou" list="{{logo}}" count="{{1}}" bind:imgUpload="imgUpload" bind:imgDel="imgDel"></upload>
                     </view>
                     <view class="one">
                         <view class="text">团队名称</view>
-                        <input class="input" name="name" value="{{form.name}}" placeholder="" />
+                        <input class="input" name="name" value="{{form.name}}" placeholder="请输入团队名称" />
+                    </view>
+                    <view class="one" style="display: none;">
+                        <view class="text">团队创建人id</view>
+                        <input class="input" name="create_id" value="{{form.create_id}}" disabled />
                     </view>
                     <view class="one">
                         <view class="text">团队创建人</view>
-                        <input class="input" name="create_user" value="{{form.create_user}}" placeholder="" />
+                        <input class="input" name="create_user" value="{{form.create_user}}" placeholder="请输入团队创建人" />
                     </view>
                     <view class="one">
                         <view class="text">团队类型</view>
-                        <picker name="type" bindchange="bindPickerChange" value="{{index}}" range="{{form.type}}">
-                            <view class="input">{{form.type[index]}}
+                        <picker mode="selector" bindchange="typeChange" name="type" value="{{form.type}}" range="{{typeList}}">
+                            <view class="input">
+                                {{form.type||'请选择'}}
                                 <image class="back" src="/image/back.png"></image>
                             </view>
                         </picker>
                     </view>
                     <view class="one">
                         <view class="text">创建时间</view>
-                        <picker name="create_time" mode="date"  value="{{form.create_time}}" start="2015-09-01" end="3017-09-01" bindchange="bindDateChange">
+                        <picker mode="date" name="create_time" value="{{form.create_time}}" start="2022-01-01" end="2100-01-01" bindchange="dataChange">
                             <view class="input">
-                                {{form.create_time}}<image class="back" src="/image/back.png"></image>
+                                {{form.create_time||'选择时间'}}
+                                <image class="back" src="/image/back.png"></image>
                             </view>
                         </picker>
                     </view>
-                </view>
-                <view class="bottom" style="height:{{infoHeight-270}}px;">
                     <view class="two">
                         <view class="two_title"> 团队队员</view>
                         <view class="two_main">
-                            <view class="two_1" wx:key="item" wx:for="{{members}}">
+                            <view class="two_1" wx:for="{{members}}" wx:key="item">
                                 <view class="team_1">
                                     <image class="two_logo1" src="{{item.icon[0].url}}"></image>
-                                    <image bindtap='delList' data-id="{{item.id}}" class="two_jian" src="/image/jian.png"></image>
+                                    <image bindtap='memDel' data-id="{{item.id}}" class="two_jian" src="/image/jian.png"></image>
                                 </view>
                                 <view class="team_text">
                                     <text class="input1" value="{{item.nickname}}"></text>
@@ -48,29 +52,35 @@
                             <view class="two_1">
                                 <view class="team_1">
                                     <view class="tianjia">
-                                        <text bindtap='clickme' class=" icon iconfont icon-jia"></text>
+                                        <text bindtap='createMem' class=" icon iconfont icon-jia"></text>
                                     </view>
                                 </view>
                             </view>
                         </view>
                     </view>
                 </view>
-                <view class="mask" catchtouchmove="preventTouchMove" wx:if="{{showModal}}"></view>
-                <view class="modalDlg" wx:if="{{showModal}}">
-                    <text class="modal_text2">选择队员</text>
-                    <checkbox-group bindchange="checkboxChange">
-                        <label class="checkbox" wx:key="item" wx:for="{{item}}">
-                            <text class="modal_box">{{item.nickname}}</text>
-                            <checkbox class="box" value="{{item._id}}" checked="{{item.checked}}" />
-                        </label>
-                    </checkbox-group>
-                    <button bindtap="determine" class="modal_button">确定</button>
-                    <text bindtap="go" class="modal_text4">取消</text>
-                </view>
             </view>
             <view class="btn-area">
                 <button class="button" formType="submit">创建团队</button>
             </view>
         </form>
     </view>
-</mobile-main>
+</mobile-main>
+<van-dialog use-slot title="添加成员" show="{{ show }}" :showCancelButton="{{false}}" confirmButtonText="关闭" :closeOnClickOverlay="{{false}}">
+    <view class="dialog">
+        <view class="dialog_1">
+            <checkbox-group bindchange="memChange">
+                <view class="userList" wx:for="{{userList}}" wx:key="item">
+                    <label>
+                        <text>{{item.nickname}}</text>
+                        <checkbox value="{{item._id}}" checked="{{item.checked}}" />
+                    </label>
+                </view>
+            </checkbox-group>
+        </view>
+        <view class="dialog_2">
+            <button type="primary" size="mini" bindtap="memfirmSubmit">确定</button>
+            <button type="warn" size="mini" bindtap="memClose">取消</button>
+        </view>
+    </view>
+</van-dialog>

+ 44 - 1
pages/createTeam/index.wxss

@@ -191,9 +191,11 @@
 .box {
   padding: 10px 10px 0 0;
 }
-.modal_box{
+
+.modal_box {
   padding: 0 0 0 0;
 }
+
 .modal_text4 {
   font-size: 12px;
   margin: 10px 0 0 0;
@@ -207,4 +209,45 @@
   text-align: center;
   font-size: small;
   margin: 30px 0 0 0;
+}
+
+.dialog {
+  float: left;
+  width: 100%;
+  max-height: 300px;
+  overflow-y: auto;
+}
+
+.dialog .dialog_1 {
+  float: left;
+  width: 100%;
+  margin: 0 0 10px 0;
+}
+
+.dialog .dialog_1 .userList {
+  float: left;
+  width: 93%;
+  padding: 10px;
+  border-bottom: 1px solid #ccc;
+}
+
+.dialog .dialog_1 .userList text {
+  float: left;
+  text-align: left;
+  font-size: 14px;
+}
+.dialog .dialog_1 .userList checkbox {
+  float: right;
+}
+
+.dialog .dialog_2 {
+  float: left;
+  width: 100%;
+  text-align: center;
+  margin: 0 0 10px 0;
+}
+
+.dialog .dialog_2 button {
+  margin: 0 10px;
+  width: 30%;
 }

+ 6 - 13
pages/dissolution/detail.js

@@ -13,16 +13,13 @@ Page({
     ids: '',
     jslist: []
   },
-  //解散申请
-  apply: function () {
-    wx.navigateTo({
-      url: `/pages/dissolution/index?id=` + this.data.ids,
-    })
-  },
-
   back: function () {
     wx.navigateBack({ url: '/pages/me/index' })
   },
+  //解散申请
+  apply: function () {
+    wx.navigateTo({url: `/pages/dissolution/index?id=${this.data.ids}`,})
+  },
 
   /**
 * 生命周期函数--监听页面加载
@@ -45,9 +42,7 @@ Page({
         wx.request({
           url: `${app.globalData.publicUrl}/courtAdmin/api/dismissapply`,
           method: 'get',
-          data: {
-            "team_id": team_id
-          },
+          data: { "team_id": team_id },
           success(res) {
             if (res.data.errcode == 0) {
               let datas = res.data.data
@@ -60,9 +55,7 @@ Page({
                   datas[i].status = '拒绝'
                 }
               }
-              that.setData({
-                jslist: datas,
-              });
+              that.setData({ jslist: datas });
             } else {
               wx.showToast({
                 title: res.data.errmsg,

+ 21 - 21
pages/dissolution/index.js

@@ -27,28 +27,24 @@ Page({
     //提交
     formSubmit: function (e) {
         const params = e.detail.value;
-        var apply_time = this.data.apply_time;
-        var form = {
-            "team_id": params.team_id,
-            "team_name": params.team_name,
-            "create_user": params.create_user,
-            "create_id": params.create_id,
-            "apply_time": apply_time,
-            "resaon": params.resaon
-        }
+        params.apply_time = this.data.apply_time;
         if (!this.WxValidate.checkForm(params)) {
             const error = this.WxValidate.errorList[0];
             wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
             return false
         } else {
             wx.request({
-                url: `${app.globalData.publicUrl}/courtAdmin/api/dismissapply`, 
+                url: `${app.globalData.publicUrl}/courtAdmin/api/dismissapply`,
                 method: 'post',
-                data: form,
+                data: params,
                 success(res) {
                     if (res.data.errcode == 0) {
-                        wx.showToast({ title: `解散审核提交成功`, icon: 'success', duration: 2000 }) 
-                        wx.navigateTo({ url: '/pages/me/index' })
+                        wx.showModal({
+                            title: '是否提交申请',
+                            success(res) {
+                                wx.navigateTo({ url: '/pages/me/index' })
+                            }
+                        })
                     } else {
                         wx.showToast({
                             title: res.data.errmsg,
@@ -59,15 +55,19 @@ Page({
                 }
             })
         }
+
+
+
+
     },
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
-        this.setData({ids: options.id,});
+        this.setData({ ids: options.id, });
         //获取当前时间
         let apply_time = moment().format('YYYY-MM-DD HH:mm:ss');
-        this.setData({apply_time: apply_time,});
+        this.setData({ apply_time: apply_time, });
         // 计算高度
         this.searchHeight();
         // 监听用户是否登录
@@ -77,18 +77,18 @@ Page({
     },
     // 监听用户是否登录
     watchLogin: function () {
+        var that = this;
+        var id = that.data.ids;
         wx.getStorage({
             key: 'token',
             success: res => {
-                var that = this;
                 wx.request({
-                    url: `${app.globalData.publicUrl}/courtAdmin/api/team/` + that.data.ids, 
+                    url: `${app.globalData.publicUrl}/courtAdmin/api/team/${id}`,
                     method: 'get',
                     data: '',
                     success(res) {
                         if (res.data.errcode == 0) {
-                            let datas = res.data.data
-                            that.setData({ form: datas,});
+                            that.setData({ form: res.data.data });
                         } else {
                             wx.showToast({
                                 title: res.data.errmsg,
@@ -104,8 +104,8 @@ Page({
             }
         })
     },
-     // 计算高度
-     searchHeight: function () {
+    // 计算高度
+    searchHeight: function () {
         let frameStyle = this.data.frameStyle;
         let client = app.globalData.client;
         let infoHeight = client.windowHeight;

+ 0 - 4
pages/dissolution/index.wxml

@@ -18,10 +18,6 @@
                     <view class="text">团队创建人id</view>
                     <input class="input" name="create_id" disabled="true" value="{{form.create_id}}" placeholder="" />
                 </view>
-                <!-- <view class="one">
-                    <view class="text">申请时间</view>
-                    <input class="input" name="apply_time" value="{{form.apply_time}}" placeholder="请输入申请时间" />
-                </view> -->
                 <view class="one">
                     <view class="text">解散团队原因</view>
                     <input class="input" name="resaon" value="{{form.resaon}}" placeholder="请输入解散原因" />