const AV = require("../../lib/av-live-query-weapp-min"); const app = getApp(); Page({ data:{ current_user: null, avatar_url: '', show_join_course_modal: false, invite_code: "" }, /**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: '../image_crop/image_crop?src='+src, }) }, }) break; } } }) }, logout: function(){ app.client.logout({ success:res=>{ console.log("注销成功"); console.log(res); this.enter_login(); }, fail:error=>{ console.error("注销失败"); console.error(error); } }) }, enter_login: function(event){ wx.navigateTo({ url: '../login/login', }) }, show_join_course_modal: function(event){ this.setData({show_join_course_modal: true}); }, onShow: function(){ app.client.get_user_info() .then(res=>{ console.log("get_user_info"); console.log(res) this.setData({current_user: app.client.current_user}) if ("image_url" in app.client.current_user && app.client.current_user.image_url) { this.setData({ avatar_url: "https://www.educoder.net/images/" + app.client.current_user.image_url }) }else{ this.setData({ avatar_url: "" }); } }) }, onShareAppMessage: function(){ } // enter_usersetting: function(event){ // wx.navigateTo({ // url: '../user/user' // }) // }, // enter_changeuser: function(event){ // console.log(event); // wx.navigateTo({ // url: '../changeuser/changeuser' // }) // }, })