You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.0 KiB
79 lines
2.0 KiB
// pages/home/about/index.js
|
|
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
|
|
},
|
|
taskList: []
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
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, ['form.name']: detail.value })
|
|
},
|
|
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) {
|
|
|
|
}
|
|
}
|
|
}
|
|
})
|