public function index() { if (empty($_COOKIE['aid'])) { $this->display('login'); } else { $sqlGood = new sql_goodMod(); $sqlSend = new sql_sendMod(); $this->assign('user', $_COOKIE['name']); // 获取学校信息 $school_info = $this->model->table($this->config['school'])->field($field)->where($con)->select(); $this->assign('s_info', $school_info); if ($_COOKIE['power'] == 0) { $brand_info = $sqlGood->get_brand_manager(0); $this->assign('b_info', $brand_info); // 展示经销商 $admin_info = $sqlGood->get_admin_manager(); $this->assign('a_info', $admin_info); $this->display('index-super'); } else { if ($_COOKIE['power'] == 1) { // $a_id = 2; ################## 这个是管理员 id,必须严格控制 $a_id = $this->in_cookie('aid', None, 1, 'True'); $good_info = $sqlGood->get_brand($a_id); $this->assign('g_info', $good_info); // 获取配送员信息 $sender_info = $sqlSend->get_sender($a_id); $this->assign('sd_info', $sender_info); $this->display('index'); } } } }
/** * 处理某品牌 * @param type 若为 show, 表示获取该品牌信息;若为 del,表示删除该品牌的信息;若为 add,表示添加该品牌信息 * @param g_id 若为 0, 表示获取所有产品,若为 其它表示获取某款产品的信息 */ public function handleBrand() { $sqlGood = new sql_goodMod(); $type = $this->in_get('type', None, 2, 'True'); $a_id = $this->in_cookie('aid', None, 1, 'True'); switch ($type) { case 'show': $g_id = $this->in_get('id', None, 1, 'True'); $good_info = $sqlGood->get_brand($a_id, 2, $g_id); echo json_encode($good_info); break; case 'add': $name = $this->in_get('name', None, 2, 'True'); $res = $sqlGood->add_brand($a_id, $name); if ($res) { $this->alert('添加成功', __ROOT__ . '/index'); } else { $this->alert('添加失败'); } break; case 'del': $g_id = $this->in_get('id', None, 1, 'True'); $res = $sqlGood->del_brand($a_id, $g_id); if ($res) { $this->alert('删除成功', __ROOT__ . '/index'); } else { $this->alert('删除失败'); } break; default: # code... break; } }