| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- 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,
- });
- }
- 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,
- }
- },
- })
|