Upgrade.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | A3Mall
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2020 http://www.a3-mall.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: xzncit <158373108@qq.com>
  8. // +----------------------------------------------------------------------
  9. namespace mall\basic;
  10. use mall\utils\HttpClient;
  11. use mall\utils\Tool;
  12. use think\facade\Config;
  13. class Upgrade {
  14. private $api_url = "http://api.a3-mall.com/";
  15. private $cert = null;
  16. private $token = null;
  17. public function __construct(){
  18. $cert = Tool::getRootPath() . "cert.key";
  19. if(file_exists($cert)){
  20. $this->cert = file_get_contents($cert);
  21. }
  22. }
  23. public function getInfo(){
  24. if(empty($this->cert)){
  25. throw new \Exception("授权文件不存在",0);
  26. }
  27. $json = HttpClient::post($this->api_url . 'auth/info',[
  28. "cert"=>$this->cert
  29. ]);
  30. return json_decode($json,true);
  31. }
  32. public function getUpdateList(){
  33. if(empty($this->cert)){
  34. throw new \Exception("授权文件不存在",0);
  35. }
  36. $json = HttpClient::post($this->api_url . 'auth/update',[
  37. "cert"=>$this->cert,
  38. "version"=>Config::get("version.version"),
  39. "version_mini"=>Config::get("version.version_mini"),
  40. "version_pc"=>Config::get("version.version_pc"),
  41. "version_app"=>Config::get("version.version_app"),
  42. "code"=>Config::get("version.code"),
  43. ]);
  44. return json_decode($json,true);
  45. }
  46. }