const app = getApp(); Component({ properties: { course_id:Number, id_:Number, refresh:{ type:Number, observer:function(r){ if (r) { this.refresh(); this.setData({ refresh: false }); } } } }, data: { list:[{text:"全部",order:""},{text:"未发布",order:0},{text:"提交中",order:1},{text:"补交中",order:2},{text:"匿评中",order:3},{text:"申诉中",order:4},{text:"已截止",order:5}] }, attached(){ this.refresh(); }, methods: { onSwitchNav({detail:{current, value}}){ if(!this.options) this.options={}; this.options.order=value.order; this.refresh(); }, refresh(){ let {course_id} = this.data; ; app.api("courses.homework_commons")({...this.options, course_id, type:1}) .then(res=>{ ; this.setData({homeworks: res.homeworks}); }).catch(e=>{ app.showError(e); }) } } })