正在显示
1 个修改的文件
包含
41 行增加
和
45 行删除
@@ -20,46 +20,46 @@ use EasyWeChat\Foundation\Application; | @@ -20,46 +20,46 @@ use EasyWeChat\Foundation\Application; | ||
20 | class IndexController extends HomeBaseController | 20 | class IndexController extends HomeBaseController |
21 | { | 21 | { |
22 | 22 | ||
23 | -// function _initialize() | ||
24 | -// { | ||
25 | -// parent::_initialize(); // TODO: Change the autogenerated stub | ||
26 | -// if (cmf_is_wechat()) { | ||
27 | -// if (empty(session('user.id'))) { | ||
28 | -// require_once EXTEND_PATH . '/WeChatCommon.php'; | ||
29 | -// $wx = new \WeChatCommon(); | ||
30 | -// if (request()->param('code') == NULL) { | ||
31 | -// $wx->code(); | ||
32 | -// } else { | ||
33 | -// $code = request()->param('code'); | ||
34 | -// $info = $wx->getOpenid($code); | ||
35 | -// if (Db::name('user')->where(['openid' => $info['openid']])->count() == 0) { | ||
36 | -// //注册新用户 | ||
37 | -// //拉去用户信息 | ||
38 | -// $return = $wx->getUserInfo($info); | ||
39 | -// $data = [ | ||
40 | -// 'user_type' => 2, | ||
41 | -// 'create_time' => time(), | ||
42 | -// 'user_nickname' => $return['nickname'], | ||
43 | -// 'sex' => $return['sex'], | ||
44 | -// 'avatar' => $return['headimgurl'], | ||
45 | -// 'openid' => $info['openid'] | ||
46 | -// ]; | ||
47 | -// if (Db::name('user')->insert($data)) { | ||
48 | -// $userId = Db::name('user')->getLastInsID(); | ||
49 | -// session('user.id', $userId); | ||
50 | -// session('user.openid', $info['openid']); | ||
51 | -// } | ||
52 | -// } else { | ||
53 | -// $userId = Db::name('user')->where(['openid' => $info['openid']])->value('id'); | ||
54 | -// session('user.id', $userId); | ||
55 | -// session('user.openid', $info['openid']); | ||
56 | -// } | ||
57 | -// } | ||
58 | -// } | ||
59 | -// } else { | ||
60 | -// $this->error('请从微信浏览器打开'); | ||
61 | -// } | ||
62 | -// } | 23 | + function _initialize() |
24 | + { | ||
25 | + parent::_initialize(); // TODO: Change the autogenerated stub | ||
26 | + if (cmf_is_wechat()) { | ||
27 | + if (empty(session('user.id'))) { | ||
28 | + require_once EXTEND_PATH . '/WeChatCommon.php'; | ||
29 | + $wx = new \WeChatCommon(); | ||
30 | + if (request()->param('code') == NULL) { | ||
31 | + $wx->code(); | ||
32 | + } else { | ||
33 | + $code = request()->param('code'); | ||
34 | + $info = $wx->getOpenid($code); | ||
35 | + if (Db::name('user')->where(['openid' => $info['openid']])->count() == 0) { | ||
36 | + //注册新用户 | ||
37 | + //拉去用户信息 | ||
38 | + $return = $wx->getUserInfo($info); | ||
39 | + $data = [ | ||
40 | + 'user_type' => 2, | ||
41 | + 'create_time' => time(), | ||
42 | + 'user_nickname' => $return['nickname'], | ||
43 | + 'sex' => $return['sex'], | ||
44 | + 'avatar' => $return['headimgurl'], | ||
45 | + 'openid' => $info['openid'] | ||
46 | + ]; | ||
47 | + if (Db::name('user')->insert($data)) { | ||
48 | + $userId = Db::name('user')->getLastInsID(); | ||
49 | + session('user.id', $userId); | ||
50 | + session('user.openid', $info['openid']); | ||
51 | + } | ||
52 | + } else { | ||
53 | + $userId = Db::name('user')->where(['openid' => $info['openid']])->value('id'); | ||
54 | + session('user.id', $userId); | ||
55 | + session('user.openid', $info['openid']); | ||
56 | + } | ||
57 | + } | ||
58 | + } | ||
59 | + } else { | ||
60 | + $this->error('请从微信浏览器打开'); | ||
61 | + } | ||
62 | + } | ||
63 | 63 | ||
64 | /** | 64 | /** |
65 | * @title 接口返回参数说明 | 65 | * @title 接口返回参数说明 |
@@ -191,11 +191,7 @@ class IndexController extends HomeBaseController | @@ -191,11 +191,7 @@ class IndexController extends HomeBaseController | ||
191 | $payRequestBuilder->setTimeExpress($timeout_express); | 191 | $payRequestBuilder->setTimeExpress($timeout_express); |
192 | 192 | ||
193 | $payResponse = new \AlipayTradeService($config); | 193 | $payResponse = new \AlipayTradeService($config); |
194 | - if (cmf_is_wechat()) { | ||
195 | - $result = $payResponse->wapPay($payRequestBuilder, $config['return_url'], $config['notify_url']); | ||
196 | - } else { | ||
197 | - $result = $payResponse->wapPay($payRequestBuilder, $config['return_url'], $config['notify_url']); | ||
198 | - } | 194 | + $result = $payResponse->wapPay($payRequestBuilder, $config['return_url'], $config['notify_url']); |
199 | } | 195 | } |
200 | } | 196 | } |
201 | 197 |
-
请 注册 或 登录 后发表评论