Browse Source

修改bug,增加学生端修改头像功能

wangjinbiao 5 years ago
parent
commit
0fe16db08e

+ 1 - 1
dorm-manager-wx/pages/student/facephoto/facephoto.js

@@ -53,7 +53,7 @@ Page({
       title: '正在上传',
     })
     wx.uploadFile({
-      url: 'http://dgt.dgtis.com/oneportal/userinfo/updateUserHeadImage.if',
+      url: api.updateUserHeadImage.if,
       filePath: file[0],
       header: { 'content-type': 'application/x-www-form-urlencoded;charset=utf-8', },
       name: 'file',

+ 33 - 0
dorm-manager-wx/pages/user/index.js

@@ -1,3 +1,4 @@
+const api = require('../../utils/api.js');
 const app = getApp(),
   {
     globalData: {
@@ -104,6 +105,38 @@ Page({
       url: e.currentTarget.dataset.url,
     })
   },
+  updateimage:function(){
+    let that=this
+    wx.chooseImage({
+      count:1,
+      success: function(res) {
+        wx.showLoading({
+          title: '正在上传',
+        })
+        wx.uploadFile({
+          url: api.updateimage,
+          filePath: res.tempFilePaths[0],
+          header: { 'content-type': 'application/x-www-form-urlencoded;charset=utf-8', },
+          name: 'file',
+          formData: {
+            'fileType': 'image',
+            'loginId': wx.getStorageSync('loginId')
+          },
+          success(res) {
+            wx.hideLoading()
+            console.log(res)
+            if (JSON.parse(res.data.data).status == true) {
+              wx.getStorageSync('userInfo').avatarUrl = api.total + JSON.parse(res.data.data).headImage
+              wx.showToast({
+                title: '修改成功',
+                icon:'none'
+              })
+            }
+          }
+        })
+      },
+    })
+  },
   goLogin,
   // navigate_auth_native
 })

+ 2 - 2
dorm-manager-wx/pages/user/index.wxml

@@ -3,11 +3,11 @@
     <image src='../../images/bg.png'></image>
   </view>
   <view class='heardimg'>
-    <image wx:if="{{photo}}" class='heard-img' src='{{photo}}'></image>
+    <image wx:if="{{photo}}" bindtap="updateimage" class='heard-img' src='{{photo}}'></image>
     <image wx:else catchtap='goLogin' class='heard-img' src='/images/no_login.png'></image>
   </view>
   <!-- 未登陆状态下同样显示未实名(领导说) - -! -->
-  <view class='nickName'>{{viewName||'未实名'}}</view>
+  <view class='nickName'>{{viewName||'未授权'}}</view>
   <view class='top-nav'>
     <view wx:for="{{topList}}" catchtap='navigate_auth_native' data-url='{{item.url}}'>
       <image src='../../images/{{item.icon}}.png'></image>

+ 1 - 1
dorm-manager-wx/pages/user/setting/index.wxss

@@ -12,7 +12,7 @@ page{
   width: 240rpx;
   height: 68rpx;
   border-radius:70rpx;
-background:#33ad37;
+background:#6282f4;
 margin: 20px auto;
 font-size:30rpx;
 color: white;

+ 2 - 0
dorm-manager-wx/utils/api.js

@@ -92,6 +92,8 @@ const index = 2,
     selfInfo: 'access/selfInfo.if', //访客统计
     editorAlumniVisitor: 'visitor/editorAlumniVisitor.if', //访客申请
     getUserInfo: 'userinfo/getUserInfo.if', //查询用户信息
+    updateUserHeadImage: 'userinfo/updateUserHeadImage.if',//上传用户和底库图片
+    updateimage: 'userinfo/updateImage.if',//修改用户头像
 
     //宿管系统--教师端
     getDeptInfo: 'deptInfo/getDeptInfolevel.if', //获取学院信息