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.

81 lines
1.8 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;
}
console.log(data);
console.log({ ...data });
app.api("courses.apply_to_join_course")({ ...data })
.then(res => {
if (res.status == 401) {
wx.showToast({
title: "请先登陆",
icon: "none"
});
return;
}
console.log(res);
wx.showToast({
title: res.message
})
if (res.data.course_id){
wx.navigateTo({
url: `/pages/course/course?course_id=${res.data.course_id}`
});
}
this.cancel();
})
.catch(error => {
console.log("hi");
if(error.code==401){
wx.showToast({
title: "请先登陆",
icon: "none"
});
}else
wx.showToast({
title: error.message,
icon: "none"
});
//console.warn(error);
})
}
}
})