public function baseinfo()
 {
     $business = $GLOBALS['db']->getRow("SELECT * FROM " . DB_PREFIX . "supplier_location WHERE `id` = " . $this->location_id);
     // 城市列表
     $city = D('AreaNew');
     $city_list = $city->order("`sort` DESC")->select();
     $city_tree = list_to_tree($city_list, $pk = 'id', $pid = 'pid', $child = '_child', $root = 0);
     $city_tree2 = tree_to_list2($city_tree);
     $prov = D('AreaNew')->where("`pid` = 0")->select();
     $this->assign('prov', $prov);
     $this->assign('business_info', $business);
     $this->assign('citys', $city_tree2);
     $this->display();
 }
Ejemplo n.º 2
0
/**
 * 将list_to_tree的树还原成列表
 * @param  array $tree  原来的树
 * @param  string $child 孩子节点的键
 * @param  string $order 排序显示的键,一般是主键 升序排列
 * @param  array  $list  过渡用的中间数组,
 * @return array        返回排过序的列表数组
 * @author yangweijie <*****@*****.**>
 */
function tree_to_list2($tree, $child = '_child', $order = 'id', $level = 0, &$list = array())
{
    if (is_array($tree)) {
        $level++;
        $refer = array();
        foreach ($tree as $key => $value) {
            $reffer = $value;
            unset($reffer[$child]);
            $reffer["level"] = $level;
            $reffer["title"] = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $level) . $reffer["title"];
            $reffer["hchildren"] = isset($value[$child]) ? "1" : "0";
            $list[] = $reffer;
            if (isset($value[$child])) {
                tree_to_list2($value[$child], $child, $order, $level, $list);
            }
        }
    }
    return $list;
}
 /**
  * 商品详情
  */
 public function detailGood()
 {
     // 		$goods = D('deal')->where("`id` = {$_REQUEST['id']}")->select();
     // 		if(!$goods){
     // 			$this->error('您所选择的商品不存在!请在商品列表中选中商品进行查看!');
     // 		}
     $goods = $this->getGoods($_REQUEST['id']);
     // 商家id
     $bid = $this->bid;
     // 城市列表
     $city = D('AreaNew');
     $city_list = $city->order("`sort` DESC")->select();
     $city_tree = list_to_tree($city_list, $pk = 'id', $pid = 'pid', $child = '_child', $root = 0);
     $city_tree2 = tree_to_list2($city_tree);
     // 输出分类
     $cate_list = D('ShopCate')->where("`pid` = {$bid}")->select();
     $this->assign('cate_list', $cate_list);
     $this->assign('citys', $city_tree2);
     $this->assign('goods', $goods[0]);
     $this->assign('next_goods', $goods[1]);
     $this->display();
 }