userList.blade.php 15 KB

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