| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- const app = getApp();
- Page({
- data: {
- },
- onLoad: function () {
- var that = this;
- that.setData({
- Containnerheight: main.getWindowHeight(),
- IsShowNull: false,
- });
- },
- onShow:function(){
- if (wx.getStorageSync("SearchNull")){
- this.setData({
- IsShowNull:true,
- })
- wx.removeStorageSync("SearchNull");
- }
- },
- onKeyInput: function (e) {
- var search = e.detail.value;
- var that = this;
- that.setData({
- SearchInfo: search,
- });
- },
- onSearch: function (e) {
- if (this.data.SearchInfo && this.data.SearchInfo.length>0){
- var search = this.data.SearchInfo;
- var arr=wx.getStorageSync("SearchWord");
- if (!arr)
- arr=[];
- var obj = {};
- obj.Key = search;
- for(var i=0;i<arr.length;i++){
- if (arr[i].Key == search){
- obj.Key = arr[i].Key;
- obj.Value = arr[i].Value;
- arr.splice(i,1);
- break;
- }
- }
- arr.unshift(obj);
- wx.setStorageSync("SearchWord", arr);
- wx.navigateTo({
- url: './searchWeb2?back=3&search=' + search+'&type=0',
- })
- }
- else{
- wx.showToast({
- title: '请输搜索内容',
- })
- }
- },
- onSearchHistory: function (e) {
- var search = e.currentTarget.dataset.search;
- var arr = wx.getStorageSync("SearchWord");
- if (!arr)
- arr = [];
- var obj = {};
- obj.Key = search;
- var b=false,type=0;
- for (var i = 0; i < arr.length; i++) {
- if (arr[i].Key == search) {
- obj.Key = arr[i].Key;
- obj.Value = arr[i].Value;
- arr.splice(i, 1);
- b=true;
- type=1
- break;
- }
- }
- if (b){
- arr.unshift(obj);
- wx.setStorageSync("SearchWord", arr);
- }
- wx.navigateTo({
- url: './searchWeb2?back=2&search=' + search + '&type='+type,
- });
- },
- close: function (e) {
- wx.navigateBack({
- delta: 1,
- });
- }
- })
|