Browse Source

no message

featrue/v4.5
xpz2018 4 years ago
parent
commit
a7b220b36b
7 changed files with 123 additions and 23 deletions
  1. 20
      components/free-input/index.js
  2. 1
      components/free-input/index.wxml
  3. 10
      pages/mall/fragment/index.wxml
  4. 67
      pages/mall/search-list/index.js
  5. 4
      pages/mall/search-list/index.json
  6. 42
      pages/mall/search-list/index.wxml
  7. 2
      pages/moment/fragment/index.js

20
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: '' })
}
}
})

1
components/free-input/index.wxml

@ -16,6 +16,7 @@
bindconfirm="getConfirm"
password="{{password}}"
disabled="{{disabled}}"
focus="{{ focus }}"
class="input"/>
<!-- 删除 -->
<view class="deleStyle" wx:if="{{value && close}}" bindtap="close">

10
pages/mall/fragment/index.wxml

@ -69,11 +69,11 @@
</view>
<bubble-popup show="{{show}}" mask="{{true}}" position="absolute" direction="top"
width="240rpx" right="4rpx" bottom="-480rpx" translateY="-100%" triangleRight="50rpx" triangleTop="-22rpx" bind:close="topBubble">
<view class="tui-menu-item" bindtap="topBubble">更新时间</view>
<view class="tui-menu-item" bindtap="topBubble">价格升序</view>
<view class="tui-menu-item" style="color: #008AFF;" bindtap="topBubble">价格降序</view>
<view class="tui-menu-item" bindtap="topBubble">排队升序</view>
<view class="tui-menu-item" style="border-bottom: 0rpx;" bindtap="topBubble">排队降序</view>
<view id="time1" class="tui-menu-item" bindtap="topBubble">更新时间</view>
<view id="time3" class="tui-menu-item" bindtap="topBubble">价格升序</view>
<view id="time4" class="tui-menu-item" style="color: #008AFF;" bindtap="topBubble">价格降序</view>
<view id="time5" class="tui-menu-item" bindtap="topBubble">排队升序</view>
<view id="time6" class="tui-menu-item" style="border-bottom: 0rpx;" bindtap="topBubble">排队降序</view>
</bubble-popup>
</view>
</view>

67
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) {
}
}
}
})

4
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"
}
}

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

@ -3,4 +3,44 @@
<view slot="content">搜索</view>
</cu-custom>
<view class="bg-white">
<free-input value="{{form.name}}" placeholder="请输入关键字" extreaWord="搜索" bind:focus="onFocusChange" bind:blur="onBlurChange" focus="{{focus}}" close="{{true}}" bind:extrea="onSearchList"></free-input>
</view>
<view class="bg-white" wx:if="{{focus}}">
<view class="cu-form-group" style="min-height:80rpx" wx:if="{{rearchStringList.length}}">
<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" wx:if="{{rearchStringList.length}}">
<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>
</view>
</view>
<view wx:else>
<view class="bg-white" style="height:90rpx;border-bottom:2rpx solid #f3f3f3">
<wux-tabi tab-data="{{tabList}}" tab-index="{{tabIndex}}" line-height="{{3}}" scroll="{{false}}" bind:change="onTabChange"></wux-tabi>
</view>
<view class="flex flex-column flex-center" wx:if="{{loading}}" style="height:{{height -90}}rpx">
<view class="load-spinner text-gray" />
<view class="text-empty" style="margin-top:48rpx">加载中...</view>
</view>
<view class="list-empty" wx:elif="{{!taskList.length}}" style="height:{{height -90}}rpx">
<image class="img-empty" src="/assets/image/list_empty.png"></image>
<view class="text-empty">暂无数据</view>
</view>
<scroll-view scroll-y scroll-top="{{top}}" style="height:{{height - 90}}rpx;" wx:else bindscrolltolower="fetchTaskList">
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{taskList}}" wx:key="pageIndex">
<view class="bg-white" style="padding:0rpx 32rpx" wx:if="{{pageIndex>0}}">
<view style="height:2rpx;background-color:#f3f3f3"></view>
</view>
<page-list dataList="{{pageItem}}"></page-list>
</view>
<!--加载更多的UI-->
<van-divider content-position="center" wx:if="{{ form.pageNum > 1}}" custom-style="padding:0rpx 120rpx">
<van-loading type="spinner" size="16" wx:if="{{!finished}}" />
<text class="text-sm" style="margin-left:8rpx">{{finished?'到底啦~':'加载中...'}}</text>
</van-divider>
</scroll-view>
</view>

2
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)){

Loading…
Cancel
Save