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.

64 lines
1.5 KiB

const app = getApp();
Component({
properties: {
hidden:{
type:Boolean,
value: true,
},
show_code:{
type:Number,
value:1
},
invite_code: String,
auto_navigate:{
type:Number,
value:1
},
opentype:{
type:String,
value:"navigateTo"
}
},
data: {
identities:[],
hidden:true
},
methods: {
cancel: function (event) {
this.setData({ hidden: true });
},
update_invite_code: function ({ detail: { value } }) {
console.log(value);
this.setData({ invite_code: value });
},
update_identities: function ({ detail: { value } }) {
var data = {assistant_professor:"", professor:"",student:""}
console.log(value);
for(var identity of value)
data[identity] = 1
console.log(data);
this.setData(data)
},
join_course: function (event) {
let { invite_code="", assistant_professor="", professor,student=""} = this.data;
console.log(this.data);
app.api("courses.apply_to_join_course")({ invite_code, assistant_professor, professor, student })
.then(res => {
console.log(res);
app.showMsg(res);
if (res.course_id&&this.data.auto_navigate&&res.message.indexOf("助教申请")==-1){
app[this.data.opentype]({
url: `{course}?course_id=${res.course_id}`
});
}
this.triggerEvent("success");
this.cancel();
})
.catch(app.showError)
}
}
})