function initTabbar() {
NVTabBar.open({
styles: {
bg: '#fff',
h: 48,
dividingLine: {
width: 0.5,
color: '#ddd'
},
badge: {
bgColor: '#ff0',
numColor: '#fff',
size: 6.0,
fontSize: 10,
centerX: 6.0,
centerY: 6.0
}
},
items: [{
w: api.winWidth / 3.0,
bg: {
marginB: -4,
image: 'rgba(0,0,0,0)',
},
iconRect: {
w: 26.0,
h: 26.0,
},
icon: {
normal: 'widget://image/tabbar/home.png',
highlight: 'widget://image/tabbar/home_s.png',
selected: 'widget://image/tabbar/home_s.png'
},
title: {
text: '首页',
size: 10.0,
normal: '#4d3833',
selected: '#f38900',
marginB: 4.0
}
}, {
w: api.winWidth / 3.0,
bg: {
marginB: -4,
image: 'rgba(0,0,0,0)',
},
iconRect: {
w: 26.0,
h: 26.0,
},
icon: {
normal: 'widget://image/tabbar/course.png',
highlight: 'widget://image/tabbar/course_s.png',
selected: 'widget://image/tabbar/course_s.png'
},
title: {
text: '课程',
size: 10.0,
normal: '#4d3833',
selected: '#f38900',
marginB: 4.0
}
}, {
w: api.winWidth / 3.0,
bg: {
marginB: -4,
image: 'rgba(0,0,0,0)',
},
iconRect: {
w: 26.0,
h: 26.0,
},
icon: {
normal: 'widget://image/tabbar/mine.png',
highlight: 'widget://image/tabbar/mine_s.png',
selected: 'widget://image/tabbar/mine_s.png'
},
title: {
text: '我的',
size: 10.0,
normal: '#4d3833',
selected: '#f38900',
marginB: 4.0
}
}],
selectedIndex: 0
}, function(ret, err) {
if (ret) {
if (ret && ret.eventType == 'click') {
if(ret.index == 2){
var token = $func.getToken();
if(token){
tabbarIndex_ = ret.index;
fnOpenFrame(ret.index);
}else{
api.sendEvent({
name: 'openLoginWin'
});
loginCallback = function(){
fnOpenFrame(2);
}
}
}else{
tabbarIndex_ = ret.index;
fnOpenFrame(ret.index);
}
}
}
});
}
代码如上