| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- 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;i<arr.length;i++){
- if (arr[i]==that.data.InputValue){
- arr.splice(i,1);
- break;
- }
- }
- if (that.data.InputValue)
- arr.unshift(that.data.InputValue);
- if (arr.length>10)
- 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,
- }
- },
- })
|