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

This commit is contained in:
Anyon 2017-05-23 17:50:05 +08:00 committed by Anyon
parent f8ec39b54e
commit a0bf759e58
2 changed files with 23 additions and 6 deletions

View File

@ -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();
}
}
}
}

View File

@ -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'))) {