editTabBar: function () {
var _curPageArr = getCurrentPages();
var _curPage = _curPageArr[_curPageArr.length - 1];
var _pagePath = _curPage.__route__;
if (_pagePath.indexOf('/') != 0) {
_pagePath = '/' + _pagePath;
}
var tabBar = this.globalData.tabBar;
for (var i = 0; i < tabBar.list.length; i++) {
tabBar.list[i].active = false;
if (tabBar.list[i].pagePath == _pagePath) {
tabBar.list[i].active = true;//根据页面地址设置当前页面状态
}
}
_curPage.setData({
tabBar: tabBar
});
},
globalData: {
userInfo: null,
tabBar: {
color: "#a9b7b7",
selectedColor: "#11cd6e",
borderStyle: "white",
list: [
{
selectedIconPath: "/image/roomres1.png",
iconPath: "/image/roomres.png",
pagePath: "/pages/welcome/roomres/roomres",
text: "订房",
clas: "menu-item",
selected: true
},
{
selectedIconPath: "/image/topselling1.png",
iconPath: "/image/topselling.png",
pagePath: "/pages/welcome/topselling/topselling",
text: "爆品",
clas: "menu-item",
selected: false
},
{
selectedIconPath: "/image/questionnaire1.png",
iconPath: "/image/questionnaire.png",
pagePath: "/pages/welcome/socialreaserch/socialreaserch",
text: "调研",
clas: "menu-item",
selected: false
},
{
selectedIconPath: "/image/local1.png",
iconPath: "/image/local.png",
pagePath: "/pages/welcome/local/local",
text: "当地",
clas: "menu-item",
selected: false
},
{
selectedIconPath: "/image/mine1.png",
iconPath: "/image/mine.png",
pagePath: "/pages/welcome/mine/mine",
text: "我的",
clas: "menu-item",
selected: false
}
],
position: "bottom"
}
}
.menu-item{
width: 20%;
float: left;
text-align: center;
padding-top: 8px;
}
.img{
width: 23px;
height: 23px;
display: block;
margin:auto;
}
.clear{
clear: both;
}
.tab-bar{
background-color: white;
position: fixed;
width: 100%;
/* padding: 0px 2%; */
}
1、在需要显示模板导航的.wxml页面配置
导入模板
底部导航会覆盖一部分内容加上
2、在.js页面配置
var app = getApp()
onLoad: function (options) {
app.editTabBar();
},
//获取当前时间戳 var timestamp = Date.parse(new Date()); timestamp = timestamp / 1000; console.log("当前时间戳为:" + timestamp); //获取当前时间 var n = timestamp * 1000; var date = new Date(n); //年 var Y = date.getFullYear(); //月 var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1); //日 var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate(); //时 var h = date.getHours(); //分 var m = date.getMinutes(); //秒 var s = date.getSeconds(); console.log("当前时间:" +Y+M+D+h+":"+m+":"+s); //转换为时间格式字符串 console.log(date.toDateString()); console.log(date.toGMTString()); console.log(date.toISOString()); console.log(date.toJSON()); console.log(date.toLocaleDateString()); console.log(date.toLocaleString()); console.log(date.toLocaleTimeString()); console.log(date.toString()); console.log(date.toTimeString()); console.log(date.toUTCString()); //时间、时间戳加减 以加一天举例,聪明的你肯定触类旁通 //加一天的时间戳: var tomorrow_timetamp = timestamp + 24 * 60 * 60; //加一天的时间: var n_to = tomorrow_timetamp * 1000; var tomorrow_date = new Date(n_to); //加一天后的年份 var Y_tomorrow = tomorrow_date.getFullYear(); //加一天后的月份 var M_tomorrow = (tomorrow_date.getMonth() + 1 < 10 ? '0' + (tomorrow_date.getMonth() + 1) : tomorrow_date.getMonth() + 1); //加一天后的日期 var D_tomorrow = tomorrow_date.getDate() < 10 ? '0' + tomorrow_date.getDate() : tomorrow_date.getDate(); //加一天后的时刻 var h_tomorrow = tomorrow_date.getHours(); //加一天后的分钟 var m_tomorrow = tomorrow_date.getMinutes(); //加一天后的秒数 var s_tomorrow = tomorrow_date.getSeconds();