您现在的位置: 微信小程序 > 微信小程序DEMO >

微信小程序学习用demo:一元夺宝:仅有主页设计

来源:微信小程序 编辑:易用通 发布时间:04-13热度:
点评:只设计了主页,但是设计方面还是值得学习的;
 

实例代码:
[HTML] 纯文本查看 复制代码
?
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!--index.wxml-->
<view class="container">
  <scroll-view class="scroll-container" upper-threshold="{{sortPanelDist}}" bindscroll="onToTop" scroll-y="true" style="height:calc(100% - 1px)">
    <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
        <block wx:for="{{imgUrls}}">
            <swiper-item>
                <image src="{{item}}" class="slide-image" style="height:{{windowWidth * 0.375}}px !important"/>
            </swiper-item>
        </block>
    </swiper>
    <view class="category-panel">
        <view class="category-item">
            <image class="category-item-image" src="../../resources/images/ic_index_tab_kind.png" />
            <text class="category-item-text">分类</text>
        </view>
        <view class="category-item">
            <image class="category-item-image" src="../../resources/images/ic_index_tab_ten.png" />
            <text class="category-item-text">优选</text>
        </view>
        <view class="category-item">
            <image class="category-item-image" src="../../resources/images/ic_index_tab_share.png" />
            <text class="category-item-text">晒单</text>
        </view>
        <view class="category-item">
            <image class="category-item-image" src="../../resources/images/ic_index_tab_qa.png" />
            <text class="category-item-text">常见问题</text>
        </view>
    </view>
    <block wx:if="{{notices.length>0}}">
        <view class="notice-panel">
            <image class="notice-image" src="../../resources/images/ic_notice.png" />
            <view class="notice-message" animation="{{animationNotice}}" style="opacity:{{noticeIdx>=0}};">
                <span style="color:#999999">恭喜</span><span style="color:#3273c3">{{notices[noticeIdx].name}}</span><span style="color:#999999">{{notices[noticeIdx].time}}</span>{{notices[noticeIdx].goods}}
            </view>
        </view>
    </block>
    <view class="sort-panel" style="position:{{sortPanelPos}};top:{{sortPanelTop}}px">
        <view class="sort-item">人气</view>
        <view class="sort-item">最新</view>
        <view class="sort-item">进度</view>
        <view class="sort-item comb on">
            <view class="comb-text">总需人次</view>
            <view class="comb-arrs down">
                <image class="comb-arr-up" src=""></image>
                <image class="comb-arr-down" src=""></image>
            </view>
        </view>
    </view>
    <view class="goods-panel">
        <import src="tpl/goodsList.wxml"/>
        <template is="goodsList" data="{{goodsList:goodsList}}"/>
    </view>
  </scroll-view>
  <view class="tabbar-border"></view>
</view>

[CSS] 纯文本查看 复制代码
?
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
.container {
    width: 100%;
    padding:0;
    margin: 0;
    background-color: #fff;
}
.scroll-container{
    width:100%;
}
.tabbar-border{
    width:100%;
    height:1px;
    position: fixed;
    bottom: 0;
    background-color: #ccc;
}
.slide-image{
    width:100%;
}
.category-panel{
    height:90px;
    width:100%;
    display:flex;
    color:#666666;
    flex-direction:row;
    font-size:11px;
    justify-content: space-around;
    border-bottom: 1px solid #f1eeec;
}
.category-item{
    display:flex;
    width:60px;
    text-align: center;
    flex-direction:column;
}
.category-item-image{
    width:36px;
    height:36px;
    overflow:unset;
    padding:15px 12px 0 12px
}
.category-item-text{
    padding:10px 0;
}
.notice-panel{
    width:100%;
    height:50px;
    display:flex;
    flex:none;
    flex-direction:row;
    border-bottom: 10px solid #e8e8e8;
}
.notice-image{
    height: 20px;
    min-width:20px;
    max-width:20px;
    padding: 10px 10px 10px 20px;
}
.notice-message{
    font-size: 12px;
    color: #666666;
    word-break:normal;
    overflow : hidden;
    word-wrap: normal;
    line-height: 40px;
    padding-right:20px;
}
.sort-panel{
    width:100%;
    height: 45px;
    display:flex;
    z-index: 1000;
    flex-direction: row;
    justify-content: space-around;
    border-bottom: 1px solid #e8e8e8;
    background-color: rgba(255, 255, 255, 0.96);
}
.sort-item{
    width:68px;
    height: 45px;
    color: #545454;
    font-size:13px;
    text-align: center;
    padding-top:13px;
}
.sort-item.on{
    color: #db3652;
    border-bottom: 2px solid #db3652;
}
 
.sort-item.comb{
    display:flex;
    flex-direction: row;
}
 
.comb-arrs {
    display:flex;
    padding: 3px 0 0 3px;
    flex-direction: column;
}
.comb-arr-up, .comb-arr-down{
    width: 11px;
    height: 6px;
    background-size:cover;
}
 
.comb-arr-up{
    background-image:url(../../resources/images/ic_arr_up.png);
}
 
.comb-arr-down{
    margin-top:1px;
    background-image:url(../../resources/images/ic_arr_down.png);
}
 
.comb-arrs.up .comb-arr-up{
    background-image:url(../../resources/images/ic_arr_up_selected.png);
}
 
.comb-arrs.up .comb-arr-down{
    background-image:url(../../resources/images/ic_arr_down.png);
}
 
.comb-arrs.down .comb-arr-up{
    background-image:url(../../resources/images/ic_arr_up.png);
}
 
.comb-arrs.down .comb-arr-down{
    background-image:url(../../resources/images/ic_arr_down_selected.png);
}
.goods-panel{
    display: flex;
    flex-wrap:wrap;
}
.goods-panel .goods-item{
    width: 50%;
    height: 220px;
    border-bottom:1px solid #e8e8e8;
}
 
.goods-item.odd{
    border-right:1px solid #e8e8e8;
}
.goods-item .goods{
    position: relative;
}
.goods {
    font-size: 14px;
    color: #262626;
    height: 180px;
    text-align: center;
}
.goods .goods-tag{
    position: absolute;
}
.goods .goods-image{
    width:140px;
    height: 140px;
}
.goods .desc-wrapper{
    height: 2.5em;
    display: table;
}
.desc-wrapper .goods-desc{
    height: 2.5em;
    overflow: hidden;
    text-align: left;
    display: inline-block;
    vertical-align: middle;
    line-height: 1.25em;
    padding: 0 5px 0 10px;
}
.goods-item .operating{
    position: relative;
    display: flex;
    flex-direction: row;
    font-size: 11px;
    color: #e6324a;
    height: 40px;
    padding: 10px 10px 4px;
}
.operating .btn {
    width: 56px;
    height: 26px;
    right: 5px;
    border-radius: 4px;
    position: absolute;
    line-height: 26px;
    text-align: center;
    border:1px solid #e6324a;
}
.operating .progress{
    height: 5px;
    margin-top:20px;
    margin-right:5px;
    border-radius: 5px;
    position: absolute;
    background-color: #e8e8e8;
}
.operating .progress-take{
    height: 5px;
    margin-top:20px;
    margin-right:5px;
    border-radius: 5px;
    position: absolute;
    background-color: #ffc63c;
}
.operating .tips{
    height:12px;
    color: #686868;
    font-size: 11px;
    line-height: 12px;
    position: absolute;
}
.tips span{
    color: #007aff;
    padding-left: 2px;
}