<?php
/**
 * Created by PhpStorm.
 * User: YRF
 * Date: 2023/11/14
 * Time: 16:42
 */

namespace app\api\controller\v8;
//允许所有的跨域请求
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: *");
header('Access-Control-Allow-Methods: POST,GET,OPTIONS');
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400');
date_default_timezone_set('PRC');


use app\common\controller\Api;
use app\common\helper\HttpHelper;
use think\Db;

class User extends Api
{
    // 无需登录的接口,*表示全部
    protected $noNeedLogin = ['*'];
    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = ['*'];
    protected $uimsApiurl="https://tyuims.tenyes.cn";
    protected $swApiurl="http://121.37.218.20:9011";
    protected $sxjApiurl="http://124.71.107.128:9040";

    //统一用户系统配置:获得token,登录验证,手机号一键登录
    public function uimsApitoken(){
        $appKey ="waterPro_54989312";
        $appSecret ="bef381707451606b34c1f9b4b18bd5d7";
        $url="/api/access_token";
        $postdata=[
            "appKey"=>$appKey,
            "appSecret"=>$appSecret,
        ];
        $res =HttpHelper::post($this->uimsApiurl.$url,$postdata);
        $jsondata=json_decode($res,true);
        if($jsondata['code']==200){
            return $jsondata['data'];
        }else{
            return $this->error("请求失败".$jsondata['msg'],$jsondata['data']);
        }
    }
    //项目运营管理API:水表,水费账单
    public function swApitoken(){
        $appKey ="sw_70304512";
        $appSecret ="186eb7122814b28af73724198afe6cfa";
        $url="/api/access_token";
        $postdata=[
            "appKey"=>$appKey,
            "appSecret"=>$appSecret,
        ];
        $res =HttpHelper::post($this->swApiurl.$url,$postdata);
        $jsondata=json_decode($res,true);
        if($jsondata['code']==200){
            return $jsondata['data'];
        }else{
            return $this->error("请求失败".$jsondata['msg'],$jsondata['data']);
        }
    }

    //行政监管API:水厂,水厂设备数据
    public function sxjApitoken(){
        $appKey ="tyorderauto_69272576";
        $appSecret ="1238cb88883413febbbabf17203b341d";
        $url="/api/access_token";
        $postdata=[
            "appKey"=>$appKey,
            "appSecret"=>$appSecret,
        ];
        $res =HttpHelper::post($this->sxjApiurl.$url,$postdata);
        print_r($res);return;

        $jsondata=json_decode($res,true);

        if($jsondata['code']==200){
            return $jsondata['data'];
        }else{
            return $this->error("请求失败".$jsondata['msg'],$jsondata['data']);
        }
    }

}