YY 3 سال پیش
والد
کامیت
68d84c2a29

+ 3 - 2
app.json

@@ -1,7 +1,8 @@
 {
   "pages": [
-    "pages/login/index",
-    "pages/home/index",
+
+    "pages/home/index",  
+      "pages/login/index",
     "pages/search/index",
     "pages/administration/index",
     "pages/administration/detail",

+ 32 - 8
pages/createTeam/index.js

@@ -54,26 +54,50 @@ Page({
         wx.navigateBack({ url: '/pages/me/index' })
     },
     //点击加号添加
-    addList: function(){
-        var  lists = this.data.lists;
+    addList: function () {
+        var lists = this.data.lists;
         var newData = {};
         lists.push(newData);//实质是添加lists数组内容,使for循环多一次
         this.setData({
-          lists: lists,
-        })  
-      },
-       //点击减号删除
+            lists: lists,
+        })
+    },
+    //点击减号删除
     delList: function () {
         var lists = this.data.lists;
         lists.pop();      //实质是删除lists数组内容,使for循环少一次
         this.setData({
-          lists: lists,
+            lists: lists,
         })
-      }, 
+    },
     //提交
     formSubmit: function (e) {
         console.log('form发生了submit事件,携带数据为:', e.detail.value)
     },
+    //上传图片
+    afterRead: function (event) {
+        const { file } = event.detail;
+        // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式app.globalData.fileUrl:
+        console.log(file);
+        wx.uploadFile({
+            url: `${app.globalData.imageUrl}/files/court/elimg/upload`,
+            filePath: file.url,
+            name: 'file',
+            formData: {},
+            success: (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 });
+                } else {
+                    wx.showToast({ title: `${res.data.errmsg}`, icon: 'fail', duration: 2000 })
+                }
+            },
+        });
+    },
+
     /**
      * 生命周期函数--监听页面加载
      */

+ 1 - 1
pages/createTeam/index.wxml

@@ -5,7 +5,7 @@
                 <view class="top">
                     <view class="zero">
                         <view class="text">团队LOGO</view>
-                        <image src="{{form.src}}" class="tou"></image>
+                        <van-uploader class="tou" file-list="{{fileList}}" preview-image="true" max-count="1" bind:after-read="afterRead" />
                     </view>
                     <view class="one">
                         <view class="text">团队名称</view>

+ 36 - 3
pages/createTeam/index.wxss

@@ -9,14 +9,14 @@
   padding: 0 0 10px 0;
   margin: 0 0 20px 0;
   background-color: #ffffff;
-  height: 200px;
+  height: 225px;
 }
 
 .zero {
   border-bottom: 1px solid #dddddd;
   padding: 20px 0 0 0;
   margin: 0 20px;
-  height: 50px;
+  height: 80px;
 }
 
 .one {
@@ -25,6 +25,13 @@
   height: 40px;
 }
 
+.zero .text {
+  position: relative;
+  top: 10px;
+  width: 40%;
+  font-size: 14px;
+}
+
 .text {
   position: relative;
   top: 10px;
@@ -36,7 +43,7 @@
   width: 50px;
   height: 50px;
   position: relative;
-  left: 280px;
+  left: 255px;
   top: -30px;
 }
 
@@ -55,6 +62,32 @@
   width: 60%;
   font-size: 16px;
 }
+.van-uploader__upload {
+  border-radius: 50%;
+  align-items: center;
+  background-color: var(--uploader-upload-background-color,#f7f8fa);
+  box-sizing: border-box;
+  display: flex;
+  flex-direction: column;
+  height: var(--uploader-size,50px);
+  justify-content: center;
+  margin: 0 8px 8px 0;
+  position: relative;
+  width: var(--uploader-size,50px);
+}
+.van-uploader__preview {
+  border-radius: 50%;
+  cursor: pointer;
+  margin: 0 8px 8px 0;
+  position: relative;
+}
+.van-uploader__preview-image {
+  border-radius: 50%;
+  display: block;
+  height: var(--uploader-size,50px);
+  overflow: hidden;
+  width: var(--uploader-size,50px);
+}
 
 .bottom {
   background-color: #ffffff;

+ 71 - 2
pages/information/index.js

@@ -11,17 +11,86 @@ Page({
         infoHeight: '',
         frameStyle: { useTop: true, name: '个人信息', leftArrow: true, useBar: false },
         form: {
-            src: '/image/tou.png',
             ranks: '比赛第一名队',
             mechanism: '吉佳通达',
             sex: ['男', '女'],
             objectSex: [{ id: 0, name: '男' }, { id: 1, name: '女' },],
-
             post: '后勤部长',
             phone: '12311111111',
             email: '123@qq.com',
         },
         index: 0,
+        // 上传图片
+        fileList: [],
+    },
+    //上传头像,更改头像
+    // changeSrc: function (event) {
+    //     var that = this;
+    //     wx.chooseImage({
+    //         count: 1,//最多可以选择的图片数量,默认9
+    //         sizeType: ['compressed', 'original'],
+    //         sourceType: ['album', 'camera'],
+    //         success: function (res) {
+    //             console.log(res.tempFilePaths + "修改页面")
+    //             var src = res.tempFilePaths;
+    //             that.setData({
+    //                 src: src,
+    //                 upSrc: true,
+
+    //             })
+    //             const { file } = event.detail;
+    //             console.log(file);
+    //             wx.uploadFile({
+    //                 url: `${app.globalData.imageUrl}/files/court/elimg/upload`,
+    //                 filePath: file.url,
+    //                 name: 'file',
+    //                 formData: {},
+    //                 success: (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 = [] } = that.data;
+    //                         fileList.push({ ...file, url: res.data });
+    //                         that.setData({ fileList });
+    //                     } else {
+    //                         wx.showToast({ title: `${res.data.errmsg}`, icon: 'fail', duration: 2000 })
+    //                     }
+    //                 },
+    //             });
+
+
+    //         }
+    //     })
+
+    // },
+    // 上传图片
+
+
+
+    //上传图片
+
+
+    afterRead: function (event) {
+        const { file } = event.detail;
+        // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式app.globalData.fileUrl:
+        console.log(file);
+        wx.uploadFile({
+            url: `${app.globalData.imageUrl}/files/court/elimg/upload`,
+            filePath: file.url,
+            name: 'file',
+            formData: {},
+            success: (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 });
+                } else {
+                    wx.showToast({ title: `${res.data.errmsg}`, icon: 'fail', duration: 2000 })
+                }
+            },
+        });
     },
     //选择
     bindPickerChange: function (e) {

+ 1 - 1
pages/information/index.wxml

@@ -4,7 +4,7 @@
             <view class="form" style="height:{{infoHeight-140}}px;">
                 <view class="zero">
                     <view class="text">头像</view>
-                    <image src="{{form.src}}" class="tou"></image>
+                    <van-uploader class="tou" file-list="{{fileList}}" preview-image="true" max-count="1" bind:after-read="afterRead" />
                 </view>
                 <view class="one">
                     <view class="text">昵称</view>

+ 35 - 2
pages/information/index.wxss

@@ -8,7 +8,7 @@
 .zero{
   border-bottom: 1px solid #dddddd;
   margin: 0 20px;
-  height: 50px;
+  height: 80px;
 }
 .one {
   border-bottom: 1px solid #dddddd;
@@ -16,6 +16,39 @@
   height: 40px;
 }
 
+.van-uploader__upload {
+  border-radius: 50%;
+  align-items: center;
+  background-color: var(--uploader-upload-background-color,#f7f8fa);
+  box-sizing: border-box;
+  display: flex;
+  flex-direction: column;
+  height: var(--uploader-size,50px);
+  justify-content: center;
+  margin: 0 8px 8px 0;
+  position: relative;
+  width: var(--uploader-size,50px);
+}
+.van-uploader__preview {
+  border-radius: 50%;
+  cursor: pointer;
+  margin: 0 8px 8px 0;
+  position: relative;
+}
+.van-uploader__preview-image {
+  border-radius: 50%;
+  display: block;
+  height: var(--uploader-size,50px);
+  overflow: hidden;
+  width: var(--uploader-size,50px);
+}
+
+.zero .text {
+  position: relative;
+  top: 30px;
+  width: 40%;
+}
+
 .text {
   position: relative;
   top: 10px;
@@ -25,7 +58,7 @@
   width: 50px;
   height: 50px;
   position: relative;
-  left: 280px;
+  left: 255px;
   top: -30px;
 }
 

+ 3 - 0
pages/teamDetails/detail.js

@@ -47,10 +47,13 @@ Page({
         id: '1',name:'老头9',head:'/image/tou.png'
       },
     ],
+    fileList: [],
   },
   back: function () {
     wx.navigateBack({ url: '/pages/home/index' })
   },
+
+
   /**
    * 生命周期函数--监听页面加载
    */

+ 1 - 0
pages/teamDetails/detail.wxml

@@ -3,6 +3,7 @@
     <view class="one">
       <view class="one-1">
         <view class="onea">
+         
           <cover-image src='/image/back.png' class="back" bindtap='back'></cover-image>
         </view>
         <view class="ones">