|
|
|
|
|
|
|
const app = getApp();
|
|
|
|
Component({
|
|
|
|
properties: {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
data: {
|
|
|
|
shixun_list:[]
|
|
|
|
},
|
|
|
|
attached(){
|
|
|
|
this.options = {page:1, limit: 10};
|
|
|
|
this.pullShixuns({refresh:1});
|
|
|
|
this.selects = {};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
clear(){
|
|
|
|
this.setData({keyword:"", showClear:0});
|
|
|
|
this.options.keyword = "";
|
|
|
|
this.pullShixuns({refresh:1});
|
|
|
|
},
|
|
|
|
onInput(e){
|
|
|
|
let {detail:{value}} = e;
|
|
|
|
if(this.data.showClear&&!value){
|
|
|
|
this.clear();
|
|
|
|
}else if(!this.data.showClear&&value){
|
|
|
|
this.setData({showClear:1});
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
onChange(e){
|
|
|
|
;
|
|
|
|
},
|
|
|
|
onSelect(e){
|
|
|
|
let {detail} = e;
|
|
|
|
;
|
|
|
|
this.selects[detail.name] = detail.value;
|
|
|
|
if(detail.value&&!this.data.select)
|
|
|
|
this.setData({select: true});
|
|
|
|
else if(!detail.value&&!this.data.select){
|
|
|
|
console.error("something unexpected happens");
|
|
|
|
}
|
|
|
|
else if(detail.from=='radio'){
|
|
|
|
let length = 0;
|
|
|
|
for(var i in this.selects){
|
|
|
|
if(this.selects[i])
|
|
|
|
length++;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
if(length==0){
|
|
|
|
this.setData({select: false});
|
|
|
|
this.selects = {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onReset(e){
|
|
|
|
;
|
|
|
|
this.setData({select:false});
|
|
|
|
this.selects = {}
|
|
|
|
},
|
|
|
|
onSubmit(e){
|
|
|
|
;
|
|
|
|
if(!this.data.select)
|
|
|
|
this.setData({select: true});
|
|
|
|
else{
|
|
|
|
let shixun_ids = [];
|
|
|
|
for(var i in this.selects){
|
|
|
|
if(this.selects[i])
|
|
|
|
shixun_ids.push(i);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
if(shixun_ids.length==0){
|
|
|
|
wx.showToast({
|
|
|
|
title: '请选择实训',icon:"none"
|
|
|
|
})
|
|
|
|
}else{
|
|
|
|
this.select_shixun_ids = shixun_ids;
|
|
|
|
this.setData({showSendDialog: true});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
search(e){
|
|
|
|
|
|
|
|
let {detail:{value}} = e;
|
|
|
|
if(this.options.keyword!=value){
|
|
|
|
this.options.keyword = value;
|
|
|
|
this.pullShixuns({refresh:1});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onPullDownRefresh(){
|
|
|
|
this.pullShixuns({refresh:1});
|
|
|
|
},
|
|
|
|
onReachBottom(){
|
|
|
|
if(this.data.status==200)
|
|
|
|
this.pullShixuns();
|
|
|
|
},
|
|
|
|
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 = {...this.options,page:1, per_page: page*per_page};
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
this.options.page++;
|
|
|
|
var {options} = this;
|
|
|
|
}
|
|
|
|
wx.showNavigationBarLoading();
|
|
|
|
return app.api("shixun_lists")(options).then(({shixun_list})=>{
|
|
|
|
let length = shixun_list.length;
|
|
|
|
if (!refresh){
|
|
|
|
shixun_list = this.data.shixun_list.concat(shixun_list);
|
|
|
|
var status = length>0?200:204;
|
|
|
|
}else{
|
|
|
|
this.selects = {};
|
|
|
|
this.setData({select: false});
|
|
|
|
var status = length>0?200:205;
|
|
|
|
}
|
|
|
|
this.setData({ shixun_list, status}, wx.hideNavigationBarLoading);
|
|
|
|
}).catch(e=>{
|
|
|
|
if(refresh)
|
|
|
|
this.setData({ shixun_list:[], status:e.code}, wx.hideNavigationBarLoading);
|
|
|
|
else
|
|
|
|
this.setData({status:e.code}, wx.hideNavigationBarLoading);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|