瀏覽代碼

登陆信息不一致问题

shish 6 年之前
父節點
當前提交
a4888945f3
共有 2 個文件被更改,包括 17 次插入6 次删除
  1. 8 3
      app/client/controllers/BaseController.php
  2. 9 3
      common/components/util.php

+ 8 - 3
app/client/controllers/BaseController.php

@@ -45,16 +45,21 @@ class BaseController extends PublicController
 		$this->shopId = $shopId;
 		$this->merchantExtend = MerchantExtendService::getByMerchantId($account);
 		$this->isWx = util::isWx();
-
+		
 		//收集访问量
 		StatVisitService::gatherVisit($account);
-
+		
 		if (empty($userId)) {
 			$this->validate = false;
 		} else {
 			$this->validate = true;
 			$this->userId = $userId;
-			$this->user = UserService::getUserInfo($userId);
+			$userInfo = UserService::getUserInfo($userId);
+			$this->user = $userInfo;
+			//客户短时间访问二家商家的商城,登陆信息一致性问题
+			if ($userInfo['merchantId'] != $account) {
+				util::logout();
+			}
 		}
 		//游客可以访问的方法
 		if (in_array($action->id, $this->withoutLogin)) {

+ 9 - 3
common/components/util.php

@@ -7,7 +7,7 @@ use yii\helpers\Json;
 
 class util
 {
-
+	
 	//判断是否微信浏览器
 	public static function isWx()
 	{
@@ -16,7 +16,7 @@ class util
 		}
 		return false;
 	}
-
+	
 	//根据两点间的经纬度计算距离
 	public static function getDistance($lat1, $lng1, $lat2, $lng2)
 	{
@@ -449,13 +449,19 @@ class util
 		self::encode(['code' => 1, 'msg' => $msg, 'data' => $data]);
 	}
 	
+	//退出当前登陆 shish 2020.3.8
+	public static function logout()
+	{
+		self::encode(['code' => 2, 'msg' => '当前登陆信息已失效,请重新登陆', 'data' => []]);
+	}
+	
 	//只输出成功状态
 	public static function ok($msg = '')
 	{
 		$msg = empty($msg) ? '操作成功' : $msg;
 		self::encode(['code' => 1, 'msg' => $msg, 'data' => []]);
 	}
-
+	
 	public static function notLogin()
 	{
 		self::encode(['code' => -1, 'msg' => '没有登陆', 'data' => []]);