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.
49 lines
1.1 KiB
49 lines
1.1 KiB
const app = getApp();
|
|
Component({
|
|
|
|
properties: {
|
|
hidden:{
|
|
type:Boolean,
|
|
value: false,
|
|
}
|
|
},
|
|
|
|
data: {
|
|
invite_code:"",
|
|
identities:[],
|
|
hidden:false
|
|
},
|
|
|
|
methods: {
|
|
cancel: function (event) {
|
|
this.setData({ hidden: true });
|
|
},
|
|
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;
|
|
}
|
|
app.api("courses.apply_to_join_course")({ ...data })
|
|
.then(res => {
|
|
console.log(res);
|
|
app.showMsg(res);
|
|
if (res.course_id){
|
|
wx.navigateTo({
|
|
url: `/course/pages/course/course?course_id=${res.course_id}`
|
|
});
|
|
}
|
|
this.cancel();
|
|
})
|
|
.catch(app.showError)
|
|
|
|
}
|
|
}
|
|
})
|