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.
74 lines
1.6 KiB
74 lines
1.6 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.client.join_course({ ...data })
|
|
.then(res => {
|
|
if (res.data.status == 401) {
|
|
wx.showToast({
|
|
title: "请先登陆",
|
|
icon: "none"
|
|
});
|
|
return;
|
|
}
|
|
console.log(res);
|
|
wx.showToast({
|
|
title: res.data.message
|
|
})
|
|
if (res.data.course_id){
|
|
wx.navigateTo({
|
|
url: `/pages/course/course?course_id=${res.data.course_id}`
|
|
});
|
|
}
|
|
this.cancel();
|
|
})
|
|
.catch(error => {
|
|
wx.showToast({
|
|
title: error.toString(),
|
|
icon: "none"
|
|
});
|
|
console.warn(error);
|
|
})
|
|
|
|
}
|
|
}
|
|
})
|