YY пре 3 година
родитељ
комит
c110151446
4 измењених фајлова са 164 додато и 77 уклоњено
  1. 62 34
      pages/information/index.js
  2. 76 27
      pages/me/index.js
  3. 17 15
      pages/me/index.wxml
  4. 9 1
      pages/me/index.wxss

+ 62 - 34
pages/information/index.js

@@ -2,7 +2,6 @@
 import WxValidate from '../../utils/wxValidate'
 import WxValidate from '../../utils/wxValidate'
 const app = getApp()
 const app = getApp()
 Page({
 Page({
-
     /**
     /**
      * 页面的初始数据
      * 页面的初始数据
      */
      */
@@ -10,7 +9,8 @@ Page({
         // 主体高度
         // 主体高度
         infoHeight: '',
         infoHeight: '',
         frameStyle: { useTop: true, name: '个人信息', leftArrow: true, useBar: false },
         frameStyle: { useTop: true, name: '个人信息', leftArrow: true, useBar: false },
-        form: {},
+        form: {
+        },
         // index: 0,
         // index: 0,
         // 上传图片
         // 上传图片
         fileList: [],
         fileList: [],
@@ -48,59 +48,87 @@ Page({
     back: function () {
     back: function () {
         wx.navigateBack({ url: '/pages/me/index' })
         wx.navigateBack({ url: '/pages/me/index' })
     },
     },
-
+    //验证必填项
+    initValidate() {
+        const rules = { phone: { required: true, tel: true }, }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { phone: { required: '请输入手机号' }, };
+        this.WxValidate = new WxValidate(rules, messages)
+    },
     /**
     /**
      * 生命周期函数--监听页面加载
      * 生命周期函数--监听页面加载
      */
      */
-    onLoad: function (e) {
+    onLoad: function (options) {
         // 计算高度
         // 计算高度
         this.searchHeight()
         this.searchHeight()
+        // 监听用户是否登录
+        this.watchLogin();
+        //验证规则函数
+        this.initValidate()
+
+    },
+    // 监听用户是否登录
+    watchLogin: function () {
         const that = this;
         const that = this;
-        // 获取用户信息
         wx.getStorage({
         wx.getStorage({
             key: 'token',
             key: 'token',
-            success: function (res) {
+            success: res => {
+                //数据请求
                 wx.request({
                 wx.request({
-                    url: `${app.globalData.publicUrl}/courtAdmin/api/user`, //接口地址
-                    method: "post",
-                    data: { "id": "", "phone": "", "type": "", "status": "" },
+                    url: `${app.globalData.publicUrl}/courtAdmin/api/user/${res.data.id}`, //接口地址
+                    method: "get",//请求方法
+                    data: {},//请求参数
                     header: {},
                     header: {},
                     success: res => {
                     success: res => {
-                        that.setData({ form: res.data.data });
-                        console.log(res.data.data);
-                        console.log(res.data.data.id);
+                        console.log(res);
+                        that.setData({ form: res.data.data })
                     },
                     },
                     error: err => {
                     error: err => {
                         console.log(err);
                         console.log(err);
                     }
                     }
                 })
                 })
+            },
+            fail: res => {
+                wx.redirectTo({ url: '/pages/login/index', })
             }
             }
         })
         })
     },
     },
     //提交
     //提交
     formSubmit: function (e) {
     formSubmit: function (e) {
-        let value = e.detail.value;
-        console.log(value);
-        wx.getStorage({
-            key: 'token',
-            success: function (res) {
-                console.log(res);
-                wx.request({
-                    url: `${app.globalData.publicUrl}/courtAdmin/api/user`, //接口地址
-                    method: "post",
-                    data: value,
-                    header: {},
-                    success: res => {
-                        wx.showToast({
-                            title: '保存成功',
-                            icon: 'success',
-                            duration: 2000
-                        })
-                        console.log(res);
-                    },
-                })
-            }
-        })
+        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 {
+            let value = e.detail.value;
+            wx.getStorage({
+                key: 'token',
+                success: function (res) {
+                    wx.request({
+                        url: `${app.globalData.publicUrl}/courtAdmin/api/user/${res.data.id}`, //接口地址
+                        method: "post",
+                        data: value,
+                        header: {},
+                        success: res => {
+                            if (res.data.errcode == 0) {
+                                wx.showToast({
+                                    title: '保存成功',
+                                    icon: 'success',
+                                    duration: 2000//延迟两秒
+                                })
+                            } else {
+                                wx.showToast({
+                                    title: '保存失败',
+                                    icon: 'success',
+                                    duration: 2000
+                                })
+                            }
+                        },
+                    })
+                }
+            })
+        }
     },
     },
     // 计算高度
     // 计算高度
     searchHeight: function () {
     searchHeight: function () {

+ 76 - 27
pages/me/index.js

@@ -22,28 +22,24 @@ Page({
         state: '已结束', date: '01.15', start: '未开始'
         state: '已结束', date: '01.15', start: '未开始'
       }
       }
     ],
     ],
-    list: [
-      {
-        id: '1', name: '张爽', company: '福瑞科技有限公司', gender: '女', src: '/image/tou.png', address: '马利克克海拉队', team: '队员',
-      },
-    ],
+    list: [{ src: '/image/tou.png', },],
+    item1: {},
     list3: [
     list3: [
-      {
-        id: '1', head: '/image/head1.png', group: '哈拉海队', time: '08:30', ball: '足球', grade: 'c', date: '2022.01.15', person: '10',
-      },
-      {
-        id: '2', head: '/image/head1.png', group: '尼奥尔队', time: '08:30', ball: '篮球', date: '2022.01.15', person: '9',
-      },
-      {
-        id: '1', head: '/image/head1.png', group: '哈拉海队', time: '08:30', ball: '足球', grade: 'c', date: '2022.01.15', person: '10',
-      },
-      {
-        id: '1', head: '/image/head1.png', group: '哈拉海队', time: '08:30', ball: '足球', grade: 'c', date: '2022.01.15', person: '10',
-      },
+      // {
+      //   id: '1', head: '/image/head1.png', name: '哈拉海队', time: '08:30', ball: '足球', grade: 'c', date: '2022.01.15', person: '10',
+      // },
+      // {
+      //   id: '2', head: '/image/head1.png', name: '尼奥尔队', time: '08:30', ball: '篮球', date: '2022.01.15', person: '9',
+      // },
+      // {
+      //   id: '1', head: '/image/head1.png', name: '哈拉海队', time: '08:30', ball: '足球', grade: 'c', date: '2022.01.15', person: '10',
+      // },
+      // {
+      //   id: '1', head: '/image/head1.png', name: '哈拉海队', time: '08:30', ball: '足球', grade: 'c', date: '2022.01.15', person: '10',
+      // },
     ],
     ],
+    item2: {},
     showModal: false,
     showModal: false,
-    
-
   },
   },
   tabPath(e) {
   tabPath(e) {
     let query = e.detail.detail;
     let query = e.detail.detail;
@@ -73,7 +69,7 @@ Page({
       url: `/pages/createTeam/index`,
       url: `/pages/createTeam/index`,
     })
     })
   },
   },
-  ToDetails:function () {
+  ToDetails: function () {
     wx.navigateTo({
     wx.navigateTo({
       url: `/pages/teamDetails/detail`,
       url: `/pages/teamDetails/detail`,
     })
     })
@@ -96,12 +92,12 @@ Page({
       url: `/pages/auditTeam/index`,
       url: `/pages/auditTeam/index`,
     })
     })
   },
   },
-//解散申请
-apply: function () {
-  wx.navigateTo({
-    url: `/pages/dissolution/index`,
-  })
-},
+  //解散申请
+  apply: function () {
+    wx.navigateTo({
+      url: `/pages/dissolution/index`,
+    })
+  },
   //解散团队弹窗
   //解散团队弹窗
   clickme: function () {
   clickme: function () {
     this.setData({
     this.setData({
@@ -116,13 +112,66 @@ apply: function () {
       showModal: false
       showModal: false
     })
     })
   },
   },
-
   /**
   /**
    * 生命周期函数--监听页面加载
    * 生命周期函数--监听页面加载
    */
    */
   onLoad: function (options) {
   onLoad: function (options) {
     // 计算高度
     // 计算高度
     this.searchHeight()
     this.searchHeight()
+    // 监听用户是否登录
+    this.watchLogin();
+    const that = this;
+    wx.getStorage({
+      key: 'token',
+      success: res => {
+        //数据请求
+        wx.request({
+          url: `${app.globalData.publicUrl}/courtAdmin/api/team`, //接口地址
+          method: "get",//请求方法
+          data: {},//请求参数
+          header: {},
+          success: res => {
+            console.log(res);
+            that.setData({ list3: res.data.data })
+            console.log(res.data.data);
+          },
+          error: err => {
+            console.log(err);
+          }
+        })
+      },
+      fail: res => {
+        wx.redirectTo({ url: '/pages/login/index', })
+      }
+    })
+
+  },
+  // 监听用户是否登录
+  watchLogin: function () {
+    const that = this;
+    wx.getStorage({
+      key: 'token',
+      success: res => {
+        //数据请求
+        wx.request({
+          url: `${app.globalData.publicUrl}/courtAdmin/api/user/${res.data.id}`, //接口地址
+          method: "get",//请求方法
+          data: {},//请求参数
+          header: {},
+          success: res => {
+            console.log(res);
+            that.setData({ item1: res.data.data })
+            console.log(res.data.data);
+          },
+          error: err => {
+            console.log(err);
+          }
+        })
+      },
+      fail: res => {
+        wx.redirectTo({ url: '/pages/login/index', })
+      }
+    })
   },
   },
   // 计算高度
   // 计算高度
   searchHeight: function () {
   searchHeight: function () {

+ 17 - 15
pages/me/index.wxml

@@ -5,15 +5,15 @@
       <image src="{{src}}" class="images"></image>
       <image src="{{src}}" class="images"></image>
     </view>
     </view>
     <view class="two">
     <view class="two">
-      <view class="list" wx:key="item" wx:for="{{list}}">
+      <view class="list" wx:key="index" wx:for="{{list}}">
         <view class="left1">
         <view class="left1">
           <view class="left1-1">
           <view class="left1-1">
-            <view class="name">{{item.name}}</view>
-            <button class="button" size="mini">{{item.team}}</button>
+            <view class="name">{{item1.nickname}}</view>
+            <button class="button" size="mini">{{item1.status=='0'?'管理员':item1.status=='1'?'团队创建人':'队员'}}</button>
           </view>
           </view>
           <view class="left11-2">
           <view class="left11-2">
-            <text class="text1">{{item.company}}</text>
-            <text class="text1">{{item.gender}}</text>
+            <text class="text1">{{item1.mechanism}}</text>
+            <text class="text1">{{item1.gender}}</text>
           </view>
           </view>
         </view>
         </view>
         <view class="right1">
         <view class="right1">
@@ -24,7 +24,9 @@
             <text class=" icon iconfont icon-qi"></text>
             <text class=" icon iconfont icon-qi"></text>
           </view>
           </view>
           <view class="qian" bindtap="modify">
           <view class="qian" bindtap="modify">
-            <text class="text3">{{item.address}}</text>
+            <text class="text3" wx:if="{{item1.status=='2'||item1.status=='3'}}">{{item1.name}}</text>
+          </view>
+          <view class="icon_arrow" bindtap="modify">
             <van-icon name="arrow" color="rgb(177, 177, 177)" />
             <van-icon name="arrow" color="rgb(177, 177, 177)" />
           </view>
           </view>
         </view>
         </view>
@@ -83,7 +85,7 @@
       <view class="listtuan" wx:if="{{total!=''}}">
       <view class="listtuan" wx:if="{{total!=''}}">
         <view class="otherInfo">
         <view class="otherInfo">
           <text class="tuan">我的团队</text>
           <text class="tuan">我的团队</text>
-          <text class="total">共参加{{total}}个队伍</text>
+          <text class="total">共参加{{list3.length||0}}个队伍</text>
           <text class="chuang" bindtap="create">创建团队</text>
           <text class="chuang" bindtap="create">创建团队</text>
         </view>
         </view>
         <view class="weui-cells mgt-0 {{!showMore? 'hiddenmore' : 'showmore'}}">
         <view class="weui-cells mgt-0 {{!showMore? 'hiddenmore' : 'showmore'}}">
@@ -93,19 +95,19 @@
                 <image src="{{item.head}}" class="dui-image"></image>
                 <image src="{{item.head}}" class="dui-image"></image>
               </view>
               </view>
               <view class="dui-right1">
               <view class="dui-right1">
-                <text class="group">{{item.group}}</text>
+                <text class="group">{{item.name}}</text>
               </view>
               </view>
-              <button class="ball" size="mini" wx:if="{{item.ball=='足球'}}" style="background-color:rgb(63, 127, 245);">{{item.ball}}</button>
-              <button class="ball" size="mini" wx:if="{{item.ball=='篮球'}}" style="background-color:rgb(245, 172, 63);">{{item.ball}}</button>
-              <!-- <text class=" icon iconfont icon-C1" wx:if="{{item.grade}}"></text> -->
-              <button class="grade" size="mini">{{item.grade}}</button>
+              <button class="ball" size="mini" wx:if="{{item.type=='0'}}" style="background-color:rgb(63, 127, 245);">乒乓球</button>
+              <button class="ball" size="mini" wx:if="{{item.type=='1'}}" style="background-color:rgb(245, 172, 63);">足球</button>
+              <button class="ball" size="mini" wx:if="{{item.type=='2'}}" style="background-color:rgb(241, 95, 127);">篮球</button>
+              <!-- <text class=" icon iconfont icon-C1" wx:if="{{item.grade}}"></text>
+              <button class="grade" size="mini">c</button> -->
             </view>
             </view>
             <view class="dui-right"><text class="person">
             <view class="dui-right"><text class="person">
-                共{{item.person}}人
+                共{{item.menber.length||0}}人
               </text>
               </text>
             </view>
             </view>
-            <text class="date">{{item.date}}</text>
-            <text class="date">{{item.time}}创建</text>
+            <text class="date">{{item.create_time}}创建</text>
           </view>
           </view>
           <block wx:if="{{list3.length>2}}">
           <block wx:if="{{list3.length>2}}">
             <view wx:if="{{showMore}}" class="van" bindtap='listToggle'>
             <view wx:if="{{showMore}}" class="van" bindtap='listToggle'>

+ 9 - 1
pages/me/index.wxss

@@ -8,7 +8,15 @@
   float: left;
   float: left;
   width: 3%;
   width: 3%;
 }
 }
+.qian{
+  float: left;
+  width: 80%;
+}
+.icon_arrow{
+  float: right;
+  width: 6%;
 
 
+}
 .theme {
 .theme {
   position: fixed;
   position: fixed;
   margin-top: 5.5%;
   margin-top: 5.5%;
@@ -501,7 +509,7 @@
   position: fixed;
   position: fixed;
   left: 0;
   left: 0;
   z-index: 9999;
   z-index: 9999;
-  margin: -450px 85px;
+  margin: -450px 85px 0 85px;
   background-color: #fff;
   background-color: #fff;
   border-radius: 36rpx;
   border-radius: 36rpx;
   display: flex;
   display: flex;