userList.blade.php 13 KB

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