first commit
This commit is contained in:
74
pgserver/application/admin/service/ApiService.php
Normal file
74
pgserver/application/admin/service/ApiService.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\service;
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of RestFullService
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
use think\facade\Request;
|
||||
|
||||
class ApiService {
|
||||
|
||||
public static $msg = [
|
||||
0 => "success",
|
||||
1 => "数据验证不通过",
|
||||
2 => "未关注公众号,请先关注!",
|
||||
100 => "未识别错误!",
|
||||
101 => '链接微信服务器失败',
|
||||
102 => '请在微信浏览器打开',
|
||||
103 => '获取微信数据失败',
|
||||
1001 => '手机号已注册',
|
||||
99998 => '对不起,您未取得该业务的操作权限,请联系管理员后再试',
|
||||
99999 => '请勿异常操作'
|
||||
];
|
||||
|
||||
/**
|
||||
* 获取错误消息
|
||||
*/
|
||||
public static function getMsg($code) {
|
||||
if (isset(self::$msg[$code]))
|
||||
return self::$msg[$code];
|
||||
return self::getMsg(100);
|
||||
}
|
||||
|
||||
/**
|
||||
* url地址组装
|
||||
*/
|
||||
public static function urlParse($url, $array) {
|
||||
$pre = "?";
|
||||
strpos($url, '?') !== FALSE && $pre = "&";
|
||||
foreach ($array as $key => $v) {
|
||||
$url .= "$pre$key=$v";
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
public static function is_allow() {
|
||||
$user_agent = strtolower(Request::server('HTTP_USER_AGENT'));
|
||||
if (strpos($user_agent, 'windowswechat') !== false) {
|
||||
//判断是否在白名单
|
||||
$allow_ips = [];
|
||||
$ip = Request::ip();
|
||||
if (!in_array($ip, $allow_ips)) {
|
||||
//apiErrMsg('请在手机端打开Ai临沂-核酸检测小程序', 99998);
|
||||
}
|
||||
}
|
||||
if (strpos($user_agent, 'micromessenger') === false) {
|
||||
//判断是否在白名单
|
||||
$allow_ips = [];
|
||||
$ip = Request::ip();
|
||||
if (!in_array($ip, $allow_ips)) {
|
||||
apiErrMsg('请使用微信小程序访问或升级到最新版微信后重试', 99998);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user