Browse Source

修改上传头像

宇宙无敌M1处理器的MacBook Pro 4 years ago
parent
commit
3f6bad2bed
4 changed files with 22 additions and 26 deletions
  1. 4 7
      mini/pages/bind/index.js
  2. 1 1
      mini/pages/bind/index.wxml
  3. 0 1
      mini/pages/order-detail/index.js
  4. 17 17
      mini/pages/user/index.js

+ 4 - 7
mini/pages/bind/index.js

xqd xqd xqd
@@ -45,7 +45,7 @@ Page({
         },
         fail: () => {
           wx.login({
-            success: function(res) {
+            success: function (res) {
               var data = Object.assign({}, e.detail, {
                 code: res.code
               })
@@ -65,11 +65,11 @@ Page({
       data: data,
       success: function (res) {
         console.log(res)
-        if(res.code == 0 && res.data.phoneNumber) {
+        if (res.code == 0 && res.data.phoneNumber) {
           that.setData({
             phone: res.data.phoneNumber
           })
-          if(res.data.session_key) {
+          if (res.data.session_key) {
             wx.setStorageSync('session_key', res.data.session_key)
           }
           util.success('手机号获取成功')
@@ -81,10 +81,7 @@ Page({
   },
 
   getUserInfo: function (e) {
-    var that = this;
-    util.wechatLogin(e, false, function (res) {
-      that.submit()
-    }, true)
+    this.submit()
   },
 
   submit: function () {

+ 1 - 1
mini/pages/bind/index.wxml

xqd
@@ -36,7 +36,7 @@
       </view>
     </view>
     <view class="sg-margin-tb">
-      <van-button type="info" block open-type="getUserInfo" bind:getuserinfo="getUserInfo">提交</van-button>
+      <van-button type="info" block  bindtap="getUserInfo">提交</van-button>
     </view>
   </view>
 </view>

+ 0 - 1
mini/pages/order-detail/index.js

xqd
@@ -74,7 +74,6 @@ Page({
       if (['checking', 'checked'].indexOf(order.status_key) != -1 && role && role.rights && role.rights.rentCheck) actionType = 'check';
       else if (order.status_key == 'checked' && role.key == 'work') actionType = 'pass'
       else if (order.status_key == 'reject' && role.key == 'work') actionType = 're-submit'
-
       changePrice = role && role.rights && role.rights.rentMoneyChange
     }
     this.setData({

+ 17 - 17
mini/pages/user/index.js

xqd xqd xqd xqd xqd xqd xqd
@@ -20,7 +20,7 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    if(app.globalData.userInfo) {
+    if (app.globalData.userInfo) {
       var user = app.globalData.userInfo
       this.setData({
         userInfo: user,
@@ -43,7 +43,7 @@ Page({
         },
         fail: () => {
           wx.login({
-            success: function(res) {
+            success: function (res) {
               var data = Object.assign({}, e.detail, {
                 code: res.code
               })
@@ -61,7 +61,7 @@ Page({
       url: 'parsePhone',
       data: data,
       success: function (res) {
-        if(res.code == 0) {
+        if (res.code == 0) {
           getApp().updateUserInfo(res.data)
           that.setData({
             userInfo: res.data
@@ -74,15 +74,14 @@ Page({
   },
 
   chooseImage() {
-    var that = this
     wx.chooseImage({
       count: 1,
       sizeType: ['original', 'compressed'],
       sourceType: ['album', 'camera'],
-      success (res) {
+      success: (res) => {
         const paths = res.tempFilePaths
-        if(paths.length > 0) {
-          that.setData({
+        if (paths.length > 0) {
+          this.setData({
             avatar: paths[0]
           })
         }
@@ -90,12 +89,12 @@ Page({
     })
   },
 
-  updateInput: function(e) {
+  updateInput: function (e) {
     app.updateInput(this, e)
   },
 
-  updateInfo: function() {
-    console.log(this.data.phone)
+  updateInfo: function () {
+    console.log(this.data.avatar)
     http({
       url: 'users/update',
       data: {
@@ -107,7 +106,7 @@ Page({
         if (res.code == 0) {
           util.success('操作成功')
           app.updateUserInfo(res.data)
-          setTimeout(function() {
+          setTimeout(function () {
             wx.navigateBack({
               delta: 0,
             })
@@ -119,27 +118,28 @@ Page({
     })
   },
 
-  save: function() {
+  save: function () {
     // if(!util.checkMobile(this.data.phone)) {
     //   util.error('手机号错误')
     //   return false
     // }
-    if(!this.data.name) {
+    if (!this.data.name) {
       util.error('姓名必填')
       return false
     }
     var that = this;
-    if(this.data.userInfo.avatar != this.data.avatar) {
-      util.uploadFile(this.data.avatar, function(res) {
+    if (this.data.userInfo.avatar != this.data.avatar) {
+      util.uploadFile(this.data.avatar, function (res) {
+        console.log(res)
         that.setData({
-          avatar: res.path
+          avatar: res.data.path
         })
         that.updateInfo()
       })
     } else {
       that.updateInfo()
     }
-    
+
   },
 
   /**