public function login($username = '', $password = '', $verify = '', $ajax = true) { layout(false); if (IS_POST) { if (C('VERIFY') && $verify != session(C('VERIFY_CODE'))) { // 验证码不对 if ($ajax) { $this->ajaxReturn(['status' => -1, 'msg' => '验证码错误']); } $this->error('验证码错误'); } $userInfo = UserModel::instance()->findByName($username); if (!$userInfo) { $this->assign("error", "用户不存在"); } else { if ($userInfo && $userInfo['password'] == processPwd($password)) { // 登陆成功 session(C('LOGIN_SESSION'), $userInfo); $this->redirect('index/index'); } else { $this->assign("error", "密码错误"); } } $this->assign("username", $username); $this->assign("password", $password); } if (I("error")) { $this->assign("error", "抱歉,您的账号已被禁用~"); } $this->display(); }
public function editShop($id, $data) { PlatformShopModel::instance()->where(['uid' => $id])->setField("name", $data['shopName']); UserModel::instance()->where(['id' => $id])->setField("tel", $data['tel']); if ($data['password'] != '') { UserModel::instance()->where(['id' => $id])->setField("tel", $data['password']); } }
public function edit($id) { $user = UserModel::instance()->findByProperties("id", $id); $shop = UserModel::instance()->findByProperties("uid", $id, "platform_shop"); $shop[0]['shopName'] = $shop[0]['name']; unset($shop[0]['name']); unset($shop[0]['id']); $data = array_merge($user[0], $shop[0]); if ($_POST) { PlatformShopModel::instance()->editShop($id, $_POST); $this->_success("编辑成功", "/admin/index/index/"); } $this->assign('data', $data); $this->display(); }
public function _initialize() { if (!UserModel::instance()->isLogin()) { // 判断用户是否登录 $this->redirect("user/login"); } else { $this->user = UserModel::instance(); $this->user->setUser(session(C("LOGIN_SESSION"))); if ($this->user->getId() == 1) { // 管理员 layout(false); $list = PlatformShopModel::instance()->getList(); $this->assign("list", $list); } else { // 店铺用户 if ($this->user->getShopStatus() == 0) { $this->redirect("user/login", ['error' => 1]); } } } }