Commit 9027be65 authored by zhuwei's avatar zhuwei

优化

parent e122141e
......@@ -27,6 +27,7 @@ class WxCallbackUntils
$this->appId = "wxd30d74d1126d3278";//测试
$this->appSecret = "f29c8c502549020d2193a464be9632dc";//测试
}
}
public function http_host()
......
......@@ -6,6 +6,7 @@ use app\api\controller\WxSdk;
use app\api\untils\WxCallbackUntils;
use app\index\extend\Basic;
use app\index\service\UserService;
use app\model\UWxInfo;
use Think\Log;
/**
......@@ -19,11 +20,14 @@ class ShareShop extends Basic
{
private $url;
private $_wxApi;
private $wxInfoModel;
public function __construct()
{
parent::__construct();
$this->_wxApi = new WxCallbackUntils();
$this->wxInfoModel = new UWxInfo();
$this->url = CURRENT_URL . "/index/shareShop";
}
......@@ -37,13 +41,18 @@ class ShareShop extends Basic
if (!$code) {
$this->_wxApi->getWxCodesnSapiBase($this->url.'?'.http_build_query($params));
} else {
$open_id = $this->_wxApi->getUserOpenId($code);
$data = $this->_wxApi->getUserInfoByAccessToken($code);
$user_service = new UserService();
$is_user = $user_service->isUserByweiXin($open_id);
$is_user = $user_service->isUserByweiXin($data['wx_union_id']);
$data["source"] = 0;
$this->wxInfoModel->addWxInfo($data);
$params['is_user'] = $is_user;
$params['wx_union_id'] = $data['wx_union_id'];
$params['device_id'] = $this->createOrderNumber();
}
}else{
//dump('普通浏览器');
$is_user = true;
}
/* $data = [
......@@ -55,11 +64,9 @@ class ShareShop extends Basic
'client' => 'b',
'is_user' => true
];*/
$params['is_user'] = $is_user;
//dump($params);
Log::write($code, '18112347151'); //记录日志
Log::write($open_id, '18112347151'); //记录日志
Log::write($params, '18112347151'); //记录日志
dump($params);
$this->assign('data',json_encode($params));
return view("share_detail");
......@@ -75,6 +82,14 @@ class ShareShop extends Basic
}
/**
* 随机数
* @return string
*/
private function createOrderNumber()
{
return time() . mt_rand(10000, 99999);
}
/**
* 浏览器判断
* @return int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment