userList.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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" data-clipboard-text="{{$user->link}}">{{$user->subscribe->code}}</a>
  92. </td>
  93. <td> {{$user->used_flow}} / {{$user->transfer_enable}} </td>
  94. <td> {{$user->t? date('Y-m-d H:i', $user->t): '未使用'}} </td>
  95. <td>
  96. @if ($user->expireWarning == '-1')
  97. <span class="badge badge-lg badge-danger"> {{$user->expire_time}} </span>
  98. @elseif ($user->expireWarning == '0')
  99. <span class="badge badge-lg badge-warning"> {{$user->expire_time}} </span>
  100. @elseif ($user->expireWarning == '1')
  101. <span class="badge badge-lg badge-default"> {{$user->expire_time}} </span>
  102. @else
  103. {{$user->expire_time}}
  104. @endif
  105. </td>
  106. <td>
  107. @if ($user->status > 0)
  108. <span class="badge badge-lg badge-primary"><i class="wb-check"
  109. aria-hidden="true"></i></span>
  110. @elseif ($user->status < 0)
  111. <span class="badge badge-lg badge-danger"><i class="wb-close"
  112. aria-hidden="true"></i></span>
  113. @else
  114. <span class="badge badge-lg badge-default"><i class="wb-minus"
  115. aria-hidden="true"></i></span>
  116. @endif
  117. </td>
  118. <td>
  119. <span class="badge badge-lg badge-{{$user->enable?'info':'danger'}}"><i
  120. class="wb-{{$user->enable?'check':'close'}}" aria-hidden="true"></i></span>
  121. </td>
  122. <td>
  123. <div class="btn-group">
  124. <a href="/admin/editUser/{{$user->id}}{{Request::getQueryString()? '?'.Request::getQueryString() : ''}}"
  125. class="btn btn-primary"><i class="icon wb-edit" aria-hidden="true"></i></a>
  126. <a href="javascript:delUser('{{$user->id}}','{{$user->email}}');"
  127. class="btn btn-danger"><i class="icon wb-trash" aria-hidden="true"></i></a>
  128. <a href="/admin/export/{{$user->id}}" class="btn btn-primary"><i
  129. class="icon wb-code" aria-hidden="true"></i></a>
  130. <a href="/admin/userMonitor/{{$user->id}}" class="btn btn-primary"><i
  131. class="icon wb-stats-bars" aria-hidden="true"></i></a>
  132. <a href="/admin/onlineIPMonitor?id={{$user->id}}" class="btn btn-primary"><i
  133. class="icon wb-cloud" aria-hidden="true"></i></a>
  134. <a href="javascript:resetTraffic('{{$user->id}}','{{$user->email}}');"
  135. class="btn btn-primary"><i class="icon wb-reload" aria-hidden="true"></i></a>
  136. <a href="javascript:switchToUser('{{$user->id}}');" class="btn btn-primary"><i
  137. class="icon wb-user" aria-hidden="true"></i></a>
  138. </div>
  139. </td>
  140. </tr>
  141. @endforeach
  142. </tbody>
  143. </table>
  144. </div>
  145. <div class="panel-footer">
  146. <div class="row">
  147. <div class="col-sm-4">
  148. 共 <code>{{$userList->total()}}</code> 个账号
  149. </div>
  150. <div class="col-sm-8">
  151. <nav class="Page navigation float-right">
  152. {{$userList->links()}}
  153. </nav>
  154. </div>
  155. </div>
  156. </div>
  157. </div>
  158. </div>
  159. @endsection
  160. @section('script')
  161. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js" type="text/javascript"></script>
  162. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js" type="text/javascript"></script>
  163. <script src="/assets/custom/Plugin/clipboardjs/clipboard.min.js" type="text/javascript"></script>
  164. <script type="text/javascript">
  165. $(document).ready(function () {
  166. $('#pay_way').val({{Request::get('pay_way')}});
  167. $('#status').val({{Request::get('status')}});
  168. $('#enable').val({{Request::get('enable')}});
  169. });
  170. // 导出原版json配置
  171. function exportSSJson() {
  172. swal.fire({
  173. title: '导出成功',
  174. text: '成功导出原版SS的用户配置信息,加密方式为系统默认的加密方式',
  175. type: 'success',
  176. timer: 1300,
  177. showConfirmButton: false,
  178. }).then(() => window.location.href = '/admin/exportSSJson')
  179. }
  180. // 批量生成账号
  181. function batchAddUsers() {
  182. swal.fire({
  183. title: '用户生成数量',
  184. input: 'range',
  185. inputAttributes: {
  186. min: 1,
  187. max: 10,
  188. },
  189. inputValue: 1,
  190. type: 'question',
  191. showCancelButton: true,
  192. cancelButtonText: '{{trans('home.ticket_close')}}',
  193. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  194. }).then((result) => {
  195. if (result.value) {
  196. $.post("/admin/batchAddUsers", {_token: '{{csrf_token()}}', amount: result.value}, function (ret) {
  197. if (ret.status === 'success') {
  198. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  199. .then(() => window.location.reload())
  200. } else {
  201. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  202. }
  203. });
  204. }
  205. });
  206. }
  207. //回车检测
  208. $(document).on("keypress", "input", function (e) {
  209. if (e.which === 13) {
  210. Search();
  211. return false;
  212. }
  213. });
  214. // 搜索
  215. function Search() {
  216. 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();
  217. }
  218. // 删除账号
  219. function delUser(id, email) {
  220. swal.fire({
  221. title: '警告',
  222. text: '确定删除用户 【' + email + '】 ?',
  223. type: 'warning',
  224. showCancelButton: true,
  225. cancelButtonText: '{{trans('home.ticket_close')}}',
  226. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  227. }).then((result) => {
  228. if (result.value) {
  229. $.post("/admin/delUser", {id: id, _token: '{{csrf_token()}}'}, function (ret) {
  230. if (ret.status === 'success') {
  231. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  232. .then(() => window.location.reload())
  233. } else {
  234. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  235. }
  236. });
  237. }
  238. });
  239. }
  240. // 重置流量
  241. function resetTraffic(id, email) {
  242. swal.fire({
  243. title: '警告',
  244. text: '确定重置 【' + email + '】 流量吗?',
  245. type: 'warning',
  246. showCancelButton: true,
  247. cancelButtonText: '{{trans('home.ticket_close')}}',
  248. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  249. }).then((result) => {
  250. if (result.value) {
  251. $.post("/admin/resetUserTraffic", {_token: '{{csrf_token()}}', id: id}, function (ret) {
  252. if (ret.status === 'success') {
  253. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  254. .then(() => window.location.reload())
  255. } else {
  256. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  257. }
  258. });
  259. }
  260. });
  261. }
  262. // 切换用户身份
  263. function switchToUser(id) {
  264. $.ajax({
  265. 'url': "/admin/switchToUser",
  266. 'data': {
  267. 'user_id': id,
  268. '_token': '{{csrf_token()}}'
  269. },
  270. 'dataType': "json",
  271. 'type': "POST",
  272. success: function (ret) {
  273. if (ret.status === 'success') {
  274. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  275. .then(() => window.location.href = "/")
  276. } else {
  277. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  278. }
  279. }
  280. });
  281. }
  282. const clipboard = new ClipboardJS('.copySubscribeLink');
  283. clipboard.on('success', function () {
  284. swal.fire({
  285. title: '复制成功',
  286. type: 'success',
  287. timer: 1000,
  288. showConfirmButton: false
  289. });
  290. });
  291. clipboard.on('error', function () {
  292. swal.fire({
  293. title: '复制失败,请手动复制',
  294. type: 'error',
  295. timer: 1500,
  296. showConfirmButton: false
  297. });
  298. });
  299. </script>
  300. @endsection