Browse Source

no message

featrue/v4.5
xpz2018 4 years ago
parent
commit
c09cdf4d5e
3 changed files with 49 additions and 16 deletions
  1. 1
      pages/agent/result/index.wxml
  2. 49
      pages/mall/search-list/index.js
  3. 15
      pages/mall/search-list/index.wxml

1
pages/agent/result/index.wxml

@ -1,4 +1,3 @@
<!--pages/agent/result/index.wxml-->
<cu-custom bgColor="bg-white" isBack="{{true}}">
<view slot="content">提交成功</view>
</cu-custom>

49
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())
}
}
})

15
pages/mall/search-list/index.wxml

@ -5,17 +5,22 @@
<view class="bg-white">
<free-input value="{{form.searchKey}}" placeholder="请输入关键字" extreaWord="搜索" bind:focus="onFocusChange" bind:blur="onBlurChange" focus="{{focus}}" close="{{true}}" bind:extrea="onSearchList"></free-input>
</view>
<view class="bg-white" style="height:90rpx;border-bottom:2rpx solid #f3f3f3" wx:if="{{!focus || rearchStringList.length == 0}}">
<view class="bg-white" style="height:90rpx;border-bottom:2rpx solid #f3f3f3" wx:if="{{!focus || searchList.length == 0}}">
<wux-tabi tab-data="{{tabList}}" tab-index="{{tabIndex}}" line-height="{{3}}" disable="{{requesting || loading}}" scroll="{{false}}" bind:change="onTabChange"></wux-tabi>
</view>
<view class="bg-white" wx:if="{{focus && rearchStringList.length}}">
<view class="bg-white" wx:if="{{focus && searchList.length}}">
<view class="cu-form-group" style="min-height:80rpx">
<view class="action" style="color:black">搜索历史</view>
<text class="cuIcon-delete" style="font-size: 17px" bindtap="clearHistory"></text>
</view>
<view class="flex flex-wrap" style="padding: 0rpx 20rpx 30rpx 20rpx">
<view class="padding-xs" wx:for-item="item" wx:for="{{rearchStringList}}" wx:key="index">
<view class="cu-tag round" style="padding:18rpx 24rpx" data-index="{{index}}" bindtap="tagClick">{{item}}</view>
<view id="keybord" class="flex flex-wrap" style="padding: 0rpx 20rpx 30rpx 20rpx;">
<view class="padding-xs" style="height: 68rpx;" wx:for-item="item" wx:for="{{searchList}}" wx:key="index">
<view class="cu-tag" style="padding:18rpx 24rpx;border-radius: 6rpx" data-index="{{index}}" bindtap="tagClick">{{item}}</view>
</view>
<view class="padding-xs" style="height: 68rpx;" wx:if="{{keyIndex}}">
<view class="cu-tag" style="padding:0rpx 12rpx;border-radius: 6rpx" bindtap="flodKeybord">
<text class="cuIcon-{{keyIndex == 1 ? 'unfold' : 'fold'}}" style="font-size: 32rpx;"></text>
</view>
</view>
</view>
</view>

Loading…
Cancel
Save