Skip to content

Commit 9b34342

Browse files
committed
修正恼人的浏览器翻译提醒
1 parent 4ed4d38 commit 9b34342

File tree

18 files changed

+490
-32
lines changed

18 files changed

+490
-32
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use App\Http\Models\ArticleLog;
7+
use Log;
8+
9+
class AutoGetLocationInfoJob extends Command
10+
{
11+
protected $signature = 'command:autoGetLocationInfoJob';
12+
protected $description = '自动获取经纬度对应的地址信息';
13+
14+
public function __construct()
15+
{
16+
parent::__construct();
17+
}
18+
19+
public function handle()
20+
{
21+
$articleLogList = ArticleLog::where('is_pull', 0)->get();
22+
foreach ($articleLogList as $articleLog) {
23+
$url = "http://apis.map.qq.com/ws/geocoder/v1/?location=" . $articleLog->lat . ',' . $articleLog->lng . '&key=XXXXX';
24+
$ret = file_get_contents($url);
25+
$result = json_decode($ret, true);
26+
//Log::info(var_export($result, true));
27+
28+
if ($result['status']) {
29+
continue;
30+
Log::error('文章日志通过API获取坐标对应的地址信息失败.');
31+
}
32+
33+
// 更新日志信息
34+
$data = [
35+
'nation' => $result['result']['address_component']['nation'],
36+
'province' => $result['result']['address_component']['province'],
37+
'city' => $result['result']['address_component']['city'],
38+
'district' => $result['result']['address_component']['district'],
39+
'street' => $result['result']['address_component']['street'],
40+
'street_number' => $result['result']['address_component']['street_number'],
41+
'address' => $result['result']['address'],
42+
'full' => $ret,
43+
'is_pull' => 1
44+
];
45+
46+
ArticleLog::where('id', $articleLog->id)->update($data);
47+
48+
// 暂停一秒,防止QPS超限导致返回错误
49+
sleep(1);
50+
}
51+
}
52+
}

app/Console/Kernel.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ class Kernel extends ConsoleKernel
1515
protected $commands = [
1616
\App\Console\Commands\AutoDecGoodsTrafficJob::class,
1717
\App\Console\Commands\AutoDisableExpireUserJob::class,
18-
\App\Console\Commands\AutoExpireInviteJob::class,
1918
\App\Console\Commands\AutoExpireCouponJob::class,
19+
\App\Console\Commands\AutoExpireInviteJob::class,
20+
//\App\Console\Commands\AutoGetLocationInfoJob::class,
2021
\App\Console\Commands\AutoResetUserTrafficJob::class,
2122
\App\Console\Commands\UserExpireWarningJob::class,
2223
\App\Console\Commands\UserTrafficWarningJob::class,
@@ -34,6 +35,7 @@ protected function schedule(Schedule $schedule)
3435
$schedule->command('command:autoDisableExpireUserJob')->everyMinute();
3536
$schedule->command('command:autoExpireCouponJob')->everyThirtyMinutes();
3637
$schedule->command('command:autoExpireInviteJob')->everyThirtyMinutes();
38+
//$schedule->command('command:autoGetLocationInfoJob')->everyMinute();
3739
$schedule->command('command:autoResetUserTrafficJob')->monthly();
3840
$schedule->command('command:userExpireWarningJob')->daily();
3941
$schedule->command('command:userTrafficWarningJob')->daily();

app/Http/Controllers/AdminController.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Http\Controllers;
44

55
use App\Http\Models\Article;
6+
use App\Http\Models\ArticleLog;
67
use App\Http\Models\Config;
78
use App\Http\Models\Invite;
89
use App\Http\Models\OrderGoods;
@@ -488,6 +489,14 @@ public function articleList(Request $request)
488489
return Response::view('admin/articleList', $view);
489490
}
490491

492+
// 文章访问日志列表
493+
public function articleLogList(Request $request)
494+
{
495+
$view['articleLogList'] = ArticleLog::paginate(10)->appends($request->except('page'));
496+
497+
return Response::view('admin/articleLogList', $view);
498+
}
499+
491500
// 添加文章
492501
public function addArticle(Request $request)
493502
{
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use App\Http\Models\Article;
6+
use Illuminate\Http\Request;
7+
use Response;
8+
9+
/**
10+
* 文章控制器
11+
* Class SubscribeController
12+
* @package App\Http\Controllers
13+
*/
14+
class ArticleController extends BaseController
15+
{
16+
// 文章详情页
17+
public function index(Request $request)
18+
{
19+
$id = $request->get('id');
20+
21+
$view['info'] = Article::where('is_del', 0)->where('id', $id)->first();
22+
if (empty($view['info'])) {
23+
exit('文章已删除');
24+
}
25+
26+
return Response::view('article/detail', $view);
27+
}
28+
29+
}

app/Http/Controllers/BaseController.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,16 @@ public function formatBytes($bytes, $precision = 2)
167167
return round($bytes, $precision) . ' ' . $units[$pow];
168168
}
169169

170+
// 浏览器类型
171+
public function browsers($tag)
172+
{
173+
$data = [
174+
'MicroMessenger' => '微信',
175+
'iPhone' => 'iPhone',
176+
'Linux' => '安卓'
177+
];
178+
}
179+
170180
/**
171181
* 写入邮件发送日志
172182
* @param int $user_id 用户ID
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use App\Http\Models\ArticleLog;
6+
use Illuminate\Http\Request;
7+
use Response;
8+
9+
/**
10+
* 定位控制器
11+
* Class LocateController
12+
* @package App\Http\Controllers
13+
*/
14+
class LocateController extends BaseController
15+
{
16+
// 接收打开文章时上报的定位坐标信息
17+
public function locate(Request $request)
18+
{
19+
$aid = $request->get('aid');
20+
$lat = $request->get('lat');
21+
$lng = $request->get('lng');
22+
23+
if (empty($lat) || empty($lng)) {
24+
return Response::json(['status' => 'fail', 'data' => '', 'message' => '经纬度不能为空']);
25+
}
26+
27+
// 将坐标写入文章打开记录中
28+
$articleLog = new ArticleLog();
29+
$articleLog->aid = $aid;
30+
$articleLog->lat = $lat;
31+
$articleLog->lng = $lng;
32+
$articleLog->ip = $request->getClientIp();
33+
$articleLog->headers = $request->header('User-Agent');
34+
$articleLog->created_at = date('Y-m-d H:i:s');
35+
$articleLog->save();
36+
37+
return Response::json(['status' => 'success', 'data' => '', 'message' => '坐标上报成功']);
38+
}
39+
40+
}

app/Http/Models/ArticleLog.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace App\Http\Models;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
/**
8+
* 文章日志
9+
* Class ArticleLog
10+
* @package App\Http\Models
11+
*/
12+
class ArticleLog extends Model
13+
{
14+
protected $table = 'article_log';
15+
protected $primaryKey = 'id';
16+
protected $fillable = [
17+
'aid',
18+
'lat',
19+
'lng',
20+
'ip',
21+
'headers',
22+
'nation',
23+
'province',
24+
'city',
25+
'district',
26+
'street',
27+
'street_number',
28+
'address',
29+
'full',
30+
'is_pull',
31+
'status'
32+
];
33+
34+
}

config/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
|
7878
*/
7979

80-
'locale' => 'en',
80+
'locale' => 'zh-CN',
8181

8282
/*
8383
|--------------------------------------------------------------------------

resources/views/404.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<!DOCTYPE html>
2-
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
3-
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
2+
<!--[if IE 8]> <html lang="{{app()->getLocale()}}" class="ie8 no-js"> <![endif]-->
3+
<!--[if IE 9]> <html lang="{{app()->getLocale()}}" class="ie9 no-js"> <![endif]-->
44
<!--[if !IE]><!-->
5-
<html lang="en">
5+
<html lang="{{app()->getLocale()}}">
66
<!--<![endif]-->
77
<!-- BEGIN HEAD -->
88

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
@extends('admin.layouts')
2+
3+
@section('css')
4+
<link href="/assets/global/plugins/datatables/datatables.min.css" rel="stylesheet" type="text/css" />
5+
<link href="/assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.css" rel="stylesheet" type="text/css" />
6+
@endsection
7+
@section('title', '控制面板')
8+
@section('content')
9+
<!-- BEGIN CONTENT BODY -->
10+
<div class="page-content">
11+
<!-- BEGIN PAGE BREADCRUMB -->
12+
<ul class="page-breadcrumb breadcrumb">
13+
<li>
14+
<a href="{{url('admin/articleList')}}">文章管理</a>
15+
<i class="fa fa-circle"></i>
16+
</li>
17+
<li>
18+
<a href="{{url('admin/articleLogList')}}">文章日志列表</a>
19+
<i class="fa fa-circle"></i>
20+
</li>
21+
</ul>
22+
<!-- END PAGE BREADCRUMB -->
23+
<!-- BEGIN PAGE BASE CONTENT -->
24+
<div class="row">
25+
<div class="col-md-12">
26+
<!-- BEGIN EXAMPLE TABLE PORTLET-->
27+
<div class="portlet light bordered">
28+
<div class="portlet-title">
29+
<div class="caption font-dark">
30+
<i class="icon-docs font-dark"></i>
31+
<span class="caption-subject bold uppercase"> 文章日志列表 </span>
32+
</div>
33+
<div class="actions">
34+
<div class="btn-group">
35+
36+
</div>
37+
</div>
38+
</div>
39+
<div class="portlet-body">
40+
<div class="table-scrollable">
41+
<table class="table table-striped table-bordered table-hover table-checkable order-column" id="sample_1">
42+
<thead>
43+
<tr>
44+
<th> ID </th>
45+
<th> 文章ID </th>
46+
<th> 坐标 </th>
47+
<th> IP </th>
48+
<th> 头部信息 </th>
49+
<th> 状态 </th>
50+
<th> 访问时间 </th>
51+
</tr>
52+
</thead>
53+
<tbody>
54+
@if($articleLogList->isEmpty())
55+
<tr>
56+
<td colspan="7">暂无数据</td>
57+
</tr>
58+
@else
59+
@foreach($articleLogList as $articleLog)
60+
<tr class="odd gradeX">
61+
<td> {{$articleLog->id}} </td>
62+
<td> <a href="{{url('article?id=' . $articleLog->aid)}}" target="_blank"> {{$articleLog->aid}} </a> </td>
63+
<td> {{$articleLog->lat}},{{$articleLog->lng}} </td>
64+
<td> {{$articleLog->ip}} </td>
65+
<td> {{$articleLog->headers}} </td>
66+
<td>
67+
@if ($articleLog->status)
68+
<span class="label label-default">已查看</span>
69+
@else
70+
<span class="label label-info">未查看</span>
71+
@endif
72+
</td>
73+
<td> {{$articleLog->created_at}} </td>
74+
</tr>
75+
@endforeach
76+
@endif
77+
</tbody>
78+
</table>
79+
</div>
80+
<div class="row">
81+
<div class="col-md-4 col-sm-4">
82+
<div class="dataTables_info" role="status" aria-live="polite">共 {{$articleLogList->total()}} 条日志</div>
83+
</div>
84+
<div class="col-md-8 col-sm-8">
85+
<div class="dataTables_paginate paging_bootstrap_full_number pull-right">
86+
{{ $articleLogList->links() }}
87+
</div>
88+
</div>
89+
</div>
90+
</div>
91+
</div>
92+
<!-- END EXAMPLE TABLE PORTLET-->
93+
</div>
94+
</div>
95+
<!-- END PAGE BASE CONTENT -->
96+
</div>
97+
<!-- END CONTENT BODY -->
98+
@endsection
99+
@section('script')
100+
<script src="/assets/global/plugins/bootbox/bootbox.min.js" type="text/javascript"></script>
101+
<script src="/js/layer/layer.js" type="text/javascript"></script>
102+
103+
<script type="text/javascript">
104+
//
105+
</script>
106+
@endsection

0 commit comments

Comments
 (0)