Browse Source

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

zs 3 năm trước cách đây
mục cha
commit
4dea2ad612

+ 76 - 34
pages/createTeam/index.js

@@ -1,6 +1,7 @@
 // pages/login/login.js
 import WxValidate from '../../utils/wxValidate'
 const app = getApp()
+
 Page({
 
     /**
@@ -11,37 +12,14 @@ Page({
         infoHeight: '',
         frameStyle: { useTop: true, name: '创建团队', leftArrow: true, useBar: false },
         form: {
-            src: '/image/tou.png',
-            ranks: '比赛第一名队',
-            mechanism: '吉佳通达',
-            type: ['乒乓球', '足球'],
-            objectSex: [{ id: 0, name: '乒乓球' }, { id: 1, name: '足球' },],
-
+            type: ['乒乓球', '足球', '篮球'],
+            objectType: [{ id: 0, name: '乒乓球' }, { id: 1, name: '足球' }, { id: 2, name: '篮球' },],
         },
-        lists: [
-            {
-                id: '1', text: '哈拉海队', logo: '/image/logo1.png', jian: '/image/jian.png '
-            },
-            {
-                id: '1', text: '哈拉海队', logo: '/image/logo1.png', jian: '/image/jian.png '
-            },
-            {
-                id: '1', text: '哈拉海队', logo: '/image/logo1.png', jian: '/image/jian.png '
-            },
-            {
-                id: '1', text: '哈拉海队', logo: '/image/logo1.png', jian: '/image/jian.png '
-            },
-            {
-                id: '1', text: '哈拉海队', logo: '/image/logo1.png', jian: '/image/jian.png '
-            },
-            {
-                id: '1', text: '哈拉海队', logo: '/image/logo1.png', jian: '/image/jian.png '
-            },
-            {
-                id: '1', text: '哈拉海队', logo: '/image/logo1.png', jian: '/image/jian.png '
-            },
-        ],
+        lists: [{ id: '1', menbers: '' }],
+        menbers:[],
         index: 0,
+        // 上传图片
+        fileList: [],
     },
     //选择
     bindPickerChange: function (e) {
@@ -56,7 +34,7 @@ Page({
     //点击加号添加
     addList: function () {
         var lists = this.data.lists;
-        var newData = {};
+        var newData = [];
         lists.push(newData);//实质是添加lists数组内容,使for循环多一次
         this.setData({
             lists: lists,
@@ -72,7 +50,46 @@ Page({
     },
     //提交
     formSubmit: function (e) {
-        console.log('form发生了submit事件,携带数据为:', e.detail.value)
+        const value = e.detail.value;
+        const that = this;
+        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 => {
+                            // var menbers = JSON.parse(res.data.menbers)
+                            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);
+                        }
+                    })
+                }
+            })
+        }
     },
     //上传图片
     afterRead: function (event) {
@@ -88,9 +105,9 @@ Page({
                 console.log(res);
                 if (res.statusCode == '200') {
                     let data = [{ name: JSON.parse(res.data).name, url: `${app.globalData.imageUrl}` + JSON.parse(res.data).uri }]
-                    const { fileList = [] } = this.data;
-                    fileList.push({ ...file, url: res.data });
-                    this.setData({ fileList });
+                    // const { fileList = [] } = this.data;
+                    // fileList.push({ ...file, url: res.data });
+                    that.setData({ fileList: data });
                 } else {
                     wx.showToast({ title: `${res.data.errmsg}`, icon: 'fail', duration: 2000 })
                 }
@@ -98,12 +115,37 @@ Page({
         });
     },
 
+    //验证必填项
+    initValidate() {
+        const rules = { name: { required: true }, type: { required: true }, create_user: { required: true }, }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { name: { required: '请输入团队名称' }, type: { required: '请输入团队类型' }, create_user: { required: '请输入团队创建人名称' }, };
+        this.WxValidate = new WxValidate(rules, messages)
+    },
     /**
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
         // 计算高度
         this.searchHeight()
+        // 监听用户是否登录
+        this.watchLogin();
+        //验证规则函数
+        this.initValidate()
+
+    },
+    // 监听用户是否登录
+    watchLogin: function () {
+        const that = this;
+        wx.getStorage({
+            key: 'token',
+            success: res => {
+                //数据请求
+            },
+            fail: res => {
+                wx.redirectTo({ url: '/pages/login/index', })
+            }
+        })
     },
     // 计算高度
     searchHeight: function () {

+ 8 - 6
pages/createTeam/index.wxml

@@ -9,15 +9,15 @@
                     </view>
                     <view class="one">
                         <view class="text">团队名称</view>
-                        <input class="input" name="ranks" value="{{form.ranks}}" placeholder="" />
+                        <input class="input" name="name" value="{{form.name}}" placeholder="" />
                     </view>
                     <view class="one">
                         <view class="text">团队创建人</view>
-                        <input class="input" name="mechanism" value="{{form.mechanism}}" placeholder="" />
+                        <input class="input" name="create_user" value="{{form.create_user}}" placeholder="" />
                     </view>
                     <view class="one">
                         <view class="text">团队类型</view>
-                        <picker name="sex" bindchange="bindPickerChange" value="{{index}}" range="{{form.type}}">
+                        <picker name="type" bindchange="bindPickerChange" value="{{index}}" range="{{form.type}}">
                             <view class="input">{{form.type[index]}}
                                 <image class="back" src="/image/back.png"></image>
                             </view>
@@ -30,10 +30,12 @@
                         <view class="two_main">
                             <view class="two_1" wx:key="item" wx:for="{{lists}}">
                                 <view class="team_1">
-                                    <image class="two_logo1" src="{{item.logo}}"></image>
-                                    <image bindtap='delList' class="two_jian" src="{{item.jian}}"></image>
+                                    <image class="two_logo1" src="/image/logo1.png"></image>
+                                    <image bindtap='delList' class="two_jian" src="/image/jian.png"></image>
+                                </view>
+                                <view class="team_text">
+                                    <input class="input1" bindinput="toMenbers" name="menbers" value="{{menbers}}" placeholder="队员名称" />
                                 </view>
-                                <view class="team_text">{{item.text}}</view>
                             </view>
                             <view class="two_1">
                                 <view class="team_1">

+ 0 - 1
pages/createTeam/index.wxss

@@ -85,7 +85,6 @@
 .bottom {
   background-color: #ffffff;
 }
-
 .two_title {
   font-size: 16px;
   padding: 20px 0 0 20px;

+ 10 - 7
pages/information/index.js

@@ -18,6 +18,7 @@ Page({
 
     afterRead: function (event) {
         const { file } = event.detail;
+        const that = this;
         // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式app.globalData.fileUrl:
         console.log(file);
         wx.uploadFile({
@@ -26,12 +27,12 @@ Page({
             name: 'file',
             formData: {},
             success: (res) => {
-                console.log(res);
+                // console.log(res);
                 if (res.statusCode == '200') {
                     let data = [{ name: JSON.parse(res.data).name, url: `${app.globalData.imageUrl}` + JSON.parse(res.data).uri }]
-                    const { fileList = [] } = this.data;
-                    fileList.push({ ...file, url: res.data });
-                    this.setData({ fileList });
+                    // const { fileList = [] } = this.data;
+                    // fileList.push({ ...file, url: res.data });
+                    that.setData({ fileList: data });
                 } else {
                     wx.showToast({ title: `${res.data.errmsg}`, icon: 'fail', duration: 2000 })
                 }
@@ -60,11 +61,11 @@ Page({
      */
     onLoad: function (options) {
         // 计算高度
-        this.searchHeight()
+        this.searchHeight();
         // 监听用户是否登录
         this.watchLogin();
         //验证规则函数
-        this.initValidate()
+        this.initValidate();
 
     },
     // 监听用户是否登录
@@ -82,6 +83,8 @@ Page({
                     success: res => {
                         console.log(res);
                         that.setData({ form: res.data.data })
+                        let icon = res.data.data.icon;
+                        this.setData({ fileList: icon })
                     },
                     error: err => {
                         console.log(err);
@@ -101,7 +104,7 @@ Page({
             wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
             return false
         } else {
-            let value = e.detail.value;
+            value.icon = this.data.fileList;
             wx.getStorage({
                 key: 'token',
                 success: function (res) {

+ 0 - 1
pages/information/index.wxml

@@ -16,7 +16,6 @@
                 </view>
                 <view class="one">
                     <view class="text">性别</view>
-
                     <input class="input" name="gender" value="{{form.gender}}" placeholder="请输入性别" />
                     <!-- <picker name="gender" bindchange="bindPickerChange" value="{{index}}" range="{{form.sex}}">
                         <view class="input">{{form.gender[index]}}</view>

+ 12 - 18
pages/me/index.js

@@ -22,23 +22,12 @@ Page({
         state: '已结束', date: '01.15', start: '未开始'
       }
     ],
-    list: [{ src: '/image/tou.png', },],
+    // list: [{ src: '/image/tou.png', },],
     item1: {},
-    list3: [
-      // {
-      //   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: {},
+    list3: [],
+    //头像
+    icon: '',
+    //团队logo
     showModal: false,
   },
   tabPath(e) {
@@ -120,6 +109,7 @@ Page({
     this.searchHeight()
     // 监听用户是否登录
     this.watchLogin();
+
     const that = this;
     wx.getStorage({
       key: 'token',
@@ -131,9 +121,10 @@ Page({
           data: {},//请求参数
           header: {},
           success: res => {
-            console.log(res);
+            // console.log(res);
             that.setData({ list3: res.data.data })
             console.log(res.data.data);
+
           },
           error: err => {
             console.log(err);
@@ -159,8 +150,11 @@ Page({
           data: {},//请求参数
           header: {},
           success: res => {
-            console.log(res);
+            // console.log(res);
             that.setData({ item1: res.data.data })
+            let icon = res.data.data.icon[0];
+            if (icon) this.setData({ icon: icon.url })
+            else this.setData({ icon: '/image/tou.png' })
             console.log(res.data.data);
           },
           error: err => {

+ 4 - 4
pages/me/index.wxml

@@ -5,7 +5,7 @@
       <image src="{{src}}" class="images"></image>
     </view>
     <view class="two">
-      <view class="list" wx:key="index" wx:for="{{list}}">
+      <view class="list">
         <view class="left1">
           <view class="left1-1">
             <view class="name">{{item1.nickname}}</view>
@@ -17,13 +17,13 @@
           </view>
         </view>
         <view class="right1">
-          <image src="{{item.src}}" class="tou"></image>
+          <image src="{{icon}}" class="tou"></image>
         </view>
         <view class="otherInfo textOver">
           <view class="biao">
             <text class=" icon iconfont icon-qi"></text>
           </view>
-          <view class="qian" bindtap="modify">
+          <view class="qian">
             <text class="text3" wx:if="{{item1.status=='2'||item1.status=='3'}}">{{item1.name}}</text>
           </view>
           <view class="icon_arrow" bindtap="modify">
@@ -92,7 +92,7 @@
           <view wx:key="item" wx:for="{{list3}}" wx:for-index="idx" wx:key="key" bindtap="ToDetails" class="list3 {{idx>1 ? 'more-item' : ''}}">
             <view class="dui-left">
               <view class="dui-left1">
-                <image src="{{item.head}}" class="dui-image"></image>
+                <image src="/image/head1.png" class="dui-image"></image>
               </view>
               <view class="dui-right1">
                 <text class="group">{{item.name}}</text>