Config.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace addon\mobileshop\shop\controller;
  13. use app\shop\controller\BaseShop;
  14. use addon\mobileshop\model\Config as ConfigModel;
  15. use app\model\system\Upgrade;
  16. /**
  17. * 配置
  18. */
  19. class Config extends BaseShop
  20. {
  21. private $config_model;
  22. public function __construct()
  23. {
  24. parent::__construct();
  25. $this->config_model = new ConfigModel();
  26. }
  27. /**
  28. * 网站部署
  29. * @return mixed
  30. */
  31. public function deploy()
  32. {
  33. $refresh_time = 0;
  34. $path = 'mshop/refresh.log';
  35. if (file_exists($path)) {
  36. $refresh_time = file_get_contents($path);
  37. }
  38. $this->assign('refresh_time', $refresh_time);
  39. // $root_url = str_replace('/index.php', '', ROOT_URL);
  40. // $this->assign("root_url", $root_url);
  41. $config_model = new ConfigModel();
  42. $config = $config_model->getMShopDomainName($this->site_id);
  43. $config = $config[ 'data' ];
  44. $this->assign('config', $config[ 'value' ]);
  45. // 检测授权
  46. $upgrade_model = new Upgrade();
  47. $auth_info = $upgrade_model->authInfo();
  48. $this->assign('is_auth', ( $auth_info[ 'code' ] == 0 ));
  49. $this->forthMenu();
  50. return $this->fetch('config/deploy');
  51. }
  52. /**
  53. * 设置移动版商家端域名配置
  54. * @return array
  55. */
  56. public function setMShopDomainName()
  57. {
  58. $config_model = new ConfigModel();
  59. $domain_name = input("domain_name", "");
  60. $result = $config_model->setMShopDomainName([
  61. 'domain_name_mobileshop' => $domain_name
  62. ]);
  63. return $result;
  64. }
  65. /**
  66. * 默认部署:无需下载,一键刷新,API接口请求地址为当前域名,编译代码存放到mobileshop文件夹中
  67. */
  68. public function downloadCsDefault()
  69. {
  70. return $this->config_model->downloadCsDefault();
  71. }
  72. /**
  73. * 独立部署:下载编译代码包后,放到网站根目录下运行
  74. */
  75. public function downloadCsIndep()
  76. {
  77. $domain = input("domain", ROOT_URL);
  78. $res = $this->config_model->downloadCsIndep($domain);
  79. echo $res[ 'message' ];
  80. }
  81. /**
  82. * 源码下载:下载uni-app代码包,可进行二次开发
  83. */
  84. public function downloados()
  85. {
  86. $res = $this->config_model->downloados();
  87. echo $res[ 'message' ];
  88. }
  89. /**
  90. * 小程序配置
  91. */
  92. public function weapp()
  93. {
  94. $weapp_model = new ConfigModel();
  95. if (request()->isAjax()) {
  96. $weapp_name = input('weapp_name', '');
  97. $weapp_original = input('weapp_original', '');
  98. $appid = input('appid', '');
  99. $appsecret = input('appsecret', '');
  100. $token = input('token', 'TOKEN');
  101. $encodingaeskey = input('encodingaeskey', '');
  102. $is_use = input('is_use', 0);
  103. $qrcode = input('qrcode', '');
  104. $data = array (
  105. "appid" => $appid,
  106. "appsecret" => $appsecret,
  107. "token" => $token,
  108. "weapp_name" => $weapp_name,
  109. "weapp_original" => $weapp_original,
  110. "encodingaeskey" => $encodingaeskey,
  111. 'qrcode' => $qrcode
  112. );
  113. $res = $weapp_model->setWeAppConfig($data, $is_use, $this->site_id, $this->app_module);
  114. return $res;
  115. } else {
  116. $weapp_config_result = $weapp_model->getWeAppConfig($this->site_id, $this->app_module);
  117. $config_info = $weapp_config_result[ 'data' ][ "value" ];
  118. $this->assign("config_info", $config_info);
  119. // 获取当前域名
  120. $url = __ROOT__;
  121. // 去除链接的http://头部
  122. $url_top = str_replace("https://", "", $url);
  123. $url_top = str_replace("http://", "", $url_top);
  124. // 去除链接的尾部/?s=
  125. $url_top = str_replace('/?s=', '', $url_top);
  126. $this->assign("url", $url_top);
  127. $this->forthMenu();
  128. return $this->fetch('config/weapp');
  129. }
  130. }
  131. }