From 921c5e5ea80b6cf4bd0b9faeae787faf6818d003 Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 9 Sep 2022 11:35:31 +0800 Subject: [PATCH] view --- app/controller/Wechat.php | 55 +++++++++++++++++++++- composer.json | 3 +- composer.lock | 98 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 152 insertions(+), 4 deletions(-) diff --git a/app/controller/Wechat.php b/app/controller/Wechat.php index 7f32f9e..8d05f2e 100644 --- a/app/controller/Wechat.php +++ b/app/controller/Wechat.php @@ -9,15 +9,68 @@ class Wechat { private Application $app; + /** + * Notes : 初始化微信 + * + * @Date : 2022/9/9 11:30 + * @Author : + */ private function initWechat() { $this->app = Factory::officialAccount(config('wechat')); } - public function config() + /** + * Notes : 获取微信授权的地址并跳转 + * + * @Date : 2022/9/9 11:29 + * @Author : + */ + public function url() { $this->initWechat(); redirect($this->app->oauth->scopes(['snsapi_userinfo'])->redirect()); } + /** + * Notes : 微信授权回调地址,获取到用户信息后,自行保存 + * + * @Date : 2022/9/9 11:29 + * @Author : + */ + public function callback() + { + $this->initWechat(); + $user = $this->app->oauth->user(); + // $user 可以用的方法: + // $user->getId(); // 对应微信的 OPENID + // $user->getNickname(); // 对应微信的 nickname + // $user->getName(); // 对应微信的 nickname + // $user->getAvatar(); // 头像网址 + // $user->getOriginal(); // 原始API返回的结果 + // $user->getToken(); // access_token, 比如用于地址共享时使用 + } + + /** + * Notes : 显示支付的页面,支付逻辑 + * + * @Date : 2022/9/9 11:32 + * @Author : + */ + public function payment() + { + + } + + /** + * Notes : 支付完成回调 + * + * @Date : 2022/9/9 11:33 + * @Author : + */ + public function paid() + { + + } + } \ No newline at end of file diff --git a/composer.json b/composer.json index 2252647..8a60b4d 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,8 @@ "topthink/think-orm": "^2.0", "alibabacloud/client": "^1.5", "aliyuncs/oss-sdk-php": "^2.6", - "overtrue/wechat": "~5.0" + "overtrue/wechat": "~5.0", + "topthink/think-view": "^1.0" }, "require-dev": { "symfony/var-dumper": "^4.2", diff --git a/composer.lock b/composer.lock index ecbbe3e..4d7881d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0769110018c42e1da8b40f73b4c3c851", + "content-hash": "ce882484244284459031028a6feeb440", "packages": [ { "name": "adbario/php-dot-notation", @@ -3241,6 +3241,100 @@ "source": "https://github.com/top-think/think-orm/tree/v2.0.54" }, "time": "2022-07-05T05:25:51+00:00" + }, + { + "name": "topthink/think-template", + "version": "v2.0.8", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-template.git", + "reference": "abfc293f74f9ef5127b5c416310a01fe42e59368" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-template/zipball/abfc293f74f9ef5127b5c416310a01fe42e59368", + "reference": "abfc293f74f9ef5127b5c416310a01fe42e59368", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=7.1.0", + "psr/simple-cache": "^1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "think\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "description": "the php template engine", + "support": { + "issues": "https://github.com/top-think/think-template/issues", + "source": "https://github.com/top-think/think-template/tree/v2.0.8" + }, + "time": "2020-12-10T07:52:03+00:00" + }, + { + "name": "topthink/think-view", + "version": "v1.0.14", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-view.git", + "reference": "edce0ae2c9551ab65f9e94a222604b0dead3576d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-view/zipball/edce0ae2c9551ab65f9e94a222604b0dead3576d", + "reference": "edce0ae2c9551ab65f9e94a222604b0dead3576d", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=7.1.0", + "topthink/think-template": "^2.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "think\\view\\driver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "description": "thinkphp template driver", + "support": { + "issues": "https://github.com/top-think/think-view/issues", + "source": "https://github.com/top-think/think-view/tree/v1.0.14" + }, + "time": "2019-11-06T11:40:13+00:00" } ], "packages-dev": [ @@ -3485,7 +3579,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.2.5" + "php": ">=7.4" }, "platform-dev": [], "plugin-api-version": "2.3.0"