diff --git a/components/free-input/index.js b/components/free-input/index.js index aaa641a..5623a9a 100644 --- a/components/free-input/index.js +++ b/components/free-input/index.js @@ -76,6 +76,10 @@ Component({ type:Boolean, value:false }, + focus:{ + type:Boolean, + value:false + }, // 是否禁用 disabled:{ type:Boolean, @@ -125,12 +129,8 @@ Component({ // 失焦 getBlur(e){ this.data.value = e.detail.value - this.setData({ - value:e.detail.value - }) - this.triggerEvent("blur", { - value: e.detail.value - },{}) + this.setData({ value:e.detail.value }) + this.triggerEvent("blur", { value: e.detail.value },{}) }, // 聚焦输入框变化 getConfirm(e){ @@ -150,12 +150,8 @@ Component({ }, // 关闭 close(){ - this.setData({ - value:'' - }) - this.triggerEvent("close", { - value: '' - }) + this.setData({ value:'' }) + this.triggerEvent("close", { value: '' }) } } }) diff --git a/components/free-input/index.wxml b/components/free-input/index.wxml index 3c15ffa..47f6688 100644 --- a/components/free-input/index.wxml +++ b/components/free-input/index.wxml @@ -16,6 +16,7 @@ bindconfirm="getConfirm" password="{{password}}" disabled="{{disabled}}" + focus="{{ focus }}" class="input"/> diff --git a/pages/mall/fragment/index.wxml b/pages/mall/fragment/index.wxml index 3566caa..30ec1a8 100644 --- a/pages/mall/fragment/index.wxml +++ b/pages/mall/fragment/index.wxml @@ -69,11 +69,11 @@ - 更新时间 - 价格升序 - 价格降序 - 排队升序 - 排队降序 + 更新时间 + 价格升序 + 价格降序 + 排队升序 + 排队降序 diff --git a/pages/mall/search-list/index.js b/pages/mall/search-list/index.js index 3a2f5e8..4c0e439 100644 --- a/pages/mall/search-list/index.js +++ b/pages/mall/search-list/index.js @@ -1,17 +1,78 @@ // pages/home/about/index.js -Page({ +const storage = require('../../../utils/storage') +const util = require('../../../utils/util') +const app = getApp() +Page({ /** * 页面的初始数据 */ data: { - + height: app.globalData.fragmentHeight - 100, + focus: true, + rearchStringList: [], + tabList: [ '交易', '行情', '订单' , '资讯'], + tabIndex: 0, + form: { + name: '', + pageSize: 10, + pageNum: 1 + }, }, - /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { + var searchString = storage.get('mall-search') + if(!util.isEmpty(searchString)){ + this.setData({rearchStringList: searchString.split(',').slice(0, 24)}) + } + this.setData({height: app.globalData.fragmentHeight - 100}) + }, + clearHistory: function(){ + var that = this + wx.removeStorage({ + key: 'mall-search', + success (res) { + that.setData({ rearchStringList: [] }) + } + }) + }, + onFocusChange: function(){ + this.setData({ focus: true }) + }, + onBlurChange: function(){ + if(util.isEmpty(this.data.form.name)){ + return + } + this.setData({ focus: false }) + }, + onTabChange: function({detail}){ + + }, + onSearchList: function({detail}){ + this.data.form.name = detail.value + if(util.isEmpty(this.data.form.name)){ + util.showToast('请输入要搜索的关键字') + return + } + var strList = this.data.rearchStringList + if(!util.isEmpty(this.data.form.name) && strList.indexOf(this.data.form.name) < 0){ + strList.splice(0, 0, this.data.form.name) + } + this.setData({ rearchStringList: strList.slice(0, 24), focus: false }) + }, + tagClick: function(e){ + this.setData({ ['form.name']: this.data.rearchStringList[e.currentTarget.dataset.index] }) + this.onSearchList({detail:{value: this.data.form.name}}) + }, + onUnload() { + if(this.data.rearchStringList.length){ + try { + wx.setStorageSync('mall-search', this.data.rearchStringList.toString()) + } catch (e) { + } + } } }) \ No newline at end of file diff --git a/pages/mall/search-list/index.json b/pages/mall/search-list/index.json index ed3ad5d..c7baeb8 100644 --- a/pages/mall/search-list/index.json +++ b/pages/mall/search-list/index.json @@ -1,5 +1,7 @@ { "usingComponents": { - "wux-cell": "/components/cell/index" + "free-input":"/components/free-input/index", + "wux-divider": "/components/divider/index", + "wux-tabi": "/components/tabi/index" } } \ No newline at end of file diff --git a/pages/mall/search-list/index.wxml b/pages/mall/search-list/index.wxml index 8fbe6c7..3b94881 100644 --- a/pages/mall/search-list/index.wxml +++ b/pages/mall/search-list/index.wxml @@ -3,4 +3,44 @@ 搜索 - \ No newline at end of file + + + + + + + 搜索历史 + + + + + {{item}} + + + + + + + + + + 加载中... + + + + 暂无数据 + + + + + + + + + + + + {{finished?'到底啦~':'加载中...'}} + + + \ No newline at end of file diff --git a/pages/moment/fragment/index.js b/pages/moment/fragment/index.js index a8b5b5f..745b1a6 100644 --- a/pages/moment/fragment/index.js +++ b/pages/moment/fragment/index.js @@ -65,7 +65,7 @@ Component({ wx.navigateTo({url: `/pages/home/city-select/index?type=1` }) }, searchList: function(){ - + util.navigateTo('/pages/mall/search-list/index') }, onTabChange: function({detail}){ if(this.data.tabIndex == Number(detail.index)){