7 changed files with 123 additions and 23 deletions
Split View
Diff Options
-
20components/free-input/index.js
-
1components/free-input/index.wxml
-
10pages/mall/fragment/index.wxml
-
67pages/mall/search-list/index.js
-
4pages/mall/search-list/index.json
-
42pages/mall/search-list/index.wxml
-
2pages/moment/fragment/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) { |
|||
|
|||
} |
|||
} |
|||
} |
|||
}) |
|||
@ -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" |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save