| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- /**
- * 时间
- */
- function tranTime($utime)
- {
- $time = time() - $utime;
- if ($time < 60) {
- $str = '刚刚';
- } elseif ($time < 60 * 60) {
- $min = floor($time / 60);
- $str = $min . '分钟前';
- } elseif ($time < 60 * 60 * 24) {
- $h = floor($time / (60 * 60));
- $str = $h . '小时前';
- } elseif ($time < 60 * 60 * 24 * 3) {
- $d = floor($time / (60 * 60 * 24));
- if ($d == 1) {
- $str = '昨天';
- } else {
- $str = '前天';
- }
- } else {
- $str = date("m-d", $utime);
- }
- return $str;
- }
- function get_user_id()
- {
- $sessionUserId = session('user.id');
- if (empty($sessionUserId)) {
- return 0;
- }
- return $sessionUserId;
- }
- function get_type()
- {
- $sessionType = session('user.type');
- if (empty($sessionType)) {
- return 0;
- }
- return $sessionType;
- }
- function my_redirect(string $url = '', int $code = 302)
- {
- throw new \think\exception\HttpResponseException(redirect($url, $code));
- }
- function page_result($code = 0, $msg = '', $data = [])
- {
- $res = ['code' => $code, 'msg' => $msg, 'data' => $data];
- $response = \think\Response::create($res, 'json');
- throw new \think\exception\HttpResponseException($response);
- }
- function addPByN($str)
- {
- $comdetails = '';
- $comdetails_arr = explode("\n", $str);
- foreach ($comdetails_arr as $v) {
- $comdetails .= "<p>{$v}</p>";
- }
- return $comdetails;
- }
- function getWorkExperience($type = 'json')
- {
- $json = '[
- {id: 1, text: "无经验"},
- {id: 2, text: "一年以下"},
- {id: 3, text: "1-3年"},
- {id: 4, text: "3-5年"},
- {id: 5, text: "5-10年"},
- {id: 6, text: "10年以上"}
- ]';
- return $type == 'json' ? $json : json_decode($json, true);
- }
- function getEducation($type = 'json')
- {
- $json = '[
- {id: 1, text: "初中"},
- {id: 2, text: "高中"},
- {id: 3, text: "中技"},
- {id: 4, text: "中专"},
- {id: 5, text: "大专"},
- {id: 6, text: "本科"},
- {id: 7, text: "硕士"},
- {id: 8, text: "博士"},
- ]';
- return $type == 'json' ? $json : json_decode($json, true);
- }
|