12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2019/6/11
- * Time: 17:50
- */
- namespace App\Traits;
- use Tymon\JWTAuth\Facades\JWTAuth;
- trait UserTrait
- {
- public function getShortUserInfo($uid) {
- try {
- $url = config("customer.manage_service_url").'/user/v2/short/info';
- $array = [
- 'json' => ['uid' => $uid], 'query' => [], 'http_errors' => false,'headers'=>['Authorization'=>"Bearer ".JWTAuth::getToken()]
- ];
- return http($url,$array, false, 'get');
- } catch (\Exception $e) {
- return [];
- }
- }
- public function getUserInfo($uid) {
- try {
- $url = config("customer.manage_service_url").'/user/memberView';
- $array = [
- 'json' => ['uid' => $uid], 'query' => [], 'http_errors' => false,'headers'=>['Authorization'=>"Bearer ".JWTAuth::getToken()]
- ];
- return http($url,$array, true, 'get');
- } catch (\Exception $e) {
- return [];
- }
- }
- public function getSystemMember($number) {
- try {
- $url = config("customer.manage_service_url").'/user/member/getSystemMember';
- $array = [
- 'json' => ['number' => $number], 'query' => [], 'http_errors' => false,'headers'=>['Authorization'=>"Bearer ".JWTAuth::getToken()]
- ];
- return http($url,$array, false, 'get');
- } catch (\Exception $e) {
- return [];
- }
- }
- public function uploadImage($img) {
- $path = public_path('image');
- if (!file_exists($path)){
- mkdir ($path,0777,true);
- }
- $fileUrl = $path.date('/Ymd').time().'.jpg';
- $content = file_get_contents($img);
- file_put_contents($fileUrl, $content);
- try {
- $url = config("customer.manage_service_url").'/config/upload';
- $array = [
- 'multipart' => [
- [
- 'name' => 'image',
- 'contents' => fopen($fileUrl, 'r'),
- 'headers' => ['X-Baz' => 'bar'],
- 'filename' => $fileUrl
- ]
- ],
- 'query' => [],
- 'http_errors' => false,
- 'headers'=>['Authorization'=>"Bearer ".JWTAuth::getToken()]
- ];
- $ossUrl = http($url,$array, false, 'post');
- } catch (\Exception $e) {
- $ossUrl = '';
- }
- unlink($fileUrl);
- return $ossUrl;
- }
- function downDown($file_url)
- {
- }
- }
|