重点在js!!!!!思路!!!
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>index</title>
<link rel="stylesheet" type="text/css" href="../css/aui.css" />
<style>
#header {
width:100%;
height:3.5rem;
background:#fff;
text-align:center;
line-height:2.2rem;
}
#header .aui-tab {
background:none;
}
.aui-bar-tab-label {
color:#656565;
}
.aui-active .aui-bar-tab-label {
color:#282828;
}
.aui-icon-home01 {
background:url(../image/my_tab01.png) no-repeat center center;
display:block;
background-size:1.1rem 1.1rem;
}
.aui-icon-my01 {
background:url(../image/my_tab02.png) no-repeat center center;
display:block;
background-size:1.1rem 1.1rem;
}
.aui-active .aui-icon-home01 {
background:url(../image/my_tab01_h.png) no-repeat center center;
background-size:1.1rem 1.1rem;
}
.aui-active .aui-icon-my01 {
background:url(../image/my_tab02_h.png) no-repeat center center;
background-size:1.1rem 1.1rem;
}
/*微招聘/发现/精英库 未选中*/
.aui-icon-job{
background:url(../image/my_job.png) no-repeat center center;
display:block;
background-size:1.1rem 1.1rem;
}
.aui-icon-find{
background:url(../image/my_find.png) no-repeat center center;
display:block;
background-size:1.1rem 1.1rem;
}
.aui-icon-cream{
background:url(../image/my_cream.png) no-repeat center center;
display:block;
background-size:1.1rem 1.1rem;
}
/*微招聘/发现/精英库 已选中*/
.aui-active .aui-icon-job {
background:url(../image/my_job_on.png) no-repeat center center;
background-size:1.1rem 1.1rem;
}
.aui-active .aui-icon-find {
background:url(../image/my_find_on.png) no-repeat center center;
background-size:1.1rem 1.1rem;
}
.aui-active .aui-icon-cream {
background:url(../image/my_cream_on.png) no-repeat center center;
background-size:1.1rem 1.1rem;
}
</style>
</head>
<body>
<header id="header" class="aui-bar aui-bar-nav" style="border-bottom:0.05rem solid #ddd;">
<a class="aui-pull-left aui-btn" tapmode onclick="fnOpenSearch()">
<span class="aui-iconfont aui-icon-search" style="color:#282828;"></span>
</a>
<div class="aui-tab aui-title" id="tab">
<div class="aui-tab-item aui-active" tapmode onclick="changeGroupIndex(0)">活动</div>
<div class="aui-tab-item" tapmode onclick="changeGroupIndex(1)">文章</div>
<div class="aui-tab-item" tapmode onclick="changeGroupIndex(2)">订阅</div>
</div>
<a class="aui-pull-right aui-btn" tapmode onclick="fnOpenList()">
<span class="aui-iconfont aui-icon-menu" style="color:#282828;"></span>
</a>
</header>
<footer class="aui-bar aui-bar-tab" id="footer">
<div class="aui-bar-tab-item aui-active" tapmode onclick="fnOpenTabFrame(0)">
<i class="aui-iconfont aui-icon-home01"></i>
<div class="aui-bar-tab-label">直播</div>
</div>
<div class="aui-bar-tab-item" tapmode onclick="fnOpenTabFrame(1)">
<i class="aui-iconfont aui-icon-job"></i>
<div class="aui-bar-tab-label">微招聘</div>
</div>
<div class="aui-bar-tab-item" tapmode onclick="fnOpenTabFrame(2)">
<i class="aui-iconfont aui-icon-find"></i>
<div class="aui-bar-tab-label">发现</div>
</div>
<div class="aui-bar-tab-item" tapmode onclick="fnOpenTabFrame(3)">
<i class="aui-iconfont aui-icon-cream"></i>
<div class="aui-bar-tab-label">精英库</div>
</div>
<div class="aui-bar-tab-item" tapmode onclick="fnOpenTabFrame(4)">
<i class="aui-iconfont aui-icon-my01"></i>
<div class="aui-bar-tab-label">我的</div>
</div>
</footer>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
apiready = function(){
fnInitEventListenner();
header = $api.byId('header');;
var footer = $api.byId('footer');
$api.fixStatusBar(header);
headerH = $api.offset(header).h;
footerH = $api.offset(footer).h;
menus = $api.domAll(footer, '.aui-bar-tab-item');
tabBars = $api.domAll(header, '.aui-tab-item');
api.setStatusBarStyle({
style: 'dark'
});
api.openFrame({
name: '',
url: '',
bounces: false,
rect: {
x: 0,
y: headerH,
w: 'auto',
h: 'auto',
marginBottom:footerH
}
});
api.openFrameGroup({
name: 'indexFrameGroup',
background: '#fff',
scrollEnabled: true,
rect: {
x: 0,
y: headerH,
w: 'auto',
h: 'auto',
marginBottom:footerH
},
index: 1,
frames:[
{
name: 'index_frame0',
url: './index_frame0.html',
pageParam:{},
bounces:true,
opaque:true,
bgColor: '#fff'
},{
name: 'index_frame1',
url: './index_frame1.html',
pageParam:{},
bounces:false,
opaque:true,
bgColor: '#fff'
},{
name: 'index_frame2',
url: './index_frame2.html',
pageParam:{},
bounces:false,
opaque:true,
bgColor: '#fff'
}
]
}, function(ret, err){
var name = ret.name;
var index = ret.index;
fnSetTabBarsSelected(index);
});
}
//打开frame
var header;
var headerH;
var footerH;
function fnOpenTabFrame(index_) {
var aIndex = [{
isgroup: false
}, {
name: 'job',
url: 'job.html',
isgroup: true
}, {
name: 'find',
url: 'find.html',
isgroup: true
}, {
name: 'cream',
url: 'cream.html',
isgroup: true
}, {
name: 'my',
url: 'my.html',
isgroup: true,
event: 'event_my_refresh'
}
];
fnSetNavMenuIndex(index_);
for (var i = 0; i < aIndex.length; i++) {
var obj = aIndex[i];
//当前被点击的
if (i === index_) {
api.setFrameGroupAttr({
name: 'indexFrameGroup',
hidden: obj.isgroup
});
if (obj.url) {
api.openFrame({
name: 'my',
url: './my.html',
bounces: false,
rect: {
x: 0,
y: 0,
w: 'auto',
h: 'auto',
marginBottom: footerH
}
});
}
if (obj.event) {
api.sendEvent({
name: obj.event,
extra: {}
});
}
} else {
//其他项
if (obj.name) {
api.setFrameAttr({
name: obj.name,
hidden: true
});
}
}
}
}
function changeGroupIndex(index_) {
fnSetTabBarsSelected(index_);
api.setFrameGroupIndex({
name: 'indexFrameGroup',
index: index_,
scroll: true
});
}
function fnInitEventListenner() {
api.addEventListener({
name:'keyback'
}, function(ret, err){
api.confirm({
title: '提示',
msg: '是否退出应用',
buttons: ['确定', '取消']
}, function(ret, err){
if( ret.buttonIndex == 1 ){
api.closeWidget();
}
});
});
}
var menus;
function fnSetNavMenuIndex(index_) {
fnSetNavMenuSelected(index_);
if (index_ == 0) {
header.style.display = 'block';
} else{
header.style.display = 'none';
}
}
var menus;
function fnSetNavMenuSelected(index_) {
for(var i = 0; i<menus.length; i++ ) {
if( index_ == i) {
$api.addCls(menus[i], 'aui-active');
} else {
$api.removeCls(menus[i], 'aui-active');
}
}
}
var tabBars;
function fnSetTabBarsSelected(index_) {
for(var i = 0; i<tabBars.length; i++ ) {
if( index_ == i) {
$api.addCls(tabBars[i], 'aui-active');
} else {
$api.removeCls(tabBars[i], 'aui-active');
}
}
}
function fnOpenPersonCenterWin(argument) {
var isLogin = false;
if (isLogin) {
;
} else {
api.openWin({
name: 'login',
url: './login.html',
pageParam: {
name: 'test'
}
});
}
}
function fnOpenSearch(){
api.openWin({
name: 'index_ss',
url: './index_ss.html',
pageParam:{'headerH':headerH}
});
}
function fnOpenList(){
api.openWin({
name: 'index_list',
url: './index_list.html',
pageParam:{'headerH':headerH}
});
}
</script>
</html>
网友评论