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.
111 lines
2.5 KiB
111 lines
2.5 KiB
5 years ago
|
const app = getApp()
|
||
|
|
||
|
Page({
|
||
|
allnavData: [
|
||
|
{
|
||
|
text: "全部",
|
||
|
exercise_status: "all",
|
||
|
course_identities: [2, 5, 6]
|
||
|
},
|
||
|
{
|
||
|
text: "未发布",
|
||
|
exercise_status: 1,
|
||
|
course_identities: [2]
|
||
|
},
|
||
|
{
|
||
|
text: '提交中',
|
||
|
exercise_status: 2,
|
||
|
course_identities: [2, 5, 6]
|
||
|
},
|
||
|
{
|
||
|
text: '已截止',
|
||
|
exercise_status: 3,
|
||
|
course_identities: [2, 5, 6]
|
||
|
},
|
||
|
],
|
||
|
data: {
|
||
|
loading: true,
|
||
|
exercises: [],
|
||
|
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]
|
||
|
},
|
||
|
],
|
||
|
currentTab: 0,
|
||
|
navScrollLeft: 0
|
||
|
},
|
||
|
pull_courses_info: function(){
|
||
|
app.client.get_user_info()
|
||
|
.then();
|
||
|
/**@todo */
|
||
|
},
|
||
|
pull_courses: function(){
|
||
|
app.client.search_exercises({ course_id: this.course_id })
|
||
|
.then(res => {console.log("pull_courses");console.log(res); this.setData({ exercises: res.data.exercises, loading: false});console.log(this.data)})
|
||
|
.catch(console.error);
|
||
|
},
|
||
|
see_exercise: function ({ currentTarget: { dataset } }){
|
||
|
wx.navigateTo({
|
||
|
url: '../exercise/exercise?exercise_id=' + dataset.exercise_id,
|
||
|
});
|
||
|
},
|
||
|
enter_exercise: function({currentTarget:{dataset}}){
|
||
|
wx.showModal({
|
||
|
title: '确认',
|
||
|
content: '开始作答吗?',
|
||
|
success: res=>{
|
||
|
if(res.confirm){
|
||
|
wx.navigateTo({
|
||
|
url: '../exercise/exercise?exercise_id='+dataset.exercise_id,
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
//事件处理函数
|
||
|
onLoad: function (options) {
|
||
|
this.course_id = options.id;
|
||
|
},
|
||
|
onShow: function(){
|
||
|
this.pull_courses();
|
||
|
},
|
||
|
switchNav(event) {
|
||
|
var cur = event.currentTarget.dataset.current;
|
||
|
//每个tab选项宽度占1/5
|
||
|
var singleNavWidth = this.data.windowWidth / 3;
|
||
|
//tab选项居中
|
||
|
this.setData({
|
||
|
navScrollLeft: (cur - 1) * singleNavWidth
|
||
|
})
|
||
|
if (this.data.currentTab == cur) {
|
||
|
return false;
|
||
|
} else {
|
||
|
this.setData({
|
||
|
currentTab: cur
|
||
|
})
|
||
|
}
|
||
|
},
|
||
|
switchTab(event) {
|
||
|
var cur = event.detail.current;
|
||
|
var singleNavWidth = this.data.windowWidth / 5;
|
||
|
this.setData({
|
||
|
currentTab: cur,
|
||
|
navScrollLeft: (cur - 1) * singleNavWidth
|
||
|
});
|
||
|
},
|
||
|
onPullDownRefresh: function(){
|
||
|
this.pull_courses();
|
||
|
}
|
||
|
})
|