userList.blade.php 11 KB

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