12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- use thans\jwt\facade\JWTAuth;
- // 应用公共文件
- function getXzqdm(){
- $payload = JWTAuth::auth();
- return $payload['xzqdm']->getValue();
- }
- function getUserId(){
- $payload = JWTAuth::auth();
- return $payload['id']->getValue();
- }
- function getQydm(){
- $payload = JWTAuth::auth();
- return $payload['qydm']->getValue();
- }
- /**
- * @return false|string
- * 获取行政区代码,并去除结尾的0
- */
- function getXzqdmSub(){
- $payload = JWTAuth::auth();
- $xzqdm = $payload['xzqdm']->getValue();
- $province = substr($xzqdm,3);
- $city = substr($xzqdm,4);
- $country = substr($xzqdm,6);
- if($province === "000000"){
- $code = substr($xzqdm,0,2);
- }else if ($city === "00000"){
- $code = substr($xzqdm,0,4);
- }else if ($country === "000"){
- $code = substr($xzqdm,0,6);
- }else{
- $code = $xzqdm ;
- }
- return $code;
- }
|