import common from '../../utils/util'; import main from '../../utils/main'; const app = getApp(); Page({ data: { IsNull:false, IsList:false, Searching:true, SearchList:[], }, onLoad: function (options) { var that = this; that.setData({ Containnerheight: main.getWindowHeight(), }); common.getStorageValue(that, "SearchTextList2", [], function () {}); }, onShow:function(){ this.setData({ Focus: true, }); }, onPullDownRefresh: function () { wx.stopPullDownRefresh(); }, onKeyInput: function (e) { console.log("onKeyInput"); var search = e.detail.value; var that = this; that.setData({ SearchInfo: search, }); }, onFocus: function (e) { console.log("onFocus"); var that = this; that.setData({ Searching:true, IsNull:false, }); }, onBindblur: function (e) { console.log("onBindblur"); }, onSearch: function (e) { if (e.currentTarget.dataset.search){ this.data.SearchInfo = e.currentTarget.dataset.search; this.setData({ SearchInfo:this.data.SearchInfo, }); } if (this.data.SearchInfo && this.data.SearchInfo.length > 0) { var search = this.data.SearchInfo; var that = this; var url = 'GetMiaoguoIntroducerSearchUser?UserID=' + app.globalData.userInfo.UserID; if (search) url += "&Key=" + search; updateData(that,search); wx.showLoading({ title: '请稍后...', }); main.getData(url, function (data) { wx.hideLoading(); if (data) { if (data.length==0){ that.setData({ IsNull:true, IsList:true, }); } else{ that.setData({ IsList:true, List:data, }); } } }); } else { wx.showToast({ title: '请输搜索内容', }) } function updateData(obj,search) { setTimeout(function () { var arr = obj.data.SearchTextList2; for (var i = 0; i < arr.length; i++) { if (arr[i] == search) { arr.splice(i, 1); break; } } arr.unshift(search); while (arr.length > 10) { arr.pop(); } wx.setStorageSync("SearchTextList2", arr); obj.setData({ SearchTextList2: arr, }); }, 2000); } }, clearInput:function(){ this.setData({ SearchInfo:"", IsNull:false, SearchList:[], Focus:true, IsList:false, }); }, goto: function (e) { var url = e.currentTarget.dataset.url; wx.navigateTo({ url: url, }); }, onClose: function () { wx.navigateBack({ delta: 1, }); }, onShareAppMessage: function () { return { title: app.globalData.ShareTitle, path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID, imageUrl: app.globalData.ShareImage, } }, })