正在显示
1 个修改的文件
包含
30 行增加
和
0 行删除
@@ -5,6 +5,7 @@ namespace app\api\controller; | @@ -5,6 +5,7 @@ namespace app\api\controller; | ||
5 | use app\common\controller\Api; | 5 | use app\common\controller\Api; |
6 | use app\common\model\Area; | 6 | use app\common\model\Area; |
7 | use app\common\model\Version; | 7 | use app\common\model\Version; |
8 | +use EasyWeChat\Foundation\Application; | ||
8 | use Qiniu\Auth; | 9 | use Qiniu\Auth; |
9 | use think\Config; | 10 | use think\Config; |
10 | use think\Hook; | 11 | use think\Hook; |
@@ -178,4 +179,33 @@ class Common extends Api | @@ -178,4 +179,33 @@ class Common extends Api | ||
178 | } | 179 | } |
179 | return; | 180 | return; |
180 | } | 181 | } |
182 | + | ||
183 | + /** | ||
184 | + * @ApiTitle (获取微信SDK配置) | ||
185 | + * @ApiSummary (获取微信SDK配置) | ||
186 | + * @ApiMethod (POST) | ||
187 | + * @ApiRoute (/api/Common/getJsSdkConfig) | ||
188 | + * @ApiParams (name="url", type="string", required=true, description="当前页面url") | ||
189 | + * @ApiParams (name="api", type="string", required=true, description="要应用的API名称逗号分割") | ||
190 | + * @ApiReturnParams (name="code", type="integer", required=true, sample="0") | ||
191 | + * @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功") | ||
192 | + * @ApiReturnParams (name="url", type="string", required=true, sample="跳转地址") | ||
193 | + * @ApiReturn ({ | ||
194 | + 'code':'1', | ||
195 | + 'msg':'返回成功', | ||
196 | + }) | ||
197 | + */ | ||
198 | + public function getJsSdkConfig() | ||
199 | + { | ||
200 | + $api = input('api'); | ||
201 | + $url = input('url'); | ||
202 | + $config = config('wechat'); | ||
203 | + // dump($config); | ||
204 | + $APIs = explode(',', $api); | ||
205 | + $Wechat = new Application($config); | ||
206 | + $Wechat->js->setUrl($url); | ||
207 | + $return['config'] = $Wechat->js->config($APIs, $debug = false, $beta = false, $json = false); | ||
208 | + $this->success('', $return); | ||
209 | + } | ||
210 | + | ||
181 | } | 211 | } |
-
请 注册 或 登录 后发表评论