userList.blade.php 17 KB

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