|
@@ -9,6 +9,9 @@ namespace app\index\controller;
|
|
|
|
|
|
use app\common\service\CommonService;
|
|
|
use app\index\exception\ApiException;
|
|
|
+use app\index\model\UserModel;
|
|
|
+use think\console\command\make\Model;
|
|
|
+use think\facade\Cache;
|
|
|
use think\facade\Session;
|
|
|
|
|
|
class Index {
|
|
@@ -21,15 +24,25 @@ class Index {
|
|
|
throw new ApiException('渠道id不为空');
|
|
|
}
|
|
|
$data = CommonService::getSetData($channelId);
|
|
|
- if (empty(Session::get('wxId'))){
|
|
|
- Session::set('visitorId','');
|
|
|
+ $info = (new UserModel())::where(['unionid' => Session::get('wxId'), 'channel_id' => $channelId])->find();
|
|
|
+ if (empty(Session::get('wxId')) || empty($info)){
|
|
|
+ Cache::set(Session::get('wxId'), '');
|
|
|
header("Location:".CommonService::getAuthUrl($channelId));
|
|
|
die();
|
|
|
}
|
|
|
- $visitorId = Session::get($visitorId);
|
|
|
- if(empty($visitorId)){
|
|
|
- Session::set('visitorId', $visitorId);
|
|
|
+ if (empty(Cache::get(Session::get('wxId')))) {
|
|
|
+ Cache::set(Session::get('wxId'), $visitorId);
|
|
|
}
|
|
|
+ $visitorId = Cache::get(Session::get('wxId'));
|
|
|
+ // $params = [
|
|
|
+// 'id' => $info['channel_id'],
|
|
|
+// 'userid' => $info['unionid'],
|
|
|
+// 'name' => $info['nickName'],
|
|
|
+// 'avatar' => $info['avatar'],
|
|
|
+// 'key' => $info['key']
|
|
|
+// ];
|
|
|
+// header('Location:http://mudu.tv/activity.php?a=userAssign&'.http_build_query($params));
|
|
|
+// die();
|
|
|
//增加客户自己的验证逻辑,例如登录,关注,付费,填手机号等
|
|
|
$key = md5($visitorId.$data['channel_auth_code']);
|
|
|
if(strpos($notifyUrl,'?') !== false){//url参数处理,将key加到url参数中
|