<view class="search-viewposrig">
<view class='search-view'>
<input class='searchinput' confirm-type="search" maxlength="30" bindinput='wxSearchInput' value='{{search}}' bindconfirm='wxSearchFn' bindfocus="wxSerchFocus" bindblur="wxSearchBlur" placeholder='请输入搜索内容'></input>
<button class="searchbtn" bindtap="wxSearchBtn">搜索</button>
</view>
<!-- 筛选 -->
<view class="chose" bindtap="tochose">
<image src="../../image/chose.png"></image>
<text>筛选</text>
</view>
</view>
.....................//
// 获取搜索框内容
wxSearchInput: function(e) {
this.data.search = e.detail.value;
},
// 点击搜索按钮
wxSearchBtn: function(value) {
var that = this;
var searchbtn = that.data.search
wx.request({
url: queryUrl +'company/search',
data: {
search: searchbtn,
type: that.data.type
},
success: function(res) {
if (searchbtn == ""){
wx.showToast({
title: '搜索内容不能为空',
icon: "none"
})
return
}else{
if (res.data.user.length > 0) {
that.setData({
subordlist: res.data.user,
})
} else {
wx.showToast({
title: "没有你搜索的内容呦!!!",
icon: "none"
})
// return
that.setData({
subordhid: true,
choseframe: false,
search: ""
})
}
}
}
})
},
小程序中搜索功能
最新推荐文章于 2024-05-01 01:18:19 发布