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.
42 lines
920 B
42 lines
920 B
5 years ago
|
const app = getApp();
|
||
|
Component({
|
||
|
properties: {
|
||
|
|
||
|
},
|
||
|
|
||
|
data: {
|
||
|
shixuns:[]
|
||
|
},
|
||
|
attached(){
|
||
|
this.options = {page:0, per_page:16};
|
||
|
this.pullShixuns();
|
||
|
//console.log(this.options)
|
||
|
},
|
||
|
methods: {
|
||
|
async pullShixuns({refresh=0}={}){
|
||
|
if(refresh){
|
||
|
if(refresh==1){
|
||
|
this.options.page = 1;
|
||
|
var { options } = this;
|
||
|
}else if(refresh==2){
|
||
|
var {page, per_page} = this.options;
|
||
|
var options = {page:1, per_page: page*per_page};
|
||
|
}
|
||
|
}else{
|
||
|
this.options.page++;
|
||
|
var {options} = this;
|
||
|
}let {shixuns} = await app.api("users.shixuns")(options);
|
||
|
if(!refresh)
|
||
|
shixuns = this.data.shixuns.concat(shixuns);
|
||
|
this.setData({shixuns});
|
||
|
return shixuns;
|
||
|
},
|
||
|
onPullDownRefresh(){
|
||
|
this.pullShixuns({refresh:2});
|
||
|
},
|
||
|
onReachBottom(){
|
||
|
this.pullShixuns({refresh:0});
|
||
|
}
|
||
|
}
|
||
|
})
|