userList.blade.php 11 KB

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