<?php
/**
 * 店铺中心导航 （可在此处优化规则权限）
 * $type 1 top_nav 2 left_nav 3 tabmenu_nav 4 position_nav(面包屑导航)
 */
function init_shop_index($type){
    if(empty($type))return false;
    $result = $left_nav_result = $tabmenu_nav_result = $tabmenu_nav = array();
    $navarray = array(1=>'top_nav',2=>'left_nav',3=>'tabmenu_nav',4=>'position_nav',);$site_info=session("site_info");
    $result = require_once ROOT_PATH."/Public/data/shop_nav_config7.php";
    $tabid = I('param.tabid');
    foreach($result as $k=>$v){
        if($k==MODULE_NAME){//顶部导航
            $result[$k]['current'] = 1;
            //面包屑导航
            $position_nav_result[0]['name'] = $v['name'];
            $position_nav_result[0]['url'] = geturl($k);
        }
        if($type == 1){unset($result[$k]['son']);}
        foreach($v['son'] as $kk=>$vv){//左部导航
            $left_nav_result[$kk] = $vv;
            if(ucfirst($vv['module']) == MODULE_NAME && $vv['action'] == ACTION_NAME){
                $left_nav_result[$kk]['current'] = 1;
                $position_nav_result[1]['name'] = $vv['name'];
                $position_nav_result[1]['url'] = geturl($vv['module']."/".$vv['action']);
            }
            $left_nav_result[$kk]['url'] = geturl($vv['module']."/index");//默认index控制器
            
            foreach($vv['son'] as $ks=>$vs){//tab切换
                $tabmenu_nav_result[$ks] = $vs;
                if(ucfirst($vv['module']) == MODULE_NAME && $vv['action'] == ACTION_NAME && $vs['tabid'] == $tabid){
                    $tabmenu_nav_result[$ks]['current'] = 1;
                    $position_nav_result[2]['name'] = $vs['name'];
                    $position_nav_result[2]['url'] = geturl($vs['module']."/".$vs['action'],array('tabid'=>$tabid),true,true);
                }
                $tabmenu_nav_result[$ks]['url'] = geturl($vs['module']."/".$vs['action'],array('tabid'=>$tabid),true,true);
                
            }
        } 
        
	}
    $View= new \Common\Vendor\TplView();
    if($type == 1){
        $View->assign('index_nav_list',$result);
    }elseif($type == 2){
        $View->assign('index_nav_list',$left_nav_result);
    }elseif($type == 3){
        $View->assign('index_nav_list',$tabmenu_nav_result);
    }elseif($type == 4){
        $View->assign('index_nav_list',$position_nav_result);
    }
    $index_nav_content=$View->fetch('Public/'.$navarray[$type].".html");
    return $index_nav_content;
}
/**
 * echarts 数组按时间格式化，填补时间中空值为0
 * @param  $array       所有需要格式化的数组
 * @param  $arraykey    所有需要格式化的键名
 */
function echarts_time_formarts($array,$arraykey){
    foreach($arraykey as $k1 => $v1){       //空值补零
        foreach($array as $k2 => $v2){
            if(empty($v2[$v1])){$array[$k2][$v1] =0;}
        }   
    }
    foreach($array as $k1 => $v1){ksort($array[$k1]);}          //按时间排序排序
    return $array;
}
/**
    * 获取订货中心首页楼层内容
    * @return str 返回完整的楼层数据
    */
function get_index_floor_content(){
    /*$where['status'] = 1;
    $where['device'] = 0;
    $floor_list=M('Floor')->where($where)->field(true)->order('sort asc,id desc')->select();
    $floorontent='';
    $PurchaseCategory=getcache('PurchaseCategory');
    foreach($floor_list as $key=>$val){
        $goods_num = 8;//调取商品数量
        $index_list_goods=$recommend_cate_arr=array();
        if(empty($val['recommend_cate'])){
            $val['recommend_cate']=$val['bind_cateid'];
        }
        $recommend_cate=explode(',',$val['recommend_cate']);
        foreach($recommend_cate as $k=>$v){
            $v_map['cat_id']=$v;
            $recommend_cate_arr[$v]=$PurchaseCategory[$v];
            $index_list_goods[$v]=D('Common/Goods')->get_goods_list(0,$v_map,'','',1,$goods_num);
        }
        $View= new \Common\Vendor\TplView();
        $View->assign('floorinfo',$val);
        $View->assign('recommend_cate_arr',$recommend_cate_arr);
        $View->assign('index_list_goods',$index_list_goods);
        $floorontent.=$View->fetch('FloorTheme/'.$val['theme']);
    }
    return $floorontent;*/
}
?>