YY 3 rokov pred
rodič
commit
908160ea54
2 zmenil súbory, kde vykonal 67 pridanie a 76 odobranie
  1. 57 68
      pages/information/index.js
  2. 10 8
      pages/information/index.wxml

+ 57 - 68
pages/information/index.js

@@ -10,65 +10,11 @@ Page({
         // 主体高度
         infoHeight: '',
         frameStyle: { useTop: true, name: '个人信息', leftArrow: true, useBar: false },
-        form: {
-            ranks: '比赛第一名队',
-            mechanism: '吉佳通达',
-            sex: ['男', '女'],
-            objectSex: [{ id: 0, name: '男' }, { id: 1, name: '女' },],
-            post: '后勤部长',
-            phone: '12311111111',
-            email: '123@qq.com',
-        },
-        index: 0,
+        form: {},
+        // 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;
@@ -92,26 +38,69 @@ Page({
             },
         });
     },
-    //选择
-    bindPickerChange: function (e) {
-        console.log('picker发送选择改变,携带值为', e.detail.value)
-        this.setData({
-            index: e.detail.value
-        })
-    },
+    // //选择
+    // bindPickerChange: function (e) {
+    //     console.log('picker发送选择改变,携带值为', e.detail.value)
+    //     this.setData({
+    //         index: e.detail.value
+    //     })
+    // },
     back: function () {
         wx.navigateBack({ url: '/pages/me/index' })
     },
-    //提交
-    formSubmit: function (e) {
-        console.log('form发生了submit事件,携带数据为:', e.detail.value)
-    },
+
     /**
      * 生命周期函数--监听页面加载
      */
-    onLoad: function (options) {
+    onLoad: function (e) {
         // 计算高度
         this.searchHeight()
+        const that = this;
+        // 获取用户信息
+        wx.getStorage({
+            key: 'token',
+            success: function (res) {
+                wx.request({
+                    url: `${app.globalData.publicUrl}/courtAdmin/api/user`, //接口地址
+                    method: "post",
+                    data: { "id": "", "phone": "", "type": "", "status": "" },
+                    header: {},
+                    success: res => {
+                        that.setData({ form: res.data.data });
+                        console.log(res.data.data);
+                        console.log(res.data.data.id);
+                    },
+                    error: err => {
+                        console.log(err);
+                    }
+                })
+            }
+        })
+    },
+    //提交
+    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);
+                    },
+                })
+            }
+        })
     },
     // 计算高度
     searchHeight: function () {

+ 10 - 8
pages/information/index.wxml

@@ -8,29 +8,31 @@
                 </view>
                 <view class="one">
                     <view class="text">昵称</view>
-                    <input class="input" name="ranks" value="{{form.ranks}}" placeholder="" />
+                    <input class="input" name="nickname" value="{{form.nickname}}" placeholder="请输入昵称" />
                 </view>
                 <view class="one">
                     <view class="text">机构</view>
-                    <input class="input" name="mechanism" value="{{form.mechanism}}" placeholder="" />
+                    <input class="input" name="mechanism" value="{{form.mechanism}}" placeholder="请输入机构" />
                 </view>
                 <view class="one">
                     <view class="text">性别</view>
-                    <picker name="sex" bindchange="bindPickerChange" value="{{index}}" range="{{form.sex}}">
-                        <view class="input">{{form.sex[index]}}</view>
-                    </picker>
+
+                    <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>
+                    </picker> -->
                 </view>
                 <view class="one">
                     <view class="text">岗位</view>
-                    <input class="input" name="post" value="{{form.post}}" placeholder="" />
+                    <input class="input" name="work" value="{{form.work}}" placeholder="请输入岗位" />
                 </view>
                 <view class="one">
                     <view class="text">手机号</view>
-                    <input class="input" name="phone" value="{{form.phone}}" placeholder="" />
+                    <input class="input" name="phone" value="{{form.phone}}" placeholder="请输入手机号" />
                 </view>
                 <view class="one">
                     <view class="text">邮箱</view>
-                    <input class="input" name="email" value="{{form.email}}" placeholder="" />
+                    <input class="input" name="email" value="{{form.email}}" placeholder="请输入邮箱" />
                 </view>
             </view>
             <view class="btn-area">