| 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,
|
| xqd
@@ -43,7 +43,7 @@ Page({
|
|
|
},
|
|
|
fail: () => {
|
|
|
wx.login({
|
|
|
- success: function(res) {
|
|
|
+ success: function (res) {
|
|
|
var data = Object.assign({}, e.detail, {
|
|
|
code: res.code
|
|
|
})
|
| xqd
@@ -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
|
| xqd
@@ -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]
|
|
|
})
|
|
|
}
|
| xqd
@@ -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: {
|
| xqd
@@ -107,7 +106,7 @@ Page({
|
|
|
if (res.code == 0) {
|
|
|
util.success('操作成功')
|
|
|
app.updateUserInfo(res.data)
|
|
|
- setTimeout(function() {
|
|
|
+ setTimeout(function () {
|
|
|
wx.navigateBack({
|
|
|
delta: 0,
|
|
|
})
|
| xqd
@@ -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()
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
|
|
|
/**
|