diff --git a/pages/agent/result/index.wxml b/pages/agent/result/index.wxml index 5206c64..fefc82f 100644 --- a/pages/agent/result/index.wxml +++ b/pages/agent/result/index.wxml @@ -1,4 +1,3 @@ - 提交成功 diff --git a/pages/mall/search-list/index.js b/pages/mall/search-list/index.js index 88ba2e6..c92bf73 100644 --- a/pages/mall/search-list/index.js +++ b/pages/mall/search-list/index.js @@ -4,6 +4,8 @@ const storage = require('../../../utils/storage') const util = require('../../../utils/util') const tdsdk = require('../../../libs/tdweapp.js') const app = getApp() +const limit = 8 +var rearchStringList = [] Page({ /** @@ -12,7 +14,8 @@ Page({ data: { height: app.globalData.fragmentHeight - 100, focus: true, - rearchStringList: [], + keyIndex: 0, // 0: 总数少于limit,不显示;1:总数大于limit,只显示limit个,箭头向下;2:总数大于limit,全部显示,箭头向上 + searchList: [], tabList: [ '交易', '行情', '订单' , '资讯'], tabIndex: 0, form: { @@ -38,7 +41,19 @@ Page({ this.setData({height: app.globalData.fragmentHeight - 100, tabIndex: this.data.tabIndex}) var searchString = storage.get('mall-search') if(!util.isEmpty(searchString)){ - this.setData({rearchStringList: searchString.split(',').slice(0, 24)}) + rearchStringList = searchString.split(',').slice(0, 24) + if(rearchStringList.length > limit){ + this.setData({searchList: rearchStringList.slice(0, limit), keyIndex: 1 }) + } else { + this.setData({searchList: rearchStringList, keyIndex: 0 }) + } + } + }, + flodKeybord: function(){ + if(this.data.keyIndex > 0 && this.data.keyIndex == 2){ + this.setData({keyIndex : 1, searchList: rearchStringList.slice(0, limit), focus: true}) + } else if(this.data.keyIndex > 0 && this.data.keyIndex == 1){ + this.setData({keyIndex : 2, searchList: rearchStringList, focus: true}) } }, clearHistory: function(){ @@ -46,7 +61,7 @@ Page({ wx.removeStorage({ key: 'mall-search', success (res) { - that.setData({ rearchStringList: [] }) + that.setData({ searchList: [], keyIndex: 0 }) } }) }, @@ -57,6 +72,9 @@ Page({ if(util.isEmpty(this.data.form.searchKey)){ return } + if(!util.isEmpty(this.data.form.searchKey) && this.data.keyIndex && this.data.focus){ + return + } this.setData({ focus: false }) }, onTabChange: function({detail}){ @@ -79,12 +97,23 @@ Page({ util.showToast('请输入要搜索的关键字') return } - var strList = this.data.rearchStringList - if(!util.isEmpty(this.data.form.searchKey) && strList.indexOf(this.data.form.searchKey) < 0){ - strList.splice(0, 0, this.data.form.searchKey) + if(!util.isEmpty(this.data.form.searchKey) && rearchStringList.indexOf(this.data.form.searchKey) < 0){ + rearchStringList.splice(0, 0, this.data.form.searchKey) + } + if(rearchStringList.length > 24){ + rearchStringList = rearchStringList.slice(0, 24) + } + var searchList = [] + if(this.data.keyIndex == 0 && rearchStringList.length > limit){ + this.data.keyIndex = 1 + searchList = rearchStringList.slice(0, limit) + } else if(this.data.keyIndex == 1){ + searchList = rearchStringList.slice(0, limit) + } else if(this.data.keyIndex == 2){ + searchList = rearchStringList } this.data.form.pageNum = 1 - this.setData({ taskList: [], loading: true, finished: false, rearchStringList: strList.slice(0, 24), focus: false, ['form.searchKey']: detail.value }) + this.setData({ taskList: [], loading: true, finished: false, searchList, keyIndex: this.data.keyIndex, focus: false, ['form.searchKey']: detail.value }) this.fetchTaskList() }, fetchTaskList: function(){ @@ -153,7 +182,7 @@ Page({ } }, tagClick: function(e){ - this.data.form.searchKey = this.data.rearchStringList[e.currentTarget.dataset.index] + this.data.form.searchKey = this.data.searchList[e.currentTarget.dataset.index] this.onSearchList({detail:{value: this.data.form.searchKey}}) }, onShow: function () { @@ -164,8 +193,8 @@ Page({ }, onUnload: function() { tdsdk.Page.onUnload() - if(this.data.rearchStringList.length){ - storage.put('mall-search', this.data.rearchStringList.toString()) + if(rearchStringList.length){ + storage.put('mall-search', rearchStringList.toString()) } } }) \ No newline at end of file diff --git a/pages/mall/search-list/index.wxml b/pages/mall/search-list/index.wxml index 12ee6f2..2be7f68 100644 --- a/pages/mall/search-list/index.wxml +++ b/pages/mall/search-list/index.wxml @@ -5,17 +5,22 @@ - + - + 搜索历史 - - - {{item}} + + + {{item}} + + + + +