效果图及结构
效果图
![效果图](https://i-blog.csdnimg.cn/blog_migrate/d9b2602226496abdc360884325ca8813.png)
结构
![结构](https://i-blog.csdnimg.cn/blog_migrate/e7a5e682e7a53f4b360bf23078ec4fee.png)
图片资源
完整源码
activity.wxml
<view class='activity_view1'>
<input class='activity_search_input' confirm-type="search" maxlength="30" bindinput='wxSearchInput' value='{{keyword}}' bindconfirm='wxSearchFn' bindfocus="wxSerchFocus" bindblur="wxSearchBlur" placeholder='请输入搜索内容'></input>
<button class='activity_search_btn' bindtap="wxSearchFn" hover-class='button-hover'>搜索</button>
</view>
<view class="activity_boxtab {{HomeIndex == 0 ?'on':''}}" bindtap="boxtwo" data-index="0">网络类</view>
<view class="activity_boxtab {{HomeIndex == 1 ?'on':''}}" bindtap="boxtwo" data-index="1">建筑类</view>
<view class="activity_boxtab {{HomeIndex == 2 ?'on':''}}" bindtap="boxtwo" data-index="2">会计类</view>
<view class="activity_boxtab {{HomeIndex == 3 ?'on':''}}" bindtap="boxtwo" data-index="3">游戏类</view>
<view class="activity_boxtab {{HomeIndex == 4 ?'on':''}}" bindtap="boxtwo" data-index="4">教育类</view>
activity.wxss
.activity_view1 {
position: relative;
overflow: hidden;
height: 70rpx;
padding: 20rpx 20rpx 25rpx 60rpx;
background-color: #6699FF;
}
.activity_search_input {
float: left;
width: 500rpx;
height: 70rpx;
font-size: 35rpx;
background-color: white;
}
.activity_search_btn {
width: 70rpx!important;
height: 70rpx!important;
background-color: rgb(159, 217, 255);
font-size: 20rpx;
color: #fff;
border: none;
}
.activity_boxtab{
display: inline-block;
width: 20%;
height: 90rpx;
line-height: 90rpx;
border-bottom: 1rpx solid #ededed;
box-sizing: border-box;
text-align: center;
color: black;
font-size: 30rpx
}
.on{
color:#405F80;
border-bottom: 5rpx solid #405F80;
}
activity.js
Page({
data:{
newsList:[],
HomeIndex:0
},
activity_view1: function (key) {
var that = this;
var newsList = wx.getStorage({
key: 'newsList',
success: function (res) {
if (key == '') {
that.setData({
newsList: res.data
})
return;
}
var arr = [];
for (let i in res.data) {
if (res.data[i].title.indexOf(key) >= 0) {
arr.push(res.data[i])
}
}
if (arr.length == 0) {
that.setData({
newsList:[]
})
} else {
that.setData({
newsList: arr
})
}
}
})
},
wxSearchInput: function (e) {
this.search(e.detail.value);
console.log(e.detail.value)
},
boxtwo: function (e) {
var index = parseInt(e.currentTarget.dataset.index)
this.setData({
HomeIndex: index
})
}
})
activity.json
{
"usingComponents": {}
}