<?php
/**
 * 购物车小页
 * @return string
 */
function min_cart(){
    $View= new \Common\Vendor\TplView();
    $city_data=init_city();
    $View->assign($city_data);

    $data=D('Common/Cart')->cart_index();
    $View->assign($data);

    $html=$View->fetch('Public/min_cart');
    return $html;
}
/**
 * 城市切换
 * @return array
 */
function init_city(){
    $result = D('Common/Area')->init();//初始化地区信息
    $regioncache = get_arearegion_cache(1);
    $result_format = D('Common/Area')->area_format($regioncache,1);//格式化省信息
    $root['regioncache']=$result_format;
    $root['address_info_format']=$result['address_info_format'];
    $province = Intval($result['address_info']['province']);
    $city = Intval($result['address_info']['city']);
    if($province>0){
        $regioncaches = get_arearegion_cache(0);
        $result_format = D('Common/Area')->area_format($regioncaches[$province]);//格式化市信息
        $root['regioncitycache']=$result_format;
        $root['regioncityon']=$province;
        if($city>0){
            $result_format = D('Common/Area')->area_format($regioncaches[$city]);//格式化区县信息
            $root['regiondistrictcache']=$result_format;
            $root['regiondistricton']=$city;
        }
    }
    return $root;
}
/**
 * 热销商品
 * @number int   显示的数量
 * @return mixed
 */
function hotlist($number){
    $number=$number?$number:5;
    $order='sell_count desc,is_hot desc';
    $field='id,goods_name,img,sell_count,shop_price,market_price';
    $map['status']=1;$map['shop_id']=0;
    $list['list']=M('Goods')->where($map)->order($order)->limit($number)->getField($field,true);
    return $list['list'];
}
?>