| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- const app = getApp();
- Page({
- data: {
- IsNull:false,
- Searching:true,
- SearchList:[],
- InfoArr:["拼音","默写","书写","组词","诗词","译文","发音","释义","反义词","近义词","部首","作者","翻译","例句"],
- },
- onLoad: function () {
- var that = this;
- that.setData({
- Containnerheight: main.getWindowHeight(),
- IsShowNull: false,
- Searching:true,
- });
- common.getStorageValue(that, "SearchTextList", [], function () {});
- },
- onShow:function(){
- this.setData({
- Focus: true,
- });
- },
- 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 = 'GetMiaoguoCardList2?UserID=' + app.globalData.userInfo.UserID;
- if (search)
- url += "&Key=" + search;
- var timeoutGetData=0;
- wx.showLoading({
- title: '请稍后...',
- });
- main.getData(url, function (data) {
- wx.hideLoading();
- clearTimeout(timeoutGetData);
- if (data) {
- if (data.List.length==0){
- that.setData({
- IsNull:true,
- });
- that.getSearchData();
- }
- else{
- app.globalData.CardList= data.List;
- var url='./mainlist?search=' + search+'&Count='+data.Count;
- wx.navigateTo({
- url: url,
- });
- }
- }
- });
- timeoutGetData=setTimeout(function(){
- wx.hideLoading();
- },10000);
- setTimeout(function () {
- var arr = that.data.SearchTextList;
- 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("SearchTextList", arr);
- that.setData({
- SearchTextList: arr,
- });
- }, 2000);
- }
- else {
- wx.showToast({
- title: '请输搜索内容',
- })
- }
- },
- getSearchData:function(){
- var that=this;
- main.searchInfomation(that.data.SearchInfo,null,null,null,function(list,obj){
- if ((!list || list.length==0) && obj){
- list=[];
- list.push(obj);
- }
- that.setData({
- SearchList:list,
- Searching:false,
- });
- });
- },
- goto: function (e) {
- var url = e.currentTarget.dataset.url;
- var search=e.currentTarget.dataset.word;
-
- if (search){
- app.globalData.TempStr=e.currentTarget.dataset.url2;
- var search=e.currentTarget.dataset.word;
- var author=e.currentTarget.dataset.author;
- var searchtype=e.currentTarget.dataset.searchtype;
- url+="&Word="+search;
- if (author)
- url+="&Author="+author;
- if (searchtype)
- url+="&SearchType="+searchtype;
-
- wx.navigateTo({
- url: url,
- });
- }
- else{
- wx.navigateTo({
- url: url,
- });
- }
-
- },
- clearInput:function(){
- console.log("clearInput");
- this.setData({
- SearchInfo:"",
- IsNull:false,
- SearchList:[],
- Focus:true,
- });
- },
- close: function (e) {
- wx.navigateBack({
- delta: 1,
- });
- },
- deleteItem: function (e) {
- var that = this;
- that.setData({
- SearchTextList: [],
- });
- wx.removeStorageSync("SearchTextList");
- },
-
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|