|
|
|
@ -8,16 +8,37 @@ Component({
|
|
|
|
|
data: {
|
|
|
|
|
shixun_list:[]
|
|
|
|
|
},
|
|
|
|
|
pageLifetimes:{
|
|
|
|
|
show(){
|
|
|
|
|
/*
|
|
|
|
|
let {status} = this.data;
|
|
|
|
|
console.log("show",status);
|
|
|
|
|
if(status<0)
|
|
|
|
|
this.pullShixuns({refresh:2 ,showError:0});
|
|
|
|
|
//limit param somehow don't work!
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
attached(){
|
|
|
|
|
this.options = {page:1, limit: 10};
|
|
|
|
|
this.pullShixuns({refresh:1});
|
|
|
|
|
let key = "cache-shixun_list"
|
|
|
|
|
let cache_shixun_list = wx.getStorageSync(key);
|
|
|
|
|
if(cache_shixun_list)
|
|
|
|
|
this.setData({shixun_list: cache_shixun_list});
|
|
|
|
|
else
|
|
|
|
|
wx.showLoading({title: '努力加载中'});
|
|
|
|
|
this.pullShixuns({refresh:1, showError: !cache_shixun_list})
|
|
|
|
|
.then(res=>{
|
|
|
|
|
if(res.shixun_list)
|
|
|
|
|
wx.setStorageSync(key, res.shixun_list);
|
|
|
|
|
})
|
|
|
|
|
this.selects = {};
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
clear(){
|
|
|
|
|
this.setData({keyword:"", showClear:0});
|
|
|
|
|
this.options.keyword = "";
|
|
|
|
|
this.pullShixuns({refresh:1});
|
|
|
|
|
this.pullShixuns({refresh:1, showError: 0});
|
|
|
|
|
},
|
|
|
|
|
onInput(e){
|
|
|
|
|
let {detail:{value}} = e;
|
|
|
|
@ -26,7 +47,6 @@ Component({
|
|
|
|
|
}else if(!this.data.showClear&&value){
|
|
|
|
|
this.setData({showClear:1});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
onSelect(e){
|
|
|
|
|
let {detail} = e;
|
|
|
|
@ -67,14 +87,11 @@ Component({
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
this.setData({shixun_ids});
|
|
|
|
|
console.info(shixun_ids);
|
|
|
|
|
this.setData({showSendDialog: true});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
search(e){
|
|
|
|
|
|
|
|
|
|
search(e){
|
|
|
|
|
let {detail:{value}} = e;
|
|
|
|
|
if(this.options.keyword!=value){
|
|
|
|
|
this.options.keyword = value;
|
|
|
|
@ -85,24 +102,26 @@ Component({
|
|
|
|
|
this.pullShixuns({refresh:1});
|
|
|
|
|
},
|
|
|
|
|
onReachBottom(){
|
|
|
|
|
if(this.data.status==200)
|
|
|
|
|
let {status} = this.data;
|
|
|
|
|
if(status!=205&&status!=204)
|
|
|
|
|
this.pullShixuns();
|
|
|
|
|
},
|
|
|
|
|
pullShixuns({refresh=0}={}){
|
|
|
|
|
pullShixuns({refresh=0, showError=1}={}){
|
|
|
|
|
if(refresh){
|
|
|
|
|
if(refresh==1){
|
|
|
|
|
this.options.page = 1;
|
|
|
|
|
var { options } = this;
|
|
|
|
|
}else if(refresh==2){
|
|
|
|
|
var {page, per_page} = this.options;
|
|
|
|
|
var options = {...this.options,page:1, per_page: page*per_page};
|
|
|
|
|
var {page, limit} = this.options;
|
|
|
|
|
var options = {...this.options,page:1, limit: page*limit};
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
this.options.page++;
|
|
|
|
|
var {options} = this;
|
|
|
|
|
}
|
|
|
|
|
wx.showNavigationBarLoading();
|
|
|
|
|
return app.api("shixun_lists")(options).then(({shixun_list})=>{
|
|
|
|
|
return app.api("shixun_lists")(options).then(res=>{
|
|
|
|
|
let {shixun_list} = res;
|
|
|
|
|
let length = shixun_list.length;
|
|
|
|
|
if (!refresh){
|
|
|
|
|
shixun_list = this.data.shixun_list.concat(shixun_list);
|
|
|
|
@ -113,11 +132,15 @@ Component({
|
|
|
|
|
var status = length>0?200:205;
|
|
|
|
|
}
|
|
|
|
|
this.setData({ shixun_list, status}, wx.hideNavigationBarLoading);
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
return res;
|
|
|
|
|
}).catch(e=>{
|
|
|
|
|
if(refresh)
|
|
|
|
|
this.setData({ shixun_list:[], status:e.code}, wx.hideNavigationBarLoading);
|
|
|
|
|
else
|
|
|
|
|
this.setData({status:e.code}, wx.hideNavigationBarLoading);
|
|
|
|
|
console.log("error!!!!",e, showError)
|
|
|
|
|
this.setData({status:e.code}, wx.hideNavigationBarLoading);
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
if(showError)
|
|
|
|
|
app.showError(e);
|
|
|
|
|
return e;
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|