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.

47 lines
1.0 KiB

const app = getApp();
Page({
data: {
schools:[]
},
onConfirm({detail:{value}}){
console.log(value);
if(!value) return;
this.search({keyword:value});
},
onSubmit({detail:{value}}){
console.log(value);
if(!value.keyword) return;
this.search({keyword:value.keyword});
},
search({keyword}){
return app.api("schools.for_option")({keyword})
.then(res => {
let { schools } = res;
if (schools.length > 100) {
schools = schools.slice(0, 100);
}
this.setData({ schools });
if(schools.length==0)
wx.showToast({
title:"没有相关单位",icon:"none"
})
})
},
clearKeyword(){
this.setData({schools:[],_keyword:'',keyword:''});
},
onInput({detail:{value}}){
this.setData({_keyword: value})
},
onLoad: function (options) {
let {keyword} = options;
if(keyword){
this.setData({keyword, _keyword: keyword});
this.search({keyword})
}
},
onShow: function () {
}
})