帖子
帖子
用户
博客
课程
显示全部楼层
2
帖子
0
勋章
10
Y币

[其他] id=left中onclick在区域内没有动作,fnOpenCitySelectorFrame没问题

[复制链接]
发表于 2018-7-22 10:01:34
<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <style>
header{
     position: relative;
     width: 100%;
     height: 50px;
     background-color: #e1017e;
}
header .left{
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100px;
  height: 50px;
  background-color: #fff;
}
header .left .arrow{
  position: absolute;
  bottom: 21px;
  left: 11px;
  width: 13px;
  height: 8px;
  background: url(../image/arrow_down.png);
  background-size: 13px 8px;
  background-position: center center;
  background-repeat: no-repeat;

}
header .left .city{
  position:relative;
  width: 100%;
  height: 50px;
  color: #fff;
  font-size: 14px;
  padding-left: 27px;
  line-height: 50px;


}
header .center{
  position: relative;
  width: 100%;
  height: 50px;
  background: url(../image/home_title.png);
  background-size: 74px 19px;
  background-position: center center;
  background-repeat: no-repeat;
}
header .right
{
   position: absolute;
   bottom: 0;
   right: 0;
   width: 40px;
   height: 50px;
   background: url(../image/home_membercenter.png);
   background-size: 30px 30px;
   background-position: center center;
   background-repeat: no-repeat;

}


nav{
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-blox-orient:horizontal;
  -webkit-flex-flow:row;
  flex-flow:row;
  position: relative;
  width: 100%;
  height: 40px;
  background-color: #e1017e;
}
nav .menu{
  -webkit-box-flex:1;
  -webkit-flex:1;
  flex:1;
  width: 100%;
  height: 40px;
  line-height: 40px;
  font-size: 13px;
  color: #f973b8;
  text-align:center;

}
nav .menu.seclted{
   font-size: 14px;
   color: #fff;
   font-weight: bolder;
  }
    </style>
</head>

<body>
<header id="header">
    <div class="left"  tapmode>
      <div class="arrow" id="arrow"></div>
      <div class="city" id="city" >北京市</div>
    </div>
    <div class="center">  </div>
    <div class="right" tapmode></div>
</header>
<nav id="nav">
  <div class="menu seclted" tapmode="seclted">水果</div>
  <div class="menu" tapmode="seclted"  onclick="fnSetNavMenuIndex(1);">食材</div>
  <div class="menu"  tapmode>零食</div>
  <div class="menu"   tapmode>牛奶</div>
  <div class="menu" tapmode  onclick="fnSetNavMenuIndex(4);">蔬菜</div>
</nav>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
var headerH;
var navH;
     apiready = function() {
       fnInitEventListenner();
      var header = $api.byId('header');
      var nav = $api.byId('nav');
      $api.fixStatusBar(header);
       headerH=$api.offset(header).h;
       navH=$api.offset(nav).h;
       menus=$api.domAll(nav,'.menu');

      var frames=[];
      for(var i=0;i<menus.length;i++)
      {

        frames.push(
          {
              name: 'main_frame_'+i,
              url: './main_frame.html'
          }
        );
      }
      api.openFrameGroup ({
          name: 'mainFrameGroup',
          scrollEnabled: true,
          rect: {
               x: 0,
               y: headerH+navH,
               w: 'auto',
               h: 'auto'
          },
          index: 0,
          frames:frames
      }, function(ret, err){
        fnSetNavMenuSelected(ret.index);
      });

    };
var menus;
function fnOpenCitySelectorFrame()
{

     api.openFrame({
         name: 'cityselector_framem',
         url: './cityselector_framem.html',
         rect: {
             x: 0,
             y: headerH,
             w: 'auto',
             h: 'auto'
         },

         bgColor: 'rgba(0,0,0,0.8)',
         vScrollBarEnabled: true,
         hScrollBarEnabled: true
     });

}
function fnInitEventListenner()
{
  api.addEventListener({
      name: 'keyback'     //名字要和api事件所描述的相同
  }, function(ret, err){
      api.confirm({
          title: '提示',
          msg: '是否退出应用',
          buttons: ['确定', '取消']
      }, function(ret, err){
          if(ret.buttonIndex==1){
            api.closeWidget();

          }
      });

  });

}
function fnOpenPersonCenter()
{
  var isLogin=false;
  if(isLogin)
  {

  }else {
    api.openWin({
        name: 'login',
        url: './login.html',
        pageParam: {
            name: 'test'
        }
    });

  }
}
function fnSetNavMenuIndex(index_)
{
  fnSetNavMenuSelected(index_)
  api.setFrameGroupIndex({
      name: 'mainFrameGroup',
      index: index_,
      scroll: true
  });

}
function fnSetNavMenuSelected(index_)
{

    for(var i=0;i<menus.length;i++)
       {
          if(index_==i)
          {
            $api.addCls(menus[i], 'seclted');
          }else {
            $api.removeCls(menus[i], 'seclted');
          }
       }
}
</script>

</html>


380
帖子
4
勋章
6
Y币
标签上没有onclick事件
您需要登录后才可以回帖 登录

本版积分规则