<button class="topbox flex-bet" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
<image :src="userinfo.avatar" class="tximg"></image>
<view>头像修改></view>
</button>
onChooseAvatar(e){
var that = this;
u.upload(e.detail.avatarUrl, (r) => {
var r = JSON.parse(r);
if (r.code == 1) {
that.userinfo.avatar= r.data.fullurl
} else {
uni.showToast({
title: r.msg,
icon: 'none'
})
}
},'avatar')
},
avatarChoose: function() {
let that = this;
uni.chooseImage({
count: 1,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success: function(res) {
var tempFilePaths = res.tempFilePaths[0];
u.upload(tempFilePaths, (r) => {
var r = JSON.parse(r);
if (r.code == 1) {
that.userinfo.avatar= r.data.fullurl
} else {
uni.showToast({
title: r.msg,
icon: 'none'
})
}
},'avatar')
}
});
},