Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 完成【我的】 #17

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: 完成【主页】
LindsBravill committed Sep 17, 2023

Unverified

This user has not yet uploaded their public signing key.
commit b0ecd0450c6d47ee65909407d7ab9e98645665e7
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -28,4 +28,4 @@ module.exports = {
},
// extends: 'eslint:recommended',
rules: {},
}
}
26 changes: 24 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
@@ -18,8 +18,30 @@ App({
}
})
})

// 获取topbar相关信息
const that = this;
// 顶部状态栏的信息
const systemInfo = wx.getSystemInfoSync();
// 胶囊按钮位置信息
const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
// 导航栏高度 = 状态栏到胶囊的间距(胶囊距上距离-状态栏高度) * 2 + 胶囊高度 + 状态栏高度
that.globalData.navBarHeight = (menuButtonInfo.top - systemInfo.statusBarHeight) * 2 + menuButtonInfo.height + systemInfo.statusBarHeight;
that.globalData.menuRight = systemInfo.screenWidth - menuButtonInfo.right;
that.globalData.menuBottom = menuButtonInfo.top - systemInfo.statusBarHeight;
that.globalData.menuHeight = menuButtonInfo.height;
that.globalData.menuWidth = menuButtonInfo.width;
that.globalData.statusBarHeight = systemInfo.statusBarHeight;
},
globalData: {
userInfo: null
userInfo: null,

// 自定义topbar相关信息
navBarHeight: 0, // 导航栏高度
statusBarHeight: 0, // 状态栏的高度
menuRight: 0, // 胶囊距右方间距(保持左、右间距一致)
menuBottom: 0, // 胶囊距底部间距(保持底部间距一致)
menuHeight: 0, // 胶囊高度(自定义内容可与胶囊高度保证一致)
menuWidth: 0, // 胶囊宽度(自定义内容可与胶囊宽度保证一致)
}
})
})
17 changes: 8 additions & 9 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"pages": [
"pages/index/index",
"pages/explore/index",
"pages/home/index",
"pages/my/index"
],
"window": {
@@ -17,19 +16,19 @@
"backgroundColor": "#000000",
"list": [
{
"pagePath": "pages/index/index",
"pagePath": "pages/home/index",
"text": "首页"
},
{
"pagePath": "pages/explore/index",
"text": "发现"
},
{
"pagePath": "pages/my/index",
"text": "我的"
}
]
},
"style": "v2",
"sitemapLocation": "sitemap.json"
"sitemapLocation": "sitemap.json",
"permission": {
"scope.userLocation": {
"desc": "您的位置信息仅用于当前小程序中获取定位"
}
}
}
25 changes: 25 additions & 0 deletions components/info-card/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// components/info-card/index.js
Component({
/**
* 组件的属性列表
*/
properties: {
data: {
"type": Object,
"value": {}
}
},

/**
* 组件的初始数据
*/
data: {
},

/**
* 组件的方法列表
*/
methods: {

}
})
7 changes: 7 additions & 0 deletions components/info-card/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"component": true,
"usingComponents": {
"t-image": "tdesign-miniprogram/image/image",
"stars-mark": "/components/stars-mark/index"
}
}
38 changes: 38 additions & 0 deletions components/info-card/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* components/info-card/index.wxss */
.card {
height: 120px;
width: 343px;
margin: 16px auto;
border-radius: 9px;
overflow: hidden;
background: #ffffff;
box-shadow: 0 6px 30px 5px #0000000d, 0 16px 24px 2px #0000000a, 0 8px 10px -5px #00000014;

.info {
height: 100%;
width: auto;
background-color: #fff;
display: inline-flex;
flex-direction: column;
justify-content: space-around;
padding-left: 16px;

.name {
color: #000000e6;
font-size: 14px;
font-weight: 400;
font-family: "PingFang SC";
text-align: left;
line-height: 22px;
}

.price {
color: #000000e6;
font-size: 14px;
font-weight: 600;
font-family: "PingFang SC";
text-align: left;
line-height: 22px;
}
}
}
10 changes: 10 additions & 0 deletions components/info-card/index.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!--components/info-card/index.wxml-->
<view class="card">
<t-image src="{{data.imgUrl}}" mode="aspectFill" width="120px" height="100%" class="imag" />
<view class="info">
<text class="name">{{data.name}}</text>
<stars-mark score="{{data.score}}"/>
<text class="price" wx:if="{{!data.free}}">¥{{data.floorPrice}} -¥{{data.ceilingPrice}}</text>
<text class="price" wx:if="{{data.free}}">{{data.free}}</text>
</view>
</view>
25 changes: 25 additions & 0 deletions components/stars-mark/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// components/stars-mark/index.js
Component({
/**
* 组件的属性列表
*/
properties: {
score: {
"type": Number,
"value": ""
}
},

/**
* 组件的初始数据
*/
data: {
},

/**
* 组件的方法列表
*/
methods: {

}
})
6 changes: 6 additions & 0 deletions components/stars-mark/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"t-icon": "tdesign-miniprogram/icon/icon"
}
}
45 changes: 45 additions & 0 deletions components/stars-mark/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* components/stars-mark/index.wxss */
.score {
height: 20px;
width: 143.6px;
font-size: 12px;
font-weight: 600;
font-family: "PingFang SC";
line-height: 20px;
display: inline-flex;
position: relative;

.stars-container {
display: inline-flex;
width: 100.6px;
position: relative;

.stars-background {
color: #dcdcdc;
display: inline-flex;
padding-top: 2px;

view {
padding-right: 5.15px;
}
}

.stars {
color: #e37318;
display: inline-flex;
padding-top: 2px;
position: absolute;
overflow: hidden;

view {
padding-right: 5.15px;
}
}
}

text {
color: #e37318;
position: absolute;
right: 0;
}
}
20 changes: 20 additions & 0 deletions components/stars-mark/index.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--components/stars-mark/index.wxml-->
<view class="score">
<view class="stars-container">
<view class="stars-background">
<t-icon name="star-filled" size="16px" />
<t-icon name="star-filled" size="16px" />
<t-icon name="star-filled" size="16px" />
<t-icon name="star-filled" size="16px" />
<t-icon name="star-filled" size="16px" />
</view>
<view class="stars" style="width: {{score*16 + (score-0.5)*5.15}}px">
<t-icon name="star-filled" size="16px" />
<t-icon name="star-filled" size="16px" />
<t-icon name="star-filled" size="16px" />
<t-icon name="star-filled" size="16px" />
<t-icon name="star-filled" size="16px" />
</view>
</view>
<text>{{score}}分</text>
</view>
4 changes: 4 additions & 0 deletions config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const config = {
// 是否使用mock数据代替api返回
useMock: true
}
11 changes: 4 additions & 7 deletions custom-tab-bar/index.js
Original file line number Diff line number Diff line change
@@ -4,13 +4,10 @@ Component({
value: 'index',
list: [{
icon: 'home',
value: 'index',
value: 'home',
label: '首页',
},{
icon: 'control-platform',
value: 'explore',
label: '发现',
}, {
},
{
icon: 'user',
value: 'my',
label: '我的'
@@ -24,7 +21,7 @@ Component({
if (curPage) {
const nameRe = /pages\/(\w+)\/index/.exec(curPage.route);

if (nameRe[1]) {
if (nameRe) {
this.setData({
value: nameRe[1]
})
4 changes: 2 additions & 2 deletions custom-tab-bar/index.json
Original file line number Diff line number Diff line change
@@ -2,6 +2,6 @@
"component": true,
"usingComponents": {
"t-tab-bar": "tdesign-miniprogram/tab-bar/tab-bar",
"t-tab-bar-item": "tdesign-miniprogram/tab-bar/tab-bar-item"
}
"t-tab-bar-item": "tdesign-miniprogram/tab-bar-item/tab-bar-item"
}
}
4 changes: 2 additions & 2 deletions custom-tab-bar/index.wxml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<t-tab-bar value="{{value}}" bind:change="handleChange">
<t-tab-bar-item wx:for="{{list}}" wx:key="index" icon="{{item.icon}}" value="{{item.value}}">
<t-tab-bar value="{{value}}" bindchange="handleChange" theme="tag" split="{{false}}">
<t-tab-bar-item wx:for="{{list}}" wx:key="index" value="{{item.value}}" icon="{{item.icon}}">
{{item.label}}
</t-tab-bar-item>
</t-tab-bar>
Loading