浏览代码

[更新]修改微信前端支持DEMO

Anyon 8 年之前
父节点
当前提交
a0bf759e58
共有 2 个文件被更改,包括 23 次插入6 次删除
  1. 22 5
      application/index/controller/Wap.php
  2. 1 1
      extend/controller/BasicWechat.php

+ 22 - 5
application/index/controller/Wap.php

@@ -1,4 +1,5 @@
 <?php
+
 // +----------------------------------------------------------------------
 // | Think.Admin
 // +----------------------------------------------------------------------
@@ -19,13 +20,25 @@ use service\PayService;
 
 class Wap extends BasicWechat {
 
-    protected $check_auth = false;
+    /**
+     * 禁用自动网页授权
+     * @var bool
+     */
+    protected $checkAuth = false;
 
+    /**
+     * 网页授权DEMO
+     */
     public function index() {
-        dump($this->oAuth());
-        dump($this->fansinfo);
+//        dump($this->oAuth(false)); // 仅获取用户openid
+        dump($this->oAuth());  // 获取用户详情信息
+        dump($this->fansinfo); // 打
     }
 
+    /**
+     * 微信二维码支付DEMO
+     * @return \think\response\Json|\think\response\View
+     */
     public function payqrc() {
         switch ($this->request->get('action')) {
             case 'payqrc':
@@ -52,6 +65,10 @@ class Wap extends BasicWechat {
         }
     }
 
+    /**
+     * 微信JSAPI支付DEMO
+     * @return \think\response\Json|\think\response\View
+     */
     public function payjs() {
         $this->openid = $this->oAuth(false);
         switch ($this->request->get('action')) {
@@ -76,7 +93,7 @@ class Wap extends BasicWechat {
                 break;
             default:
                 return view();
-
         }
     }
-}
+
+}

+ 1 - 1
extend/controller/BasicWechat.php

@@ -69,7 +69,7 @@ class BasicWechat extends Controller {
     protected function oAuth($fullMode = true) {
         // 本地开发调试用户 openid
         if (in_array($this->request->host(), ['127.0.0.1', 'localhost'])) {
-            session('openid', 'o38gps3vNdCqaggFfrBRCRikwlWY');
+            session('openid', 'oBWB3wWVNujb-PJlmPmxC5CBTNF0');
         }
         // 检查缓存中 openid 信息是否完整
         if (($this->openid = session('openid'))) {