add file
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
const app = getApp()
|
||||
Component({
|
||||
properties: {
|
||||
navbarData: { //navbarData 由父页面传递的数据,变量名字自命名
|
||||
type: Object,
|
||||
value: {},
|
||||
observer: function (newVal, oldVal) {}
|
||||
}
|
||||
},
|
||||
data: {
|
||||
height: '',
|
||||
//默认值 默认显示左上角
|
||||
navbarData: {
|
||||
showCapsule: 1
|
||||
}
|
||||
},
|
||||
attached: function () {
|
||||
// 获取是否是通过分享进入的小程序
|
||||
this.setData({
|
||||
share: app.globalData.share
|
||||
})
|
||||
// 定义导航栏的高度 方便对齐
|
||||
this.setData({
|
||||
height: app.globalData.height
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
// 返回上一页面
|
||||
_navback() {
|
||||
wx.navigateBack()
|
||||
},
|
||||
//返回到首页
|
||||
_backhome() {
|
||||
wx.navigateTo({
|
||||
url: '/Pages/index/index',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"component": true
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<view class='nav-wrap' style='height: {{height*2 + 10}}px;'>
|
||||
<view class='nav-title' style='line-height: {{height*2 + 44}}px;'>{{navbarData.title}}</view>
|
||||
<view style='display: flex; justify-content: space-around;flex-direction: column'>
|
||||
<view class='nav-capsule' style='height: {{height*2 + 44}}px;' wx:if='{{navbarData.showCapsule}}'>
|
||||
<view bindtap='_navback' wx:if='{{!share}}'>
|
||||
<image style="display: flex;align-items: center;" class='back-pre' src="/static/images/yishi/tabbar_icon/back.png" mode="heightFix"></image>
|
||||
</view>
|
||||
<view class='navbar-v-line' wx:if='{{!share}}'></view>
|
||||
<view bindtap='_backhome'>
|
||||
<image style="display: flex;align-items: center;" class='back-home' src='/static/images/yaoshi/tabbar_icon/home.png' mode='heightFix'></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,54 @@
|
||||
/* 顶部要固定定位 标题要居中 自定义按钮和标题要和右边微信原生的胶囊上下对齐 */
|
||||
.nav-wrap {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
top: 0;
|
||||
background: rgb(255, 255, 255);
|
||||
color: #000;
|
||||
z-index: 9999999;
|
||||
}
|
||||
/* 标题要居中 */
|
||||
.nav-title {
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
max-width: 400rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
margin: auto;
|
||||
font-size: 34rpx;
|
||||
color: #000000;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.nav-capsule {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-left: 30rpx;
|
||||
width: 140rpx;
|
||||
justify-content: space-between;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.navbar-v-line {
|
||||
width: 1px;
|
||||
height: 34rpx;
|
||||
background-color: #000000;
|
||||
}
|
||||
|
||||
.back-pre, .back-home {
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
margin-top: 4rpx;
|
||||
padding: 10rpx;
|
||||
}
|
||||
.nav-capsule .back-home {
|
||||
width: 36rpx;
|
||||
height: 40rpx;
|
||||
margin-top: 3rpx;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user