Config.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
  4. * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
  5. * @author pillar<ltmn@qq.com>
  6. * 应用配置
  7. */
  8. namespace app\green\controller;
  9. use app\green\model\GreenConfig;
  10. class Config extends Common{
  11. public function initialize(){
  12. parent::initialize();
  13. if(!$this->founder){
  14. $this->error('您无权限操作');
  15. }
  16. }
  17. //文案配置
  18. public function index(){
  19. $info = GreenConfig::where(['member_miniapp_id' => $this->member_miniapp_id])->find();
  20. if(request()->isAjax()){
  21. $data = [
  22. 'shore_img' => $this->request->param('shore_img/s'),
  23. 'shore_text' => $this->request->param('shore_text/s')
  24. ];
  25. if(empty($info)){
  26. $info = new GreenConfig;
  27. $info->member_miniapp_id = $this->member_miniapp_id;
  28. }
  29. $info->config = json_encode($data);
  30. $info->service_telephone = $this->request->param('service_telephone/s');
  31. $info->is_wechat_touser = $this->request->param('is_wechat_touser/d');
  32. $result = $info->save();
  33. if($result){
  34. return enjson(200,'操作成功',['url' => url('config/index')]);
  35. }else{
  36. return enjson(0,'操作失败');
  37. }
  38. }else{
  39. $view['pathMaps'] = [['name' =>' 文案配置','url' => url("config/index")]];
  40. $view['config'] = empty($info->config) ? '' : json_decode($info->config,true);
  41. $view['info'] = $info;
  42. return view()->assign($view);
  43. }
  44. }
  45. /**
  46. * 投递指南
  47. * @return void
  48. */
  49. public function help(){
  50. if(request()->isAjax()){
  51. $data['help'] = $this->request->param('help/s');
  52. $result = GreenConfig::configs($data,$this->member_miniapp_id);
  53. if($result){
  54. return enjson(200,'操作成功',['url' => url('config/help')]);
  55. }else{
  56. return enjson(0,'操作失败');
  57. }
  58. }else{
  59. $view['config'] = GreenConfig::getConfig($this->member_miniapp_id);
  60. $view['pathMaps']= [['name' =>' 投递指南','url' => url("config/help")]];
  61. return view()->assign($view);
  62. }
  63. }
  64. }