Setting.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 app\admin\controller\system;
  10. use app\admin\controller\Auth;
  11. use mall\library\delivery\aliyun\Aliyun;
  12. use think\facade\Config;
  13. use think\facade\Request;
  14. use mall\response\Response;
  15. use think\facade\View;
  16. use app\common\models\Setting as SettingModel;
  17. class Setting extends Auth {
  18. /**
  19. * 站点设置
  20. * @return string|\think\response\Json
  21. * @throws \think\db\exception\DataNotFoundException
  22. * @throws \think\db\exception\DbException
  23. * @throws \think\db\exception\ModelNotFoundException
  24. */
  25. public function index(){
  26. if(Request::isAjax()){
  27. SettingModel::saveData(Request::param());
  28. return Response::returnArray("操作成功!");
  29. }
  30. $array = [];
  31. foreach(["web_name", "web_title", "web_keywords", "web_description", "web_copyright", "web_logo"] as $value){
  32. $array[$value] = SettingModel::getStringData($value);
  33. }
  34. return View::fetch("",[ "data"=>$array ]);
  35. }
  36. /**
  37. * 邮箱设置
  38. * @return string|\think\response\Json
  39. * @throws \think\db\exception\DataNotFoundException
  40. * @throws \think\db\exception\DbException
  41. * @throws \think\db\exception\ModelNotFoundException
  42. */
  43. public function email(){
  44. if(Request::isAjax()){
  45. SettingModel::saveData("email",Request::param());
  46. return Response::returnArray("操作成功!");
  47. }
  48. return View::fetch("",[ "data"=>SettingModel::getArrayData("email") ]);
  49. }
  50. /**
  51. * 上传设置
  52. * @return string|\think\response\Json
  53. * @throws \think\db\exception\DataNotFoundException
  54. * @throws \think\db\exception\DbException
  55. * @throws \think\db\exception\ModelNotFoundException
  56. */
  57. public function upload(){
  58. if(Request::isAjax()){
  59. SettingModel::saveData("upload",Request::post());
  60. return Response::returnArray("操作成功!");
  61. }
  62. return View::fetch("",[
  63. "city"=>Config::get("oss.aliyun.city"),
  64. "data"=>SettingModel::getArrayData("upload")
  65. ]);
  66. }
  67. /**
  68. * 物流查询
  69. * @return string|\think\response\Json
  70. */
  71. public function delivery(){
  72. if(Request::isAjax()){
  73. $post = Request::post();
  74. Aliyun::setConfig($post);
  75. return Response::returnArray("操作成功!");
  76. }
  77. return View::fetch("",[
  78. "data"=>Aliyun::getConfig()
  79. ]);
  80. }
  81. /**
  82. * 联系方式
  83. * @return string|\think\response\Json
  84. * @throws \think\db\exception\DataNotFoundException
  85. * @throws \think\db\exception\DbException
  86. * @throws \think\db\exception\ModelNotFoundException
  87. */
  88. public function address(){
  89. if(Request::isAjax()){
  90. SettingModel::saveData("address",Request::post());
  91. return Response::returnArray("操作成功!");
  92. }
  93. return View::fetch("",[ "data"=>SettingModel::getArrayData("address") ]);
  94. }
  95. /**
  96. * 备案信息
  97. * @return string|\think\response\Json
  98. * @throws \think\db\exception\DataNotFoundException
  99. * @throws \think\db\exception\DbException
  100. * @throws \think\db\exception\ModelNotFoundException
  101. */
  102. public function copyright(){
  103. if(Request::isAjax()){
  104. SettingModel::saveData("copyright",Request::post());
  105. return Response::returnArray("操作成功!");
  106. }
  107. return View::fetch("",[ "data"=>SettingModel::getArrayData("copyright")["copyright"] ]);
  108. }
  109. }