1234567
This commit is contained in:
@@ -59,24 +59,35 @@ Page({
|
||||
},
|
||||
updateUserAvatar: function() {
|
||||
var that = this;
|
||||
wx.getUserProfile({
|
||||
desc: '用于更新您的头像',
|
||||
wx.chooseMedia({
|
||||
count: 1,
|
||||
mediaType: ['image'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: function(res) {
|
||||
var userInfo = res.userInfo;
|
||||
e.request('miniprogram/user/update', {
|
||||
avatar: userInfo.avatarUrl
|
||||
}, true).then(function(res) {
|
||||
if (res.code == 200) {
|
||||
that.getContent();
|
||||
wx.showToast({
|
||||
title: '头像更新成功',
|
||||
icon: 'success'
|
||||
});
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: res.message,
|
||||
icon: 'none'
|
||||
});
|
||||
wx.uploadFile({
|
||||
url: 'https://t-jm.v0750.com/miniprogram/upload',
|
||||
filePath: res.tempFiles[0].tempFilePath,
|
||||
name: 'file',
|
||||
success: function(uploadRes) {
|
||||
var data = JSON.parse(uploadRes.data);
|
||||
if (data.code == 200) {
|
||||
e.request('https://t-jm.v0750.com/miniprogram/user/update', {
|
||||
avatar: data.data.url
|
||||
}, true).then(function(res) {
|
||||
if (res.code == 200) {
|
||||
that.getContent();
|
||||
wx.showToast({
|
||||
title: '头像更新成功',
|
||||
icon: 'success'
|
||||
});
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: res.message,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -84,26 +95,29 @@ Page({
|
||||
},
|
||||
updateUserNickname: function() {
|
||||
var that = this;
|
||||
wx.getUserProfile({
|
||||
desc: '用于更新您的昵称',
|
||||
wx.showModal({
|
||||
title: '修改昵称',
|
||||
editable: true,
|
||||
placeholderText: '请输入新昵称',
|
||||
success: function(res) {
|
||||
var userInfo = res.userInfo;
|
||||
e.request('miniprogram/user/update', {
|
||||
nickname: userInfo.nickName
|
||||
}, true).then(function(res) {
|
||||
if (res.code == 200) {
|
||||
that.getContent();
|
||||
wx.showToast({
|
||||
title: '昵称更新成功',
|
||||
icon: 'success'
|
||||
});
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: res.message,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
if (res.confirm && res.content) {
|
||||
e.request('https://t-jm.v0750.com/miniprogram/user/update', {
|
||||
nickname: res.content
|
||||
}, true).then(function(res) {
|
||||
if (res.code == 200) {
|
||||
that.getContent();
|
||||
wx.showToast({
|
||||
title: '昵称更新成功',
|
||||
icon: 'success'
|
||||
});
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: res.message,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user