import common from '../../utils/util'; import main from '../../utils/main'; import constant from '../../utils/constant'; const app = getApp(); Page({ data: { ImagePath: app.globalData.uploadImageUrl, SchoolSearch:constant.arrSchoolSearch, SearchList:[], IsFocus:true, }, onLoad: function (options) { var that = this; that.setData({ Containnerheight: main.getWindowHeight(), IsSearchFinish:false, IsSample:true, }); that.getKey(); }, bindKeyInput:function(e){ var that=this; var isExist=true; if (!e.detail.value) isExist=false; that.setData({ InputValue:e.detail.value, IsSearchFinish:isExist, }); if (e.detail.value) that.searchData(); }, searchKey:function(e){ var that=this; that.setData({ InputValue:e.currentTarget.dataset.key, }); that.searchData({currentTarget:{dataset:{rowcount:-1}}}); }, clearInput:function(){ var that=this; that.setData({ InputValue:"", IsSearchFinish:false, IsFocus:true, List:[], }); }, bindConfirm:function(){ this.searchData({currentTarget:{dataset:{rowcount:-1}}}); }, onBlur:function(){ var that=this; that.setData({ IsFocus:false, }); }, removeSearchData:function(){ wx.removeStorageSync('SearchKey'); this.getKey(); }, searchData:function(e){ var that=this; var rowcount=4; if (e && e.currentTarget.dataset.rowcount){ that.getKey(); rowcount=e.currentTarget.dataset.rowcount; } var key=that.data.InputValue; wx.showLoading({title:"加载中"}); main.getData("GetMPSSchool?Key="+key+"&RowCount="+rowcount, function (data) { if (data) { var isSample=true; if (rowcount==-1) isSample=false; that.setData({ List:data, IsSearchFinish:true, IsSample:isSample, }); } switch(key){ case "上": case "学": case "中": case "初": case "上海": case "上海市": case "学校": case "中学": case "初级": setTimeout(function(){ wx.hideLoading(); },3000); break; default: wx.hideLoading(); break; } }); }, goto: function (e) { this.getKey(); main.goto(e); }, close: function (e) { wx.navigateBack({ delta: 1, }); }, getKey:function(e){ var that=this; var arr=wx.getStorageSync('SearchKey'); if (!arr) arr=[]; //去重 for(var i=0;i10) arr.pop(); that.setData({ SearchList:arr, }); wx.setStorageSync('SearchKey', arr); }, onShareTimeline: function () { return this.onShareAppMessage(); }, onShareAppMessage: function () { return { title: app.globalData.ShareTitle, path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID, imageUrl: app.globalData.ShareImage, } }, })