<!-- 搜索框 -->
<view class='search'>
<image class="" src='../../images/search.jpg'></image>
<input type='text' placeholder='请输入您想要的内容' confirm-type='search' value="{{inputValue}}" bindinput='inputBind'></input>
</view>
//搜索框文本内容显示
inputBind: function (event) {
this.setData({
inputValue: event.detail.value
})
console.log('bindInput' + this.data.inputValue)
this.query();
},
data: {
show1: '',
show: '',
shows: '',
showJsonList: [],
checkPage: '',
inputValue: '', //搜索的内容
// currentTab: 0
result: [],
isShow: false,
toView: ''
},
/**
* 搜索执行按钮
*/
query: function () {
if (this.data.inputValue == '') {
this.setData({
isShow: false
})
return;
}
console.log(this.data.inputValue, ' this.data.result');
var that = this
that.setData({
result: [],
isShow: true
})
var val = [];
console.log(this.data.inputValue, ' this');
for (var i = 1; i < this.data.showJsonList.length; i++) {
for (var j = 0; j < this.data.showJsonList[i].data.length; j++) {
var searchTitle = this.data.showJsonList[i].data[j].chinese_name;
if (searchTitle.indexOf(this.data.inputValue) != -1) {
val.push(this.data.showJsonList[i].data[j])
// this.data.result.push( this.data.showJsonList[i].data[j]);
// console.log(val, 'val');
}
}
}
that.setData({
result: val
})
},