| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- // 应用公共文件
- function jump($msg = '', $url = null, $wait = 3)
- {
- if (is_null($url)) {
- $url = 'javascript:history.back(-1);';
- } else {
- $url = "location.href = '" . url($url) . "'";
- }
- $result = [
- 'msg' => $msg,
- 'url' => $url,
- 'wait' => $wait,
- ];
- $html = view('/public/jump', $result);
- throw new \think\exception\HttpResponseException($html);
- }
- function ajax_success($data = '')
- {
- $res = ['code' => 0, 'msg' => '成功', 'data' => $data];
- $response = \think\Response::create($res, 'json');
- throw new \think\exception\HttpResponseException($response);
- }
- function ajax_error($msg = '', $data = [])
- {
- ajax_return(1, $msg, $data);
- }
- function get_user_id()
- {
- $sessionUserId = session('mobile.user.id');
- if (empty($sessionUserId)) {
- session('back_url', request()->url());
- $response = redirect('/mobile/login/login');
- throw new \think\exception\HttpResponseException($response);
- }
- return $sessionUserId;
- }
- function get_soldier()
- {
- $id = session('mobile.soldier.id');
- if (empty($id)) {
- $response = redirect('/mobile/soldier/login');
- throw new \think\exception\HttpResponseException($response);
- }
- $soldier = \app\common\model\SoldierModel::find($id);
- return $soldier;
- }
- function get_open_id()
- {
- $open_id = session('mobile.open_id');
- if (empty($open_id)) {
- $response = redirect('/mobile/seat/login');
- throw new \think\exception\HttpResponseException($response);
- }
- return $open_id;
- }
- function tip($title = '', $msg = '')
- {
- $result = [
- 'title' => $title,
- 'msg' => $msg,
- ];
- $html = view('/public/tip', $result);
- throw new \think\exception\HttpResponseException($html);
- }
|