const app = getApp(); Page({ data:{ version:global.config.version, imgDir: global.config.imgDir, eduImgDir: global.config.eduImgDir, user: {}, show_join_course_modal: false }, /**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({ url: '/avatar/pages/image_crop/image_crop?src='+src,fail:console.error }) }, }) break; } } }) }, logout: function(){ app.callApi({name:"accounts.logout",success:res=>{ console.log("注销成功"); console.log(res); this.onShow(); }, fail:error=>{ console.error("注销失败"); console.error(error); } }) }, enter_login: function(event){ wx.navigateTo({ url: '/account/pages/login/login',fail:console.error }) }, show_join_course_modal: function(event){ this.setData({show_join_course_modal: true}); }, onShow: function(){ app.api("users.get_user_info")() .then(user=>{ console.log("get_user_info"); console.log(user) this.setData({user}) }) }, onShareAppMessage: function(){ } })