85 lines
1.9 KiB
JavaScript
85 lines
1.9 KiB
JavaScript
const app = getApp()
|
|
// component/Nav/index.js
|
|
Component({
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
Text:{
|
|
type:String,
|
|
value:"衡水喜屏智慧社区"
|
|
},
|
|
NavPosition:{
|
|
type:String,
|
|
value:'fixed'
|
|
},
|
|
backColor:{
|
|
type:String,
|
|
value:"#000"
|
|
},
|
|
backSize:{
|
|
type:String,
|
|
value:"36rpx"
|
|
},
|
|
backImg:{
|
|
type:String,
|
|
value:"arrow-left"
|
|
},
|
|
pageUrl:{
|
|
type:String,
|
|
value:""
|
|
},
|
|
//返回上一页的类型 0返回上一页 1去底部导航 2不保留当前页面跳转 除了0其他必须有pageUrl
|
|
backType:{
|
|
type:String,
|
|
value:0
|
|
},
|
|
color:{
|
|
type:String,
|
|
value:'#000'
|
|
},
|
|
showBack:{
|
|
type:Boolean,
|
|
value:true
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
s: app.system.statusBarHeight, // 状态栏高度
|
|
n: (app.menu.top - app.system.statusBarHeight) * 2 + app.menu.height, // 导航栏高度
|
|
t: app.menu.top, // 胶囊局顶部距离
|
|
h: app.menu.height, // 胶囊高度
|
|
|
|
},
|
|
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
handleNavigateBack(){
|
|
let that = this
|
|
if(that.data.backType == 0){
|
|
wx.navigateBack({
|
|
delta:1
|
|
})
|
|
}else if(that.data.backType == 1 && that.data.pageUrl){
|
|
wx.switchTab({
|
|
url: `/pages/${that.data.pageUrl}/${that.data.pageUrl}`,
|
|
})
|
|
}else if(that.data.backType == 2 && that.data.pageUrl){
|
|
wx.redirectTo({
|
|
url: `/pages/${that.data.pageUrl}/${that.data.pageUrl}`,
|
|
})
|
|
}else if(that.data.backType != 0){
|
|
wx.showToast({
|
|
title: '请传pageUrl',
|
|
icon:"none"
|
|
})
|
|
}
|
|
},
|
|
}
|
|
})
|