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.

117 lines
2.6 KiB

const app = getApp();
const navData= [
{
text: "全部",
exercise_status: "all",
course_identities: [2, 5, 6]
},
{
text: '提交中',
exercise_status: 2,
course_identities: [2, 5, 6]
},
{
text: '已截止',
exercise_status: 3,
course_identities: [2, 5, 6]
},
{
text: "未发布",
exercise_status: 1,
course_identities: [2]
}
]
Component({
options: {
pureDataPattern: /^_/
},
properties: {
course_id:{
type:Number
},
id_:{
type:Number
},
refresh:{
type:Boolean,
observer:function(v){
if(v) {
this.onPullDownRefresh();
this.setData({ refresh: false });
}
}
}
},
data: {
imgDir: global.config.imgDir,
loading: true,
require_login: false,
page_status: 0,
exercises: [],
current_status: "all",
navList:navData,
currentTab: 0,
navScrollLeft: 0,
user:{}
},
attached(){
app.api("courses.top_banner")({ course_id: this.data.course_id })
.then(res => {
this.setData({ course: res })
console.log(res)
})
this.pull_exercise();
this.setData({ require_login: false });
},
methods: {
switchNav({detail:{current,value}}){
this.setData({ current_status: value.exercise_status});
},
exercise_result: function ({ currentTarget: { dataset } }) {
app.navigateTo({
url: `{exercise_result}?exercise_id=${dataset.exercise_id}`,
})
},
see_grade: function ({ currentTarget: { dataset } }) {
app.navigateTo({
url: `{exercise_grade}?exercise_id=${dataset.exercise_id}`,
})
},
edit_exercise: function ({ currentTarget: { dataset } }) {
app.navigateTo({
url: `{exercise_setting}?course_id=${this.data.course_id}&exercise_id=${dataset.exercise_id}`,
})
},
create_exercise: function () {
app.navigateTo({
url: `{exercise_setting}?course_id=${this.data.course_id}`,
})
},
pull_exercise: function () {
app.api("courses.exercises")({ course_id: this.data.course_id })
.then(res => {
console.log(res);
if (res.exercises) {
this.setData({ exercises: res.exercises, loading: false });
}
console.log(this.data)
})
.catch(e => {
console.error(e);
app.showError(e)
});
},
see_exercise: function ({ currentTarget: { dataset } }) {
app.navigateTo({
url: '{exercise}?exercise_id=' + dataset.exercise_id,
});
},
onPullDownRefresh: function () {
this.pull_exercise();
}
}
})