Files
lichebao/components/navBar/navBar.js
T
2021-07-04 18:09:48 +08:00

96 lines
1.8 KiB
JavaScript

import Utils from '../../commons/js/utils/util'
Component({
/**
* 组件的属性列表
*/
properties: {
titleText: {
type: String,
value: ''
},
txtColor: {
type: String,
value: 'transparent'
},
bgColor: {
type: String,
value: '#fe2643'
},
isShowBg: {
type: Boolean,
value: false
},
type: {
type: String,
value: ''
},
city:{
type: String,
value: ''
},
homeShowBar:{
type: Boolean,
value: true
},
homeShowTitle:{
type: Boolean,
value: false
}
},
attached: function () {
this.setNavSize()
},
data: {
isShowRetBtn: false,
isShowHomeBtn: false,
homeInfo:{
placeholder: '搜索城市好店、好评...',
url: '/pages/search/index'
}
},
pageLifetimes: {
show: function () {
let pages = getCurrentPages();
if (pages.length == 1) {
this.setData({
isShowRetBtn: true
})
}
if (Utils.getCurrentPath().url == 'pages/index/index') {
this.setData({
isShowHomeBtn: true
})
}
},
},
methods: {
// 通过获取系统信息计算导航栏高度
setNavSize: function () {
var that = this,
sysinfo = wx.getSystemInfoSync(),
statusHeight = sysinfo.statusBarHeight,
isiOS = sysinfo.system.indexOf('iOS') > -1,
navHeight;
if (!isiOS) {
navHeight = 48;
} else {
navHeight = 44;
}
that.setData({
status: statusHeight,
navHeight: navHeight
})
},
// 返回事件
back: function () {
wx.navigateBack({
delta: 1
})
},
home: function () {
wx.switchTab({
url: '/pages/index/index'
})
}
}
})