作者 郭文星

111

@@ -30,7 +30,7 @@ return [ @@ -30,7 +30,7 @@ return [
30 'title' => 'token', 30 'title' => 'token',
31 'type' => 'string', 31 'type' => 'string',
32 'content' => [], 32 'content' => [],
33 - 'value' => 'Fdc2022666fdC', 33 + 'value' => 'Wyc666666',
34 'rule' => 'required', 34 'rule' => 'required',
35 'msg' => '', 35 'msg' => '',
36 'tip' => '', 36 'tip' => '',
@@ -42,7 +42,7 @@ return [ @@ -42,7 +42,7 @@ return [
42 'title' => 'aes_key', 42 'title' => 'aes_key',
43 'type' => 'string', 43 'type' => 'string',
44 'content' => [], 44 'content' => [],
45 - 'value' => 'vfVRWaOmV7B19NqjE6zPBHaBTEDgv71plzhEGr8SxiQ', 45 + 'value' => 'HJXrDOoAhdN64J2Z33DyLo1gJsT6vw2xh9xbSzpD1Nn',
46 'rule' => 'required', 46 'rule' => 'required',
47 'msg' => '', 47 'msg' => '',
48 'tip' => '', 48 'tip' => '',
  1 +<?php
  2 +
  3 +/**
  4 + * 首字母排序A-Z(含汉字)
  5 + */
  6 +
  7 +use app\admin\model\User;
  8 +use app\api\controller\v1\WxxcxPush;
  9 +
  10 +if (!function_exists('getFirstChar')) {
  11 + function getFirstChar($s)
  12 + {
  13 + $s0 = mb_substr($s, 0, 1); //获取名字的姓
  14 + $s = iconv('UTF-8', 'gb2312', $s0); //将UTF-8转换成GB2312编码
  15 +//var_dump(ord($s0));
  16 +// var_dump(ord($s));
  17 + if (ord($s0) > 128) { //汉字开头,汉字没有以U、V开头的
  18 +
  19 + $asc = ord($s{0}) * 256 + ord($s{1}) - 65536;
  20 + if ($asc >= -20319 and $asc <= -20284) return "A";
  21 + if ($asc >= -20283 and $asc <= -19776) return "B";
  22 + if ($asc >= -19775 and $asc <= -19219) return "C";
  23 + if ($asc >= -19218 and $asc <= -18711) return "D";
  24 + if ($asc >= -18710 and $asc <= -18527) return "E";
  25 + if ($asc >= -18526 and $asc <= -18240) return "F";
  26 + if ($asc >= -18239 and $asc <= -17760) return "G";
  27 + if ($asc >= -17759 and $asc <= -17248) return "H";
  28 + if ($asc >= -17247 and $asc <= -17418) return "I";
  29 + if ($asc >= -17417 and $asc <= -16475) return "J";
  30 + if ($asc >= -16474 and $asc <= -16213) return "K";
  31 + if ($asc >= -16212 and $asc <= -15641) return "L";
  32 + if ($asc >= -15640 and $asc <= -15166) return "M";
  33 + if ($asc >= -15165 and $asc <= -14923) return "N";
  34 + if ($asc >= -14922 and $asc <= -14915) return "O";
  35 + if ($asc >= -14914 and $asc <= -14631) return "P";
  36 + if ($asc >= -14630 and $asc <= -14150) return "Q";
  37 + if ($asc >= -14149 and $asc <= -14091) return "R";
  38 + if ($asc >= -14090 and $asc <= -13319) return "S";
  39 + if ($asc >= -13318 and $asc <= -12839) return "T";
  40 + if ($asc >= -12838 and $asc <= -12557) return "W";
  41 + if ($asc >= -12556 and $asc <= -11848) return "X";
  42 + if ($asc >= -11847 and $asc <= -11056) return "Y";
  43 + if ($asc >= -11055 and $asc <= -10247) return "Z";
  44 + } else if (ord($s) >= 48 && ord($s) <= 57) {//数字开头
  45 + $aa = @iconv_substr($s, 0, 1, 'utf-8');
  46 + switch ($aa) {
  47 + case 1:
  48 + return "Y";
  49 + case 2:
  50 + return "E";
  51 + case 3:
  52 + return "S";
  53 + case 4:
  54 + return "S";
  55 + case 5:
  56 + return "W";
  57 + case 6:
  58 + return "L";
  59 + case 7:
  60 + return "Q";
  61 + case 8:
  62 + return "B";
  63 + case 9:
  64 + return "J";
  65 + case 0:
  66 + return "L";
  67 + }
  68 + } else if (ord($s) >= 65 && ord($s) <= 90) { //大写英文开头
  69 + return substr($s, 0, 1);
  70 + } else if (ord($s) >= 97 && ord($s) <= 122) { //小写英文开头
  71 + return strtoupper(substr($s, 0, 1));
  72 + } else {
  73 + return iconv_substr($s0, 0, 1, 'utf-8');
  74 +//中英混合的词语,不适合上面的各种情况,因此直接提取首个字符即可
  75 + }
  76 + }
  77 +}
  78 +if (!function_exists('http_request')) {
  79 +// curl请求
  80 + function http_request($url, $timeout = 30, $header = array())
  81 + {
  82 + if (!function_exists('curl_init')) {
  83 + throw new Exception('server not install curl');
  84 + }
  85 + $ch = curl_init();
  86 + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  87 + curl_setopt($ch, CURLOPT_HEADER, true);
  88 + curl_setopt($ch, CURLOPT_URL, $url);
  89 + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
  90 + if (!empty($header)) {
  91 + curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  92 + }
  93 + $data = curl_exec($ch);
  94 + list($header, $data) = explode("\r\n\r\n", $data);
  95 + $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  96 + if ($http_code == 301 || $http_code == 302) {
  97 + $matches = array();
  98 + preg_match('/Location:(.*?)\n/', $header, $matches);
  99 + $url = trim(array_pop($matches));
  100 + curl_setopt($ch, CURLOPT_URL, $url);
  101 + curl_setopt($ch, CURLOPT_HEADER, false);
  102 + $data = curl_exec($ch);
  103 + }
  104 +
  105 + if ($data == false) {
  106 + curl_close($ch);
  107 + }
  108 + @curl_close($ch);
  109 +
  110 + return $data;
  111 + }
  112 +}
  113 +
  114 +if (!function_exists('insert_openid_info')) {
  115 + /**
  116 + * 将授权用户信息保存起来
  117 + */
  118 + function insert_openid_info($data)
  119 + {
  120 + $data['upt_time'] = time();
  121 + $res = \think\Db::name("openid_info")->where("openid", $data['openid'])->find();
  122 +// file_put_contents("ccc.txt", date("Y-m-d H:i:s") . json_encode($data) . PHP_EOL, FILE_APPEND);
  123 + if (!empty($res)) {
  124 + \think\Db::name("openid_info")->where("openid", $data['openid'])->update($data);
  125 + } else {
  126 + \think\Db::name("openid_info")->insertGetId($data);
  127 + }
  128 + return true;
  129 + }
  130 +}
  131 +/**
  132 + * 生成订单号
  133 + * 重复就重新生成
  134 + */
  135 +if (!function_exists('getOrderSn')) {
  136 + function getOrderSn()
  137 + {
  138 + $orderid = date("YmdHis") . mt_rand(1000, 999999);
  139 + $odcks = \think\Db::name('order')
  140 + ->where(['order_no' => $orderid])
  141 + ->find();
  142 + while (!empty($odcks)) {
  143 + $orderid = date("YmdHis") . mt_rand(1000, 999999);
  144 + }
  145 + return $orderid;
  146 + }
  147 +}
  148 +
  149 + if(!function_exists('beingPushed')){
  150 + /**
  151 + * 发送模板消息
  152 + * @return void
  153 + * @throws \think\db\exception\DataNotFoundException
  154 + * @throws \think\db\exception\ModelNotFoundException
  155 + * @throws \think\exception\DbException
  156 + */
  157 + function SendMessage($order_id){
  158 + $order=\think\Db::name("order")->find($order_id);
  159 + $wxxcxpush=new WxxcxPush();
  160 + $user=new User();
  161 + $user=$user->find($order['user_id']);
  162 + $res=$wxxcxpush->Message($user['wx_xcx_openid'],$order_id);
  163 + if ($res !== false) {
  164 + return $res;
  165 + }
  166 + }
  167 + }
  168 + if(!function_exists('OrderSendMessage')){
  169 + /**
  170 + * 发送模板消息
  171 + * @return void
  172 + * @throws \think\db\exception\DataNotFoundException
  173 + * @throws \think\db\exception\ModelNotFoundException
  174 + * @throws \think\exception\DbException
  175 + */
  176 + function OrderSendMessage($order_id){
  177 + $order=\think\Db::name("order")->find($order_id);
  178 + $wxxcxpush=new WxxcxPush();
  179 + $user=new User();
  180 + $user=$user->find($order['user_id']);
  181 + $driver=new \app\admin\model\Driver();
  182 + $driver=$driver->find($order['driver_id']);
  183 + $driver_user=$user->find($driver['user_id']);
  184 + $res=$wxxcxpush->Message($driver_user['wx_xcx_openid'],$order_id);
  185 + $res=$wxxcxpush->Message($user['wx_xcx_openid'],$order_id);
  186 + if ($res !== false) {
  187 + return $res;
  188 + }
  189 + }
  190 + }
  191 +
  192 +
  193 + if(!function_exists('beingPushed')){
  194 + /**
  195 + * 发送模板消息
  196 + * @return void
  197 + * @throws \think\db\exception\DataNotFoundException
  198 + * @throws \think\db\exception\ModelNotFoundException
  199 + * @throws \think\exception\DbException
  200 + */
  201 + function refundSendMessage($order_id){
  202 + $order=\think\Db::name("order")->find($order_id);
  203 + $wxxcxpush=new WxxcxPush();
  204 + $user=new User();
  205 + $user=$user->find($order['user_id']);
  206 + $res=$wxxcxpush->refundMessage($user['wx_xcx_openid'],$order_id);
  207 + if ($res !== false) {
  208 + return $res;
  209 + }
  210 + }
  211 + }
  212 +
  213 +
  214 +if (!function_exists('beingPushed')) {
  215 + /**
  216 + * 小程序模板推送选择类型
  217 + * @param $type @模板类型
  218 + * @param $openid @接收人ID
  219 + * @param $page @跳转页面
  220 + * @param $temp @具体提醒参数
  221 + * @throws \think\Exception
  222 + * @throws \think\exception\PDOException
  223 + */
  224 + function beingPushed($type, $openid, $page, $temp)
  225 + {
  226 +
  227 + $data = [];
  228 + $data['touser'] = $openid;
  229 + $data['page'] = $page;
  230 + //模板内容,格式形如 { "key1": { "value": any }, "key2": { "value": any } }
  231 + switch ($type) {
  232 + case 1:
  233 + //待审批事项提醒(新版本的长期订阅)
  234 + $data['template_id'] = "ws6bz6-WyHHA-upU2oRzc_C5toDUexe9ZicQ-ITtImA";
  235 + $data['data'] = [
  236 + "thing10" => [
  237 + 'value' =>$temp['value1'],//审核状态(待处理)
  238 + ],
  239 + "thing12" => [
  240 + 'value' => $temp['value2'],//申请人(测试黄超)
  241 + ],
  242 +
  243 + "thing8" => [
  244 + 'value' => $temp['value3'],//原因(入州报备审核)
  245 + ]
  246 + ];
  247 + break;
  248 + case 2:
  249 + //审核结果通知(新版本的长期订阅)
  250 + $data['template_id'] = "Qt2xqfH8uQyTm1A0ReNxeybtAydAhfhi4HinnyB5f0s";
  251 + $data['data'] = [
  252 + "thing1" => [
  253 + 'value' => $temp['value1'],//提醒内容(已审核)
  254 + ],
  255 +// "name1" => [
  256 +// 'value' => $temp['value2'],//审核人
  257 +// ],
  258 + "thing4" => [
  259 + 'value' => $temp['value3'],//提示说明
  260 + ]
  261 + ];
  262 + break;
  263 + case 3:
  264 + //待审批事项提醒(老版本的一次性订阅)
  265 + $data['template_id'] = "vVOonN76AFjxgz77iG-hcWrH6HJ-vPGKyIyAK0VzPIk";
  266 + $data['data'] = [
  267 + "thing1" => [
  268 + 'value' => $temp['value1'],//待办事项
  269 + ],
  270 + "thing4" => [
  271 + 'value' => $temp['value2'],//流程状态
  272 + ],
  273 + "thing2" => [
  274 + 'value' => $temp['value3'],//申请人
  275 + ],
  276 + "time3" => [
  277 + 'value' => $temp['value4'],//申请时间
  278 + ],
  279 + "thing5" => [
  280 + 'value' => $temp['value5'],//备注描述
  281 + ]
  282 + ];
  283 + break;
  284 + case 4:
  285 + //审核结果通知(老版本的一次性订阅)
  286 + $data['template_id'] = "qR9reAuv_Ulelyg1H2xbN-GoWGWFRhS0t4nhtvnFr5Q";
  287 + $data['data'] = [
  288 + "character_string1" => [
  289 + 'value' => $temp['value1'],//审核结果
  290 + ],
  291 + "date3" => [
  292 + 'value' => $temp['value2'],//审核人
  293 + ],
  294 + "thing5" => [
  295 + 'value' => $temp['value3'],//审批时间
  296 + ],
  297 + "thing6" => [
  298 + 'value' => $temp['value4'],//审批时间
  299 + ],
  300 + "thing7" => [
  301 + 'value' => $temp['value5'],//审批时间
  302 + ]
  303 + ];
  304 + break;
  305 + case 5:
  306 + //预约结果通知
  307 + $data['template_id'] = "oczyQ_SabASMQRRhDedXRGUEzCAuGh1xBw8sp2HVPvQ";
  308 + $data['data'] = [
  309 + "thing1" => [
  310 + 'value' => $temp['value1'],//备注
  311 + ],
  312 + "thing2" => [
  313 + 'value' =>$temp['value2'],//日期
  314 + ],
  315 + "number3" => [
  316 + 'value' => $temp['value3'],//就诊人
  317 + ],
  318 + "time4" => [
  319 + 'value' => $temp['value4'],//就诊人
  320 + ],
  321 + "thing6" => [
  322 + 'value' => $temp['value5'],//就诊人
  323 + ]
  324 + ];
  325 + break;
  326 + case 6:
  327 + //预约结果通知
  328 + $data['template_id'] = "Dfvkyn3So2YE5aVJtkUTFWdjgzpo6VvWkNHZBOMb_n4";
  329 + $data['data'] = [
  330 + "character_string1" => [
  331 + 'value' => $temp['value1'],//备注
  332 + ],
  333 + "number2" => [
  334 + 'value' =>$temp['value2'],//日期
  335 + ],
  336 + "name3" => [
  337 + 'value' => $temp['value3'],//就诊人
  338 + ],
  339 + "date4" => [
  340 + 'value' => $temp['value4'],//就诊人
  341 + ],
  342 + "thing9" => [
  343 + 'value' => $temp['value5'],//就诊人
  344 + ]
  345 + ];
  346 + break;
  347 + }
  348 +
  349 + return sendSubscribeMessage($data);
  350 + }
  351 +}
  352 +
  353 +if (!function_exists('sendSubscribeMessage')) {
  354 + /**
  355 + * 小程序订阅消息推送
  356 + * @param $data
  357 + * @throws \think\Exception
  358 + * @throws \think\exception\PDOException
  359 + */
  360 + function sendSubscribeMessage($data)
  361 + {
  362 + //access_token
  363 + $access_token = getAccessToken();
  364 +
  365 + //请求url
  366 + $url = 'https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=' . $access_token;
  367 +
  368 + //file_put_contents('notify.txt',$data.PHP_EOL,FILE_APPEND);
  369 + //跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版
  370 + $data['miniprogram_state'] = 'formal';
  371 +
  372 + return curlPost($url, json_encode($data));
  373 + }
  374 +}
  375 +
  376 +if (!function_exists('getAccessToken')) {
  377 + /**
  378 + * 获取access_token
  379 + * @return mixed
  380 + * @throws \think\Exception
  381 + * @throws \think\exception\PDOException
  382 + */
  383 + function getAccessToken()
  384 + {
  385 + $wx_xcx_token = \think\Db::name("wechat_token")->where("type", "wx_xcx")->find();
  386 + if (empty($wx_xcx_token) || empty($wx_xcx_token['access_token']) || $wx_xcx_token['over_time'] <= time()) {
  387 + //微信小程序失效
  388 + //当前时间戳
  389 + $now_time = strtotime(date('Y-m-d H:i:s', time()));
  390 +
  391 + //获取新的access_token
  392 + $appid = config("site.wxxcx_AppID");
  393 + $secret = config("site.wxxcx_AppSecret");
  394 + $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $secret;
  395 + $res = json_decode(file_get_contents($url), true);
  396 +
  397 + $access_token = $res['access_token'];
  398 + if (!empty($access_token)) {
  399 + $time = time();
  400 + $update_data = [
  401 + "access_token" => $access_token,
  402 + "over_time" => $time + 7200,
  403 + "type" => "wx_xcx",
  404 + "updatetime" => $time
  405 + ];
  406 + if (!empty($wx_xcx_token)) {
  407 + //更新
  408 + \think\Db::name("wechat_token")->where("id", $wx_xcx_token['id'])->update($update_data);
  409 + } else {
  410 + //新增
  411 + \think\Db::name("wechat_token")->insertGetId($update_data);
  412 + }
  413 + }
  414 + } else {
  415 + $access_token = $wx_xcx_token['access_token'];
  416 + }
  417 + return $access_token;
  418 + }
  419 +}
  420 +
  421 +if (!function_exists('curlPost')) {
  422 + /**
  423 + * 发送post请求
  424 + */
  425 + function curlPost($url, $data)
  426 + {
  427 + $ch = curl_init();
  428 + $params[CURLOPT_URL] = $url; //请求url地址
  429 + $params[CURLOPT_HEADER] = FALSE; //是否返回响应头信息
  430 + $params[CURLOPT_SSL_VERIFYPEER] = false;
  431 + $params[CURLOPT_SSL_VERIFYHOST] = false;
  432 + $params[CURLOPT_RETURNTRANSFER] = true; //是否将结果返回
  433 + $params[CURLOPT_POST] = true;
  434 + $params[CURLOPT_POSTFIELDS] = $data;
  435 + curl_setopt_array($ch, $params); //传入curl参数
  436 + $content = curl_exec($ch); //执行
  437 +// file_put_contents('notify.txt', $content . date('Y-m-d H:i:s', time()) . PHP_EOL, FILE_APPEND);
  438 + curl_close($ch); //关闭连接
  439 + return $content;
  440 + }
  441 +}
  442 +
  443 +if (!function_exists('array_callback')) {
  444 + /**
  445 + * 20190729 kevin
  446 + * 规范数据返回函数
  447 + * @param unknown $state
  448 + * @param unknown $msg
  449 + * @param unknown $data
  450 + * @return multitype:unknown
  451 + */
  452 + function array_callback($state = true, $msg = '', $data = array())
  453 + {
  454 + return array('state' => $state, 'msg' => $msg, 'data' => $data);
  455 + }
  456 +}
  1 +<?php
  2 +
  3 +//配置文件
  4 +return [
  5 + 'exception_handle' => '\\app\\api\\library\\ExceptionHandle',
  6 +];
  1 +<?php
  2 +
  3 +namespace app\api\controller;
  4 +
  5 +use app\api\controller\inspection\Task;
  6 +use app\common\controller\Api;
  7 +use fast\Http;
  8 +
  9 +/**
  10 + * 首页接口
  11 + */
  12 +class Index extends Api
  13 +{
  14 + protected $noNeedLogin = ['*'];
  15 + protected $noNeedRight = ['*'];
  16 +
  17 + /**
  18 + * 首页
  19 + *
  20 + */
  21 + public function index()
  22 + {
  23 + $this->success('请求成功');
  24 + }
  25 +
  26 +
  27 + function getAccessToken() {
  28 + $appId = "wx58ceff4e93cfc523";
  29 + $appSecret = "baf744d21875280a5e98611f66adaf91";
  30 + $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appId}&secret={$appSecret}";
  31 + $result = json_decode(file_get_contents($url), true);
  32 + return $result["access_token"] ?? null;
  33 + }
  34 + function createMiniProgramQRCode($accessToken, $path, $width = 430) {
  35 + $url = "https://api.weixin.qq.com/wxa/getwxacode?access_token={$accessToken}";
  36 +
  37 + $data = json_encode([
  38 + 'path' => $path,
  39 + 'width' => $width
  40 + ]);
  41 + $options = [
  42 + 'http' => [
  43 + 'method' => 'POST',
  44 + 'header' => 'Content-type:application/json',
  45 + 'content' => $data,
  46 + ],
  47 + ];
  48 + //POST参数
  49 + $result = $this->httpRequest($url,$data,"POST");
  50 + $file_name=md5(rand(1000,9999).time()). '.png';
  51 + $filename= 'uploads/' . $file_name ;
  52 + $ret = file_put_contents($filename, $result, true);
  53 + $task=new Task();
  54 + $res=$task->fileUpload($file_name);
  55 + return $res;
  56 + }
  57 + //把请求发送到微信服务器换取二维码
  58 + public function httpRequest($url,$data='',$method='GET'){
  59 + $curl = curl_init();
  60 + curl_setopt($curl, CURLOPT_URL,$url);
  61 + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
  62 + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
  63 + curl_setopt($curl, CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);
  64 + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
  65 + curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
  66 + if($method=='POST')
  67 + {
  68 + curl_setopt($curl, CURLOPT_POST, 1);
  69 + if ($data !='')
  70 + {
  71 + curl_setopt($curl, CURLOPT_POSTFIELDS,$data);
  72 + }
  73 + }
  74 +
  75 + curl_setopt($curl, CURLOPT_TIMEOUT, 30);
  76 + curl_setopt($curl, CURLOPT_HEADER, 0);
  77 + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  78 + $result = curl_exec($curl);
  79 + curl_close($curl);
  80 + return $result;
  81 + }
  82 + public function test(){
  83 + $accessToken = $this->getAccessToken();
  84 + if ($accessToken) {
  85 + $path = 'pages/index/index'; // 小程序内的页面路径
  86 + $qrCodeData = $this->createMiniProgramQRCode($accessToken, $path);
  87 + print_r($qrCodeData);return;
  88 + return $qrCodeData;
  89 + }
  90 + }
  91 +
  92 +
  93 + /***
  94 + * 公众号推送审核信息给经纪人
  95 + */
  96 + public function senWxmsgToAgentUser($titdesc="", $remark="")
  97 + { $appId = 'wxb7dd0c03865a94e0';
  98 + $appSecret = '6af75a6fb8211da45631630e34769f82';
  99 + $openId = 'o5ABA4yWDTLRTf3LkBMMHoV7XOvQ';
  100 + $unionId = 'ojyUX6oNFoQMqoCd1JWtfwQs-CeA';
  101 + // 获取token
  102 + $myurl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appId . "&secret=" . $appSecret;
  103 + $json_token = http_request($myurl);
  104 + $access_tokens = json_decode($json_token, true);
  105 + $accessToken = $access_tokens['access_token'];
  106 +// 发送消息的接口地址
  107 + $sendMessageUrl = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$accessToken}";
  108 +
  109 +// 构造要发送的消息数据
  110 + $data = [
  111 + 'touser' => $openId,
  112 + 'msgtype' => 'text',
  113 + 'text' => [
  114 + 'content' => '你好,这是一个公众号消息'
  115 + ]
  116 + ];
  117 +
  118 +// 对数据进行JSON编码
  119 + $jsonData = json_encode($data, JSON_UNESCAPED_UNICODE);
  120 +
  121 +// 发送HTTP POST请求
  122 + $ch = curl_init();
  123 + curl_setopt($ch, CURLOPT_URL, $sendMessageUrl);
  124 + curl_setopt($ch, CURLOPT_POST, true);
  125 + curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
  126 + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  127 + $response = curl_exec($ch);
  128 + curl_close($ch);
  129 +
  130 +// 处理响应结果
  131 + $result = json_decode($response, true);
  132 + if ($result['errcode'] == 0) {
  133 + echo "消息发送成功";
  134 + } else {
  135 + echo "消息发送失败,错误代码:{$result['errcode']},错误信息:{$result['errmsg']}";
  136 + }
  137 + }
  138 + function http_request($url, $data = array())
  139 + {
  140 + $ch = curl_init();
  141 + curl_setopt($ch, CURLOPT_URL, $url);
  142 + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  143 + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  144 + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  145 + // 我们在POST数据哦!
  146 + curl_setopt($ch, CURLOPT_POST, 1);
  147 + // 把post的变量加上
  148 + curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  149 + $output = curl_exec($ch);
  150 + curl_close($ch);
  151 + return $output;
  152 + }
  153 +}
  1 +<?php
  2 +
  3 +return [
  4 + 'Keep login' => '保持会话',
  5 + 'Username' => '用户名',
  6 + 'User id' => '会员ID',
  7 + 'Nickname' => '昵称',
  8 + 'Password' => '密码',
  9 + 'Sign up' => '注 册',
  10 + 'Sign in' => '登 录',
  11 + 'Sign out' => '退 出',
  12 + 'Guest' => '游客',
  13 + 'Welcome' => '%s,你好!',
  14 + 'Add' => '添加',
  15 + 'Edit' => '编辑',
  16 + 'Delete' => '删除',
  17 + 'Move' => '移动',
  18 + 'Name' => '名称',
  19 + 'Status' => '状态',
  20 + 'Weigh' => '权重',
  21 + 'Operate' => '操作',
  22 + 'Warning' => '温馨提示',
  23 + 'Default' => '默认',
  24 + 'Article' => '文章',
  25 + 'Page' => '单页',
  26 + 'OK' => '确定',
  27 + 'Cancel' => '取消',
  28 + 'Loading' => '加载中',
  29 + 'More' => '更多',
  30 + 'Normal' => '正常',
  31 + 'Hidden' => '隐藏',
  32 + 'Submit' => '提交',
  33 + 'Reset' => '重置',
  34 + 'Execute' => '执行',
  35 + 'Close' => '关闭',
  36 + 'Search' => '搜索',
  37 + 'Refresh' => '刷新',
  38 + 'First' => '首页',
  39 + 'Previous' => '上一页',
  40 + 'Next' => '下一页',
  41 + 'Last' => '末页',
  42 + 'None' => '无',
  43 + 'Home' => '主页',
  44 + 'Online' => '在线',
  45 + 'Logout' => '退出',
  46 + 'Profile' => '个人资料',
  47 + 'Index' => '首页',
  48 + 'Hot' => '热门',
  49 + 'Recommend' => '推荐',
  50 + 'Dashboard' => '控制台',
  51 + 'Code' => '编号',
  52 + 'Message' => '内容',
  53 + 'Line' => '行号',
  54 + 'File' => '文件',
  55 + 'Menu' => '菜单',
  56 + 'Type' => '类型',
  57 + 'Title' => '标题',
  58 + 'Content' => '内容',
  59 + 'Append' => '追加',
  60 + 'Memo' => '备注',
  61 + 'Parent' => '父级',
  62 + 'Params' => '参数',
  63 + 'Permission' => '权限',
  64 + 'Advance search' => '高级搜索',
  65 + 'Check all' => '选中全部',
  66 + 'Expand all' => '展开全部',
  67 + 'Begin time' => '开始时间',
  68 + 'End time' => '结束时间',
  69 + 'Create time' => '创建时间',
  70 + 'Flag' => '标志',
  71 + 'Please login first' => '请登录后操作',
  72 + 'Uploaded successful' => '上传成功',
  73 + 'You can upload up to %d file%s' => '你最多还可以上传%d个文件',
  74 + 'You can choose up to %d file%s' => '你最多还可以选择%d个文件',
  75 + 'Chunk file write error' => '分片写入失败',
  76 + 'Chunk file info error' => '分片文件错误',
  77 + 'Chunk file merge error' => '分片合并错误',
  78 + 'Chunk file disabled' => '未开启分片上传功能',
  79 + 'Cancel upload' => '取消上传',
  80 + 'Upload canceled' => '上传已取消',
  81 + 'No file upload or server upload limit exceeded' => '未上传文件或超出服务器上传限制',
  82 + 'Uploaded file format is limited' => '上传文件格式受限制',
  83 + 'Uploaded file is not a valid image' => '上传文件不是有效的图片文件',
  84 + 'Are you sure you want to cancel this upload?' => '确定取消上传?',
  85 + 'Remove file' => '移除文件',
  86 + 'You can only upload a maximum of %s files' => '你最多允许上传 %s 个文件',
  87 + 'You can\'t upload files of this type' => '不允许上传的文件类型',
  88 + 'Server responded with %s code' => '服务端响应(Code:%s)',
  89 + 'File is too big (%sMiB), Max filesize: %sMiB' => '当前上传(%sM),最大允许上传文件大小:%sM',
  90 + 'Redirect now' => '立即跳转',
  91 + 'Operation completed' => '操作成功!',
  92 + 'Operation failed' => '操作失败!',
  93 + 'Unknown data format' => '未知的数据格式!',
  94 + 'Network error' => '网络错误!',
  95 + 'Advanced search' => '高级搜索',
  96 + 'Invalid parameters' => '未知参数',
  97 + 'No results were found' => '记录未找到',
  98 + 'Parameter %s can not be empty' => '参数%s不能为空',
  99 + 'You have no permission' => '你没有权限访问',
  100 + 'An unexpected error occurred' => '发生了一个意外错误,程序猿正在紧急处理中',
  101 + 'This page will be re-directed in %s seconds' => '页面将在 %s 秒后自动跳转',
  102 +];
  1 +<?php
  2 +
  3 +return [];
  1 +<?php
  2 +
  3 +return [
  4 + 'User center' => '会员中心',
  5 + 'Register' => '注册',
  6 + 'Login' => '登录',
  7 + 'Sign up successful' => '注册成功',
  8 + 'Username can not be empty' => '用户名不能为空',
  9 + 'Username must be 3 to 30 characters' => '用户名必须3-30个字符',
  10 + 'Username must be 6 to 30 characters' => '用户名必须6-30个字符',
  11 + 'Password can not be empty' => '密码不能为空',
  12 + 'Password must be 6 to 30 characters' => '密码必须6-30个字符',
  13 + 'Mobile is incorrect' => '手机格式不正确',
  14 + 'Username already exist' => '用户名已经存在',
  15 + 'Nickname already exist' => '昵称已经存在',
  16 + 'Email already exist' => '邮箱已经存在',
  17 + 'Mobile already exist' => '手机号已经存在',
  18 + 'Username is incorrect' => '用户名不正确',
  19 + 'Email is incorrect' => '邮箱不正确',
  20 + 'Account is locked' => '账户已经被锁定',
  21 + 'Password is incorrect' => '密码不正确',
  22 + 'Account is incorrect' => '账户不正确',
  23 + 'Account not exist' => '账户不存在',
  24 + 'Account can not be empty' => '账户不能为空',
  25 + 'Username or password is incorrect' => '用户名或密码不正确',
  26 + 'You are not logged in' => '你当前还未登录',
  27 + 'You\'ve logged in, do not login again' => '你已经存在,请不要重复登录',
  28 + 'Profile' => '个人资料',
  29 + 'Verify email' => '邮箱验证',
  30 + 'Change password' => '修改密码',
  31 + 'Captcha is incorrect' => '验证码不正确',
  32 + 'Logged in successful' => '登录成功',
  33 + 'Logout successful' => '退出成功',
  34 + 'Operation failed' => '操作失败',
  35 + 'Invalid parameters' => '参数不正确',
  36 + 'Change password failure' => '修改密码失败',
  37 + 'Change password successful' => '修改密码成功',
  38 + 'Reset password successful' => '重置密码成功',
  39 +];
  1 +<?php
  2 +
  3 +namespace app\api\library;
  4 +
  5 +use Exception;
  6 +use think\exception\Handle;
  7 +
  8 +/**
  9 + * 自定义API模块的错误显示
  10 + */
  11 +class ExceptionHandle extends Handle
  12 +{
  13 +
  14 + public function render(Exception $e)
  15 + {
  16 + // 在生产环境下返回code信息
  17 + if (!\think\Config::get('app_debug')) {
  18 + $statuscode = $code = 500;
  19 + $msg = 'An error occurred';
  20 + // 验证异常
  21 + if ($e instanceof \think\exception\ValidateException) {
  22 + $code = 0;
  23 + $statuscode = 200;
  24 + $msg = $e->getError();
  25 + }
  26 + // Http异常
  27 + if ($e instanceof \think\exception\HttpException) {
  28 + $statuscode = $code = $e->getStatusCode();
  29 + }
  30 + return json(['code' => $code, 'msg' => $msg, 'time' => time(), 'data' => null], $statuscode);
  31 + }
  32 +
  33 + //其它此交由系统处理
  34 + return parent::render($e);
  35 + }
  36 +
  37 +}
  1 +<!DOCTYPE html>
  2 +<html lang="en">
  3 +<head>
  4 + <meta charset="UTF-8">
  5 + <title>Title</title>
  6 +</head>
  7 +<body>
  8 +
  9 +</body>
  10 +</html>
  1 +.weixin-menu-setting {
  2 + margin: 0;
  3 + margin-bottom: 10px;
  4 + width: 100%;
  5 +}
  6 +
  7 +.mobile-head-title {
  8 + color: #fff;
  9 + text-align: center;
  10 + padding-top: 33px;
  11 + font-size: 15px;
  12 + width: auto;
  13 + overflow: hidden;
  14 + text-overflow: ellipsis;
  15 + white-space: nowrap;
  16 + word-wrap: normal;
  17 + margin: 0 40px 0 70px;
  18 +}
  19 +
  20 +.weixin-body {
  21 + padding: 0;
  22 + margin: 0;
  23 + margin-left: 337px;
  24 +}
  25 +
  26 +.weixin-content, .no-weixin-content {
  27 + background-color: #f4f5f9;
  28 + border: 1px solid #e7e7eb;
  29 + padding: 15px;
  30 +}
  31 +
  32 +.no-weixin-content {
  33 + border: #fff;
  34 + background-color: #fff;
  35 + vertical-align: middle;
  36 + padding-top: 200px;
  37 + text-align: center;
  38 +}
  39 +
  40 +@media (max-width: 720px) {
  41 + .weixin-body {
  42 + margin-left: 0;
  43 + margin-top: 560px;
  44 + }
  45 +}
  46 +
  47 +.weixin-menu-title {
  48 + border-bottom: 1px solid #e7e7eb;
  49 + font-size: 16px;
  50 + padding: 0 20px;
  51 + line-height: 55px;
  52 + margin-bottom: 20px;
  53 +}
  54 +
  55 +.mobile-menu-preview {
  56 + display: block;
  57 + float: left;
  58 + position: relative;
  59 + width: 317px;
  60 + height: 550px;
  61 + background: transparent url(../images/mobile_header_bg.png) no-repeat 0 0;
  62 + background-position: 0 0;
  63 + border: 1px solid #e7e7eb;
  64 +}
  65 +
  66 +.mobile-menu-preview .menu-list {
  67 + position: absolute;
  68 + height: 50px;
  69 + bottom: 0;
  70 + left: 0;
  71 + right: 0;
  72 + border-top: 1px solid #e7e7eb;
  73 + background: transparent url(../images/mobile_footer_bg.png) no-repeat 0 0;
  74 + background-position: 0 0;
  75 + background-repeat: no-repeat;
  76 + padding-left: 43px;
  77 + margin: 0;
  78 +}
  79 +
  80 +.menu-list .menu-item, .menu-list .add-item {
  81 + line-height: 50px;
  82 + position: relative;
  83 + float: left;
  84 + text-align: center;
  85 + width: 33.33%;
  86 + list-style: none;
  87 +}
  88 +
  89 +.ui-sortable-placeholder {
  90 + background-color: #fff;
  91 +}
  92 +
  93 +.menu-item a, .add-item a {
  94 + display: block;
  95 + width: auto;
  96 + overflow: hidden;
  97 + text-overflow: ellipsis;
  98 + white-space: nowrap;
  99 + word-wrap: normal;
  100 + color: #616161;
  101 + text-decoration: none;
  102 +}
  103 +
  104 +.menu-item.current a.menu-link {
  105 + border: 1px solid #44b549;
  106 + line-height: 48px;
  107 + background-color: #fff;
  108 + color: #44b549;
  109 +}
  110 +
  111 +.menu-item .icon-menu-dot {
  112 + background: url(../images/mobile_index.png) 0 0 no-repeat;
  113 + width: 7px;
  114 + height: 7px;
  115 + vertical-align: middle;
  116 + display: inline-block;
  117 + margin-right: 2px;
  118 + margin-top: -2px;
  119 + bottom: 60px;
  120 + background-color: #fafafa;
  121 + border-top-width: 0;
  122 +}
  123 +
  124 +.menu-item .menu-link, .add-item .menu-link {
  125 + border-left-width: 0;
  126 + border-left: 1px solid #e7e7eb;
  127 + text-align: center;
  128 +}
  129 +
  130 +.sub-menu-item a, .add-sub-item a {
  131 + border: 1px solid #d0d0d0;
  132 + position: relative;
  133 + padding: 0 0.5em;
  134 +}
  135 +
  136 +.sub-menu-item.current a {
  137 + border: 1px solid #44b549;
  138 + background-color: #fff;
  139 + color: #44b549;
  140 + z-index: 1;
  141 +}
  142 +
  143 +.sub-menu-list li a:hover {
  144 + background: #f1f1f1;
  145 +}
  146 +
  147 +.menu-item.current .menu-link {
  148 + border: 1px solid #44b549;
  149 + line-height: 48px;
  150 + background-color: #fff;
  151 + color: #44b549;
  152 +}
  153 +
  154 +.sub-menu-box {
  155 + position: absolute;
  156 + bottom: 60px;
  157 + left: 0;
  158 + width: 100%;
  159 + background-color: #fff;
  160 + border-top: none;
  161 +}
  162 +
  163 +.sub-menu-list {
  164 + line-height: 50px;
  165 + margin: 0;
  166 + padding: 0;
  167 +}
  168 +
  169 +.sub-menu-list li {
  170 + line-height: 44px;
  171 + margin: -1px -1px 0;
  172 + list-style: none;
  173 +}
  174 +
  175 +.sub-menu-box .arrow {
  176 + position: absolute;
  177 + left: 50%;
  178 + margin-left: -6px;
  179 +}
  180 +
  181 +.sub-menu-box .arrow-in {
  182 + bottom: -5px;
  183 + display: inline-block;
  184 + width: 0;
  185 + height: 0;
  186 + border-width: 6px;
  187 + border-style: dashed;
  188 + border-color: transparent;
  189 + border-bottom-width: 0;
  190 + border-top-color: #fafafa;
  191 + border-top-style: solid;
  192 +}
  193 +
  194 +.sub-menu-box .arrow-out {
  195 + bottom: -6px;
  196 + display: inline-block;
  197 + width: 0;
  198 + height: 0;
  199 + border-width: 6px;
  200 + border-style: dashed;
  201 + border-color: transparent;
  202 + border-bottom-width: 0;
  203 + border-top-color: #d0d0d0;
  204 + border-top-style: solid;
  205 +}
  206 +
  207 +.sub-menu-item.current {
  208 +
  209 +}
  210 +
  211 +.sub-menu-inner-add {
  212 + display: block;
  213 + border-top: 1px solid #e7e7eb;
  214 + width: auto;
  215 + overflow: hidden;
  216 + text-overflow: ellipsis;
  217 + white-space: nowrap;
  218 + word-wrap: normal;
  219 + cursor: pointer;
  220 +}
  221 +
  222 +.weixin-icon {
  223 + background: url(../images/weixin_icon.png) 0 -4418px no-repeat;
  224 + width: 16px;
  225 + height: 16px;
  226 + vertical-align: middle;
  227 + display: inline-block;
  228 + line-height: 100px;
  229 + overflow: hidden;
  230 +}
  231 +
  232 +.weixin-icon.add-gray {
  233 + background-position: 0 0;
  234 +}
  235 +
  236 +.weixin-icon.sort-gray {
  237 + background: url(../images/weixin_icon.png) 0 -32px no-repeat;
  238 + background-position: 0 -32px;
  239 + margin-top: -1px;
  240 + display: none;
  241 + width: 20px;
  242 +}
  243 +
  244 +.weixin-icon.big-add-gray {
  245 + background-position: -36px 0;
  246 + width: 36px;
  247 + height: 36px;
  248 + vertical-align: middle;
  249 +}
  250 +
  251 +.menu-item a.menu-link:hover {
  252 +
  253 +}
  254 +
  255 +.add-item.extra, .add-item.extra {
  256 + float: none;
  257 + width: auto;
  258 + overflow: hidden;
  259 +}
  260 +
  261 +table.btn-bar {
  262 + width: 100%;
  263 +}
  264 +
  265 +table.btn-bar td {
  266 + text-align: center;
  267 +}
  268 +
  269 +.item-info .item-head {
  270 + position: relative;
  271 + padding: 0;
  272 + border-bottom: 1px solid #e7e7eb;
  273 +}
  274 +
  275 +.item-info .item-delete {
  276 + position: absolute;
  277 + top: 0;
  278 + right: 0;
  279 +}
  280 +
  281 +table.weixin-form td {
  282 + vertical-align: middle;
  283 + height: 24px;
  284 + line-height: 24px;
  285 + padding: 8px 0;
  286 +}
  287 +
  288 +#menu-content {
  289 + background-color: #fff;
  290 + padding: 16px 20px;
  291 + border: 1px solid #e7e7eb;
  292 +}
  293 +
  294 +.menu-content-tips {
  295 + color: #8d8d8d;
  296 + padding-bottom: 10px;
  297 +}
  298 +
  299 +.form-item dl {
  300 + position: relative;
  301 + margin: 10px 0;
  302 +}
  303 +
  304 +.form-item dl dt {
  305 + width: 90px;
  306 + height: 30px;
  307 + line-height: 30px;
  308 + text-align: right;
  309 + position: absolute;
  310 + vertical-align: middle;
  311 + top: 0;
  312 + left: 0;
  313 + bottom: 0;
  314 + display: block;
  315 +}
  316 +
  317 +.form-item dl dd {
  318 + position: relative;
  319 + display: block;
  320 + margin-left: 90px;
  321 + line-height: 30px;
  322 +}
  323 +
  324 +.form-item .input-box {
  325 + display: inline-block;
  326 + position: relative;
  327 + height: 30px;
  328 + line-height: 30px;
  329 + vertical-align: middle;
  330 + width: 278px;
  331 + font-size: 14px;
  332 + padding: 0 10px;
  333 + border: 1px solid #e7e7eb;
  334 + box-shadow: none;
  335 + -moz-box-shadow: none;
  336 + -webkit-box-shadow: none;
  337 + border-radius: 0;
  338 + -moz-border-radius: 0;
  339 + -webkit-border-radius: 0;
  340 + background-color: #fff;
  341 +}
  342 +
  343 +.form-item .input-box input {
  344 + width: 100%;
  345 + background-color: transparent;
  346 + border: 0;
  347 + outline: 0;
  348 + height: 30px;
  349 +}
  350 +
  351 +.clickbox {
  352 + text-align: center;
  353 + margin: 40px 0;
  354 +}
  355 +
  356 +.create-click {
  357 + display: inline-block;
  358 + padding-top: 30px;
  359 + position: relative;
  360 + width: 240px;
  361 + height: 120px;
  362 + border: 2px dotted #d9dadc;
  363 + text-align: center;
  364 + margin-bottom: 20px;
  365 + margin-left: 50px;
  366 +}
  367 +
  368 +.create-click a {
  369 + display: block;
  370 +}
  371 +
  372 +.create-click a strong {
  373 + display: block;
  374 +}
  375 +
  376 +.keytitle {
  377 + position: absolute;
  378 + width: 100%;
  379 + text-align: center;
  380 + top: 0px;
  381 + height: 35px;
  382 + line-height: 35px;
  383 + background: #f4f5f9;
  384 +}
  385 +
  386 +dl.is-item dd > label {
  387 + margin-left: 5px;
  388 +}