Skip to content

Commit

Permalink
增加企业微信和第三方开放平台实例
Browse files Browse the repository at this point in the history
  • Loading branch information
jianyan74 committed Jun 9, 2018
1 parent 9a6abcc commit fccdc7b
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 2 deletions.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,21 @@ composer require jianyan74/yii2-easy-wechat

// 微信小程序配置 具体可参考EasyWechat
'wechatMiniProgramConfig' => [],

// 微信开放平台第三方平台配置 具体可参考EasyWechat
'wechatOpenPlatformConfig' => [],

// 微信企业微信配置 具体可参考EasyWechat
'wechatWorkConfig' => [],
```

配置文档

[微信配置说明文档.](https://www.easywechat.com/docs/master/zh-CN/official-account/configuration)
[微信支付配置说明文档.](https://www.easywechat.com/docs/master/zh-CN/payment/jssdk)
[微信小程序配置说明文档.](https://www.easywechat.com/docs/master/zh-CN/mini-program/index)
[微信小程序配置说明文档.](https://www.easywechat.com/docs/master/zh-CN/mini-program/index)
[微信开放平台第三方平台](https://www.easywechat.com/docs/master/zh-CN/open-platform/index)
[企业微信](https://www.easywechat.com/docs/master/zh-CN/wework/index)

## 使用例子

Expand All @@ -75,6 +85,20 @@ $payment = Yii::$app->wechat->payment;
```php
$miniProgram = Yii::$app->wechat->miniProgram;
```

获取微信开放平台第三方平台实例

```php
$openPlatform = Yii::$app->wechat->openPlatform;
```

获取企业微信实例

```php
$work = Yii::$app->wechat->work;
```


微信支付(JsApi):

```php
Expand Down
46 changes: 45 additions & 1 deletion src/Wechat.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ class Wechat extends Component
*/
private static $_miniProgram;

/**
* 第三方开放平台 SKD
*
* @var Factory
*/
private static $_openPlatform;

/**
* 企业微信 SKD
*
* @var Factory
*/
private static $_work;

/**
* @var WechatUser
*/
Expand Down Expand Up @@ -156,7 +170,7 @@ public function getPayment()
}

/**
* 获取 EasyWeChat 微信支付实例
* 获取 EasyWeChat 微信小程序实例
*
* @return Factory
*/
Expand All @@ -170,6 +184,36 @@ public function getMiniProgram()
return self::$_miniProgram;
}

/**
* 获取 EasyWeChat 微信第三方开放平台实例
*
* @return Factory
*/
public function getOpenPlatform()
{
if (!self::$_openPlatform instanceof Factory)
{
self::$_openPlatform = Factory::openPlatform(Yii::$app->params['wechatOpenPlatformConfig']);
}

return self::$_openPlatform;
}

/**
* 获取 EasyWeChat 企业微信实例
*
* @return Factory
*/
public function getWork()
{
if (!self::$_work instanceof Factory)
{
self::$_work = Factory::work(Yii::$app->params['wechatWorkConfig']);
}

return self::$_work;
}

/**
* 获取微信身份信息
*
Expand Down

0 comments on commit fccdc7b

Please sign in to comment.