Commit 67ad384b authored by zhuwei's avatar zhuwei

shareShop

parent 87371e77
<?php
namespace app\index\controller;
use app\api\controller\WxSdk;
use app\api\untils\WxCallbackUntils;
use app\index\extend\Basic;
use app\index\service\UserService;
use Think\Log;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/6/4
* Time : 18:06
* Intro:
*/
class ShareShop extends Basic
{
private $url;
private $_wxApi;
public function __construct()
{
parent::__construct();
$this->_wxApi = new WxCallbackUntils();
$this->url = CURRENT_URL . "/index/shareShop";
}
public function shareShop()
{
$params = $this->params;
$code = empty($_GET['code']) ? null : $_GET['code'];
if (!$code) {
$this->_wxApi->getWxCodesnSapiBase($this->url);
} else {
$open_id = $this->_wxApi->getUserOpenId($code);
$user_service = new UserService();
$is_user = $user_service->isUserByweiXin($open_id);
$data = [
'id' => '1',
'housename' => '怡华苑路304号',
'user_tel' => '13918937741',
'user_name' => '于盼盼',
'share' => '1',
'client' => 'b',
'client' => 'b',
'is_user' => $is_user,
];
$this->assign('data',json_encode($data));
return view("share_detail");
}
}
}
\ No newline at end of file
...@@ -21,7 +21,6 @@ class WxAuthorization extends Basic ...@@ -21,7 +21,6 @@ class WxAuthorization extends Basic
public function __construct() public function __construct()
{ {
parent::__construct();
$this->_wxApi = new WxCallbackUntils(); $this->_wxApi = new WxCallbackUntils();
$this->url = CURRENT_URL . "/index/getWxInfo"; $this->url = CURRENT_URL . "/index/getWxInfo";
} }
...@@ -49,26 +48,4 @@ class WxAuthorization extends Basic ...@@ -49,26 +48,4 @@ class WxAuthorization extends Basic
} }
public function getWxInfoV2()
{
$code = empty($_GET['code']) ? null : $_GET['code'];
if (!$code) {
$this->_wxApi->getWxCodesnSapiBase(CURRENT_URL . "/index/getWxInfoV2");
} else {
$userInfo = $this->_wxApi->getUserOpenId($code);
$data = [
'id' => '2',
'housename' => '怡华苑路304号',
'user_tel' => '13918937741',
'user_name' => '于盼盼',
'share' => '1',
'client' => 'b',
];
$this->assign('data',json_encode($data));
return view("share_detail");
}
}
} }
\ No newline at end of file
...@@ -442,4 +442,19 @@ class UserService ...@@ -442,4 +442,19 @@ class UserService
} }
} }
public function isUserByweiXin($open_id){
if(!$open_id){
return false;
}
$param['wx_open_id'] = $open_id;
$fields='a.user_phone';
$result = $this->user->getUserInfoByOpenId($param, $fields);
if ($result) {
return true;
}else{
return false;
}
}
} }
\ No newline at end of file
...@@ -969,5 +969,20 @@ class Users extends Model ...@@ -969,5 +969,20 @@ class Users extends Model
//echo $this->getLastSql(); //echo $this->getLastSql();
return $result; return $result;
} }
public function getUserInfoByOpenId($param, $fields)
{
$where_ = [];
if (isset($param["wx_open_id"])) {
$where_["b.wx_open_id"] = $param["wx_open_id"];
}
$data = $this
->field($fields)
->alias("a")
->join("u_wx_info b", "a.buyer_id=b.id", "left")
->where($where_)
->select();
return $data;
}
} }
...@@ -280,7 +280,7 @@ Route::group('index', [ ...@@ -280,7 +280,7 @@ Route::group('index', [
'addNotice' => ['index/notice/addNotice', ['method' => 'POST']], //新增公告 'addNotice' => ['index/notice/addNotice', ['method' => 'POST']], //新增公告
'addNoticeView' => ['index/notice/addNoticeView', ['method' => 'GET']], //新增公告 'addNoticeView' => ['index/notice/addNoticeView', ['method' => 'GET']], //新增公告
'getWxInfo' => ['index/WxAuthorization/getWxInfo', ['method' => 'POST|GET']], //wx 'getWxInfo' => ['index/WxAuthorization/getWxInfo', ['method' => 'POST|GET']], //wx
'getWxInfoV2' => ['index/WxAuthorization/getWxInfoV2', ['method' => 'POST|GET']], //wx 'shareShop' => ['index/ShareShop/shareShop', ['method' => 'POST|GET']], //wx
'evaluationList' => ['index/Evaluation/evaluationList', ['method' => 'POST|GET']], //评价列表 朱伟 2018-06-13 'evaluationList' => ['index/Evaluation/evaluationList', ['method' => 'POST|GET']], //评价列表 朱伟 2018-06-13
......
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