index.blade.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/vendor/bootstrap-table/bootstrap-table.min.css" type="text/css" rel="stylesheet">
  4. <link href="/assets/custom/range.min.css" type="text/css" rel="stylesheet">
  5. <style>
  6. .table a {
  7. text-decoration: none;
  8. }
  9. </style>
  10. @endsection
  11. @section('content')
  12. <div class="page-content container-fluid">
  13. <div class="panel">
  14. <div class="panel-heading">
  15. <h2 class="panel-title">用户列表</h2>
  16. <div class="panel-actions">
  17. <button class="btn btn-outline-default" onclick="batchAddUsers()">
  18. <i class="icon wb-plus" aria-hidden="true"></i>批量生成
  19. </button>
  20. <a href="{{route('admin.user.create')}}" class="btn btn-outline-default">
  21. <i class="icon wb-user-add" aria-hidden="true"></i>添加用户
  22. </a>
  23. </div>
  24. </div>
  25. <div class="panel-body">
  26. <div class="form-row">
  27. <div class="form-group col-xxl-1 col-lg-1 col-md-1 col-sm-4">
  28. <input type="number" class="form-control" id="id" name="id" value="{{Request::input('id')}}" placeholder="ID"/>
  29. </div>
  30. <div class="form-group col-xxl-2 col-lg-3 col-md-3 col-sm-4">
  31. <input type="text" class="form-control" id="email" name="email" value="{{Request::input('email')}}" placeholder="用户名"/>
  32. </div>
  33. <div class="form-group col-xxl-2 col-lg-3 col-md-3 col-sm-4">
  34. <input type="text" class="form-control" id="wechat" name="wechat" value="{{Request::input('wechat')}}" placeholder="微信"/>
  35. </div>
  36. <div class="form-group col-xxl-2 col-lg-3 col-md-3 col-sm-4">
  37. <input type="number" class="form-control" id="qq" name="qq" value="{{Request::input('qq')}}" placeholder="QQ"/>
  38. </div>
  39. <div class="form-group col-xxl-1 col-lg-2 col-md-2 col-sm-4">
  40. <input type="number" class="form-control" id="port" name="port" value="{{Request::input('port')}}" placeholder="端口"/>
  41. </div>
  42. <div class="form-group col-xxl-1 col-lg-3 col-md-3 col-4">
  43. <select class="form-control" id="group" name="group" onChange="Search()">
  44. <option value="" hidden>用户分组</option>
  45. @foreach($userGroups as $key => $group)
  46. <option value="{{$key}}">{{$group}}</option>
  47. @endforeach
  48. </select>
  49. </div>
  50. <div class="form-group col-xxl-1 col-lg-3 col-md-3 col-4">
  51. <select class="form-control" id="level" name="level" onChange="Search()">
  52. <option value="" hidden>用户分组</option>
  53. @foreach($levels as $key => $level)
  54. <option value="{{$key}}">{{$level}}</option>
  55. @endforeach
  56. </select>
  57. </div>
  58. <div class="form-group col-xxl-1 col-lg-3 col-md-3 col-4">
  59. <select class="form-control" id="status" name="status" onChange="Search()">
  60. <option value="" hidden>账号状态</option>
  61. <option value="-1">禁用</option>
  62. <option value="0">未激活</option>
  63. <option value="1">正常</option>
  64. </select>
  65. </div>
  66. <div class="form-group col-xxl-1 col-lg-3 col-md-3 col-4">
  67. <select class="form-control" id="enable" name="enable" onChange="Search()">
  68. <option value="" hidden>代理状态</option>
  69. <option value="1">启用</option>
  70. <option value="0">禁用</option>
  71. </select>
  72. </div>
  73. <div class="form-group col-xxl-1 col-lg-3 col-md-3 col-4 btn-group">
  74. <button class="btn btn-primary" onclick="Search()">搜 索</button>
  75. <a href="{{route('admin.user.index')}}" class="btn btn-danger">重 置</a>
  76. </div>
  77. </div>
  78. <table class="text-md-center" data-toggle="table" data-mobile-responsive="true">
  79. <thead class="thead-default">
  80. <tr>
  81. <th> #</th>
  82. <th> 用户名</th>
  83. <th> 余额</th>
  84. <th> 端口</th>
  85. <th> 订阅码</th>
  86. <th> 流量使用</th>
  87. <th> 最后使用</th>
  88. <th> 有效期</th>
  89. <th> 状态</th>
  90. <th> 代理</th>
  91. <th> 操作</th>
  92. </tr>
  93. </thead>
  94. <tbody>
  95. @foreach ($userList as $user)
  96. <tr class="{{$user->trafficWarning ? ' table-danger' : ''}}">
  97. <td> {{$user->id}} </td>
  98. <td> {{$user->email}} </td>
  99. <td> {{$user->credit}} </td>
  100. <td>
  101. {!!$user->port? : '<span class="badge badge-lg badge-danger"> 未分配 </span>'!!}
  102. </td>
  103. <td>
  104. <a href="javascript:" class="copySubscribeLink" data-clipboard-action="copy" data-clipboard-text="{{$user->link}}">{{$user->subscribe->code}}</a>
  105. </td>
  106. <td> {{$user->used_flow}} / {{$user->transfer_enable_formatted}} </td>
  107. <td> {{$user->t? date('Y-m-d H:i', $user->t): '未使用'}} </td>
  108. <td>
  109. @if ($user->expireWarning === -1)
  110. <span class="badge badge-lg badge-danger"> {{$user->expired_at}} </span>
  111. @elseif ($user->expireWarning === 0)
  112. <span class="badge badge-lg badge-warning"> {{$user->expired_at}} </span>
  113. @elseif ($user->expireWarning === 1)
  114. <span class="badge badge-lg badge-default"> {{$user->expired_at}} </span>
  115. @else
  116. {{$user->expired_at}}
  117. @endif
  118. </td>
  119. <td>
  120. @if ($user->status > 0)
  121. <span class="badge badge-lg badge-primary">
  122. <i class="wb-check" aria-hidden="true"></i>
  123. </span>
  124. @elseif ($user->status < 0)
  125. <span class="badge badge-lg badge-danger">
  126. <i class="wb-close" aria-hidden="true"></i>
  127. </span>
  128. @else
  129. <span class="badge badge-lg badge-default">
  130. <i class="wb-minus" aria-hidden="true"></i>
  131. </span>
  132. @endif
  133. </td>
  134. <td>
  135. <span class="badge badge-lg badge-{{$user->enable?'info':'danger'}}">
  136. <i class="wb-{{$user->enable?'check':'close'}}" aria-hidden="true"></i>
  137. </span>
  138. </td>
  139. <td>
  140. <div class="btn-group" role="group">
  141. <button type="button" class="btn btn-primary dropdown-toggle" data-boundary="viewport" data-toggle="dropdown" aria-expanded="false">
  142. <i class="icon wb-wrench" aria-hidden="true"></i>
  143. </button>
  144. <div class="dropdown-menu" role="menu">
  145. <a class="dropdown-item" href="{{route('admin.user.edit', ['user'=>$user->id, Request::getQueryString()])}}" role="menuitem">
  146. <i class="icon wb-edit" aria-hidden="true"></i> 编辑
  147. </a>
  148. <a class="dropdown-item" href="javascript:delUser('{{route('admin.user.destroy', $user->id)}}','{{$user->email}}')" role="menuitem">
  149. <i class="icon wb-trash" aria-hidden="true"></i> 删除
  150. </a>
  151. <a class="dropdown-item" href="{{route('admin.user.export', $user->id)}}" role="menuitem">
  152. <i class="icon wb-code" aria-hidden="true"></i> 配置信息
  153. </a>
  154. <a class="dropdown-item" href="{{route('admin.user.monitor', $user->id)}}" role="menuitem">
  155. <i class="icon wb-stats-bars" aria-hidden="true"></i> 流量统计
  156. </a>
  157. <a class="dropdown-item" href="{{route('admin.user.online', $user->id)}}" role="menuitem">
  158. <i class="icon wb-cloud" aria-hidden="true"></i> 在线巡查
  159. </a>
  160. <a class="dropdown-item" href="javascript:resetTraffic('{{$user->id}}','{{$user->email}}')" role="menuitem">
  161. <i class="icon wb-reload" aria-hidden="true"></i> 重置流量
  162. </a>
  163. <a class="dropdown-item" href="javascript:switchToUser('{{$user->id}}')" role="menuitem">
  164. <i class="icon wb-user" aria-hidden="true"></i> 用户视角
  165. </a>
  166. </div>
  167. </div>
  168. </td>
  169. </tr>
  170. @endforeach
  171. </tbody>
  172. </table>
  173. </div>
  174. <div class="panel-footer">
  175. <div class="row">
  176. <div class="col-sm-4">
  177. 共 <code>{{$userList->total()}}</code> 个账号
  178. </div>
  179. <div class="col-sm-8">
  180. <nav class="Page navigation float-right">
  181. {{$userList->links()}}
  182. </nav>
  183. </div>
  184. </div>
  185. </div>
  186. </div>
  187. </div>
  188. @endsection
  189. @section('script')
  190. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js" type="text/javascript"></script>
  191. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js" type="text/javascript"></script>
  192. <script src="/assets/custom/Plugin/clipboardjs/clipboard.min.js" type="text/javascript"></script>
  193. <script type="text/javascript">
  194. $(document).ready(function() {
  195. $('#group').val({{Request::input('group')}});
  196. $('#level').val({{Request::input('level')}});
  197. $('#pay_way').val({{Request::input('pay_way')}});
  198. $('#status').val({{Request::input('status')}});
  199. $('#enable').val({{Request::input('enable')}});
  200. });
  201. // 批量生成账号
  202. function batchAddUsers() {
  203. swal.fire({
  204. title: '用户生成数量',
  205. input: 'range',
  206. inputAttributes: {min: 1, max: 10},
  207. inputValue: 1,
  208. type: 'question',
  209. showCancelButton: true,
  210. cancelButtonText: '{{trans('home.ticket_close')}}',
  211. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  212. }).then((result) => {
  213. if (result.value) {
  214. $.post('{{route('admin.user.batch')}}', {_token: '{{csrf_token()}}', amount: result.value}, function(ret) {
  215. if (ret.status === 'success') {
  216. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false}).
  217. then(() => window.location.reload());
  218. }
  219. else {
  220. swal.fire({title: ret.message, type: 'error'}).then(() => window.location.reload());
  221. }
  222. });
  223. }
  224. });
  225. }
  226. //回车检测
  227. $(document).on('keypress', 'input', function(e) {
  228. if (e.which === 13) {
  229. Search();
  230. return false;
  231. }
  232. });
  233. // 搜索
  234. function Search() {
  235. window.location.href = '{{route('admin.user.index')}}' + '?id=' + $('#id').val() + '&email=' + $('#email').val() + '&wechat=' +
  236. $('#wechat').val() + '&qq=' + $('#qq').val() + '&port=' + $('#port').val() + '&group=' + $('#group option:selected').val() + '&level='
  237. + $('#level option:selected').val() + '&status=' + $('#status option:selected').val() + '&enable=' + $('#enable option:selected').val();
  238. }
  239. // 删除账号
  240. function delUser(url, email) {
  241. swal.fire({
  242. title: '警告',
  243. text: '确定删除用户 【' + email + '】 ?',
  244. type: 'warning',
  245. showCancelButton: true,
  246. cancelButtonText: '{{trans('home.ticket_close')}}',
  247. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  248. }).then((result) => {
  249. if (result.value) {
  250. $.ajax({
  251. method: 'DELETE',
  252. url: url,
  253. data: {_token: '{{csrf_token()}}'},
  254. dataType: 'json',
  255. success: function(ret) {
  256. if (ret.status === 'success') {
  257. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  258. }
  259. else {
  260. swal.fire({title: ret.message, type: 'error'}).then(() => window.location.reload());
  261. }
  262. },
  263. });
  264. }
  265. });
  266. }
  267. // 重置流量
  268. function resetTraffic(id, email) {
  269. swal.fire({
  270. title: '警告',
  271. text: '确定重置 【' + email + '】 流量吗?',
  272. type: 'warning',
  273. showCancelButton: true,
  274. cancelButtonText: '{{trans('home.ticket_close')}}',
  275. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  276. }).then((result) => {
  277. if (result.value) {
  278. $.post('{{route('admin.user.reset')}}', {_token: '{{csrf_token()}}', id: id}, function(ret) {
  279. if (ret.status === 'success') {
  280. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false}).
  281. then(() => window.location.reload());
  282. }
  283. else {
  284. swal.fire({title: ret.message, type: 'error'}).then(() => window.location.reload());
  285. }
  286. });
  287. }
  288. });
  289. }
  290. // 切换用户身份
  291. function switchToUser(id) {
  292. $.post('{{route('admin.user.switch')}}', {_token: '{{csrf_token()}}', user_id: id}, function(ret) {
  293. if (ret.status === 'success') {
  294. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  295. }
  296. else {
  297. swal.fire({title: ret.message, type: 'error'}).then(() => window.location.reload());
  298. }
  299. });
  300. }
  301. const clipboard = new ClipboardJS('.copySubscribeLink');
  302. clipboard.on('success', function() {
  303. swal.fire({
  304. title: '复制成功',
  305. type: 'success',
  306. timer: 1000,
  307. showConfirmButton: false,
  308. });
  309. });
  310. clipboard.on('error', function() {
  311. swal.fire({
  312. title: '复制失败,请手动复制',
  313. type: 'error',
  314. timer: 1500,
  315. showConfirmButton: false,
  316. });
  317. });
  318. </script>
  319. @endsection