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.

91 lines
2.3 KiB

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: ""
},
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});
},
cancel_join_course_modal: function(event){
this.setData({show_join_course_modal: false});
},
update_invite_code: function({detail: {value}}){
this.setData({invite_code: value});
},
update_identities: function({detail: {value}}){
this.setData({identities: value})
},
join_course: function(event){
const {invite_code, identities} = this.data;
let data = {invite_code: invite_code};
for(var identity of identities){
data[identity] = 1;
}
console.log(data);
console.log({ ...data });
app.client.join_course({...data})
.then(res=>{
console.log(res);
wx.showToast({
title: res.data.message
})
wx.navigateTo({
url: "../course_detail/course_detail?course_id="+res.data.course_id
});
this.cancel_join_course_modal();
})
.catch(error=>{
wx.showToast({
title: error.toString(),
icon: "none"
});
console.warn(error);
})
},
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 })
}
})
}
// enter_usersetting: function(event){
// wx.navigateTo({
// url: '../user/user'
// })
// },
// enter_changeuser: function(event){
// console.log(event);
// wx.navigateTo({
// url: '../changeuser/changeuser'
// })
// },
})