Skip to content

Commit ff1aa66

Browse files
committed
feat 首页添加搜索框
1 parent 213277c commit ff1aa66

File tree

3 files changed

+50
-4
lines changed

3 files changed

+50
-4
lines changed

pages/index/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const user = require('../../services/user.js');
66
const app = getApp()
77
Page({
88
data: {
9+
goodsCount: 0,
910
newGoods: [],
1011
hotGoods: [],
1112
topics: [],
@@ -40,6 +41,11 @@ Page({
4041
},
4142
onLoad: function (options) {
4243
this.getIndexData();
44+
util.request(api.GoodsCount).then(res => {
45+
this.setData({
46+
goodsCount: res.data.goodsCount
47+
});
48+
});
4349
},
4450
onReady: function () {
4551
// 页面渲染完成

pages/index/index.wxml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
21
<!--index.wxml-->
32
<view class="container">
3+
<view class="search">
4+
<navigator url="/pages/search/search" class="input">
5+
<image class="icon"></image>
6+
<text class="txt">商品搜索, 共{{goodsCount}}款好物</text>
7+
</navigator>
8+
</view>
49
<swiper class="banner" indicator-dots="true" autoplay="true" interval="3000" duration="1000">
510
<swiper-item wx:for="{{banner}}" wx:key="{{item.id}}">
611
<navigator url="{{item.link}}">
@@ -9,7 +14,7 @@
914
</swiper-item>
1015
</swiper>
1116
<view class="m-menu">
12-
<navigator class="item" url="{{item.url}}" wx:for="{{channel}}" wx:key="{{item.id}}">
17+
<navigator class="item" url="{{item.url}}" wx:for="{{channel}}" wx:key="{{item.id}}">
1318
<image src="{{item.icon_url}}" background-size="cover"></image>
1419
<text>{{item.name}}</text>
1520
</navigator>
@@ -79,8 +84,8 @@
7984
<view class="a-section a-topic" wx:if="topics.length > 0">
8085
<view class="h">
8186
<view>
82-
<navigator url="../topic/topic" open-type="switchTab">
83-
<text class="txt">专题精选</text>
87+
<navigator url="../topic/topic" open-type="switchTab">
88+
<text class="txt">专题精选</text>
8489
</navigator>
8590
</view>
8691
</view>

pages/index/index.wxss

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
2+
.search {
3+
height: 88rpx;
4+
width: 100%;
5+
padding: 0 30rpx;
6+
background: #fff;
7+
display: flex;
8+
align-items: center;
9+
}
10+
11+
.search .input {
12+
width: 690rpx;
13+
height: 56rpx;
14+
background: #ededed;
15+
border-radius: 8rpx;
16+
display: flex;
17+
align-items: center;
18+
justify-content: center;
19+
}
20+
21+
.search .icon {
22+
background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/search2-2fb94833aa.png) center no-repeat;
23+
background-size: 100%;
24+
width: 28rpx;
25+
height: 28rpx;
26+
}
27+
28+
.search .txt {
29+
height: 42rpx;
30+
line-height: 42rpx;
31+
color: #666;
32+
padding-left: 10rpx;
33+
font-size: 30rpx;
34+
}
35+
136
.banner {
237
width: 750rpx;
338
height: 417rpx;

0 commit comments

Comments
 (0)