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.

61 lines
1.5 KiB

const app = getApp();
Page({
data: {
tidings:[],
list:[
{text:"全部", type:""},{text:"课堂提醒",type:"course"},{text:"互动提醒", type:"interaction"},{text:"审核",type:"apply"},{text:"通知", type:"notice"}
]
},
changeType({detail:{current, value}}){
this.options.type=value.type;
this.refresh({refresh:1})
.then(res=>{
this.setData({scrollTop:0});
});
},
refresh({refresh=0}={}){
if(refresh){
this.setData({ loading: 1 });
if(refresh==1){
this.options.page=1;
var { options } = this;
}else if(refresh==2){
var { per_page, page, type} = this.options;
var options = {per_page:per_page*page, page:1, type};
}
}else{
this.options.page++;
var {options} = this;
}
//console.log(options);
return app.api("users.tidings")(options).then(res => {
let {tidings} = res;
if(!refresh)
tidings = this.data.tidings.concat(tidings);
this.setData({ tidings ,loading:0});
}).catch(e=>{
//app.showError(e);
this.setData({loading:0});
})
},
onLoad: function (options) {
this.options = { page: 1, per_page: 10 };
//console.log(this.options);
},
_onReachBottom(){
this.refresh();
},
onShow: function () {
this.refresh({refresh:2})
wx.hideTabBarRedDot({index: 1});
wx.removeTabBarBadge({index: 1});
},
onPullDownRefresh: function () {
this.refresh({refresh:2});
},
onShareAppMessage: function () {
}
})