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.
140 lines
3.1 KiB
140 lines
3.1 KiB
5 years ago
|
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(){
|
||
|
this.onLoad();
|
||
|
},
|
||
|
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("pull_exercise");
|
||
|
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,
|
||
|
});
|
||
|
},
|
||
|
enter_exercise: function ({ currentTarget: { dataset } }) {
|
||
|
wx.showModal({
|
||
|
title: '确认',
|
||
|
content: '开始作答吗?',
|
||
|
success: res => {
|
||
|
if (res.confirm) {
|
||
|
app.navigateTo({
|
||
|
url: '{exercise}?exercise_id=' + dataset.exercise_id,
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
onLoad: function (options) {
|
||
|
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 });
|
||
|
},
|
||
|
onShow: function () {
|
||
|
|
||
|
},
|
||
|
onPullDownRefresh: function () {
|
||
|
this.pull_exercise();
|
||
|
},
|
||
|
onShareAppMessage: function () {
|
||
|
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
|
||
|
|