159 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
			
		
		
	
	
			159 lines
		
	
	
		
			4.3 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
<?php
 | 
						|
 | 
						|
namespace app\controller\api;
 | 
						|
 | 
						|
use app\exception\RepositoryException;
 | 
						|
use app\repository\AccountRepository;
 | 
						|
use app\service\ExtraConfig;
 | 
						|
use Exception;
 | 
						|
use think\facade\Config as CConfig;
 | 
						|
use think\response\Json;
 | 
						|
 | 
						|
class Index extends Base
 | 
						|
{
 | 
						|
    protected $noNeedLogin = [
 | 
						|
        'miniProgramSetting',
 | 
						|
        'clearFootmarks',
 | 
						|
        'baseConfig',
 | 
						|
        'purchaseinstructions',
 | 
						|
        'addWechat',
 | 
						|
        'work',
 | 
						|
        'kf',
 | 
						|
        'hotKeywords',
 | 
						|
        'statement',
 | 
						|
        'about'
 | 
						|
    ];
 | 
						|
 | 
						|
    public function index(): Json
 | 
						|
    {
 | 
						|
        return json(['code' => 0, 'msg' => 'I am index']);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * 测试用
 | 
						|
     *
 | 
						|
     * @return Json
 | 
						|
     * @throws RepositoryException
 | 
						|
     */
 | 
						|
    public function test(): Json
 | 
						|
    {
 | 
						|
        $userId = $this->request->middleware('userInfo')['user_id'] ?? 0;
 | 
						|
        $user   = AccountRepository::getInstance()->findById($userId, []);
 | 
						|
 | 
						|
        return json(['code' => 0, 'msg' => 'I am test ', 'data' => $user]);
 | 
						|
    }
 | 
						|
 | 
						|
    public function login(): Json
 | 
						|
    {
 | 
						|
        $userId = $this->request->middleware('userInfo')['user_id'] ?? 0;
 | 
						|
        return json(['code' => 0, 'msg' => 'I am login '.$userId]);
 | 
						|
    }
 | 
						|
 | 
						|
    public function notify()
 | 
						|
    {
 | 
						|
        $beginNotifyList = AccountRepository::getInstance()->getBeginNotifyList();
 | 
						|
        //        $res = Queue::later(3, NotifySms::class, $beginNotifyList);
 | 
						|
        //        $getSuccessList = AccountRepository::getInstance()->getSuccessList();
 | 
						|
        return $this->json(0, 'success', $beginNotifyList);
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    /**
 | 
						|
     * 小程序个性装修配置
 | 
						|
     */
 | 
						|
    public function miniProgramSetting(): Json
 | 
						|
    {
 | 
						|
        $conf = ExtraConfig::miniProgram();
 | 
						|
        foreach ($conf["footBar"] as &$item) {
 | 
						|
            $item["icon"] = resourceJoin($item["icon"],$this->request->domain());
 | 
						|
        }
 | 
						|
        foreach ($conf["recommend"] as &$item) {
 | 
						|
            $item["icon"] = resourceJoin($item["icon"],$this->request->domain());
 | 
						|
        }
 | 
						|
        return $this->json(0, 'success', $conf);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * 基础配置
 | 
						|
     *
 | 
						|
     * @return Json
 | 
						|
     */
 | 
						|
    public function baseConfig(): Json
 | 
						|
    {
 | 
						|
        try {
 | 
						|
            CConfig::load('extra/base', 'base');
 | 
						|
            $res = config('base')['show_video'] ?? 0;
 | 
						|
            return $this->json(0, 'success', ['v' => (int) $res]);
 | 
						|
        } catch (Exception $e) {
 | 
						|
            return $this->json(5000, '获取基础配置失败');
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * 免责声明
 | 
						|
     *
 | 
						|
     * @return Json
 | 
						|
     */
 | 
						|
    public function statement(): Json
 | 
						|
    {
 | 
						|
        try {
 | 
						|
            CConfig::load('extra/statement', 'statement');
 | 
						|
            $content = config('statement')['content'] ?? '';
 | 
						|
            $content  = replaceStoragePath($content);
 | 
						|
            return $this->json(0, 'success', ['content' => $content]);
 | 
						|
        } catch (Exception $e) {
 | 
						|
            return $this->json(5000, '获取免责声明失败');
 | 
						|
        }
 | 
						|
    }
 | 
						|
    /**
 | 
						|
     * 购买须知
 | 
						|
     *
 | 
						|
     * @return Json
 | 
						|
     */
 | 
						|
    public function purchaseinstructions(): Json
 | 
						|
    {
 | 
						|
        try {
 | 
						|
            CConfig::load('extra/purchaseinstructions', 'purchaseinstructions');
 | 
						|
            $content = config('purchaseinstructions')['content'] ?? '';
 | 
						|
 | 
						|
            $content  = replaceStoragePath($content);
 | 
						|
            return $this->json(0, 'success', ['content' => $content]);
 | 
						|
        } catch (Exception $e) {
 | 
						|
            return $this->json(5000, '获取失败');
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * 添加微信
 | 
						|
     *
 | 
						|
     * @return Json
 | 
						|
     */
 | 
						|
    public function addWechat(): Json
 | 
						|
    {
 | 
						|
        try {
 | 
						|
            CConfig::load('extra/addwechat', 'addwechat');
 | 
						|
            $res = config('addwechat')?? [];
 | 
						|
            $res["wechat"]  = resourceJoin($res["wechat"],$this->request->domain());
 | 
						|
            $res["content"]  = replaceStoragePath($res["content"]);
 | 
						|
            return $this->json(0, 'success', $res);
 | 
						|
        } catch (Exception $e) {
 | 
						|
            return $this->json(5000, '获取添加微信失败');
 | 
						|
        }
 | 
						|
    }
 | 
						|
    /**
 | 
						|
     * 关于我们
 | 
						|
     *
 | 
						|
     * @return Json
 | 
						|
     */
 | 
						|
    public function about(): Json
 | 
						|
    {
 | 
						|
        try {
 | 
						|
            CConfig::load('extra/about', 'about');
 | 
						|
            $res = config('about')?? [];
 | 
						|
             $res["content"]  = replaceStoragePath($res["content"]);
 | 
						|
            return $this->json(0, 'success', $res);
 | 
						|
        } catch (Exception $e) {
 | 
						|
            return $this->json(5000, '获取关于我们失败');
 | 
						|
        }
 | 
						|
    }
 | 
						|
} |