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.
55 lines
1.5 KiB
55 lines
1.5 KiB
import {getFormatDatetime} from "../../../js/utils";
|
|
|
|
const app = getApp();
|
|
Component({
|
|
properties: {
|
|
exercise_id:Number,
|
|
exercise_status: Number,
|
|
current_status:{
|
|
type:Number,
|
|
value: 100 // @todo
|
|
},
|
|
user_exercise_status:Number
|
|
},
|
|
|
|
data: {
|
|
|
|
},
|
|
|
|
methods: {
|
|
onLoad:function(){
|
|
if(this.data.exercise_status==3||this.data.current_status<2){
|
|
app.redirectTo({ url: `{exercise}?exercise_id=${this.data.exercise_id}` });
|
|
}
|
|
this.refresh()
|
|
.then(res=>{
|
|
if(res.exercise.exercise_status==3)
|
|
// for 通知进入的情况,跳转
|
|
app.redirectTo({ url: `{exercise}?exercise_id=${this.data.exercise_id}` });
|
|
})
|
|
},
|
|
async refresh(){
|
|
let {exercise_id} = this.data;
|
|
let data = await app.api("exercises.exercise_setting")({exercise_id});
|
|
let date = new Date(data.exercise.end_time);
|
|
data.exercise.end_time_str = getFormatDatetime(date);
|
|
this.setData(data);
|
|
return data;
|
|
},
|
|
onTap(){
|
|
let {time} = this.data.exercise;
|
|
if(time&&time>0){
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: `答题时间为${time}分钟\n开始答题后即开始计时`,
|
|
success:res=>{
|
|
if(res.confirm)
|
|
app.redirectTo({ url: `{exercise}?exercise_id=${this.data.exercise_id}` });
|
|
}
|
|
})
|
|
}else
|
|
app.redirectTo({url:`{exercise}?exercise_id=${this.data.exercise_id}`});
|
|
}
|
|
}
|
|
})
|