layout && in_array(Yii::$app->id, [AppEnum::BACKEND, AppEnum::MERCHANT])) { $this->layout = '@addons/Happiness/' . $this->module->id . '/views/layouts/client'; } $redirect_url = '/happiness/client/auth/login'; $this->admin = Yii::$app->happiness_store_user->identity; Yii::error('action:'.$this->getRoute().';store_id:'.$this->admin->store_id); if(empty($this->admin)) return $this->redirect([$redirect_url]); $store_id = $this->admin['store_id']; $store = HappinessStore::findOne(['id' => $store_id]); if(empty($store)){ return $this->redirect([$redirect_url]); } //判断当前登录用户记录的登录信息和修改后账号是否相同 $loginAdmin = Yii::$app->session->get("happiness_store"); if ($loginAdmin->shop_mobile != $store->shop_mobile) { //账号被修改退出登录 Yii::$app->store_user->logout(); return $this->redirect([$redirect_url]); } $mall = Mall::findOne(['id'=>$store['mall_id']]); $this->mall = $mall; $this->mall_id = $mall['id']; $this->store_id = $store['id']; $this->store = $store; } /** * @return array */ public function behaviors() { return [ 'actionLog' => [ 'class' => ActionLogBehavior::class ] ]; } /** * @param $action * @return bool * @throws UnauthorizedHttpException * @throws \yii\web\BadRequestHttpException */ public function beforeAction($action) { if (!parent::beforeAction($action)) { return false; } // 每页数量 $this->pageSize = Yii::$app->request->get('per-page', 10); $this->pageSize > 50 && $this->pageSize = 50; return true; } }