4 changed files with 92 additions and 64 deletions
@ -1,55 +1,60 @@ |
|||||
// components/navigationBar.js
|
// components/navigationBar.js
|
||||
Component({ |
Component({ |
||||
|
/** |
||||
/** |
* 组件的属性列表 |
||||
* 组件的属性列表 |
*/ |
||||
*/ |
properties: { |
||||
properties: { |
title: { |
||||
title:{ |
type: String, |
||||
type: String, |
value: "续期提醒", |
||||
value: '续期提醒' |
}, |
||||
}, |
backgroundImage: { |
||||
backgroundImage:{ |
type: String, |
||||
type: String, |
value: "", |
||||
value: '' |
}, |
||||
}, |
isSowArrow: { |
||||
isSowArrow:{ |
type: Boolean, |
||||
type: Boolean, |
value: false, |
||||
value: false |
}, |
||||
}, |
isShowBg: { |
||||
isShowBg:{ |
type: Boolean, |
||||
type: Boolean, |
value: false, |
||||
value: false |
|
||||
}, |
|
||||
height:{ |
|
||||
type:String, |
|
||||
value:'' |
|
||||
} |
|
||||
}, |
}, |
||||
|
height: { |
||||
|
type: String, |
||||
|
value: "", |
||||
|
}, |
||||
|
titleAlign: { |
||||
|
type: String, |
||||
|
value: "center", // 默认居中对齐
|
||||
|
}, |
||||
|
}, |
||||
|
|
||||
/** |
/** |
||||
* 组件的初始数据 |
* 组件的初始数据 |
||||
*/ |
*/ |
||||
data: { |
data: { |
||||
// 状态栏高度
|
// 状态栏高度
|
||||
statusBarHeight: wx.getStorageSync('statusBarHeight') + 'px', |
statusBarHeight: wx.getStorageSync("statusBarHeight") + "px", |
||||
// 导航栏高度
|
// 导航栏高度
|
||||
navigationBarHeight: wx.getStorageSync('navigationBarHeight') + 'px', |
navigationBarHeight: wx.getStorageSync("navigationBarHeight") + "px", |
||||
// 胶囊按钮高度
|
// 胶囊按钮高度
|
||||
menuButtonHeight: wx.getStorageSync('menuButtonHeight') + 'px', |
menuButtonHeight: wx.getStorageSync("menuButtonHeight") + "px", |
||||
// 导航栏和状态栏高度
|
// 导航栏和状态栏高度
|
||||
navigationBarAndStatusBarHeight: wx.getStorageSync('statusBarHeight') + wx.getStorageSync('navigationBarHeight') + 'px' |
navigationBarAndStatusBarHeight: |
||||
|
wx.getStorageSync("statusBarHeight") + |
||||
|
wx.getStorageSync("navigationBarHeight") + |
||||
|
"px", |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 组件的方法列表 |
||||
|
*/ |
||||
|
methods: { |
||||
|
handleGoToBack() { |
||||
|
wx.navigateBack({ |
||||
|
delta: 1, |
||||
|
}); |
||||
}, |
}, |
||||
|
}, |
||||
/** |
}); |
||||
* 组件的方法列表 |
|
||||
*/ |
|
||||
methods: { |
|
||||
handleGoToBack(){ |
|
||||
wx.navigateBack({ |
|
||||
delta: 1 |
|
||||
}) |
|
||||
} |
|
||||
} |
|
||||
}) |
|
||||
|
@ -1,18 +1,31 @@ |
|||||
<!-- components/navigationBar.wxml --> |
<!-- components/navigationBar.wxml --> |
||||
<view class="navigation-container" style="{{'height: ' + navigationBarAndStatusBarHeight}}"> |
<view class="navigation-container" style="{{'height: ' + navigationBarAndStatusBarHeight}}"> |
||||
<view class="navbg" wx:if="{{isShowBg && backgroundImage}}" style="background-image:url({{backgroundImage}}); background-size: 100% 100%; background-repeat: no-repeat; height: {{height}}"> |
<view class="navbg" wx:if="{{isShowBg && backgroundImage}}" style="background-image:url({{backgroundImage}}); background-size: 100% 100%; background-repeat: no-repeat; height: {{height}}"> |
||||
<!-- 空白来占位状态栏 --> |
<!-- 空白来占位状态栏 --> |
||||
<view style="{{'height: ' + statusBarHeight}}"></view> |
<view style="{{'height: ' + statusBarHeight}}"></view> |
||||
<!-- 自定义导航栏 --> |
<!-- 自定义导航栏 --> |
||||
|
<view class="navigation-bar" style=" height: {{navigationBarHeight}}"> |
||||
<view class="navigation-bar" style=" height: {{navigationBarHeight}}"> |
<view class="arrow-content"> |
||||
<view class="arrow-content"> |
<view class="arrow" wx:if="{{isSowArrow}}" bindtap="handleGoToBack"></view> |
||||
<view class="arrow" wx:if="{{isSowArrow}}" bindtap="handleGoToBack"></view> |
</view> |
||||
</view> |
<view class="navigation-title {{titleAlign === 'left' ? 'left-align' : 'center-align'}}" style="{{'line-height:' + navigationBarHeight}}"> |
||||
<view class="navigation-title" style="{{'line-height:' + navigationBarHeight}}">{{title}}</view> |
{{title}} |
||||
</view> |
</view> |
||||
</view> |
</view> |
||||
|
</view> |
||||
|
<view class="navbg" wx:else> |
||||
|
<!-- 空白来占位状态栏 --> |
||||
|
<view style="{{'height: ' + statusBarHeight}}"></view> |
||||
|
<!-- 自定义导航栏 --> |
||||
|
<view class="navigation-bar" style=" height: {{navigationBarHeight}}"> |
||||
|
<view class="arrow-content"> |
||||
|
<view class="arrow" wx:if="{{isSowArrow}}" bindtap="handleGoToBack"></view> |
||||
|
</view> |
||||
|
<view class="navigation-title {{titleAlign === 'left' ? 'left-align' : 'center-align'}}" style="{{'line-height:' + navigationBarHeight}}"> |
||||
|
{{title}} |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
</view> |
</view> |
||||
<!-- 空白占位fixed空出的位置 --> |
<!-- 空白占位fixed空出的位置 --> |
||||
<view style="{{'height: ' + navigationBarAndStatusBarHeight}}"></view> |
<view style="{{'height: ' + navigationBarAndStatusBarHeight}}"></view> |
Loading…
Reference in new issue