<?php
/**
 * Author: luzheng.liu
 * Time: 2020/12/5 00:49
 */

namespace app\common\service;


use app\index\model\SettingModel;

class CommonService {

    static $setData;

    public static function getSetData() {
        if (empty(self::$setData)){
            $data = (new SettingModel())::where(['id' => 1])->find();
            self::$setData = $data;
            return $data;
        }
        return self::$setData;

    }

    public static function getAuthUrl() {
        $baseUrl = self::getBaeUrl();
        return $baseUrl.'?redirecturi='.self::getRedirectUrl();
    }

    public static function getBaeUrl() {
        $data = self::getSetData();
        return "http://{$data['domain']}/api/wechat/focusarea/{$data['site_id']}/{$data['unique_key']}";

    }

    public static function getRedirectUrl() {
        $data = self::getSetData();
        return $data['redirct_url'];
    }
}