You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.7 KiB
74 lines
1.7 KiB
5 years ago
|
const app = getApp();
|
||
5 years ago
|
Page({
|
||
5 years ago
|
data:{
|
||
5 years ago
|
version:global.config.version,
|
||
|
imgDir: global.config.imgDir,
|
||
|
eduImgDir: global.config.eduImgDir,
|
||
|
user: {},
|
||
|
show_join_course_modal: false
|
||
5 years ago
|
},
|
||
5 years ago
|
/**on tap */
|
||
|
onTapAvatar: function({currentTarget:{dataset}}){
|
||
|
wx.showActionSheet({
|
||
|
itemList: ["查看图片","更改头像"],
|
||
|
success:res=>{
|
||
|
switch(res.tapIndex){
|
||
|
case 0:
|
||
|
wx.previewImage({
|
||
|
urls: [dataset.src],
|
||
|
});
|
||
|
break;
|
||
|
case 1:
|
||
|
console.log("点击更改头像");
|
||
|
wx.chooseImage({
|
||
|
count:1,
|
||
|
success: function(res) {
|
||
|
console.log("choose image")
|
||
|
console.log(res);
|
||
|
const src = res.tempFilePaths[0]
|
||
|
wx.navigateTo({
|
||
5 years ago
|
url: '/avatar/pages/image_crop/image_crop?src='+src,fail:console.error
|
||
5 years ago
|
})
|
||
|
},
|
||
|
})
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
|
||
|
},
|
||
|
|
||
5 years ago
|
logout: function(){
|
||
5 years ago
|
app.callApi({name:"accounts.logout",success:res=>{
|
||
5 years ago
|
console.log("注销成功");
|
||
|
console.log(res);
|
||
5 years ago
|
this.onShow();
|
||
5 years ago
|
},
|
||
|
fail:error=>{
|
||
|
console.error("注销失败");
|
||
|
console.error(error);
|
||
|
}
|
||
5 years ago
|
})
|
||
|
},
|
||
5 years ago
|
enter_login: function(event){
|
||
5 years ago
|
wx.navigateTo({
|
||
5 years ago
|
url: '/account/pages/login/login',fail:console.error
|
||
5 years ago
|
})
|
||
|
},
|
||
|
show_join_course_modal: function(event){
|
||
|
this.setData({show_join_course_modal: true});
|
||
|
},
|
||
5 years ago
|
|
||
5 years ago
|
onShow: function(){
|
||
5 years ago
|
app.api("users.get_user_info")()
|
||
5 years ago
|
.then(user=>{
|
||
5 years ago
|
console.log("get_user_info");
|
||
5 years ago
|
console.log(user)
|
||
|
this.setData({user})
|
||
5 years ago
|
})
|
||
5 years ago
|
},
|
||
|
|
||
|
onShareAppMessage: function(){
|
||
|
|
||
5 years ago
|
}
|
||
5 years ago
|
})
|