Skip to content

Commit 3782baf

Browse files
committed
feat: 完成【首页】、【地区选择】、【筛选】
1. 本地 mock 2. 【首页】骨架屏 + 无限滚动翻页 3. 通过延迟加载加快【地区选择】页的打开速度 4. 将部分颜色提取为全局变量
1 parent 664636f commit 3782baf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1056
-244
lines changed

app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ App({
2020
})
2121
},
2222
globalData: {
23-
userInfo: null
23+
city: null, // 当前选择的城市
2424
}
2525
})

app.json

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"pages": [
3-
"pages/index/index",
4-
"pages/explore/index",
5-
"pages/my/index"
3+
"pages/home/index",
4+
"pages/my/index",
5+
"pages/city-picker/index"
66
],
77
"window": {
88
"backgroundTextStyle": "light",
@@ -12,24 +12,17 @@
1212
},
1313
"tabBar": {
1414
"custom": true,
15-
"color": "#000000",
16-
"selectedColor": "#000000",
17-
"backgroundColor": "#000000",
1815
"list": [
1916
{
20-
"pagePath": "pages/index/index",
17+
"pagePath": "pages/home/index",
2118
"text": "首页"
2219
},
23-
{
24-
"pagePath": "pages/explore/index",
25-
"text": "发现"
26-
},
2720
{
2821
"pagePath": "pages/my/index",
2922
"text": "我的"
3023
}
3124
]
3225
},
33-
"style": "v2",
34-
"sitemapLocation": "sitemap.json"
26+
"sitemapLocation": "sitemap.json",
27+
"lazyCodeLoading": "requiredComponents"
3528
}

app.less

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
/**app.wxss**/
2-
.container {
3-
height: 100%;
4-
display: flex;
5-
flex-direction: column;
6-
align-items: center;
7-
justify-content: space-between;
8-
padding: 200rpx 0;
9-
box-sizing: border-box;
10-
}
2+
@import '/style/global.less';
3+
4+
page {
5+
color: @main-text-color;
6+
font-family: "PingFang SC", sans-serif;
7+
}

custom-tab-bar/index.js

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,31 @@
1-
1+
// custom-tab-bar/index.js
22
Component({
3+
4+
/** 组件的初始数据 */
35
data: {
4-
value: 'index',
5-
list: [{
6-
icon: 'home',
7-
value: 'index',
8-
label: '首页',
9-
},{
10-
icon: 'control-platform',
11-
value: 'explore',
12-
label: '发现',
13-
}, {
14-
icon: 'user',
15-
value: 'my',
16-
label: '我的'
17-
}]
6+
value: '',
7+
list: [
8+
{ value: 'home', label: '首页', icon: 'home' },
9+
{ value: 'my', label: '我的', icon: 'user' },
10+
],
1811
},
1912
lifetimes: {
2013
ready() {
2114
const pages = getCurrentPages();
2215
const curPage = pages[pages.length - 1];
23-
2416
if (curPage) {
2517
const nameRe = /pages\/(\w+)\/index/.exec(curPage.route);
26-
27-
if (nameRe[1]) {
28-
this.setData({
29-
value: nameRe[1]
30-
})
31-
}
18+
if (nameRe && nameRe[1])
19+
this.setData({ value: nameRe[1] })
3220
}
3321
}
3422
},
35-
methods: {
36-
handleChange(e) {
37-
const { value } = e.detail;
3823

39-
// this.setData({ value });
40-
wx.switchTab({
41-
url: `/pages/${value}/index`,
42-
})
43-
}
24+
/** 组件的方法列表 */
25+
methods: {
26+
onChange(event) {
27+
const { value } = event.detail
28+
wx.switchTab({ url: `/pages/${value}/index` })
29+
},
4430
}
4531
})

custom-tab-bar/index.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"component": true,
33
"usingComponents": {
44
"t-tab-bar": "tdesign-miniprogram/tab-bar/tab-bar",
5-
"t-tab-bar-item": "tdesign-miniprogram/tab-bar/tab-bar-item"
5+
"t-tab-bar-item": "tdesign-miniprogram/tab-bar-item/tab-bar-item"
66
}
77
}

custom-tab-bar/index.wxml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<t-tab-bar value="{{value}}" bind:change="handleChange">
2-
<t-tab-bar-item wx:for="{{list}}" wx:key="index" icon="{{item.icon}}" value="{{item.value}}">
3-
{{item.label}}
4-
</t-tab-bar-item>
1+
<!--custom-tab-bar/index.wxml-->
2+
<t-tab-bar value="{{ value }}" bindchange="onChange" theme="tag" split="{{ false }}">
3+
<t-tab-bar-item wx:for="{{ list }}" wx:key="index" value="{{ item.value }}" icon="{{ item.icon }}">{{ item.label }}</t-tab-bar-item>
54
</t-tab-bar>

images/head-bg.png

177 KB
Loading
114 KB
Loading
109 KB
Loading
27.7 KB
Loading

0 commit comments

Comments
 (0)